1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
<?php
if (! interface_exists ( 'PostmanConfigTextHelper' )) {
interface PostmanConfigTextHelper {
public function isOauthHost();
public function isGoogle();
public function isMicrosoft();
public function isYahoo();
public function getCallbackUrl();
public function getCallbackDomain();
public function getClientIdLabel();
public function getClientSecretLabel();
public function getCallbackUrlLabel();
public function getCallbackDomainLabel();
public function getOwnerName();
public function getServiceName();
public function getApplicationDescription();
public function getApplicationPortalName();
public function getApplicationPortalUrl();
public function getOAuthPort();
public function getEncryptionType();
}
}
if (! class_exists ( 'PostmanAbstractConfigTextHelper' )) {
/**
*
* @author jasonhendriks
*/
abstract class PostmanAbstractConfigTextHelper implements PostmanConfigTextHelper {
public function getOAuthHelp() {
$attention = __ ( 'Attention' );
/* translators: parameters available are 1=portal-url, 2=portal-name, 3=clientId-name, 4=clientSecret-name, 5=callbackUrl, 6=service-name, 7=portal-application (e.g. Open the Google Developer Console, create a Client ID for web application using the URL's displayed below, and copy the Client ID and Client Secret here.) */
$errorMessage = sprintf ( __ ( 'Open the <a href="%1$s" target="_new">%2$s</a>, create <b>%7$s</b> with the values displayed below, and copy the generated %3$s and %4$s here.', Postman::TEXT_DOMAIN ), $this->getApplicationPortalUrl (), $this->getApplicationPortalName (), $this->getClientIdLabel (), $this->getClientSecretLabel (), $this->getCallbackUrlLabel (), $this->getOwnerName (), $this->getApplicationDescription () );
$text = sprintf ( '<b style="color:red">%s!</b> %s', $attention, $errorMessage );
/* translators: parameters available are 1=clientId-name, 2=service-name, 3=FAQ-URL, 4=Video-URL (e.g. See How do I get a Google Client ID? in the F.A.Q.) */
$howToTemplate = __ ( 'See <a href="%3$s" target="_new">How do I get a %1$s %2$s?</a> in the F.A.Q. or <a href="%4$s" target="_new">watch our How-To video 📺</a>.', Postman::TEXT_DOMAIN );
$text .= sprintf ( ' %s', sprintf ( $howToTemplate, $this->getOwnerName (), $this->getClientIdLabel (), 'https://wordpress.org/plugins/postman-smtp/faq/', 'https://vimeo.com/128589255' ) );
return $text;
}
function isOauthHost() {
return false;
}
function isGoogle() {
return false;
}
function isMicrosoft() {
return false;
}
function isYahoo() {
return false;
}
public function getRequestPermissionLinkText() {
/* translators: where %s is the Email Service Owner (e.g. Google, Microsoft or Yahoo) */
return sprintf ( _x ( 'Grant permission with %s', 'Command to initiate OAuth authentication', Postman::TEXT_DOMAIN ), $this->getOwnerName () );
}
}
}
if (! class_exists ( 'PostmanGoogleOAuthScribe' )) {
class PostmanGoogleOAuthScribe extends PostmanAbstractConfigTextHelper {
public function isGoogle() {
return true;
}
function isOauthHost() {
return true;
}
public function getCallbackUrl() {
// see https://codex.wordpress.org/Function_Reference/admin_url#Related
return admin_url ( 'options-general.php' ) . '?page=postman';
}
function getCallbackDomain() {
$urlParts = parse_url ( $this->getCallbackUrl () );
if (isset ( $urlParts ['scheme'] ) && isset ( $urlParts ['host'] )) {
return $urlParts ['scheme'] . "://" . $urlParts ['host'];
} else {
throw new Exception ();
}
}
public function getClientIdLabel() {
/* Translators: This description is specific to Google */
return _x ( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN );
}
public function getClientSecretLabel() {
/* Translators: This description is specific to Google */
return _x ( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN );
}
public function getCallbackUrlLabel() {
/* Translators: This description is specific to Google */
return _x ( 'Authorized redirect URI', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN );
}
public function getCallbackDomainLabel() {
/* Translators: This description is specific to Google */
return _x ( 'Authorized JavaScript origins', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN );
}
public function getOwnerName() {
/* Translators: This description is specific to Google */
return _x ( 'Google', 'Name of the email service owner', Postman::TEXT_DOMAIN );
}
public function getServiceName() {
/* Translators: This description is specific to Google */
return _x ( 'Gmail', 'Name of the email service', Postman::TEXT_DOMAIN );
}
public function getApplicationDescription() {
/* Translators: This description is specific to Google */
return _x ( 'a Client ID for web application', 'Description of the email service OAuth 2.0 Application', Postman::TEXT_DOMAIN );
}
public function getApplicationPortalName() {
/* Translators: This description is specific to Google */
return _x ( 'Google Developers Console Gmail Wizard', 'Name of the email service portal', Postman::TEXT_DOMAIN );
}
public function getApplicationPortalUrl() {
return 'https://www.google.com/accounts/Logout?continue=https://console.developers.google.com/start/api?id=gmail';
}
public function getOAuthPort() {
return 465;
}
public function getEncryptionType() {
return PostmanOptions::SECURITY_TYPE_SMTPS;
}
}
}
if (! class_exists ( 'PostmanMicrosoftOAuthScribe' )) {
class PostmanMicrosoftOAuthScribe extends PostmanAbstractConfigTextHelper {
public function isMicrosoft() {
return true;
}
function isOauthHost() {
return true;
}
public function getCallbackUrl() {
return admin_url ( 'options-general.php' );
}
function getCallbackDomain() {
$urlParts = parse_url ( $this->getCallbackUrl () );
if (isset ( $urlParts ['host'] )) {
return $urlParts ['host'];
} else {
throw new Exception ();
}
}
public function getClientIdLabel() {
/* Translators: This description is specific to Microsoft */
return _x ( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN );
}
public function getClientSecretLabel() {
/* Translators: This description is specific to Microsoft */
return _x ( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN );
}
public function getCallbackUrlLabel() {
/* Translators: This description is specific to Microsoft */
return _x ( 'Redirect URL', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN );
}
public function getCallbackDomainLabel() {
/* Translators: This description is specific to Microsoft */
return _x ( 'Root Domain', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN );
}
public function getOwnerName() {
/* Translators: This description is specific to Microsoft */
return _x ( 'Microsoft', 'Name of the email service owner', Postman::TEXT_DOMAIN );
}
public function getServiceName() {
/* Translators: This description is specific to Microsoft */
return _x ( 'Outlook.com', 'Name of the email service', Postman::TEXT_DOMAIN );
}
public function getApplicationDescription() {
/* Translators: This description is specific to Microsoft */
return _x ( 'an Application', 'Description of the email service OAuth 2.0 Application', Postman::TEXT_DOMAIN );
}
public function getApplicationPortalName() {
/* Translators: This description is specific to Microsoft */
return _x ( 'Microsoft Developer Center', 'Name of the email service portal', Postman::TEXT_DOMAIN );
}
public function getApplicationPortalUrl() {
return 'https://account.live.com/developers/applications/index';
}
public function getOAuthPort() {
return 587;
}
public function getEncryptionType() {
return PostmanOptions::SECURITY_TYPE_STARTTLS;
}
}
}
if (! class_exists ( 'PostmanYahooOAuthScribe' )) {
class PostmanYahooOAuthScribe extends PostmanAbstractConfigTextHelper {
public function isYahoo() {
return true;
}
function isOauthHost() {
return true;
}
public function getCallbackUrl() {
return admin_url ( 'options-general.php' ) . '?page=postman';
}
function getCallbackDomain() {
$urlParts = parse_url ( $this->getCallbackUrl () );
if (isset ( $urlParts ['host'] )) {
return $urlParts ['host'];
} else {
throw new Exception ();
}
}
public function getClientIdLabel() {
/* Translators: This description is specific to Yahoo */
return _x ( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN );
}
public function getClientSecretLabel() {
/* Translators: This description is specific to Yahoo */
return _x ( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN );
}
public function getCallbackUrlLabel() {
/* Translators: This description is specific to Yahoo */
return _x ( 'Home Page URL', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN );
}
public function getCallbackDomainLabel() {
/* Translators: This description is specific to Yahoo */
return _x ( 'Callback Domain', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN );
}
public function getOwnerName() {
/* Translators: This description is specific to Yahoo */
return _x ( 'Yahoo', 'Name of the email service owner', Postman::TEXT_DOMAIN );
}
public function getServiceName() {
/* Translators: This description is specific to Yahoo */
return _x ( 'Yahoo Mail', 'Name of the email service', Postman::TEXT_DOMAIN );
}
public function getApplicationDescription() {
/* Translators: This description is specific to Yahoo */
return _x ( 'an Application', 'Description of the email service OAuth 2.0 Application', Postman::TEXT_DOMAIN );
}
public function getApplicationPortalName() {
/* Translators: This description is specific to Yahoo */
return _x ( 'Yahoo Developer Network', 'Name of the email service portal', Postman::TEXT_DOMAIN );
}
public function getApplicationPortalUrl() {
return 'https://developer.yahoo.com/apps/';
}
public function getOAuthPort() {
return 465;
}
public function getEncryptionType() {
return PostmanOptions::SECURITY_TYPE_SMTPS;
}
}
}
if (! class_exists ( 'PostmanNonOAuthScribe' )) {
class PostmanNonOAuthScribe extends PostmanAbstractConfigTextHelper {
protected $hostname;
public function __construct($hostname) {
$this->hostname = $hostname;
}
public function isGoogle() {
return PostmanUtils::endsWith ( $this->hostname, 'gmail.com' );
}
public function isMicrosoft() {
return PostmanUtils::endsWith ( $this->hostname, 'live.com' );
}
public function isYahoo() {
return PostmanUtils::endsWith ( $this->hostname, 'yahoo.com' );
}
public function getOAuthHelp() {
$text = __ ( 'Enter an Outgoing Mail Server with OAuth2 capabilities.', Postman::TEXT_DOMAIN );
return sprintf ( '<span style="color:red" class="normal">%s</span>', $text );
}
public function getCallbackUrl() {
return '';
}
function getCallbackDomain() {
return '';
}
public function getClientIdLabel() {
return _x ( 'Client ID', 'Name of the OAuth 2.0 Client ID', Postman::TEXT_DOMAIN );
}
public function getClientSecretLabel() {
return _x ( 'Client Secret', 'Name of the OAuth 2.0 Client Secret', Postman::TEXT_DOMAIN );
}
public function getCallbackUrlLabel() {
return _x ( 'Redirect URI', 'Name of the Application Callback URI', Postman::TEXT_DOMAIN );
}
public function getCallbackDomainLabel() {
return _x ( 'Website Domain', 'Name of the Application Callback Domain', Postman::TEXT_DOMAIN );
}
public function getOwnerName() {
return '';
}
public function getServiceName() {
return '';
}
public function getApplicationDescription() {
return '';
}
public function getApplicationPortalName() {
return '';
}
public function getApplicationPortalUrl() {
return '';
}
public function getOAuthPort() {
return '';
}
public function getEncryptionType() {
return '';
}
public function getRequestPermissionLinkText() {
return __ ( 'Grant OAuth 2.0 Permission', Postman::TEXT_DOMAIN );
}
}
}
|