SendGrid - Version 1.4.6

Version Description

  • Added constants for SendGrid settings
Download this release

Release Info

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

Code changes from version 1.4.1 to 1.4.6

assets/banner-772x250.jpg ADDED
Binary file
assets/icon-128x128.png ADDED
Binary file
assets/icon-256x256.png ADDED
Binary file
assets/screenshot-1.png CHANGED
Binary file
assets/screenshot-2.png CHANGED
Binary file
assets/screenshot-3.png CHANGED
Binary file
assets/screenshot-4.png CHANGED
Binary file
assets/screenshot-5.png CHANGED
Binary file
assets/screenshot-6.png CHANGED
Binary file
assets/screenshot-7.png CHANGED
Binary file
lib/class-sendgrid-settings.php CHANGED
@@ -40,7 +40,7 @@ class Sendgrid_Settings
40
  $body = $_POST['sendgrid_body'];
41
  $headers = $_POST['sendgrid_headers'];
42
  $sent = wp_mail($to, $subject, $body, $headers);
43
- if ( 'api' == get_option('sendgrid_api') )
44
  {
45
  $sent = json_decode( $sent );
46
  if ( "success" == $sent->message )
@@ -54,7 +54,7 @@ class Sendgrid_Settings
54
  }
55
 
56
  }
57
- elseif ( 'smtp' == get_option('sendgrid_api') )
58
  {
59
  if ( true === $sent )
60
  {
@@ -68,55 +68,78 @@ class Sendgrid_Settings
68
  } else {
69
  $message = 'Options saved.';
70
  $status = 'updated';
71
-
72
- $user = $_POST['sendgrid_user'];
73
- update_option( 'sendgrid_user', $user );
74
 
75
- $password = $_POST['sendgrid_pwd'];
76
- update_option( 'sendgrid_pwd', $password );
 
 
 
77
 
78
- $method = $_POST['sendgrid_api'];
79
- if ( 'smtp' == $method and ! class_exists('Swift') )
80
  {
81
- $message = 'You must have <a href="http://wordpress.org/plugins/swift-mailer/" target="_blank">' .
82
- 'Swift-mailer plugin</a> installed and activated';
83
- $status = 'error';
84
 
85
- update_option( 'sendgrid_api', 'api' );
86
- } else {
87
- update_option( 'sendgrid_api', $method );
 
88
  }
89
 
90
- $name = $_POST['sendgrid_name'];
91
- update_option( 'sendgrid_from_name', $name );
 
 
 
92
 
93
- $email = $_POST['sendgrid_email'];
94
- update_option( 'sendgrid_from_email', $email );
 
 
 
95
 
96
- $reply_to = $_POST['sendgrid_reply_to'];
97
- update_option( 'sendgrid_reply_to', $reply_to );
 
 
 
98
 
99
- $categories = $_POST['sendgrid_categories'];
100
- update_option( 'sendgrid_categories', $categories );
 
 
 
101
  }
102
  }
103
 
104
- $user = get_option('sendgrid_user');
105
- $password = get_option('sendgrid_pwd');
106
- $method = get_option('sendgrid_api');
107
- $name = get_option('sendgrid_from_name');
108
- $email = get_option('sendgrid_from_email');
109
- $reply_to = get_option('sendgrid_reply_to');
110
- $categories = get_option('sendgrid_categories');
111
-
112
- $valid_credentials = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  if ( $user and $password )
114
  {
115
  if ( in_array( 'curl', get_loaded_extensions() ) )
116
  {
117
- $valid_credentials = Sendgrid_Tools::check_username_password( $user, $password );
118
-
119
- if ( ! $valid_credentials )
120
  {
121
  $message = 'Invalid username/password';
122
  $status = 'error';
@@ -126,6 +149,8 @@ class Sendgrid_Settings
126
  $status = 'error';
127
  }
128
  }
 
 
129
 
130
  require_once dirname( __FILE__ ) . '/../view/sendgrid_settings.php';
131
  }
40
  $body = $_POST['sendgrid_body'];
41
  $headers = $_POST['sendgrid_headers'];
42
  $sent = wp_mail($to, $subject, $body, $headers);
43
+ if ( 'api' == Sendgrid_Tools::get_send_method() )
44
  {
45
  $sent = json_decode( $sent );
46
  if ( "success" == $sent->message )
54
  }
55
 
56
  }
57
+ elseif ( 'smtp' == Sendgrid_Tools::get_send_method() )
58
  {
59
  if ( true === $sent )
60
  {
68
  } else {
69
  $message = 'Options saved.';
70
  $status = 'updated';
 
 
 
71
 
72
+ if (isset($_POST['sendgrid_user']))
73
+ {
74
+ $user = $_POST['sendgrid_user'];
75
+ update_option('sendgrid_user', $user);
76
+ }
77
 
78
+ if (isset($_POST['sendgrid_pwd']))
 
79
  {
80
+ $password = $_POST['sendgrid_pwd'];
81
+ update_option('sendgrid_pwd', $password);
82
+ }
83
 
84
+ if (isset($_POST['sendgrid_api']))
85
+ {
86
+ $method = $_POST['sendgrid_api'];
87
+ update_option('sendgrid_api', $method);
88
  }
89
 
90
+ if (isset($_POST['sendgrid_name']))
91
+ {
92
+ $name = $_POST['sendgrid_name'];
93
+ update_option('sendgrid_from_name', $name);
94
+ }
95
 
96
+ if (isset($_POST['sendgrid_email']))
97
+ {
98
+ $email = $_POST['sendgrid_email'];
99
+ update_option('sendgrid_from_email', $email);
100
+ }
101
 
102
+ if (isset($_POST['sendgrid_reply_to']))
103
+ {
104
+ $reply_to = $_POST['sendgrid_reply_to'];
105
+ update_option('sendgrid_reply_to', $reply_to);
106
+ }
107
 
108
+ if (isset($_POST['sendgrid_categories']))
109
+ {
110
+ $categories = $_POST['sendgrid_categories'];
111
+ update_option('sendgrid_categories', $categories);
112
+ }
113
  }
114
  }
115
 
116
+ $user = Sendgrid_Tools::get_username();
117
+ $password = Sendgrid_Tools::get_password();
118
+ $method = Sendgrid_Tools::get_send_method();
119
+ $name = Sendgrid_Tools::get_from_name();
120
+ $email = Sendgrid_Tools::get_from_email();
121
+ $reply_to = Sendgrid_Tools::get_reply_to();
122
+ $categories = Sendgrid_Tools::get_categories();
123
+
124
+ $allowed_methods = array('smtp', 'api');
125
+ if (!in_array($method, $allowed_methods))
126
+ {
127
+ $message = 'Invalid send method, available methods are: "api" or "smtp".';
128
+ $status = 'error';
129
+ }
130
+
131
+ if ('smtp' == $method and !class_exists('Swift'))
132
+ {
133
+ $message = 'You must have <a href="http://wordpress.org/plugins/swift-mailer/" target="_blank">' .
134
+ 'Swift-mailer plugin</a> installed and activated';
135
+ $status = 'error';
136
+ }
137
+
138
  if ( $user and $password )
139
  {
140
  if ( in_array( 'curl', get_loaded_extensions() ) )
141
  {
142
+ if ( ! Sendgrid_Tools::check_username_password( $user, $password ) )
 
 
143
  {
144
  $message = 'Invalid username/password';
145
  $status = 'error';
149
  $status = 'error';
150
  }
151
  }
152
+
153
+ $are_global_credentials = ( defined('SENDGRID_USERNAME') and defined('SENDGRID_PASSWORD') );
154
 
155
  require_once dirname( __FILE__ ) . '/../view/sendgrid_settings.php';
156
  }
lib/class-sendgrid-statistics.php CHANGED
@@ -25,7 +25,7 @@ class Sendgrid_Statistics
25
  */
26
  public static function add_dashboard_widget()
27
  {
28
- if ( ! Sendgrid_Tools::check_username_password( get_option('sendgrid_user'), get_option('sendgrid_pwd') ) ) {
29
  return;
30
  }
31
 
@@ -50,7 +50,7 @@ class Sendgrid_Statistics
50
  */
51
  public static function add_statistics_menu()
52
  {
53
- if ( ! Sendgrid_Tools::check_username_password( get_option('sendgrid_user'), get_option('sendgrid_pwd') ) ) {
54
  return;
55
  }
56
 
@@ -111,8 +111,8 @@ class Sendgrid_Statistics
111
  }
112
 
113
  $parameters = array();
114
- $parameters['api_user'] = get_option('sendgrid_user');
115
- $parameters['api_key'] = get_option('sendgrid_pwd');
116
  $parameters['data_type'] = 'global';
117
  $parameters['metric'] = 'all';
118
 
@@ -123,8 +123,12 @@ class Sendgrid_Statistics
123
  $parameters['end_date'] = $_POST['end_date'];
124
  }
125
 
126
- if ( $_POST['type'] and 'wordpress' == $_POST['type'] ) {
127
- $parameters['category'] = 'wp_sendgrid_plugin';
 
 
 
 
128
  }
129
 
130
  echo Sendgrid_Tools::curl_request( 'api/stats.get.json', $parameters );
25
  */
26
  public static function add_dashboard_widget()
27
  {
28
+ if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) ) {
29
  return;
30
  }
31
 
50
  */
51
  public static function add_statistics_menu()
52
  {
53
+ if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) ) {
54
  return;
55
  }
56
 
111
  }
112
 
113
  $parameters = array();
114
+ $parameters['api_user'] = Sendgrid_Tools::get_username();
115
+ $parameters['api_key'] = Sendgrid_Tools::get_password();
116
  $parameters['data_type'] = 'global';
117
  $parameters['metric'] = 'all';
118
 
123
  $parameters['end_date'] = $_POST['end_date'];
124
  }
125
 
126
+ if ( $_POST['type'] && 'general' != $_POST['type'] ) {
127
+ if( 'wordpress' == $_POST['type'] ) {
128
+ $parameters['category'] = 'wp_sendgrid_plugin';
129
+ } else {
130
+ $parameters['category'] = urlencode( $_POST['type'] );
131
+ }
132
  }
133
 
134
  echo Sendgrid_Tools::curl_request( 'api/stats.get.json', $parameters );
lib/class-sendgrid-tools.php CHANGED
@@ -47,4 +47,120 @@ class Sendgrid_Tools
47
 
48
  return curl_exec( $process );
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
47
 
48
  return curl_exec( $process );
49
  }
50
+
51
+ /**
52
+ * Return username from the database or global variable
53
+ *
54
+ * @return string username
55
+ */
56
+ public static function get_username()
57
+ {
58
+ if ( defined('SENDGRID_USERNAME') and defined('SENDGRID_PASSWORD') ) {
59
+ return SENDGRID_USERNAME;
60
+ } else {
61
+ return get_option('sendgrid_user');
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Return password from the database or global variable
67
+ *
68
+ * @return string password
69
+ */
70
+ public static function get_password()
71
+ {
72
+ if ( defined('SENDGRID_USERNAME') and defined('SENDGRID_PASSWORD') ) {
73
+ return SENDGRID_PASSWORD;
74
+ } else {
75
+ return get_option('sendgrid_pwd');
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Return send method from the database or global variable
81
+ *
82
+ * @return string send_method
83
+ */
84
+ public static function get_send_method()
85
+ {
86
+ if ( defined('SENDGRID_SEND_METHOD') ) {
87
+ return SENDGRID_SEND_METHOD;
88
+ } elseif ( get_option('sendgrid_api') ) {
89
+ return get_option('sendgrid_api');
90
+ } else {
91
+ return 'api';
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Return from name from the database or global variable
97
+ *
98
+ * @return string from_name
99
+ */
100
+ public static function get_from_name()
101
+ {
102
+ if ( defined('SENDGRID_FROM_NAME') ) {
103
+ return SENDGRID_FROM_NAME;
104
+ } else {
105
+ return get_option('sendgrid_from_name');
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Return from email address from the database or global variable
111
+ *
112
+ * @return string from_email
113
+ */
114
+ public static function get_from_email()
115
+ {
116
+ if ( defined('SENDGRID_FROM_EMAIL') ) {
117
+ return SENDGRID_FROM_EMAIL;
118
+ } else {
119
+ return get_option('sendgrid_from_email');
120
+ }
121
+ }
122
+
123
+ /**
124
+ * Return reply to email address from the database or global variable
125
+ *
126
+ * @return string reply_to
127
+ */
128
+ public static function get_reply_to()
129
+ {
130
+ if ( defined('SENDGRID_REPLY_TO') ) {
131
+ return SENDGRID_REPLY_TO;
132
+ } else {
133
+ return get_option('sendgrid_reply_to');
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Return categories from the database or global variable
139
+ *
140
+ * @return string categories
141
+ */
142
+ public static function get_categories()
143
+ {
144
+ if ( defined('SENDGRID_CATEGORIES') ) {
145
+ return SENDGRID_CATEGORIES;
146
+ } else {
147
+ return get_option('sendgrid_categories');
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Return categories array
153
+ *
154
+ * @return array categories
155
+ */
156
+ public static function get_categories_array()
157
+ {
158
+ $categories = Sendgrid_Tools::get_categories();
159
+ if ( strlen( trim( $categories ) ) )
160
+ {
161
+ return explode( ',', $categories );
162
+ }
163
+
164
+ return array();
165
+ }
166
  }
lib/overwrite-sendgrid-methods.php CHANGED
@@ -43,9 +43,9 @@ if ( ! function_exists('wp_mail'))
43
  */
44
  function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() )
45
  {
46
- $sendgrid = new SendGrid( get_option('sendgrid_user'), get_option('sendgrid_pwd') );
47
  $mail = new SendGrid\Mail();
48
- $method = get_option( 'sendgrid_api' );
49
 
50
  // Compact the input, apply the filters, and extract them back out
51
  extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
@@ -166,7 +166,7 @@ if ( ! function_exists('wp_mail'))
166
  // From email and name
167
  // If we don't have a name from the input headers
168
  if ( !isset( $from_name ) )
169
- $from_name = get_option( 'sendgrid_from_name' );
170
 
171
  /* If we don't have an email from the input headers default to wordpress@$sitename
172
  * Some hosts will block outgoing mail from this address if it doesn't exist but
@@ -176,7 +176,7 @@ if ( ! function_exists('wp_mail'))
176
  */
177
 
178
  if ( !isset( $from_email ) ) {
179
- $from_email = trim( get_option('sendgrid_from_email') );
180
  if (!$from_email)
181
  {
182
  // Get the site domain and get rid of www.
@@ -251,7 +251,7 @@ if ( ! function_exists('wp_mail'))
251
  ->setCategory( SENDGRID_CATEGORY )
252
  ->setFrom( $from_email );
253
 
254
- $categories = explode( ',', get_option('sendgrid_categories') );
255
  foreach ($categories as $category)
256
  {
257
  $mail->addCategory($category);
@@ -279,7 +279,7 @@ if ( ! function_exists('wp_mail'))
279
  }
280
  if ( ! isset( $replyto ) )
281
  {
282
- $replyto = trim( get_option('sendgrid_reply_to') );
283
  }
284
  $reply_to_found = preg_match( '/.*<(.*)>.*/i', $replyto, $result );
285
  if ( $reply_to_found )
43
  */
44
  function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() )
45
  {
46
+ $sendgrid = new SendGrid( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() );
47
  $mail = new SendGrid\Mail();
48
+ $method = Sendgrid_Tools::get_send_method();
49
 
50
  // Compact the input, apply the filters, and extract them back out
51
  extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) );
166
  // From email and name
167
  // If we don't have a name from the input headers
168
  if ( !isset( $from_name ) )
169
+ $from_name = Sendgrid_Tools::get_from_name();
170
 
171
  /* If we don't have an email from the input headers default to wordpress@$sitename
172
  * Some hosts will block outgoing mail from this address if it doesn't exist but
176
  */
177
 
178
  if ( !isset( $from_email ) ) {
179
+ $from_email = trim( Sendgrid_Tools::get_from_email() );
180
  if (!$from_email)
181
  {
182
  // Get the site domain and get rid of www.
251
  ->setCategory( SENDGRID_CATEGORY )
252
  ->setFrom( $from_email );
253
 
254
+ $categories = explode( ',', Sendgrid_Tools::get_categories() );
255
  foreach ($categories as $category)
256
  {
257
  $mail->addCategory($category);
279
  }
280
  if ( ! isset( $replyto ) )
281
  {
282
+ $replyto = trim( Sendgrid_Tools::get_reply_to() );
283
  }
284
  $reply_to_found = preg_match( '/.*<(.*)>.*/i', $replyto, $result );
285
  if ( $reply_to_found )
readme.txt CHANGED
@@ -3,12 +3,12 @@ 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.0
7
- Stable tag: 1.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Email Delivery. Simplified.
12
 
13
  == Description ==
14
 
@@ -27,11 +27,11 @@ Emails are tracked and automatically tagged for statistics within the SendGrid D
27
  There are a couple levels of integration between your WordPress installation and the SendGrid plugin:
28
 
29
  * The simplest option is to Install it, Configure it, and the SendGrid plugin for WordPress will start sending your emails through SendGrid.
30
- * We amended wp_mail() function so all email sends from wordpress should go through SendGrid. The wp_mail function is sending text emails as default, but you have an option of sending an email with HTML content.
31
 
32
  How to use `wp_mail()` function:
33
 
34
- We amended `wp_mail()` function so all email sends from wordpress should go through SendGrid.
35
 
36
  You can send emails using the following function: `wp_mail($to, $subject, $message, $headers = '', $attachments = array())`
37
 
@@ -50,7 +50,7 @@ After wp_mail function you need to run the `remove_filter('wp_mail_content_type'
50
  Example about how to send an HTML email using different headers:
51
 
52
  `$subject = 'test plugin';
53
- $message = 'testing wordpress plugin';
54
  $to = 'address1@sendgrid.com, Address2 <address2@sendgrid.com@>, address3@sendgrid.com';
55
  or
56
  $to = array('address1@sendgrid.com', 'Address2 <address2@sendgrid.com>', 'address3@sendgrid.com');
@@ -89,6 +89,19 @@ To auto install the SendGrid Plugin from the WordPress admin:
89
  4. Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">http://sendgrid.com/partner/wordpress</a>
90
  5. Navigate to "Settings" -> "SendGrid Settings" and enter your SendGrid credentials
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  == Frequently asked questions ==
93
 
94
  = What credentials do I need to add on settings page =
@@ -107,38 +120,60 @@ Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" tar
107
 
108
  == Changelog ==
109
 
110
- = 1.0 =
111
- * Fixed issue: Add error message when PHP-curl extension is not enabled.
112
- = 1.1 =
113
- * Added SendGrid Statistics
114
- = 1.1.1 =
115
- * Added default category on sending
116
- = 1.1.2 =
117
- * Fix display for october charts
118
- = 1.1.3 =
119
- * Fix missing argument warning message
120
- = 1.2 =
121
- * Added statistics for emails sent through wordpress plugin
122
- = 1.2.1 =
123
- * Fix errors: set_html_content_type error, WP_DEBUG enabled notice, Reply-To header is overwritten by default option
124
- = 1.3 =
125
- * Added support for Wordpress 3.8, fixed visual issues for Wordpress 3.7
126
- = 1.3.1 =
127
- * Fixed reply-to to accept: "name <email@example.com>"
128
- = 1.3.2 =
129
- * Fix URL for loading image
130
  = 1.4 =
131
  * Fix warnings for static method, add notice for php version < 5.3.0, refactor plugin code
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
  == Upgrade notice ==
134
 
135
- = 1.1 =
136
- * SendGrid Statistics can be used by selecting the time interval for which you want to see your statistics.
137
- = 1.2 =
138
- * Now you can switch between Sendgrid general statistics and Sendgrid wordpress statistics.
139
- = 1.3 =
140
- * Added support for Wordpress 3.8, fixed visual issues for Wordpress 3.7
 
 
 
 
 
 
141
  = 1.4 =
142
  * Fix warnings for static method, add notice for php version < 5.3.0, refactor plugin code
143
- = 1.4.1 =
144
- * Added support to set additional categories
 
 
 
 
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.0.1
7
+ Stable tag: 1.4.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Send emails throught Sendgrid from your WordPress installation using SMTP or API integration.
12
 
13
  == Description ==
14
 
27
  There are a couple levels of integration between your WordPress installation and the SendGrid plugin:
28
 
29
  * The simplest option is to Install it, Configure it, and the SendGrid plugin for WordPress will start sending your emails through SendGrid.
30
+ * We amended wp_mail() function so all email sends from WordPress should go through SendGrid. The wp_mail function is sending text emails as default, but you have an option of sending an email with HTML content.
31
 
32
  How to use `wp_mail()` function:
33
 
34
+ We amended `wp_mail()` function so all email sends from WordPress should go through SendGrid.
35
 
36
  You can send emails using the following function: `wp_mail($to, $subject, $message, $headers = '', $attachments = array())`
37
 
50
  Example about how to send an HTML email using different headers:
51
 
52
  `$subject = 'test plugin';
53
+ $message = 'testing WordPress plugin';
54
  $to = 'address1@sendgrid.com, Address2 <address2@sendgrid.com@>, address3@sendgrid.com';
55
  or
56
  $to = array('address1@sendgrid.com', 'Address2 <address2@sendgrid.com>', 'address3@sendgrid.com');
89
  4. Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">http://sendgrid.com/partner/wordpress</a>
90
  5. Navigate to "Settings" -> "SendGrid Settings" and enter your SendGrid credentials
91
 
92
+ Define SendGrid settings as global variables (wp-config.php):
93
+
94
+ 1. Set credentials (both need to be set in order to get credentials from variables and not from the database):
95
+ * Username: define('SENDGRID_USERNAME', 'sendgrid_username');
96
+ * Password: define('SENDGRID_PASSWORD', 'sendgrid_password');
97
+
98
+ 2. Set email related settings:
99
+ * Send method ('api' or 'smtp'): define('SENDGRID_SEND_METHOD', 'api');
100
+ * From name: define('SENDGRID_FROM_NAME', 'Example Name');
101
+ * From email: define('SENDGRID_FROM_EMAIL', 'from_email@example.com');
102
+ * Reply to email: define('SENDGRID_REPLY_TO', 'reply_to@example.com');
103
+ * Categories: define('SENDGRID_CATEGORIES', 'category_1,category_2');
104
+
105
  == Frequently asked questions ==
106
 
107
  = What credentials do I need to add on settings page =
120
 
121
  == Changelog ==
122
 
123
+ = 1.4.6 =
124
+ * Added constants for SendGrid settings
125
+ = 1.4.5 =
126
+ * Fix changelog order in readme file
127
+ = 1.4.4 =
128
+ * Fix unicode filename for icon-128x128.png image
129
+ = 1.4.3 =
130
+ * Update plugin logo, description, screenshots on installation page
131
+ = 1.4.2 =
132
+ * Added SendGrid Statistics for the categories added in the SendGrid Settings Page
133
+ = 1.4.1 =
134
+ * Added support to set additional categories
 
 
 
 
 
 
 
 
135
  = 1.4 =
136
  * Fix warnings for static method, add notice for php version < 5.3.0, refactor plugin code
137
+ = 1.3.2 =
138
+ * Fix URL for loading image
139
+ = 1.3.1 =
140
+ * Fixed reply-to to accept: "name <email@example.com>"
141
+ = 1.3 =
142
+ * Added support for WordPress 3.8, fixed visual issues for WordPress 3.7
143
+ = 1.2.1 =
144
+ * Fix errors: set_html_content_type error, WP_DEBUG enabled notice, Reply-To header is overwritten by default option
145
+ = 1.2 =
146
+ * Added statistics for emails sent through WordPress plugin
147
+ = 1.1.3 =
148
+ * Fix missing argument warning message
149
+ = 1.1.2 =
150
+ * Fix display for october charts
151
+ = 1.1.1 =
152
+ * Added default category on sending
153
+ = 1.1 =
154
+ * Added SendGrid Statistics
155
+ = 1.0 =
156
+ * Fixed issue: Add error message when PHP-curl extension is not enabled.
157
 
158
  == Upgrade notice ==
159
 
160
+ = 1.4.6 =
161
+ * Added constants for SendGrid settings
162
+ = 1.4.5 =
163
+ * Fix changelog order in readme file
164
+ = 1.4.4 =
165
+ * Fix unicode filename for icon-128x128.png image
166
+ = 1.4.3 =
167
+ * Update plugin logo, description, screenshots on installation page
168
+ = 1.4.2 =
169
+ * Added SendGrid Statistics for the categories added in the SendGrid Settings Page
170
+ = 1.4.1 =
171
+ * Added support to set additional categories
172
  = 1.4 =
173
  * Fix warnings for static method, add notice for php version < 5.3.0, refactor plugin code
174
+ = 1.3 =
175
+ * Added support for WordPress 3.8, fixed visual issues for WordPress 3.7
176
+ = 1.2 =
177
+ * Now you can switch between Sendgrid general statistics and Sendgrid WordPress statistics.
178
+ = 1.1 =
179
+ * SendGrid Statistics can be used by selecting the time interval for which you want to see your statistics.
view/js/sendgrid.stats.js CHANGED
@@ -109,6 +109,9 @@ jQuery(document).ready(function($) {
109
 
110
  /* Get stats from request */
111
  response = jQuery.parseJSON(response);
 
 
 
112
  jQuery.each(response, function(key, value) {
113
  var dateString = _splitDate(value.date);
114
  var date = Date.UTC(dateString[0], _convertMonthToUTC(dateString[1]), dateString[2]);
109
 
110
  /* Get stats from request */
111
  response = jQuery.parseJSON(response);
112
+ if (undefined != response.error) {
113
+ response = [];
114
+ }
115
  jQuery.each(response, function(key, value) {
116
  var dateString = _splitDate(value.date);
117
  var date = Date.UTC(dateString[0], _convertMonthToUTC(dateString[1]), dateString[2]);
view/sendgrid_contextual_help.php CHANGED
@@ -79,4 +79,24 @@
79
  remove_filter('wp_mail_content_type', 'set_html_content_type');
80
  </span>
81
  to remove the 'text/html' filter to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  </p>
79
  remove_filter('wp_mail_content_type', 'set_html_content_type');
80
  </span>
81
  to remove the 'text/html' filter to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
82
+ <p><b>Define SendGrid settings as global variables (wp-config.php):</b></p>
83
+ <p>
84
+ <ol>
85
+ <li>Set credentials (both need to be set in order to get credentials from variables and not from the database):
86
+ <ul>
87
+ <li>Username: <span class="code">define('SENDGRID_USERNAME', 'sendgrid_username');</span></li>
88
+ <li>Password: <span class="code">define('SENDGRID_PASSWORD', 'sendgrid_password');</span></li>
89
+ </ul>
90
+ </li>
91
+ <li>Set email related settings:
92
+ <ul>
93
+ <li>Send method ('api' or 'smtp'): <span class="code">define('SENDGRID_SEND_METHOD', 'api');</span></li>
94
+ <li>From name: <span class="code">define('SENDGRID_FROM_NAME', 'Example Name');</span></li>
95
+ <li>From email: <span class="code">define('SENDGRID_FROM_EMAIL', 'from_email@example.com');</span></li>
96
+ <li>Reply to email: <span class="code">define('SENDGRID_REPLY_TO', 'reply_to@example.com');</span></li>
97
+ <li>Categories: <span class="code">define('SENDGRID_CATEGORIES', 'category_1,category_2');</span></li>
98
+ </ul>
99
+ </li>
100
+ </ol>
101
+ </p>
102
  </p>
view/sendgrid_settings.php CHANGED
@@ -17,19 +17,28 @@
17
  <tr valign="top">
18
  <th scope="row"><?php _e("Username: "); ?></th>
19
  <td>
20
- <input type="text" required="true" name="sendgrid_user" value="<?php echo $user; ?>" size="20" class="regular-text">
21
  </td>
22
  </tr>
23
  <tr valign="top">
24
  <th scope="row"><?php _e("Password: "); ?></th>
25
  <td>
26
- <input type="password" required="true" name="sendgrid_pwd" value="<?php echo $password; ?>" size="20" class="regular-text">
27
  </td>
28
  </tr>
 
 
 
 
 
 
 
 
 
29
  <tr valign="top">
30
  <th scope="row"><?php _e("Send Mail with: "); ?></th>
31
  <td>
32
- <select name="sendgrid_api">
33
  <option value="api" id="api" <?php echo ( 'api' == $method ) ? 'selected' : '' ?>><?php _e('API') ?></option>
34
  <option value="smtp" id="smtp" <?php echo ( 'smtp' == $method ) ? 'selected' : '' ?>><?php _e('SMTP') ?></option>
35
  </select>
@@ -44,21 +53,21 @@
44
  <tr valign="top">
45
  <th scope="row"><?php _e("Name: "); ?></th>
46
  <td>
47
- <input type="text" name="sendgrid_name" value="<?php echo $name; ?>" size="20" class="regular-text">
48
  <p class="description"><?php _e('Name as it will appear in recipient clients.') ?></p>
49
  </td>
50
  </tr>
51
  <tr valign="top">
52
  <th scope="row"><?php _e("Sending Address: "); ?></th>
53
  <td>
54
- <input type="email" name="sendgrid_email" value="<?php echo $email; ?>" size="20" class="regular-text">
55
  <p class="description"><?php _e('Email address from which the message will be sent,') ?></p>
56
  </td>
57
  </tr>
58
  <tr valign="top">
59
  <th scope="row"><?php _e("Reply Address: "); ?></th>
60
  <td>
61
- <input type="email" name="sendgrid_reply_to" value="<?php echo $reply_to; ?>" size="20" class="regular-text">
62
  <span><small><em><?php _e('Leave blank to use Sending Address.') ?></em></small></span>
63
  <p class="description"><?php _e('Email address where replies will be returned.') ?></p>
64
  </td>
@@ -66,12 +75,19 @@
66
  <tr valign="top">
67
  <th scope="row"><?php _e("Categories: "); ?></th>
68
  <td>
69
- <input type="text" name="sendgrid_categories" value="<?php echo $categories; ?>" size="20" class="regular-text">
70
  <span><small><em><?php _e('Leave blank to send without categories.') ?></em></small></span>
71
  <p class="description"><?php _e('Associates the category of the email this should be logged as. <br />
72
  Categories must be separated by commas (Example: category1, category2).') ?></p>
73
  </td>
74
  </tr>
 
 
 
 
 
 
 
75
  </tbody>
76
  </table>
77
  <p class="submit">
@@ -79,7 +95,7 @@
79
  </p>
80
  </form>
81
  <br />
82
- <?php if ( $valid_credentials ): ?>
83
  <h2><?php _e('SendGrid Test') ?></h2>
84
  <h3><?php _e('Send a test email with these settings') ?></h3>
85
  <form name="sendgrid_test" method="POST" action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?>">
17
  <tr valign="top">
18
  <th scope="row"><?php _e("Username: "); ?></th>
19
  <td>
20
+ <input type="text" required="true" name="sendgrid_user" value="<?php echo $user; ?>" size="20" class="regular-text" <?php disabled( $are_global_credentials ); ?>>
21
  </td>
22
  </tr>
23
  <tr valign="top">
24
  <th scope="row"><?php _e("Password: "); ?></th>
25
  <td>
26
+ <input type="password" required="true" name="sendgrid_pwd" value="<?php echo ( $are_global_credentials ? "******" : $password ); ?>" size="20" class="regular-text" <?php disabled( $are_global_credentials ); ?>>
27
  </td>
28
  </tr>
29
+ <?php if ( $are_global_credentials ): ?>
30
+ <tr valign="top">
31
+ <td colspan="2">
32
+ <p>
33
+ <?php _e('Your credentials are already configured in the config file. You can not, also, specify them in the interface.'); ?>
34
+ </p>
35
+ </td>
36
+ </tr>
37
+ <?php endif; ?>
38
  <tr valign="top">
39
  <th scope="row"><?php _e("Send Mail with: "); ?></th>
40
  <td>
41
+ <select name="sendgrid_api" <?php disabled( defined('SENDGRID_SEND_METHOD') ); ?>>
42
  <option value="api" id="api" <?php echo ( 'api' == $method ) ? 'selected' : '' ?>><?php _e('API') ?></option>
43
  <option value="smtp" id="smtp" <?php echo ( 'smtp' == $method ) ? 'selected' : '' ?>><?php _e('SMTP') ?></option>
44
  </select>
53
  <tr valign="top">
54
  <th scope="row"><?php _e("Name: "); ?></th>
55
  <td>
56
+ <input type="text" name="sendgrid_name" value="<?php echo $name; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_FROM_NAME') ); ?>>
57
  <p class="description"><?php _e('Name as it will appear in recipient clients.') ?></p>
58
  </td>
59
  </tr>
60
  <tr valign="top">
61
  <th scope="row"><?php _e("Sending Address: "); ?></th>
62
  <td>
63
+ <input type="email" name="sendgrid_email" value="<?php echo $email; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_FROM_EMAIL') ); ?>>
64
  <p class="description"><?php _e('Email address from which the message will be sent,') ?></p>
65
  </td>
66
  </tr>
67
  <tr valign="top">
68
  <th scope="row"><?php _e("Reply Address: "); ?></th>
69
  <td>
70
+ <input type="email" name="sendgrid_reply_to" value="<?php echo $reply_to; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_REPLY_TO') ); ?>>
71
  <span><small><em><?php _e('Leave blank to use Sending Address.') ?></em></small></span>
72
  <p class="description"><?php _e('Email address where replies will be returned.') ?></p>
73
  </td>
75
  <tr valign="top">
76
  <th scope="row"><?php _e("Categories: "); ?></th>
77
  <td>
78
+ <input type="text" name="sendgrid_categories" value="<?php echo $categories; ?>" size="20" class="regular-text" <?php disabled( defined('SENDGRID_CATEGORIES') ); ?>>
79
  <span><small><em><?php _e('Leave blank to send without categories.') ?></em></small></span>
80
  <p class="description"><?php _e('Associates the category of the email this should be logged as. <br />
81
  Categories must be separated by commas (Example: category1, category2).') ?></p>
82
  </td>
83
  </tr>
84
+ <tr valign="top">
85
+ <td colspan="2">
86
+ <p>
87
+ <?php _e('Disabled fields in this form means that they are already configured in the config file.'); ?>
88
+ </p>
89
+ </td>
90
+ </tr>
91
  </tbody>
92
  </table>
93
  <p class="submit">
95
  </p>
96
  </form>
97
  <br />
98
+ <?php if ( !isset($status) or 'updated' == $status ): ?>
99
  <h2><?php _e('SendGrid Test') ?></h2>
100
  <h3><?php _e('Send a test email with these settings') ?></h3>
101
  <form name="sendgrid_test" method="POST" action="<?php echo str_replace('%7E', '~', $_SERVER['REQUEST_URI']); ?>">
view/sendgrid_stats.php CHANGED
@@ -6,8 +6,16 @@
6
  </div>
7
  <div class="pull-right sendgrid-statistics-change-type">
8
  <select id="sendgrid-statistics-change-type">
9
- <option value="wordpress" selected="selected">Wordpress statistics</option>
10
  <option value="general">General statistics</option>
 
 
 
 
 
 
 
 
 
11
  </select>
12
  </div>
13
 
6
  </div>
7
  <div class="pull-right sendgrid-statistics-change-type">
8
  <select id="sendgrid-statistics-change-type">
 
9
  <option value="general">General statistics</option>
10
+ <option value="wordpress" selected="selected">Wordpress statistics</option>
11
+ <?php $categories = Sendgrid_Tools::get_categories_array(); ?>
12
+ <?php if ( is_array( $categories ) and count( $categories ) > 0 ): ?>
13
+ <optgroup label="Categories:">
14
+ <?php foreach ( $categories as $cateogry ): ?>
15
+ <option value="<?php echo $cateogry; ?>"><?php echo $cateogry; ?></option>
16
+ <?php endforeach; ?>
17
+ </optgroup>
18
+ <?php endif; ?>
19
  </select>
20
  </div>
21
 
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.4.1
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  License: GPLv2
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.4.6
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  License: GPLv2