SendGrid - Version 1.7.3

Version Description

  • Add global config for content-type
  • Validate send_method and port set in config file
  • Be able to define categories for which you would like to see your stats
Download this release

Release Info

Developer team-rs
Plugin Icon 128x128 SendGrid
Version 1.7.3
Comparing to
See all releases

Code changes from version 1.7.2 to 1.7.3

assets/screenshot-11.png ADDED
Binary file
lib/class-sendgrid-settings.php CHANGED
@@ -72,7 +72,7 @@ class Sendgrid_Settings {
72
 
73
  wp_enqueue_style( 'sendgrid', plugin_dir_url( __FILE__ ) . '../view/css/sendgrid.css' );
74
 
75
- wp_enqueue_script( 'sendgrid', plugin_dir_url( __FILE__ ) . '../view/js/sendgrid.settings-v1.7.0.js', array('jquery') );
76
  }
77
 
78
  /**
@@ -85,25 +85,30 @@ class Sendgrid_Settings {
85
  $response = self::do_post($_POST);
86
  }
87
 
88
- $user = Sendgrid_Tools::get_username();
89
- $password = Sendgrid_Tools::get_password();
90
- $api_key = Sendgrid_Tools::get_api_key();
91
- $send_method = Sendgrid_Tools::get_send_method();
92
- $auth_method = Sendgrid_Tools::get_auth_method();
93
- $name = stripslashes( Sendgrid_Tools::get_from_name() );
94
- $email = Sendgrid_Tools::get_from_email();
95
- $reply_to = Sendgrid_Tools::get_reply_to();
96
- $categories = stripslashes( Sendgrid_Tools::get_categories() );
97
- $template = stripslashes( Sendgrid_Tools::get_template() );
98
- $port = Sendgrid_Tools::get_port();
99
-
100
- $allowed_methods = array('API');
 
 
 
 
 
101
  if ( class_exists( 'Swift' ) ) {
102
- $allowed_methods[] = 'SMTP';
103
  }
104
 
105
- if ( ! in_array( strtoupper( $send_method ), $allowed_methods ) ) {
106
- $message = 'Invalid send method, available methods are: "API" or "SMTP".';
107
  $status = 'error';
108
  }
109
 
@@ -119,6 +124,25 @@ class Sendgrid_Settings {
119
  $message = 'Template not found.';
120
  $status = 'error';
121
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  $is_env_auth_method = defined('SENDGRID_AUTH_METHOD');
124
  $is_env_send_method = defined('SENDGRID_SEND_METHOD');
@@ -126,8 +150,9 @@ class Sendgrid_Settings {
126
  $is_env_password = defined('SENDGRID_PASSWORD');
127
  $is_env_api_key = defined('SENDGRID_API_KEY');
128
  $is_env_port = defined('SENDGRID_PORT');
 
129
 
130
- if ( $response ) {
131
  $message = $response['message'];
132
  $status = $response['status'];
133
  if( array_key_exists('error_type', $response) ) {
@@ -229,6 +254,10 @@ class Sendgrid_Settings {
229
  update_option('sendgrid_categories', $params['sendgrid_categories']);
230
  }
231
 
 
 
 
 
232
  if ( isset( $params['sendgrid_template'] ) ) {
233
  if ( ! Sendgrid_Tools::check_template( $params['sendgrid_template'] ) ) {
234
  $response = array(
@@ -244,7 +273,7 @@ class Sendgrid_Settings {
244
  update_option('sendgrid_api', $params['send_method']);
245
  }
246
 
247
- if ( isset( $params['auth_method'] ) ) {
248
  update_option('sendgrid_auth_method', $params['auth_method']);
249
  }
250
 
@@ -252,6 +281,10 @@ class Sendgrid_Settings {
252
  update_option('sendgrid_port', $params['sendgrid_port']);
253
  }
254
 
 
 
 
 
255
  if( isset( $response ) and $response['status'] == 'error')
256
  return $response;
257
 
72
 
73
  wp_enqueue_style( 'sendgrid', plugin_dir_url( __FILE__ ) . '../view/css/sendgrid.css' );
74
 
75
+ wp_enqueue_script( 'sendgrid', plugin_dir_url( __FILE__ ) . '../view/js/sendgrid.settings-v1.7.3.js', array('jquery') );
76
  }
77
 
78
  /**
85
  $response = self::do_post($_POST);
86
  }
87
 
88
+ $status = '';
89
+ $message = '';
90
+
91
+ $user = Sendgrid_Tools::get_username();
92
+ $password = Sendgrid_Tools::get_password();
93
+ $api_key = Sendgrid_Tools::get_api_key();
94
+ $send_method = Sendgrid_Tools::get_send_method();
95
+ $auth_method = Sendgrid_Tools::get_auth_method();
96
+ $name = stripslashes( Sendgrid_Tools::get_from_name() );
97
+ $email = Sendgrid_Tools::get_from_email();
98
+ $reply_to = Sendgrid_Tools::get_reply_to();
99
+ $categories = stripslashes( Sendgrid_Tools::get_categories() );
100
+ $template = stripslashes( Sendgrid_Tools::get_template() );
101
+ $port = Sendgrid_Tools::get_port();
102
+ $content_type = Sendgrid_Tools::get_content_type();
103
+ $stats_categories = stripslashes( Sendgrid_Tools::get_stats_categories() );
104
+
105
+ $allowed_send_methods = array('API');
106
  if ( class_exists( 'Swift' ) ) {
107
+ $allowed_send_methods[] = 'SMTP';
108
  }
109
 
110
+ if ( ! in_array( strtoupper( $send_method ), $allowed_send_methods ) ) {
111
+ $message = 'Invalid send method configured in the config file, available methods are: ' . join( ", ", $allowed_send_methods );
112
  $status = 'error';
113
  }
114
 
124
  $message = 'Template not found.';
125
  $status = 'error';
126
  }
127
+
128
+ if ( ! in_array( $port, Sendgrid_Tools::$allowed_ports ) ) {
129
+ $message = 'Invalid port configured in the config file, available ports are: ' . join( ",", Sendgrid_Tools::$allowed_ports );
130
+ $status = 'error';
131
+ }
132
+
133
+ if ( ! in_array( $auth_method, Sendgrid_Tools::$allowed_auth_methods ) ) {
134
+ $message = 'Invalid authentication method configured in the config file, available options are: ' . join( ", ", Sendgrid_Tools::$allowed_auth_methods );
135
+ $status = 'error';
136
+ }
137
+
138
+ $allowed_content_type = array('plaintext', 'html');
139
+
140
+ if ( defined('SENDGRID_CONTENT_TYPE') ) {
141
+ if ( ! in_array( SENDGRID_CONTENT_TYPE , $allowed_content_type ) ) {
142
+ $message = 'Invalid content type, available content types are: "plaintext" or "html".';
143
+ $status = 'error';
144
+ }
145
+ }
146
 
147
  $is_env_auth_method = defined('SENDGRID_AUTH_METHOD');
148
  $is_env_send_method = defined('SENDGRID_SEND_METHOD');
150
  $is_env_password = defined('SENDGRID_PASSWORD');
151
  $is_env_api_key = defined('SENDGRID_API_KEY');
152
  $is_env_port = defined('SENDGRID_PORT');
153
+ $is_env_content_type = defined('SENDGRID_CONTENT_TYPE');
154
 
155
+ if ( $response && $status != 'error' ) {
156
  $message = $response['message'];
157
  $status = $response['status'];
158
  if( array_key_exists('error_type', $response) ) {
254
  update_option('sendgrid_categories', $params['sendgrid_categories']);
255
  }
256
 
257
+ if ( isset( $params['sendgrid_stats_categories'] ) ) {
258
+ update_option('sendgrid_stats_categories', $params['sendgrid_stats_categories']);
259
+ }
260
+
261
  if ( isset( $params['sendgrid_template'] ) ) {
262
  if ( ! Sendgrid_Tools::check_template( $params['sendgrid_template'] ) ) {
263
  $response = array(
273
  update_option('sendgrid_api', $params['send_method']);
274
  }
275
 
276
+ if ( isset( $params['auth_method'] ) && in_array( $params['auth_method'], Sendgrid_Tools::$allowed_auth_methods ) ) {
277
  update_option('sendgrid_auth_method', $params['auth_method']);
278
  }
279
 
281
  update_option('sendgrid_port', $params['sendgrid_port']);
282
  }
283
 
284
+ if ( isset( $params['content_type'] ) ) {
285
+ update_option( 'sendgrid_content_type', $params['content_type'] );
286
+ }
287
+
288
  if( isset( $response ) and $response['status'] == 'error')
289
  return $response;
290
 
lib/class-sendgrid-statistics.php CHANGED
@@ -109,7 +109,7 @@ class Sendgrid_Statistics
109
  }
110
 
111
  // Javascript
112
- wp_enqueue_script( 'sendgrid-stats', plugin_dir_url( __FILE__ ) . '../view/js/sendgrid.stats-v1.7.0.js', array('jquery') );
113
  wp_enqueue_script( 'jquery-flot', plugin_dir_url( __FILE__ ) . '../view/js/jquery.flot.js', array('jquery') );
114
  wp_enqueue_script( 'jquery-flot-time', plugin_dir_url( __FILE__ ) . '../view/js/jquery.flot.time.js', array('jquery') );
115
  wp_enqueue_script( 'jquery-flot-tofflelegend', plugin_dir_url( __FILE__ ) . '../view/js/jquery.flot.togglelegend.js', array('jquery') );
109
  }
110
 
111
  // Javascript
112
+ wp_enqueue_script( 'sendgrid-stats', plugin_dir_url( __FILE__ ) . '../view/js/sendgrid.stats-v1.7.3.js', array('jquery') );
113
  wp_enqueue_script( 'jquery-flot', plugin_dir_url( __FILE__ ) . '../view/js/jquery.flot.js', array('jquery') );
114
  wp_enqueue_script( 'jquery-flot-time', plugin_dir_url( __FILE__ ) . '../view/js/jquery.flot.time.js', array('jquery') );
115
  wp_enqueue_script( 'jquery-flot-tofflelegend', plugin_dir_url( __FILE__ ) . '../view/js/jquery.flot.togglelegend.js', array('jquery') );
lib/class-sendgrid-tools.php CHANGED
@@ -8,6 +8,10 @@ class Sendgrid_Tools
8
  const VALID_CREDENTIALS_STATUS = "valid";
9
  const INVALID_CREDENTIALS_STATUS = "invalid";
10
 
 
 
 
 
11
  /**
12
  * Check username/password
13
  *
@@ -389,6 +393,20 @@ class Sendgrid_Tools
389
  }
390
  }
391
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
  /**
393
  * Return categories array
394
  *
@@ -396,13 +414,11 @@ class Sendgrid_Tools
396
  */
397
  public static function get_categories_array()
398
  {
399
- $categories = Sendgrid_Tools::get_categories();
400
- if ( strlen( trim( $categories ) ) )
401
- {
402
- return explode( ',', $categories );
403
- }
404
-
405
- return array();
406
  }
407
 
408
  /**
@@ -419,6 +435,20 @@ class Sendgrid_Tools
419
  }
420
  }
421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  /**
423
  * Returns decrypted string using the key or empty string in case of error
424
  *
8
  const VALID_CREDENTIALS_STATUS = "valid";
9
  const INVALID_CREDENTIALS_STATUS = "invalid";
10
 
11
+ // used static variable because php 5.3 doesn't support array as constant
12
+ public static $allowed_ports = array(Sendgrid_SMTP::TLS, Sendgrid_SMTP::TLS_ALTERNATIVE, Sendgrid_SMTP::SSL);
13
+ public static $allowed_auth_methods = array('apikey', 'credentials');
14
+
15
  /**
16
  * Check username/password
17
  *
393
  }
394
  }
395
 
396
+ /**
397
+ * Return stats categories from the database or global variable
398
+ *
399
+ * @return string categories
400
+ */
401
+ public static function get_stats_categories()
402
+ {
403
+ if ( defined('SENDGRID_STATS_CATEGORIES') ) {
404
+ return SENDGRID_STATS_CATEGORIES;
405
+ } else {
406
+ return get_option('sendgrid_stats_categories');
407
+ }
408
+ }
409
+
410
  /**
411
  * Return categories array
412
  *
414
  */
415
  public static function get_categories_array()
416
  {
417
+ $general_categories = Sendgrid_Tools::get_categories();
418
+ $stats_categories = Sendgrid_Tools::get_stats_categories();
419
+ $general_categories_array = $general_categories? explode( ',', trim( $general_categories ) ):array();
420
+ $stats_categories_array = $stats_categories? explode( ',', trim( $stats_categories ) ):array();
421
+ return array_unique( array_merge( $general_categories_array, $stats_categories_array ) );
 
 
422
  }
423
 
424
  /**
435
  }
436
  }
437
 
438
+ /**
439
+ * Return content type from the database or global variable
440
+ *
441
+ * @return string content_type
442
+ */
443
+ public static function get_content_type()
444
+ {
445
+ if ( defined('SENDGRID_CONTENT_TYPE') ) {
446
+ return SENDGRID_CONTENT_TYPE;
447
+ } else {
448
+ return get_option('sendgrid_content_type');
449
+ }
450
+ }
451
+
452
  /**
453
  * Returns decrypted string using the key or empty string in case of error
454
  *
lib/sendgrid/class-sendgrid-api.php CHANGED
@@ -48,6 +48,8 @@ class Sendgrid_API implements Sendgrid_Send {
48
  }
49
 
50
  $response = wp_remote_post( self::URL, $data );
 
 
51
 
52
  if ( "success" == json_decode( $response['body'])->message )
53
  return true;
48
  }
49
 
50
  $response = wp_remote_post( self::URL, $data );
51
+ if ( !is_array( $response ) or !isset( $response['body'] ) )
52
+ return false;
53
 
54
  if ( "success" == json_decode( $response['body'])->message )
55
  return true;
lib/sendgrid/class-sendgrid-php.php CHANGED
@@ -23,19 +23,21 @@ class Sendgrid_WP {
23
  break;
24
  }
25
 
26
- return null;
27
  }
28
 
29
  private static function api_instance( $auth_method ) {
30
  switch ( $auth_method ) {
31
  case 'apikey':
32
- return new Sendgrid_API( "apikey", Sendgrid_Tools::get_api_key() );
33
  break;
34
 
35
  case 'credentials':
36
- return new Sendgrid_API( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
37
  break;
38
  }
 
 
39
  }
40
 
41
  private static function smtp_instance( $auth_method )
@@ -57,10 +59,18 @@ class Sendgrid_WP {
57
  case 'credentials':
58
  $smtp = new Sendgrid_SMTP( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
59
  break;
 
 
 
 
60
  }
61
 
62
  if ( Sendgrid_Tools::get_port() ) {
63
- $smtp->set_port( Sendgrid_Tools::get_port() );
 
 
 
 
64
  }
65
 
66
  return $smtp;
23
  break;
24
  }
25
 
26
+ return self::api_instance( $auth_method );
27
  }
28
 
29
  private static function api_instance( $auth_method ) {
30
  switch ( $auth_method ) {
31
  case 'apikey':
32
+ return new Sendgrid_API( "apikey", Sendgrid_Tools::get_api_key() );
33
  break;
34
 
35
  case 'credentials':
36
+ return new Sendgrid_API( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
37
  break;
38
  }
39
+
40
+ return null;
41
  }
42
 
43
  private static function smtp_instance( $auth_method )
59
  case 'credentials':
60
  $smtp = new Sendgrid_SMTP( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
61
  break;
62
+
63
+ default:
64
+ return null;
65
+ break;
66
  }
67
 
68
  if ( Sendgrid_Tools::get_port() ) {
69
+ if ( in_array( Sendgrid_Tools::get_port(), Sendgrid_Tools::$allowed_ports ) ) {
70
+ $smtp->set_port( Sendgrid_Tools::get_port() );
71
+ } else {
72
+ $smtp->set_port( Sendgrid_SMTP::TLS );
73
+ }
74
  }
75
 
76
  return $smtp;
lib/sendgrid/sendgrid-wp-mail.php CHANGED
@@ -254,10 +254,17 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
254
  }
255
  }
256
 
257
- // Set Content-Type and charset
258
- // If we don't have a content-type from the input headers
259
- if ( ! isset( $content_type ) )
260
- $content_type = 'text/plain';
 
 
 
 
 
 
 
261
 
262
  $content_type = apply_filters( 'wp_mail_content_type', $content_type );
263
 
@@ -315,6 +322,10 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
315
 
316
  $sendgrid = Sendgrid_WP::get_instance();
317
 
 
 
 
 
318
  return $sendgrid->send($mail);
319
  }
320
 
254
  }
255
  }
256
 
257
+ // Set Content-Type from header of from global variable
258
+ $global_content_type = Sendgrid_Tools::get_content_type();
259
+ if ( ! isset( $content_type ) ) {
260
+ if ( ! ( $global_content_type ) or ( 'plaintext' == $global_content_type ) ) {
261
+ $content_type = 'text/plain';
262
+ } elseif ( 'html' == $global_content_type ) {
263
+ $content_type = 'text/html';
264
+ } else {
265
+ $content_type = 'text/plain';
266
+ }
267
+ }
268
 
269
  $content_type = apply_filters( 'wp_mail_content_type', $content_type );
270
 
322
 
323
  $sendgrid = Sendgrid_WP::get_instance();
324
 
325
+ if ( ! $sendgrid ) {
326
+ return false;
327
+ }
328
+
329
  return $sendgrid->send($mail);
330
  }
331
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: team-rs
3
  Donate link: http://sendgrid.com/
4
  Tags: email, email reliability, email templates, sendgrid, smtp, transactional email, wp_mail,email infrastructure, email marketing, marketing email, deliverability, email deliverability, email delivery, email server, mail server, email integration, cloud email
5
  Requires at least: 3.3
6
- Tested up to: 4.3
7
- Stable tag: 1.7.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -110,6 +110,7 @@ SendGrid settings can optionally be defined as global variables (wp-config.php):
110
  * Reply to email: define('SENDGRID_REPLY_TO', 'reply_to@example.com');
111
  * Categories: define('SENDGRID_CATEGORIES', 'category_1,category_2');
112
  * Template: define('SENDGRID_TEMPLATE', 'templateID');
 
113
 
114
  == Frequently asked questions ==
115
 
@@ -129,9 +130,14 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
129
  8. Select the time interval for which you want to see SendGrid statistics and charts.
130
  9. Now you are able to configure port number when using SMTP method.
131
  10. You are able to configure what template to use for sending emails.
 
132
 
133
  == Changelog ==
134
 
 
 
 
 
135
  = 1.7.2 =
136
  * Check your credentials after updating, you might need to reenter your credentials
137
  * Fixed mcrypt library depencency issue
@@ -214,6 +220,10 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
214
 
215
  == Upgrade notice ==
216
 
 
 
 
 
217
  = 1.7.2 =
218
  * Check your credentials after updating, you might need to reenter your credentials
219
  * Fixed mcrypt library depencency issue
3
  Donate link: http://sendgrid.com/
4
  Tags: email, email reliability, email templates, sendgrid, smtp, transactional email, wp_mail,email infrastructure, email marketing, marketing email, deliverability, email deliverability, email delivery, email server, mail server, email integration, cloud email
5
  Requires at least: 3.3
6
+ Tested up to: 4.4
7
+ Stable tag: 1.7.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
110
  * Reply to email: define('SENDGRID_REPLY_TO', 'reply_to@example.com');
111
  * Categories: define('SENDGRID_CATEGORIES', 'category_1,category_2');
112
  * Template: define('SENDGRID_TEMPLATE', 'templateID');
113
+ * Content-type: define('SENDGRID_CONTENT_TYPE', 'html');
114
 
115
  == Frequently asked questions ==
116
 
130
  8. Select the time interval for which you want to see SendGrid statistics and charts.
131
  9. Now you are able to configure port number when using SMTP method.
132
  10. You are able to configure what template to use for sending emails.
133
+ 11. You are able to configure categories for which you would like to see your stats.
134
 
135
  == Changelog ==
136
 
137
+ = 1.7.3 =
138
+ * Add global config for content-type
139
+ * Validate send_method and port set in config file
140
+ * Be able to define categories for which you would like to see your stats
141
  = 1.7.2 =
142
  * Check your credentials after updating, you might need to reenter your credentials
143
  * Fixed mcrypt library depencency issue
220
 
221
  == Upgrade notice ==
222
 
223
+ = 1.7.3 =
224
+ * Add global config for content-type
225
+ * Validate send_method and port set in config file
226
+ * Be able to define categories for which you would like to see your stats
227
  = 1.7.2 =
228
  * Check your credentials after updating, you might need to reenter your credentials
229
  * Fixed mcrypt library depencency issue
view/js/{sendgrid.settings-v1.7.0.js → sendgrid.settings-v1.7.3.js} RENAMED
@@ -3,14 +3,16 @@ jQuery(document).ready(function($) {
3
  if ( $('#auth_method').find("option:selected").val() == 'apikey' ) {
4
  $(".apikey").show();
5
  $(".credentials").hide();
6
- } else {
 
7
  $(".apikey").hide();
8
  $(".credentials").show();
 
9
  }
10
 
11
  if ( $('#send_method').find("option:selected").val() == 'api' ) {
12
  $(".port").hide();
13
- } else {
14
  $(".port").show();
15
  }
16
 
3
  if ( $('#auth_method').find("option:selected").val() == 'apikey' ) {
4
  $(".apikey").show();
5
  $(".credentials").hide();
6
+ $(".send_method").show();
7
+ } else if ( $('#auth_method').find("option:selected").val() == 'credentials' ) {
8
  $(".apikey").hide();
9
  $(".credentials").show();
10
+ $(".send_method").show();
11
  }
12
 
13
  if ( $('#send_method').find("option:selected").val() == 'api' ) {
14
  $(".port").hide();
15
+ } else if ( $('#send_method').find("option:selected").val() == 'smtp' ) {
16
  $(".port").show();
17
  }
18
 
view/js/{sendgrid.stats-v1.7.0.js → sendgrid.stats-v1.7.3.js} RENAMED
File without changes
view/sendgrid_settings.php CHANGED
@@ -20,43 +20,46 @@
20
  <select name="auth_method" id="auth_method" <?php disabled( $is_env_auth_method ); ?> >
21
  <option value="apikey" id="apikey" <?php echo ( 'apikey' == $auth_method ) ? 'selected' : '' ?>><?php _e('Api Key') ?></option>
22
  <option value="credentials" id="credentials" <?php echo ( 'credentials' == $auth_method ) ? 'selected' : '' ?>><?php _e('Username&Password') ?></option>
 
 
 
23
  </select>
24
  </td>
25
  </tr>
26
- <tr valign="top" class="apikey">
27
  <th scope="row"><?php _e("API key: "); ?></th>
28
  <td>
29
  <input type="password" name="sendgrid_apikey" value="<?php echo ( $is_env_api_key ? "************" : $api_key ); ?>" size="50" <?php disabled( $is_env_api_key ); ?>>
30
  </td>
31
  </tr>
32
- <tr valign="top" class="credentials">
33
  <th scope="row"><?php _e("Username: "); ?></th>
34
  <td>
35
  <input type="text" name="sendgrid_username" value="<?php echo $user; ?>" size="20" class="regular-text" <?php disabled( $is_env_username ); ?>>
36
  </td>
37
  </tr>
38
- <tr valign="top" class="credentials">
39
  <th scope="row"><?php _e("Password: "); ?></th>
40
  <td>
41
  <input type="password" name="sendgrid_password" value="<?php echo ( $is_env_password ? "******" : $password ); ?>" size="20" class="regular-text" <?php disabled( $is_env_password ); ?>>
42
  </td>
43
  </tr>
44
- <tr valign="top">
45
  <th scope="row"><?php _e("Send Mail with: "); ?></th>
46
  <td>
47
  <select name="send_method" id="send_method" <?php disabled( defined('SENDGRID_SEND_METHOD') ); ?>>
48
- <?php foreach ( $allowed_methods as $method ): ?>
49
  <option value="<?php echo strtolower( $method ); ?>" <?php echo ( strtolower( $method ) == $send_method ) ? 'selected' : '' ?>><?php _e( $method ) ?></option>
50
  <?php endforeach; ?>
51
  </select>
52
- <?php if ( ! in_array( "SMTP", $allowed_methods ) ): ?>
53
  <p>
54
  <?php _e('Swift is required in order to be able to send via SMTP.'); ?>
55
  </p>
56
  <?php endif; ?>
57
  </td>
58
  </tr>
59
- <tr valign="top" class="port">
60
  <th scope="row"><?php _e("Port: "); ?></th>
61
  <td>
62
  <select name="sendgrid_port" id="sendgrid_port" <?php disabled( $is_env_port ); ?>>
@@ -109,7 +112,7 @@
109
  <input type="text" name="sendgrid_categories" value="<?php echo $categories; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_CATEGORIES') ); ?>>
110
  <span><small><em><?php _e('Leave blank to send without categories.') ?></em></small></span>
111
  <p class="description"><?php _e('Associates the category of the email this should be logged as. <br />
112
- Categories must be separated by commas (Example: category1, category2).') ?></p>
113
  </td>
114
  </tr>
115
  <tr valign="top">
@@ -121,6 +124,30 @@
121
  Example: 0b1240a5-188d-4ea7-93c1-19a7a89466b2.') ?></p>
122
  </td>
123
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  <tr valign="top">
125
  <td colspan="2">
126
  <p>
20
  <select name="auth_method" id="auth_method" <?php disabled( $is_env_auth_method ); ?> >
21
  <option value="apikey" id="apikey" <?php echo ( 'apikey' == $auth_method ) ? 'selected' : '' ?>><?php _e('Api Key') ?></option>
22
  <option value="credentials" id="credentials" <?php echo ( 'credentials' == $auth_method ) ? 'selected' : '' ?>><?php _e('Username&Password') ?></option>
23
+ <?php if ( ! in_array( $auth_method, Sendgrid_Tools::$allowed_auth_methods ) ) { ?>
24
+ <option value="<?php echo $auth_method; ?>" id="<?php echo $auth_method; ?>" selected><?php echo $auth_method; ?></option>
25
+ <?php } ?>
26
  </select>
27
  </td>
28
  </tr>
29
+ <tr valign="top" class="apikey" style="display: none;">
30
  <th scope="row"><?php _e("API key: "); ?></th>
31
  <td>
32
  <input type="password" name="sendgrid_apikey" value="<?php echo ( $is_env_api_key ? "************" : $api_key ); ?>" size="50" <?php disabled( $is_env_api_key ); ?>>
33
  </td>
34
  </tr>
35
+ <tr valign="top" class="credentials" style="display: none;">
36
  <th scope="row"><?php _e("Username: "); ?></th>
37
  <td>
38
  <input type="text" name="sendgrid_username" value="<?php echo $user; ?>" size="20" class="regular-text" <?php disabled( $is_env_username ); ?>>
39
  </td>
40
  </tr>
41
+ <tr valign="top" class="credentials" style="display: none;">
42
  <th scope="row"><?php _e("Password: "); ?></th>
43
  <td>
44
  <input type="password" name="sendgrid_password" value="<?php echo ( $is_env_password ? "******" : $password ); ?>" size="20" class="regular-text" <?php disabled( $is_env_password ); ?>>
45
  </td>
46
  </tr>
47
+ <tr valign="top" class="send_method" style="display: none;">
48
  <th scope="row"><?php _e("Send Mail with: "); ?></th>
49
  <td>
50
  <select name="send_method" id="send_method" <?php disabled( defined('SENDGRID_SEND_METHOD') ); ?>>
51
+ <?php foreach ( $allowed_send_methods as $method ): ?>
52
  <option value="<?php echo strtolower( $method ); ?>" <?php echo ( strtolower( $method ) == $send_method ) ? 'selected' : '' ?>><?php _e( $method ) ?></option>
53
  <?php endforeach; ?>
54
  </select>
55
+ <?php if ( ! in_array( "SMTP", $allowed_send_methods ) ): ?>
56
  <p>
57
  <?php _e('Swift is required in order to be able to send via SMTP.'); ?>
58
  </p>
59
  <?php endif; ?>
60
  </td>
61
  </tr>
62
+ <tr valign="top" class="port" style="display: none;">
63
  <th scope="row"><?php _e("Port: "); ?></th>
64
  <td>
65
  <select name="sendgrid_port" id="sendgrid_port" <?php disabled( $is_env_port ); ?>>
112
  <input type="text" name="sendgrid_categories" value="<?php echo $categories; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_CATEGORIES') ); ?>>
113
  <span><small><em><?php _e('Leave blank to send without categories.') ?></em></small></span>
114
  <p class="description"><?php _e('Associates the category of the email this should be logged as. <br />
115
+ Categories must be separated by commas (Example: category1,category2).') ?></p>
116
  </td>
117
  </tr>
118
  <tr valign="top">
124
  Example: 0b1240a5-188d-4ea7-93c1-19a7a89466b2.') ?></p>
125
  </td>
126
  </tr>
127
+ <tr valign="top">
128
+ <th scope="row"><?php _e("Content-type: "); ?></th>
129
+ <td>
130
+ <select name="content_type" id="content_type" <?php disabled( $is_env_content_type ); ?> >
131
+ <option value="plaintext" id="plaintext" <?php echo ( 'plaintext' == $content_type ) ? 'selected' : '' ?>><?php _e('text/plain') ?></option>
132
+ <option value="html" id="html" <?php echo ( 'html' == $content_type ) ? 'selected' : '' ?>><?php _e('text/html') ?></option>
133
+ </select>
134
+ </td>
135
+ </tr>
136
+ </tbody>
137
+ </table>
138
+ <br />
139
+ <h3><?php _e('Statistics settings') ?></h3>
140
+ <table class="form-table">
141
+ <tbody>
142
+ <tr valign="top">
143
+ <th scope="row"><?php _e("Categories: "); ?></th>
144
+ <td>
145
+ <input type="text" name="sendgrid_stats_categories" value="<?php echo $stats_categories; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_STATS_CATEGORIES') ); ?>>
146
+ <span><small><em><?php _e('Leave blank for not showing category stats.') ?></em></small></span>
147
+ <p class="description"><?php _e('Add some categories for which you would like to see your stats. <br />
148
+ Categories must be separated by commas (Example: category1,category2).') ?></p>
149
+ </td>
150
+ </tr>
151
  <tr valign="top">
152
  <td colspan="2">
153
  <p>
wpsendgrid.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: SendGrid
4
  Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
5
  Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
6
- Version: 1.7.2
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  Text Domain: sendgrid-email-delivery-simplified
3
  Plugin Name: SendGrid
4
  Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
5
  Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
6
+ Version: 1.7.3
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  Text Domain: sendgrid-email-delivery-simplified