SendGrid - Version 1.10.0

Version Description

  • Added basic Multisite functionality
  • WARNING: Multisite users need to network activate this plugin and reconfigure it.
  • Fixed an issue where other users would see the SendGrid statistics widget on the dashboard.
Download this release

Release Info

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

Code changes from version 1.9.5 to 1.10.0

lib/class-sendgrid-mc-optin.php CHANGED
@@ -10,7 +10,7 @@ class Sendgrid_OptIn_API_Endpoint{
10
  *
11
  * @return void
12
  */
13
- public function __construct(){
14
  add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
15
  add_action( 'parse_request', array( $this, 'sniff_requests' ), 0 );
16
  }
@@ -21,7 +21,7 @@ class Sendgrid_OptIn_API_Endpoint{
21
  * @param array $vars List of current public query vars
22
  * @return array $vars
23
  */
24
- public function add_query_vars( $vars ){
25
  $vars[] = '__sg_api';
26
  $vars[] = 'token';
27
 
@@ -34,7 +34,7 @@ class Sendgrid_OptIn_API_Endpoint{
34
  *
35
  * @return die if API request
36
  */
37
- public function sniff_requests(){
38
  global $wp;
39
 
40
  if( isset( $wp->query_vars['__sg_api'] ) )
@@ -50,33 +50,31 @@ class Sendgrid_OptIn_API_Endpoint{
50
  *
51
  * @return void
52
  */
53
- protected function handle_request(){
54
  global $wp;
55
 
56
  $token = $wp->query_vars['token'];
57
- if ( !$token )
58
  {
59
  wp_redirect( 'sg-subscription-missing-token' );
60
-
61
  exit();
62
  }
63
 
64
- $transient = get_transient( $token );
65
 
66
- if ( !$transient ||
67
- !is_array( $transient ) ||
68
- !isset( $transient['email'] ) ||
69
- !isset( $transient['first_name'] ) ||
70
- !isset( $transient['last_name'] ) )
71
  {
72
  wp_redirect( 'sg-subscription-invalid-token' );
73
-
74
  exit();
75
  }
76
 
77
  $subscribed = Sendgrid_NLVX::create_and_add_recipient_to_list(
78
- $transient['email'],
79
- $transient['first_name'],
80
  $transient['last_name'] );
81
 
82
  if ( $subscribed )
@@ -84,14 +82,18 @@ class Sendgrid_OptIn_API_Endpoint{
84
  $page = Sendgrid_Tools::get_mc_signup_confirmation_page_url();
85
 
86
  if ( $page == false ) {
87
- set_transient( $token, null );
 
 
 
 
88
  wp_redirect( 'sg-subscription-success' );
89
-
90
  exit();
91
  }
92
  else
93
  {
94
  $page = add_query_arg( 'sg_token', $token, $page );
 
95
  wp_redirect( $page );
96
  exit();
97
  }
@@ -100,9 +102,8 @@ class Sendgrid_OptIn_API_Endpoint{
100
  }
101
  else
102
  {
103
- wp_redirect( 'sg-error' );
104
-
105
- exit();
106
  }
107
  }
108
 
@@ -130,22 +131,31 @@ class Sendgrid_OptIn_API_Endpoint{
130
 
131
  $token = Sendgrid_OptIn_API_Endpoint::generate_email_token( $email, $first_name, $last_name );
132
 
133
- $transient = get_transient($token);
134
 
135
  if ( $transient and isset( $transient['email'] ) and ! $from_settings ) {
136
  return false;
137
  }
138
 
139
- if( false == set_transient( $token,
140
- array(
141
- 'email' => $email,
142
- 'first_name' => $first_name,
 
 
 
 
 
 
 
 
 
143
  'last_name' => $last_name ),
144
  24 * 60 * 60 ) and ! $from_settings and $transient ) {
145
  return false;
146
  }
147
 
148
- $confirmation_link = site_url() . '?__sg_api=1&token=' . $token;
149
  $headers = new SendGrid\Email();
150
  $headers->addSubstitution( '%confirmation_link%', array( $confirmation_link ) )
151
  ->addCategory( 'wp_sendgrid_subscription_widget' );
@@ -183,6 +193,10 @@ function register_shortcode_first_name($atts)
183
  $token = $_GET['sg_token'];
184
  $transient = get_transient( $token );
185
 
 
 
 
 
186
  if ( ! $transient ||
187
  ! is_array( $transient ) ||
188
  ! isset( $transient['first_name'] ) )
@@ -209,8 +223,12 @@ function register_shortcode_last_name($atts)
209
  $token = $_GET['sg_token'];
210
  $transient = get_transient( $token );
211
 
212
- if ( ! $transient ||
213
- ! is_array( $transient ) ||
 
 
 
 
214
  ! isset( $transient['last_name'] ) )
215
  {
216
  return '';
@@ -235,8 +253,12 @@ function register_shortcode_email($atts)
235
  $token = $_GET['sg_token'];
236
  $transient = get_transient( $token );
237
 
238
- if ( ! $transient ||
239
- ! is_array( $transient ) ||
 
 
 
 
240
  ! isset( $transient['email'] ) )
241
  {
242
  return '';
@@ -264,8 +286,17 @@ function sg_invalidate_token() {
264
 
265
  $token = $_GET['sg_token'];
266
  $transient = get_transient( $token );
267
- if ( $token && $transient ) {
268
- set_transient( $token, null );
 
 
 
 
 
 
 
 
 
269
  }
270
  }
271
 
10
  *
11
  * @return void
12
  */
13
+ public function __construct() {
14
  add_filter( 'query_vars', array( $this, 'add_query_vars' ), 0 );
15
  add_action( 'parse_request', array( $this, 'sniff_requests' ), 0 );
16
  }
21
  * @param array $vars List of current public query vars
22
  * @return array $vars
23
  */
24
+ public function add_query_vars( $vars ) {
25
  $vars[] = '__sg_api';
26
  $vars[] = 'token';
27
 
34
  *
35
  * @return die if API request
36
  */
37
+ public function sniff_requests() {
38
  global $wp;
39
 
40
  if( isset( $wp->query_vars['__sg_api'] ) )
50
  *
51
  * @return void
52
  */
53
+ protected function handle_request() {
54
  global $wp;
55
 
56
  $token = $wp->query_vars['token'];
57
+ if ( ! $token )
58
  {
59
  wp_redirect( 'sg-subscription-missing-token' );
 
60
  exit();
61
  }
62
 
63
+ $transient = ( is_multisite() ? get_site_transient( $token ) : get_transient( $token ) );
64
 
65
+ if ( ! $transient or
66
+ ! is_array( $transient ) or
67
+ ! isset( $transient['email'] ) or
68
+ ! isset( $transient['first_name'] ) or
69
+ ! isset( $transient['last_name'] ) )
70
  {
71
  wp_redirect( 'sg-subscription-invalid-token' );
 
72
  exit();
73
  }
74
 
75
  $subscribed = Sendgrid_NLVX::create_and_add_recipient_to_list(
76
+ $transient['email'],
77
+ $transient['first_name'],
78
  $transient['last_name'] );
79
 
80
  if ( $subscribed )
82
  $page = Sendgrid_Tools::get_mc_signup_confirmation_page_url();
83
 
84
  if ( $page == false ) {
85
+ if ( is_multisite() ) {
86
+ set_site_transient( $token, null );
87
+ } else {
88
+ set_transient( $token, null );
89
+ }
90
  wp_redirect( 'sg-subscription-success' );
 
91
  exit();
92
  }
93
  else
94
  {
95
  $page = add_query_arg( 'sg_token', $token, $page );
96
+
97
  wp_redirect( $page );
98
  exit();
99
  }
102
  }
103
  else
104
  {
105
+ wp_redirect( 'sg-error' );
106
+ exit();
 
107
  }
108
  }
109
 
131
 
132
  $token = Sendgrid_OptIn_API_Endpoint::generate_email_token( $email, $first_name, $last_name );
133
 
134
+ $transient = ( is_multisite() ? get_site_transient($token) : get_transient($token) );
135
 
136
  if ( $transient and isset( $transient['email'] ) and ! $from_settings ) {
137
  return false;
138
  }
139
 
140
+ if ( is_multisite() ) {
141
+ if ( false == set_site_transient( $token,
142
+ array(
143
+ 'email' => $email,
144
+ 'first_name' => $first_name,
145
+ 'last_name' => $last_name ),
146
+ 24 * 60 * 60 ) and ! $from_settings and $transient ) {
147
+ return false;
148
+ }
149
+ } elseif ( false == set_transient( $token,
150
+ array(
151
+ 'email' => $email,
152
+ 'first_name' => $first_name,
153
  'last_name' => $last_name ),
154
  24 * 60 * 60 ) and ! $from_settings and $transient ) {
155
  return false;
156
  }
157
 
158
+ $confirmation_link = site_url() . '/?__sg_api=1&token=' . $token;
159
  $headers = new SendGrid\Email();
160
  $headers->addSubstitution( '%confirmation_link%', array( $confirmation_link ) )
161
  ->addCategory( 'wp_sendgrid_subscription_widget' );
193
  $token = $_GET['sg_token'];
194
  $transient = get_transient( $token );
195
 
196
+ if ( is_multisite() ) {
197
+ $transient = get_site_transient( $token );
198
+ }
199
+
200
  if ( ! $transient ||
201
  ! is_array( $transient ) ||
202
  ! isset( $transient['first_name'] ) )
223
  $token = $_GET['sg_token'];
224
  $transient = get_transient( $token );
225
 
226
+ if ( is_multisite() ) {
227
+ $transient = get_site_transient( $token );
228
+ }
229
+
230
+ if ( ! $transient or
231
+ ! is_array( $transient ) or
232
  ! isset( $transient['last_name'] ) )
233
  {
234
  return '';
253
  $token = $_GET['sg_token'];
254
  $transient = get_transient( $token );
255
 
256
+ if ( is_multisite() ) {
257
+ $transient = get_site_transient( $token );
258
+ }
259
+
260
+ if ( ! $transient or
261
+ ! is_array( $transient ) or
262
  ! isset( $transient['email'] ) )
263
  {
264
  return '';
286
 
287
  $token = $_GET['sg_token'];
288
  $transient = get_transient( $token );
289
+
290
+ if ( is_multisite() ) {
291
+ $transient = get_site_transient( $token );
292
+ }
293
+
294
+ if ( $token and $transient ) {
295
+ if ( is_multisite() ) {
296
+ set_site_transient( $token, null );
297
+ } else {
298
+ set_transient( $token, null );
299
+ }
300
  }
301
  }
302
 
lib/class-sendgrid-settings.php CHANGED
@@ -20,17 +20,33 @@ class Sendgrid_Settings {
20
  */
21
  public function __construct( $plugin_directory )
22
  {
23
- // Add SendGrid settings page in the menu
24
- add_action( 'admin_menu', array( __CLASS__, 'add_settings_menu' ) );
25
-
26
- // Add SendGrid settings page in the plugin list
27
- add_filter( 'plugin_action_links_' . $plugin_directory, array( __CLASS__, 'add_settings_link' ) );
28
-
29
- // Add SendGrid Help contextual menu in the settings page
30
- add_filter( 'contextual_help', array( __CLASS__, 'show_contextual_help' ), 10, 3 );
31
 
32
- // Add SendGrid javascripts in header
33
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_headers' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
  /**
@@ -43,6 +59,16 @@ class Sendgrid_Settings {
43
  array( __CLASS__, 'show_settings_page' ));
44
  }
45
 
 
 
 
 
 
 
 
 
 
 
46
  /**
47
  * Add SendGrid settings page in the plugin list
48
  *
@@ -84,7 +110,7 @@ class Sendgrid_Settings {
84
  */
85
  public static function add_headers( $hook )
86
  {
87
- if ( SENDGRID_PLUGIN_SETTINGS != $hook ) {
88
  return;
89
  }
90
 
@@ -107,7 +133,7 @@ class Sendgrid_Settings {
107
 
108
  if ( 'POST' == $_SERVER['REQUEST_METHOD'] and ! isset( $_POST['sg_dismiss_widget_notice'] ) ) {
109
  $response = self::do_post( $_POST );
110
- if( isset( $response['status'] ) and $response['status'] == 'error' ) {
111
  $error_from_update = true;
112
  }
113
  }
@@ -251,14 +277,14 @@ class Sendgrid_Settings {
251
  }
252
  }
253
 
254
- if( defined( 'SENDGRID_FROM_EMAIL' ) ) {
255
  if ( ! Sendgrid_Tools::is_valid_email( SENDGRID_FROM_EMAIL ) ) {
256
  $message = 'Sending email address is not valid in config file.';
257
  $status = 'error';
258
  }
259
  }
260
 
261
- if( defined( 'SENDGRID_REPLY_TO' ) ) {
262
  if ( ! Sendgrid_Tools::is_valid_email( SENDGRID_REPLY_TO ) ) {
263
  $message = 'Reply email address is not valid in config file.';
264
  $status = 'error';
@@ -550,7 +576,7 @@ class Sendgrid_Settings {
550
  }
551
 
552
  if ( isset( $params['sendgrid_name'] ) ) {
553
- update_option( 'sendgrid_from_name', $params['sendgrid_name'] );
554
  }
555
 
556
  if ( isset( $params['sendgrid_email'] ) ) {
@@ -560,7 +586,7 @@ class Sendgrid_Settings {
560
  'status' => 'error'
561
  );
562
  } else {
563
- update_option( 'sendgrid_from_email', $params['sendgrid_email'] );
564
  }
565
  }
566
 
@@ -571,16 +597,16 @@ class Sendgrid_Settings {
571
  'status' => 'error'
572
  );
573
  } else {
574
- update_option( 'sendgrid_reply_to', $params['sendgrid_reply_to'] );
575
  }
576
  }
577
 
578
  if ( isset( $params['sendgrid_categories'] ) ) {
579
- update_option( 'sendgrid_categories', $params['sendgrid_categories'] );
580
  }
581
 
582
  if ( isset( $params['sendgrid_stats_categories'] ) ) {
583
- update_option( 'sendgrid_stats_categories', $params['sendgrid_stats_categories'] );
584
  }
585
 
586
  if ( isset( $params['sendgrid_template'] ) ) {
@@ -590,24 +616,24 @@ class Sendgrid_Settings {
590
  'status' => 'error'
591
  );
592
  } else {
593
- update_option( 'sendgrid_template', $params['sendgrid_template'] );
594
  }
595
  }
596
 
597
  if ( isset( $params['send_method'] ) ) {
598
- update_option( 'sendgrid_api', $params['send_method'] );
599
  }
600
 
601
- if ( isset( $params['auth_method'] ) && in_array( $params['auth_method'], Sendgrid_Tools::$allowed_auth_methods ) ) {
602
- update_option( 'sendgrid_auth_method', $params['auth_method'] );
603
  }
604
 
605
  if ( isset( $params['sendgrid_port'] ) ) {
606
- update_option( 'sendgrid_port', $params['sendgrid_port'] );
607
  }
608
 
609
  if ( isset( $params['content_type'] ) ) {
610
- update_option( 'sendgrid_content_type', $params['content_type'] );
611
  }
612
 
613
  if ( isset( $params['unsubscribe_group'] ) ) {
20
  */
21
  public function __construct( $plugin_directory )
22
  {
23
+ add_action( 'init', array( __CLASS__, 'set_up_menu' ) );
24
+ }
 
 
 
 
 
 
25
 
26
+ /**
27
+ * Method that is called to set up the settings menu
28
+ *
29
+ * @return void
30
+ */
31
+ public static function set_up_menu()
32
+ {
33
+ if ( ! is_multisite() and current_user_can('manage_options') ) {
34
+ // Add SendGrid settings page in the menu
35
+ add_action( 'admin_menu', array( __CLASS__, 'add_settings_menu' ) );
36
+ // Add SendGrid settings page in the plugin list
37
+ add_filter( 'plugin_action_links_' . $plugin_directory, array( __CLASS__, 'add_settings_link' ) );
38
+ // Add SendGrid Help contextual menu in the settings page
39
+ add_filter( 'contextual_help', array( __CLASS__, 'show_contextual_help' ), 10, 3 );
40
+ // Add SendGrid javascripts in header
41
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_headers' ) );
42
+ } elseif ( is_multisite() and is_super_admin() ) {
43
+ // Add SendGrid settings page in the network admin menu
44
+ add_action( 'network_admin_menu', array( __CLASS__, 'add_network_settings_menu' ) );
45
+ // Add SendGrid Help contextual menu in the settings page
46
+ add_filter( 'contextual_help', array( __CLASS__, 'show_contextual_help' ), 10, 3 );
47
+ // Add SendGrid javascripts in header
48
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_headers' ) );
49
+ }
50
  }
51
 
52
  /**
59
  array( __CLASS__, 'show_settings_page' ));
60
  }
61
 
62
+ /**
63
+ * Add SendGrid settings page in the network menu
64
+ *
65
+ * @return void
66
+ */
67
+ public static function add_network_settings_menu() {
68
+ add_menu_page( __( 'SendGrid Settings' ), __( 'SendGrid Settings' ), 'manage_options', 'sendgrid-settings',
69
+ array( __CLASS__, 'show_settings_page' ));
70
+ }
71
+
72
  /**
73
  * Add SendGrid settings page in the plugin list
74
  *
110
  */
111
  public static function add_headers( $hook )
112
  {
113
+ if ( strpos( $hook, 'sendgrid-settings' ) === false ) {
114
  return;
115
  }
116
 
133
 
134
  if ( 'POST' == $_SERVER['REQUEST_METHOD'] and ! isset( $_POST['sg_dismiss_widget_notice'] ) ) {
135
  $response = self::do_post( $_POST );
136
+ if ( isset( $response['status'] ) and $response['status'] == 'error' ) {
137
  $error_from_update = true;
138
  }
139
  }
277
  }
278
  }
279
 
280
+ if ( defined( 'SENDGRID_FROM_EMAIL' ) ) {
281
  if ( ! Sendgrid_Tools::is_valid_email( SENDGRID_FROM_EMAIL ) ) {
282
  $message = 'Sending email address is not valid in config file.';
283
  $status = 'error';
284
  }
285
  }
286
 
287
+ if ( defined( 'SENDGRID_REPLY_TO' ) ) {
288
  if ( ! Sendgrid_Tools::is_valid_email( SENDGRID_REPLY_TO ) ) {
289
  $message = 'Reply email address is not valid in config file.';
290
  $status = 'error';
576
  }
577
 
578
  if ( isset( $params['sendgrid_name'] ) ) {
579
+ Sendgrid_Tools::set_from_name( $params['sendgrid_name'] );
580
  }
581
 
582
  if ( isset( $params['sendgrid_email'] ) ) {
586
  'status' => 'error'
587
  );
588
  } else {
589
+ Sendgrid_Tools::set_from_email( $params['sendgrid_email'] );
590
  }
591
  }
592
 
597
  'status' => 'error'
598
  );
599
  } else {
600
+ Sendgrid_Tools::set_reply_to( $params['sendgrid_reply_to'] );
601
  }
602
  }
603
 
604
  if ( isset( $params['sendgrid_categories'] ) ) {
605
+ Sendgrid_Tools::set_categories( $params['sendgrid_categories'] );
606
  }
607
 
608
  if ( isset( $params['sendgrid_stats_categories'] ) ) {
609
+ Sendgrid_Tools::set_stats_categories( $params['sendgrid_stats_categories'] );
610
  }
611
 
612
  if ( isset( $params['sendgrid_template'] ) ) {
616
  'status' => 'error'
617
  );
618
  } else {
619
+ Sendgrid_Tools::set_template( $params['sendgrid_template'] );
620
  }
621
  }
622
 
623
  if ( isset( $params['send_method'] ) ) {
624
+ Sendgrid_Tools::set_send_method( $params['send_method'] );
625
  }
626
 
627
+ if ( isset( $params['auth_method'] ) and in_array( $params['auth_method'], Sendgrid_Tools::$allowed_auth_methods ) ) {
628
+ Sendgrid_Tools::set_auth_method( $params['auth_method'] );
629
  }
630
 
631
  if ( isset( $params['sendgrid_port'] ) ) {
632
+ Sendgrid_Tools::set_port( $params['sendgrid_port'] );
633
  }
634
 
635
  if ( isset( $params['content_type'] ) ) {
636
+ Sendgrid_Tools::set_content_type( $params['content_type'] );
637
  }
638
 
639
  if ( isset( $params['unsubscribe_group'] ) ) {
lib/class-sendgrid-statistics.php CHANGED
@@ -6,17 +6,38 @@ class Sendgrid_Statistics
6
  {
7
  public function __construct()
8
  {
9
- // Add SendGrid widget in dashboard
10
- add_action( 'wp_dashboard_setup', array( __CLASS__, 'add_dashboard_widget' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- // Add SendGrid stats page in menu
13
- add_action( 'admin_menu', array( __CLASS__, 'add_statistics_menu' ) );
14
 
15
- // Add SendGrid javascripts in header
16
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_headers' ) );
 
 
 
17
 
18
- // Add SendGrid page for get statistics through ajax
19
- add_action( 'wp_ajax_sendgrid_get_stats', array( __CLASS__, 'get_ajax_statistics' ) );
 
 
 
 
20
  }
21
 
22
  /**
@@ -27,17 +48,23 @@ class Sendgrid_Statistics
27
  */
28
  public static function add_dashboard_widget()
29
  {
 
 
 
 
30
  switch ( Sendgrid_Tools::get_auth_method() )
31
  {
32
  case "apikey":
33
  $apikey = Sendgrid_Tools::get_api_key();
34
- if ( ! Sendgrid_Tools::check_api_key( $apikey ) or ! Sendgrid_Tools::check_api_key_stats( $apikey ) )
35
  return;
 
36
  break;
37
 
38
  case "credentials":
39
- if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) )
40
  return;
 
41
  break;
42
  }
43
 
@@ -66,13 +93,15 @@ class Sendgrid_Statistics
66
  {
67
  case "apikey":
68
  $apikey = Sendgrid_Tools::get_api_key();
69
- if ( ! Sendgrid_Tools::check_api_key( $apikey ) )
70
  return;
 
71
  break;
72
 
73
  case "credentials":
74
- if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) )
75
  return;
 
76
  break;
77
  }
78
 
@@ -80,6 +109,32 @@ class Sendgrid_Statistics
80
  array( __CLASS__, "show_statistics_page" ) );
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  /**
84
  * Display SendGrid statistics page
85
  *
@@ -104,7 +159,7 @@ class Sendgrid_Statistics
104
  */
105
  public static function add_headers( $hook )
106
  {
107
- if ( "index.php" != $hook && SENDGRID_PLUGIN_STATISTICS != $hook ) {
108
  return;
109
  }
110
 
6
  {
7
  public function __construct()
8
  {
9
+ add_action( 'init', array( __CLASS__, 'set_up_menu' ) );
10
+ }
11
+
12
+ /**
13
+ * Method that is called to set up the settings menu
14
+ *
15
+ * @return void
16
+ */
17
+ public static function set_up_menu()
18
+ {
19
+ if ( ! is_multisite() and current_user_can('manage_options') ) {
20
+ // Add SendGrid widget in dashboard
21
+ add_action( 'wp_dashboard_setup', array( __CLASS__, 'add_dashboard_widget' ) );
22
+
23
+ // Add SendGrid stats page in menu
24
+ add_action( 'admin_menu', array( __CLASS__, 'add_statistics_menu' ) );
25
 
26
+ // Add SendGrid javascripts in header
27
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_headers' ) );
28
 
29
+ // Add SendGrid page for get statistics through ajax
30
+ add_action( 'wp_ajax_sendgrid_get_stats', array( __CLASS__, 'get_ajax_statistics' ) );
31
+ } elseif ( is_multisite() and is_super_admin() ) {
32
+ // Add SendGrid stats page in menu
33
+ add_action( 'network_admin_menu', array( __CLASS__, 'add_network_statistics_menu' ) );
34
 
35
+ // Add SendGrid javascripts in header
36
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_headers' ) );
37
+
38
+ // Add SendGrid page for get statistics through ajax
39
+ add_action( 'wp_ajax_sendgrid_get_stats', array( __CLASS__, 'get_ajax_statistics' ) );
40
+ }
41
  }
42
 
43
  /**
48
  */
49
  public static function add_dashboard_widget()
50
  {
51
+ if ( ! current_user_can('manage_options') ) {
52
+ return;
53
+ }
54
+
55
  switch ( Sendgrid_Tools::get_auth_method() )
56
  {
57
  case "apikey":
58
  $apikey = Sendgrid_Tools::get_api_key();
59
+ if ( ! Sendgrid_Tools::check_api_key( $apikey ) or ! Sendgrid_Tools::check_api_key_stats( $apikey ) ) {
60
  return;
61
+ }
62
  break;
63
 
64
  case "credentials":
65
+ if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) ) {
66
  return;
67
+ }
68
  break;
69
  }
70
 
93
  {
94
  case "apikey":
95
  $apikey = Sendgrid_Tools::get_api_key();
96
+ if ( ! Sendgrid_Tools::check_api_key( $apikey ) ) {
97
  return;
98
+ }
99
  break;
100
 
101
  case "credentials":
102
+ if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) ) {
103
  return;
104
+ }
105
  break;
106
  }
107
 
109
  array( __CLASS__, "show_statistics_page" ) );
110
  }
111
 
112
+ /**
113
+ * Add SendGrid statistics page in the network menu
114
+ *
115
+ * @return void
116
+ */
117
+ public static function add_network_statistics_menu() {
118
+ switch ( Sendgrid_Tools::get_auth_method() )
119
+ {
120
+ case "apikey":
121
+ $apikey = Sendgrid_Tools::get_api_key();
122
+ if ( ! Sendgrid_Tools::check_api_key( $apikey ) ) {
123
+ return;
124
+ }
125
+ break;
126
+
127
+ case "credentials":
128
+ if ( ! Sendgrid_Tools::check_username_password( Sendgrid_Tools::get_username(), Sendgrid_Tools::get_password() ) ) {
129
+ return;
130
+ }
131
+ break;
132
+ }
133
+
134
+ add_menu_page( __( 'SendGrid Stats' ), __( 'SendGrid Stats' ), 'manage_options', 'sendgrid-statistics',
135
+ array( __CLASS__, 'show_statistics_page' ));
136
+ }
137
+
138
  /**
139
  * Display SendGrid statistics page
140
  *
159
  */
160
  public static function add_headers( $hook )
161
  {
162
+ if ( "index.php" != $hook and strpos( $hook, 'sendgrid-statistics' ) === false ) {
163
  return;
164
  }
165
 
lib/class-sendgrid-tools.php CHANGED
@@ -141,9 +141,9 @@ class Sendgrid_Tools
141
 
142
  // check unsubscribe group permission
143
  if ( Sendgrid_Tools::check_api_key_scopes( $apikey, array( "asm.groups.read" ) ) ) {
144
- update_option( 'sendgrid_asm_permission', 'true' );
145
  } else {
146
- update_option( 'sendgrid_asm_permission', 'false' );
147
  }
148
 
149
  if ( ! Sendgrid_Tools::check_api_key_scopes( $apikey, array( "mail.send" ) ) ) {
@@ -249,6 +249,8 @@ class Sendgrid_Tools
249
  {
250
  if ( defined( 'SENDGRID_USERNAME' ) ) {
251
  return SENDGRID_USERNAME;
 
 
252
  } else {
253
  $username = get_option( 'sendgrid_user' );
254
  if( $username ) {
@@ -269,11 +271,19 @@ class Sendgrid_Tools
269
  */
270
  public static function set_username( $username )
271
  {
272
- if( ! isset( $username ) ) {
273
- return update_option( 'sendgrid_username', '' );
274
- }
 
 
 
 
 
 
 
275
 
276
- return update_option( 'sendgrid_username', $username );
 
277
  }
278
 
279
  /**
@@ -285,10 +295,12 @@ class Sendgrid_Tools
285
  {
286
  if ( defined( 'SENDGRID_PASSWORD' ) ) {
287
  return SENDGRID_PASSWORD;
 
 
288
  } else {
289
  $password = get_option( 'sendgrid_pwd' );
290
  $new_password = get_option( 'sendgrid_password' );
291
- if( $new_password and ! $password ) {
292
  update_option( 'sendgrid_pwd', self::decrypt( $new_password, AUTH_KEY ) );
293
  delete_option( 'sendgrid_password' );
294
  }
@@ -307,7 +319,11 @@ class Sendgrid_Tools
307
  */
308
  public static function set_password( $password )
309
  {
310
- return update_option( 'sendgrid_pwd', $password );
 
 
 
 
311
  }
312
 
313
  /**
@@ -319,10 +335,12 @@ class Sendgrid_Tools
319
  {
320
  if ( defined( 'SENDGRID_API_KEY' ) ) {
321
  return SENDGRID_API_KEY;
 
 
322
  } else {
323
  $apikey = get_option( 'sendgrid_api_key' );
324
  $new_apikey = get_option( 'sendgrid_apikey' );
325
- if( $new_apikey and ! $apikey ) {
326
  update_option( 'sendgrid_api_key', self::decrypt( $new_apikey, AUTH_KEY ) );
327
  delete_option( 'sendgrid_apikey' );
328
  }
@@ -341,6 +359,8 @@ class Sendgrid_Tools
341
  {
342
  if ( defined( 'SENDGRID_MC_API_KEY' ) ) {
343
  return SENDGRID_MC_API_KEY;
 
 
344
  } else {
345
  return get_option( 'sendgrid_mc_api_key' );
346
  }
@@ -355,6 +375,8 @@ class Sendgrid_Tools
355
  {
356
  if ( defined( 'SENDGRID_MC_LIST_ID' ) ) {
357
  return SENDGRID_MC_LIST_ID;
 
 
358
  } else {
359
  return get_option( 'sendgrid_mc_list_id' );
360
  }
@@ -369,6 +391,8 @@ class Sendgrid_Tools
369
  {
370
  if ( defined( 'SENDGRID_MC_OPT_USE_TRANSACTIONAL' ) ) {
371
  return SENDGRID_MC_OPT_USE_TRANSACTIONAL;
 
 
372
  } else {
373
  return get_option( 'sendgrid_mc_opt_use_transactional' );
374
  }
@@ -383,6 +407,8 @@ class Sendgrid_Tools
383
  {
384
  if ( defined( 'SENDGRID_MC_OPT_REQ_FNAME_LNAME' ) ) {
385
  return SENDGRID_MC_OPT_REQ_FNAME_LNAME;
 
 
386
  } else {
387
  return get_option( 'sendgrid_mc_opt_req_fname_lname' );
388
  }
@@ -397,6 +423,8 @@ class Sendgrid_Tools
397
  {
398
  if ( defined( 'SENDGRID_MC_OPT_INCL_FNAME_LNAME' ) ) {
399
  return SENDGRID_MC_OPT_INCL_FNAME_LNAME;
 
 
400
  } else {
401
  return get_option( 'sendgrid_mc_opt_incl_fname_lname' );
402
  }
@@ -411,6 +439,8 @@ class Sendgrid_Tools
411
  {
412
  if ( defined( 'SENDGRID_MC_SIGNUP_EMAIL_SUBJECT' ) ) {
413
  return SENDGRID_MC_SIGNUP_EMAIL_SUBJECT;
 
 
414
  } else {
415
  return get_option( 'sendgrid_mc_signup_email_subject' );
416
  }
@@ -425,6 +455,8 @@ class Sendgrid_Tools
425
  {
426
  if ( defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT' ) ) {
427
  return SENDGRID_MC_SIGNUP_EMAIL_CONTENT;
 
 
428
  } else {
429
  return get_option( 'sendgrid_mc_signup_email_content' );
430
  }
@@ -439,6 +471,8 @@ class Sendgrid_Tools
439
  {
440
  if ( defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT_TEXT' ) ) {
441
  return SENDGRID_MC_SIGNUP_EMAIL_CONTENT_TEXT;
 
 
442
  } else {
443
  return get_option( 'sendgrid_mc_signup_email_content_text' );
444
  }
@@ -453,6 +487,8 @@ class Sendgrid_Tools
453
  {
454
  if ( defined( 'SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE' ) ) {
455
  return SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE;
 
 
456
  } else {
457
  return get_option( 'sendgrid_mc_signup_confirmation_page' );
458
  }
@@ -471,7 +507,7 @@ class Sendgrid_Tools
471
  }
472
 
473
  $confirmation_pages = get_pages( array( 'parent' => 0 ) );
474
- foreach ($confirmation_pages as $key => $page) {
475
  if ( $page->ID == $page_id ) {
476
  return $page->guid;
477
  }
@@ -487,7 +523,11 @@ class Sendgrid_Tools
487
  */
488
  public static function get_mc_auth_valid()
489
  {
490
- return get_option( 'sendgrid_mc_auth_valid' );
 
 
 
 
491
  }
492
 
493
  /**
@@ -497,7 +537,11 @@ class Sendgrid_Tools
497
  */
498
  public static function get_mc_widget_notice_dismissed()
499
  {
500
- return get_option( 'sendgrid_mc_widget_notice_dismissed' );
 
 
 
 
501
  }
502
 
503
  /**
@@ -509,7 +553,11 @@ class Sendgrid_Tools
509
  */
510
  public static function set_api_key( $apikey )
511
  {
512
- return update_option( 'sendgrid_api_key', $apikey );
 
 
 
 
513
  }
514
 
515
  /**
@@ -521,7 +569,11 @@ class Sendgrid_Tools
521
  */
522
  public static function set_mc_api_key( $apikey )
523
  {
524
- return update_option( 'sendgrid_mc_api_key', $apikey );
 
 
 
 
525
  }
526
 
527
  /**
@@ -533,7 +585,11 @@ class Sendgrid_Tools
533
  */
534
  public static function set_mc_list_id( $list_id )
535
  {
536
- return update_option( 'sendgrid_mc_list_id', $list_id );
 
 
 
 
537
  }
538
 
539
  /**
@@ -545,7 +601,11 @@ class Sendgrid_Tools
545
  */
546
  public static function set_mc_opt_use_transactional( $use_transactional )
547
  {
548
- return update_option( 'sendgrid_mc_opt_use_transactional', $use_transactional );
 
 
 
 
549
  }
550
 
551
  /**
@@ -557,7 +617,11 @@ class Sendgrid_Tools
557
  */
558
  public static function set_mc_opt_req_fname_lname( $req_fname_lname )
559
  {
560
- return update_option( 'sendgrid_mc_opt_req_fname_lname', $req_fname_lname );
 
 
 
 
561
  }
562
 
563
  /**
@@ -569,7 +633,11 @@ class Sendgrid_Tools
569
  */
570
  public static function set_mc_opt_incl_fname_lname( $incl_fname_lname )
571
  {
572
- return update_option( 'sendgrid_mc_opt_incl_fname_lname', $incl_fname_lname );
 
 
 
 
573
  }
574
 
575
  /**
@@ -581,7 +649,11 @@ class Sendgrid_Tools
581
  */
582
  public static function set_mc_signup_email_subject( $email_subject )
583
  {
584
- return update_option( 'sendgrid_mc_signup_email_subject', $email_subject );
 
 
 
 
585
  }
586
 
587
  /**
@@ -593,7 +665,11 @@ class Sendgrid_Tools
593
  */
594
  public static function set_mc_signup_email_content( $email_content )
595
  {
596
- return update_option( 'sendgrid_mc_signup_email_content', $email_content );
 
 
 
 
597
  }
598
 
599
  /**
@@ -605,7 +681,11 @@ class Sendgrid_Tools
605
  */
606
  public static function set_mc_signup_email_content_text( $email_content )
607
  {
608
- return update_option( 'sendgrid_mc_signup_email_content_text', $email_content );
 
 
 
 
609
  }
610
 
611
  /**
@@ -617,7 +697,11 @@ class Sendgrid_Tools
617
  */
618
  public static function set_mc_signup_confirmation_page( $confirmation_page )
619
  {
620
- return update_option( 'sendgrid_mc_signup_confirmation_page', $confirmation_page );
 
 
 
 
621
  }
622
 
623
  /**
@@ -629,7 +713,11 @@ class Sendgrid_Tools
629
  */
630
  public static function set_mc_auth_valid( $auth_valid )
631
  {
632
- return update_option( 'sendgrid_mc_auth_valid', $auth_valid );
 
 
 
 
633
  }
634
 
635
  /**
@@ -641,7 +729,11 @@ class Sendgrid_Tools
641
  */
642
  public static function set_mc_widget_notice_dismissed( $notice_dismissed )
643
  {
644
- return update_option( 'sendgrid_mc_widget_notice_dismissed', $notice_dismissed );
 
 
 
 
645
  }
646
 
647
  /**
@@ -653,6 +745,8 @@ class Sendgrid_Tools
653
  {
654
  if ( defined( 'SENDGRID_SEND_METHOD' ) ) {
655
  return SENDGRID_SEND_METHOD;
 
 
656
  } elseif ( get_option( 'sendgrid_api' ) ) {
657
  return get_option( 'sendgrid_api' );
658
  } else {
@@ -660,6 +754,22 @@ class Sendgrid_Tools
660
  }
661
  }
662
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
663
  /**
664
  * Return auth method from the database or global variable
665
  *
@@ -669,6 +779,8 @@ class Sendgrid_Tools
669
  {
670
  if ( defined( 'SENDGRID_AUTH_METHOD' ) ) {
671
  return SENDGRID_AUTH_METHOD;
 
 
672
  } elseif ( get_option( 'sendgrid_auth_method' ) ) {
673
  $auth_method = get_option( 'sendgrid_auth_method' );
674
  if ( 'username' == $auth_method ) {
@@ -686,6 +798,22 @@ class Sendgrid_Tools
686
  }
687
  }
688
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
689
  /**
690
  * Return port from the database or global variable
691
  *
@@ -695,11 +823,29 @@ class Sendgrid_Tools
695
  {
696
  if ( defined( 'SENDGRID_PORT' ) ) {
697
  return SENDGRID_PORT;
 
 
698
  } else {
699
  return get_option( 'sendgrid_port', Sendgrid_SMTP::TLS );
700
  }
701
  }
702
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
703
  /**
704
  * Return from name from the database or global variable
705
  *
@@ -709,11 +855,29 @@ class Sendgrid_Tools
709
  {
710
  if ( defined( 'SENDGRID_FROM_NAME' ) ) {
711
  return SENDGRID_FROM_NAME;
 
 
712
  } else {
713
  return get_option( 'sendgrid_from_name' );
714
  }
715
  }
716
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
717
  /**
718
  * Return from email address from the database or global variable
719
  *
@@ -723,11 +887,29 @@ class Sendgrid_Tools
723
  {
724
  if ( defined( 'SENDGRID_FROM_EMAIL' ) ) {
725
  return SENDGRID_FROM_EMAIL;
 
 
726
  } else {
727
  return get_option( 'sendgrid_from_email' );
728
  }
729
  }
730
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  /**
732
  * Return reply to email address from the database or global variable
733
  *
@@ -737,11 +919,29 @@ class Sendgrid_Tools
737
  {
738
  if ( defined( 'SENDGRID_REPLY_TO' ) ) {
739
  return SENDGRID_REPLY_TO;
 
 
740
  } else {
741
  return get_option( 'sendgrid_reply_to' );
742
  }
743
  }
744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
745
  /**
746
  * Return categories from the database or global variable
747
  *
@@ -751,11 +951,29 @@ class Sendgrid_Tools
751
  {
752
  if ( defined( 'SENDGRID_CATEGORIES' ) ) {
753
  return SENDGRID_CATEGORIES;
 
 
754
  } else {
755
  return get_option( 'sendgrid_categories' );
756
  }
757
  }
758
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
759
  /**
760
  * Return stats categories from the database or global variable
761
  *
@@ -765,11 +983,29 @@ class Sendgrid_Tools
765
  {
766
  if ( defined( 'SENDGRID_STATS_CATEGORIES' ) ) {
767
  return SENDGRID_STATS_CATEGORIES;
 
 
768
  } else {
769
  return get_option( 'sendgrid_stats_categories' );
770
  }
771
  }
772
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
773
  /**
774
  * Return categories array
775
  *
@@ -793,11 +1029,29 @@ class Sendgrid_Tools
793
  {
794
  if ( defined( 'SENDGRID_TEMPLATE' ) ) {
795
  return SENDGRID_TEMPLATE;
 
 
796
  } else {
797
  return get_option( 'sendgrid_template' );
798
  }
799
  }
800
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
801
  /**
802
  * Return content type from the database or global variable
803
  *
@@ -807,6 +1061,8 @@ class Sendgrid_Tools
807
  {
808
  if ( defined( 'SENDGRID_CONTENT_TYPE' ) ) {
809
  return SENDGRID_CONTENT_TYPE;
 
 
810
  } else {
811
  return get_option( 'sendgrid_content_type' );
812
  }
@@ -821,7 +1077,11 @@ class Sendgrid_Tools
821
  */
822
  public static function set_unsubscribe_group( $unsubscribe_group )
823
  {
824
- return update_option( 'sendgrid_unsubscribe_group', $unsubscribe_group );
 
 
 
 
825
  }
826
 
827
  /**
@@ -833,11 +1093,29 @@ class Sendgrid_Tools
833
  {
834
  if ( defined( 'SENDGRID_UNSUBSCRIBE_GROUP' ) ) {
835
  return SENDGRID_UNSUBSCRIBE_GROUP;
 
 
836
  } else {
837
  return get_option( 'sendgrid_unsubscribe_group' );
838
  }
839
  }
840
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
841
  /**
842
  * Get asm_permission value from db
843
  *
@@ -845,7 +1123,11 @@ class Sendgrid_Tools
845
  */
846
  public static function get_asm_permission()
847
  {
848
- return get_option( 'sendgrid_asm_permission' );
 
 
 
 
849
  }
850
 
851
  /**
@@ -880,6 +1162,22 @@ class Sendgrid_Tools
880
  return $response;
881
  }
882
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
883
  /**
884
  * Returns decrypted string using the key or empty string in case of error
885
  *
141
 
142
  // check unsubscribe group permission
143
  if ( Sendgrid_Tools::check_api_key_scopes( $apikey, array( "asm.groups.read" ) ) ) {
144
+ Sendgrid_Tools::set_asm_permission( 'true' );
145
  } else {
146
+ Sendgrid_Tools::set_asm_permission( 'false' );
147
  }
148
 
149
  if ( ! Sendgrid_Tools::check_api_key_scopes( $apikey, array( "mail.send" ) ) ) {
249
  {
250
  if ( defined( 'SENDGRID_USERNAME' ) ) {
251
  return SENDGRID_USERNAME;
252
+ } elseif ( is_multisite() ) {
253
+ return get_site_option( 'sendgrid_username' );
254
  } else {
255
  $username = get_option( 'sendgrid_user' );
256
  if( $username ) {
271
  */
272
  public static function set_username( $username )
273
  {
274
+ if ( is_multisite() ) {
275
+ if( ! isset( $username ) ) {
276
+ return update_site_option( 'sendgrid_username', '' );
277
+ }
278
+
279
+ return update_site_option( 'sendgrid_username', $username );
280
+ } else {
281
+ if ( ! isset( $username ) ) {
282
+ return update_option( 'sendgrid_username', '' );
283
+ }
284
 
285
+ return update_option( 'sendgrid_username', $username );
286
+ }
287
  }
288
 
289
  /**
295
  {
296
  if ( defined( 'SENDGRID_PASSWORD' ) ) {
297
  return SENDGRID_PASSWORD;
298
+ } elseif ( is_multisite() ) {
299
+ return get_site_option( 'sendgrid_pwd' );
300
  } else {
301
  $password = get_option( 'sendgrid_pwd' );
302
  $new_password = get_option( 'sendgrid_password' );
303
+ if ( $new_password and ! $password ) {
304
  update_option( 'sendgrid_pwd', self::decrypt( $new_password, AUTH_KEY ) );
305
  delete_option( 'sendgrid_password' );
306
  }
319
  */
320
  public static function set_password( $password )
321
  {
322
+ if ( is_multisite() ) {
323
+ return update_site_option( 'sendgrid_pwd', $password );
324
+ } else {
325
+ return update_option( 'sendgrid_pwd', $password );
326
+ }
327
  }
328
 
329
  /**
335
  {
336
  if ( defined( 'SENDGRID_API_KEY' ) ) {
337
  return SENDGRID_API_KEY;
338
+ } elseif ( is_multisite() ) {
339
+ return get_site_option( 'sendgrid_api_key' );
340
  } else {
341
  $apikey = get_option( 'sendgrid_api_key' );
342
  $new_apikey = get_option( 'sendgrid_apikey' );
343
+ if ( $new_apikey and ! $apikey ) {
344
  update_option( 'sendgrid_api_key', self::decrypt( $new_apikey, AUTH_KEY ) );
345
  delete_option( 'sendgrid_apikey' );
346
  }
359
  {
360
  if ( defined( 'SENDGRID_MC_API_KEY' ) ) {
361
  return SENDGRID_MC_API_KEY;
362
+ } elseif ( is_multisite() ) {
363
+ return get_site_option( 'sendgrid_mc_api_key' );
364
  } else {
365
  return get_option( 'sendgrid_mc_api_key' );
366
  }
375
  {
376
  if ( defined( 'SENDGRID_MC_LIST_ID' ) ) {
377
  return SENDGRID_MC_LIST_ID;
378
+ } elseif ( is_multisite() ) {
379
+ return get_site_option( 'sendgrid_mc_list_id' );
380
  } else {
381
  return get_option( 'sendgrid_mc_list_id' );
382
  }
391
  {
392
  if ( defined( 'SENDGRID_MC_OPT_USE_TRANSACTIONAL' ) ) {
393
  return SENDGRID_MC_OPT_USE_TRANSACTIONAL;
394
+ } elseif ( is_multisite() ) {
395
+ return get_site_option( 'sendgrid_mc_opt_use_transactional' );
396
  } else {
397
  return get_option( 'sendgrid_mc_opt_use_transactional' );
398
  }
407
  {
408
  if ( defined( 'SENDGRID_MC_OPT_REQ_FNAME_LNAME' ) ) {
409
  return SENDGRID_MC_OPT_REQ_FNAME_LNAME;
410
+ } elseif ( is_multisite() ) {
411
+ return get_site_option( 'sendgrid_mc_opt_req_fname_lname' );
412
  } else {
413
  return get_option( 'sendgrid_mc_opt_req_fname_lname' );
414
  }
423
  {
424
  if ( defined( 'SENDGRID_MC_OPT_INCL_FNAME_LNAME' ) ) {
425
  return SENDGRID_MC_OPT_INCL_FNAME_LNAME;
426
+ } elseif ( is_multisite() ) {
427
+ return get_site_option( 'sendgrid_mc_opt_incl_fname_lname' );
428
  } else {
429
  return get_option( 'sendgrid_mc_opt_incl_fname_lname' );
430
  }
439
  {
440
  if ( defined( 'SENDGRID_MC_SIGNUP_EMAIL_SUBJECT' ) ) {
441
  return SENDGRID_MC_SIGNUP_EMAIL_SUBJECT;
442
+ } elseif ( is_multisite() ) {
443
+ return get_site_option( 'sendgrid_mc_signup_email_subject' );
444
  } else {
445
  return get_option( 'sendgrid_mc_signup_email_subject' );
446
  }
455
  {
456
  if ( defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT' ) ) {
457
  return SENDGRID_MC_SIGNUP_EMAIL_CONTENT;
458
+ } elseif ( is_multisite() ) {
459
+ return get_site_option( 'sendgrid_mc_signup_email_content' );
460
  } else {
461
  return get_option( 'sendgrid_mc_signup_email_content' );
462
  }
471
  {
472
  if ( defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT_TEXT' ) ) {
473
  return SENDGRID_MC_SIGNUP_EMAIL_CONTENT_TEXT;
474
+ } elseif ( is_multisite() ) {
475
+ return get_site_option( 'sendgrid_mc_signup_email_content_text' );
476
  } else {
477
  return get_option( 'sendgrid_mc_signup_email_content_text' );
478
  }
487
  {
488
  if ( defined( 'SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE' ) ) {
489
  return SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE;
490
+ } elseif ( is_multisite() ) {
491
+ return get_site_option( 'sendgrid_mc_signup_confirmation_page' );
492
  } else {
493
  return get_option( 'sendgrid_mc_signup_confirmation_page' );
494
  }
507
  }
508
 
509
  $confirmation_pages = get_pages( array( 'parent' => 0 ) );
510
+ foreach ( $confirmation_pages as $key => $page ) {
511
  if ( $page->ID == $page_id ) {
512
  return $page->guid;
513
  }
523
  */
524
  public static function get_mc_auth_valid()
525
  {
526
+ if ( is_multisite() ) {
527
+ return get_site_option( 'sendgrid_mc_auth_valid' );
528
+ } else {
529
+ return get_option( 'sendgrid_mc_auth_valid' );
530
+ }
531
  }
532
 
533
  /**
537
  */
538
  public static function get_mc_widget_notice_dismissed()
539
  {
540
+ if ( is_multisite() ) {
541
+ return get_site_option( 'sendgrid_mc_widget_notice_dismissed' );
542
+ } else {
543
+ return get_option( 'sendgrid_mc_widget_notice_dismissed' );
544
+ }
545
  }
546
 
547
  /**
553
  */
554
  public static function set_api_key( $apikey )
555
  {
556
+ if ( is_multisite() ) {
557
+ return update_site_option( 'sendgrid_api_key', $apikey );
558
+ } else {
559
+ return update_option( 'sendgrid_api_key', $apikey );
560
+ }
561
  }
562
 
563
  /**
569
  */
570
  public static function set_mc_api_key( $apikey )
571
  {
572
+ if ( is_multisite() ) {
573
+ return update_site_option( 'sendgrid_mc_api_key', $apikey );
574
+ } else {
575
+ return update_option( 'sendgrid_mc_api_key', $apikey );
576
+ }
577
  }
578
 
579
  /**
585
  */
586
  public static function set_mc_list_id( $list_id )
587
  {
588
+ if ( is_multisite() ) {
589
+ return update_site_option( 'sendgrid_mc_list_id', $list_id );
590
+ } else {
591
+ return update_option( 'sendgrid_mc_list_id', $list_id );
592
+ }
593
  }
594
 
595
  /**
601
  */
602
  public static function set_mc_opt_use_transactional( $use_transactional )
603
  {
604
+ if ( is_multisite() ) {
605
+ return update_site_option( 'sendgrid_mc_opt_use_transactional', $use_transactional );
606
+ } else {
607
+ return update_option( 'sendgrid_mc_opt_use_transactional', $use_transactional );
608
+ }
609
  }
610
 
611
  /**
617
  */
618
  public static function set_mc_opt_req_fname_lname( $req_fname_lname )
619
  {
620
+ if ( is_multisite() ) {
621
+ return update_site_option( 'sendgrid_mc_opt_req_fname_lname', $req_fname_lname );
622
+ } else {
623
+ return update_option( 'sendgrid_mc_opt_req_fname_lname', $req_fname_lname );
624
+ }
625
  }
626
 
627
  /**
633
  */
634
  public static function set_mc_opt_incl_fname_lname( $incl_fname_lname )
635
  {
636
+ if ( is_multisite() ) {
637
+ return update_site_option( 'sendgrid_mc_opt_incl_fname_lname', $incl_fname_lname );
638
+ } else {
639
+ return update_option( 'sendgrid_mc_opt_incl_fname_lname', $incl_fname_lname );
640
+ }
641
  }
642
 
643
  /**
649
  */
650
  public static function set_mc_signup_email_subject( $email_subject )
651
  {
652
+ if ( is_multisite() ) {
653
+ return update_site_option( 'sendgrid_mc_signup_email_subject', $email_subject );
654
+ } else {
655
+ return update_option( 'sendgrid_mc_signup_email_subject', $email_subject );
656
+ }
657
  }
658
 
659
  /**
665
  */
666
  public static function set_mc_signup_email_content( $email_content )
667
  {
668
+ if ( is_multisite() ) {
669
+ return update_site_option( 'sendgrid_mc_signup_email_content', $email_content );
670
+ } else {
671
+ return update_option( 'sendgrid_mc_signup_email_content', $email_content );
672
+ }
673
  }
674
 
675
  /**
681
  */
682
  public static function set_mc_signup_email_content_text( $email_content )
683
  {
684
+ if ( is_multisite() ) {
685
+ return update_site_option( 'sendgrid_mc_signup_email_content_text', $email_content );
686
+ } else {
687
+ return update_option( 'sendgrid_mc_signup_email_content_text', $email_content );
688
+ }
689
  }
690
 
691
  /**
697
  */
698
  public static function set_mc_signup_confirmation_page( $confirmation_page )
699
  {
700
+ if ( is_multisite() ) {
701
+ return update_site_option( 'sendgrid_mc_signup_confirmation_page', $confirmation_page );
702
+ } else {
703
+ return update_option( 'sendgrid_mc_signup_confirmation_page', $confirmation_page );
704
+ }
705
  }
706
 
707
  /**
713
  */
714
  public static function set_mc_auth_valid( $auth_valid )
715
  {
716
+ if ( is_multisite() ) {
717
+ return update_site_option( 'sendgrid_mc_auth_valid', $auth_valid );
718
+ } else {
719
+ return update_option( 'sendgrid_mc_auth_valid', $auth_valid );
720
+ }
721
  }
722
 
723
  /**
729
  */
730
  public static function set_mc_widget_notice_dismissed( $notice_dismissed )
731
  {
732
+ if ( is_multisite() ) {
733
+ return update_site_option( 'sendgrid_mc_widget_notice_dismissed', $notice_dismissed );
734
+ } else {
735
+ return update_option( 'sendgrid_mc_widget_notice_dismissed', $notice_dismissed );
736
+ }
737
  }
738
 
739
  /**
745
  {
746
  if ( defined( 'SENDGRID_SEND_METHOD' ) ) {
747
  return SENDGRID_SEND_METHOD;
748
+ } elseif ( is_multisite() and get_site_option( 'sendgrid_api' ) ) {
749
+ return get_site_option( 'sendgrid_api' );
750
  } elseif ( get_option( 'sendgrid_api' ) ) {
751
  return get_option( 'sendgrid_api' );
752
  } else {
754
  }
755
  }
756
 
757
+ /**
758
+ * Sets the send method in the database
759
+ *
760
+ * @param type string $method
761
+ *
762
+ * @return bool
763
+ */
764
+ public static function set_send_method( $method )
765
+ {
766
+ if ( is_multisite() ) {
767
+ return update_site_option( 'sendgrid_api', $method );
768
+ } else {
769
+ return update_option( 'sendgrid_api', $method );
770
+ }
771
+ }
772
+
773
  /**
774
  * Return auth method from the database or global variable
775
  *
779
  {
780
  if ( defined( 'SENDGRID_AUTH_METHOD' ) ) {
781
  return SENDGRID_AUTH_METHOD;
782
+ } elseif ( is_multisite() and get_site_option( 'sendgrid_auth_method' ) ) {
783
+ return get_site_option( 'sendgrid_auth_method' );
784
  } elseif ( get_option( 'sendgrid_auth_method' ) ) {
785
  $auth_method = get_option( 'sendgrid_auth_method' );
786
  if ( 'username' == $auth_method ) {
798
  }
799
  }
800
 
801
+ /**
802
+ * Sets the send method in the database
803
+ *
804
+ * @param type string $method
805
+ *
806
+ * @return bool
807
+ */
808
+ public static function set_auth_method( $method )
809
+ {
810
+ if ( is_multisite() ) {
811
+ return update_site_option( 'sendgrid_auth_method', $method );
812
+ } else {
813
+ return update_option( 'sendgrid_auth_method', $method );
814
+ }
815
+ }
816
+
817
  /**
818
  * Return port from the database or global variable
819
  *
823
  {
824
  if ( defined( 'SENDGRID_PORT' ) ) {
825
  return SENDGRID_PORT;
826
+ } elseif ( is_multisite() ) {
827
+ return get_site_option( 'sendgrid_port', Sendgrid_SMTP::TLS );
828
  } else {
829
  return get_option( 'sendgrid_port', Sendgrid_SMTP::TLS );
830
  }
831
  }
832
 
833
+ /**
834
+ * Sets the port in the database
835
+ *
836
+ * @param type string $port
837
+ *
838
+ * @return bool
839
+ */
840
+ public static function set_port( $port )
841
+ {
842
+ if ( is_multisite() ) {
843
+ return update_site_option( 'sendgrid_port', $port );
844
+ } else {
845
+ return update_option( 'sendgrid_port', $port );
846
+ }
847
+ }
848
+
849
  /**
850
  * Return from name from the database or global variable
851
  *
855
  {
856
  if ( defined( 'SENDGRID_FROM_NAME' ) ) {
857
  return SENDGRID_FROM_NAME;
858
+ } elseif ( is_multisite() ) {
859
+ return get_site_option( 'sendgrid_from_name' );
860
  } else {
861
  return get_option( 'sendgrid_from_name' );
862
  }
863
  }
864
 
865
+ /**
866
+ * Sets from name in the database
867
+ *
868
+ * @param type string $name
869
+ *
870
+ * @return bool
871
+ */
872
+ public static function set_from_name( $name )
873
+ {
874
+ if ( is_multisite() ) {
875
+ return update_site_option( 'sendgrid_from_name', $name );
876
+ } else {
877
+ return update_option( 'sendgrid_from_name', $name );
878
+ }
879
+ }
880
+
881
  /**
882
  * Return from email address from the database or global variable
883
  *
887
  {
888
  if ( defined( 'SENDGRID_FROM_EMAIL' ) ) {
889
  return SENDGRID_FROM_EMAIL;
890
+ } elseif ( is_multisite() ) {
891
+ return get_site_option( 'sendgrid_from_email' );
892
  } else {
893
  return get_option( 'sendgrid_from_email' );
894
  }
895
  }
896
 
897
+ /**
898
+ * Sets from email in the database
899
+ *
900
+ * @param type string $email
901
+ *
902
+ * @return bool
903
+ */
904
+ public static function set_from_email( $email )
905
+ {
906
+ if ( is_multisite() ) {
907
+ return update_site_option( 'sendgrid_from_email', $email );
908
+ } else {
909
+ return update_option( 'sendgrid_from_email', $email );
910
+ }
911
+ }
912
+
913
  /**
914
  * Return reply to email address from the database or global variable
915
  *
919
  {
920
  if ( defined( 'SENDGRID_REPLY_TO' ) ) {
921
  return SENDGRID_REPLY_TO;
922
+ } elseif ( is_multisite() ) {
923
+ return get_site_option( 'sendgrid_reply_to' );
924
  } else {
925
  return get_option( 'sendgrid_reply_to' );
926
  }
927
  }
928
 
929
+ /**
930
+ * Sets reply to email in the database
931
+ *
932
+ * @param type string $email
933
+ *
934
+ * @return bool
935
+ */
936
+ public static function set_reply_to( $email )
937
+ {
938
+ if ( is_multisite() ) {
939
+ return update_site_option( 'sendgrid_reply_to', $email );
940
+ } else {
941
+ return update_option( 'sendgrid_reply_to', $email );
942
+ }
943
+ }
944
+
945
  /**
946
  * Return categories from the database or global variable
947
  *
951
  {
952
  if ( defined( 'SENDGRID_CATEGORIES' ) ) {
953
  return SENDGRID_CATEGORIES;
954
+ } elseif ( is_multisite() ) {
955
+ return get_site_option( 'sendgrid_categories' );
956
  } else {
957
  return get_option( 'sendgrid_categories' );
958
  }
959
  }
960
 
961
+ /**
962
+ * Sets categories in the database
963
+ *
964
+ * @param type string $categories
965
+ *
966
+ * @return bool
967
+ */
968
+ public static function set_categories( $categories )
969
+ {
970
+ if ( is_multisite() ) {
971
+ return update_site_option( 'sendgrid_categories', $categories );
972
+ } else {
973
+ return update_option( 'sendgrid_categories', $categories );
974
+ }
975
+ }
976
+
977
  /**
978
  * Return stats categories from the database or global variable
979
  *
983
  {
984
  if ( defined( 'SENDGRID_STATS_CATEGORIES' ) ) {
985
  return SENDGRID_STATS_CATEGORIES;
986
+ } elseif ( is_multisite() ) {
987
+ return get_site_option( 'sendgrid_stats_categories' );
988
  } else {
989
  return get_option( 'sendgrid_stats_categories' );
990
  }
991
  }
992
 
993
+ /**
994
+ * Sets stats categories in the database
995
+ *
996
+ * @param type string $categories
997
+ *
998
+ * @return bool
999
+ */
1000
+ public static function set_stats_categories( $categories )
1001
+ {
1002
+ if ( is_multisite() ) {
1003
+ return update_site_option( 'sendgrid_stats_categories', $categories );
1004
+ } else {
1005
+ return update_option( 'sendgrid_stats_categories', $categories );
1006
+ }
1007
+ }
1008
+
1009
  /**
1010
  * Return categories array
1011
  *
1029
  {
1030
  if ( defined( 'SENDGRID_TEMPLATE' ) ) {
1031
  return SENDGRID_TEMPLATE;
1032
+ } elseif ( is_multisite() ) {
1033
+ return get_site_option( 'sendgrid_template' );
1034
  } else {
1035
  return get_option( 'sendgrid_template' );
1036
  }
1037
  }
1038
 
1039
+ /**
1040
+ * Sets the template in the database
1041
+ *
1042
+ * @param type string $template
1043
+ *
1044
+ * @return bool
1045
+ */
1046
+ public static function set_template( $template )
1047
+ {
1048
+ if ( is_multisite() ) {
1049
+ return update_site_option( 'sendgrid_template', $template );
1050
+ } else {
1051
+ return update_option( 'sendgrid_template', $template );
1052
+ }
1053
+ }
1054
+
1055
  /**
1056
  * Return content type from the database or global variable
1057
  *
1061
  {
1062
  if ( defined( 'SENDGRID_CONTENT_TYPE' ) ) {
1063
  return SENDGRID_CONTENT_TYPE;
1064
+ } elseif ( is_multisite() ) {
1065
+ return get_site_option( 'sendgrid_content_type' );
1066
  } else {
1067
  return get_option( 'sendgrid_content_type' );
1068
  }
1077
  */
1078
  public static function set_unsubscribe_group( $unsubscribe_group )
1079
  {
1080
+ if ( is_multisite() ) {
1081
+ return update_site_option( 'sendgrid_unsubscribe_group', $unsubscribe_group );
1082
+ } else {
1083
+ return update_option( 'sendgrid_unsubscribe_group', $unsubscribe_group );
1084
+ }
1085
  }
1086
 
1087
  /**
1093
  {
1094
  if ( defined( 'SENDGRID_UNSUBSCRIBE_GROUP' ) ) {
1095
  return SENDGRID_UNSUBSCRIBE_GROUP;
1096
+ } elseif ( is_multisite() ) {
1097
+ return get_site_option( 'sendgrid_unsubscribe_group' );
1098
  } else {
1099
  return get_option( 'sendgrid_unsubscribe_group' );
1100
  }
1101
  }
1102
 
1103
+ /**
1104
+ * Set asm_permission value in db
1105
+ *
1106
+ * @param type string $permission
1107
+ *
1108
+ * @return bool
1109
+ */
1110
+ public static function set_asm_permission( $permission )
1111
+ {
1112
+ if ( is_multisite() ) {
1113
+ return update_site_option( 'sendgrid_asm_permission', $permission );
1114
+ } else {
1115
+ return update_option( 'sendgrid_asm_permission', $permission );
1116
+ }
1117
+ }
1118
+
1119
  /**
1120
  * Get asm_permission value from db
1121
  *
1123
  */
1124
  public static function get_asm_permission()
1125
  {
1126
+ if ( is_multisite() ) {
1127
+ return get_site_option( 'sendgrid_asm_permission' );
1128
+ } else {
1129
+ return get_option( 'sendgrid_asm_permission' );
1130
+ }
1131
  }
1132
 
1133
  /**
1162
  return $response;
1163
  }
1164
 
1165
+ /**
1166
+ * Sets the content-type in the database
1167
+ *
1168
+ * @param type string $content_type
1169
+ *
1170
+ * @return bool
1171
+ */
1172
+ public static function set_content_type( $content_type )
1173
+ {
1174
+ if ( is_multisite() ) {
1175
+ return update_site_option( 'sendgrid_content_type', $content_type );
1176
+ } else {
1177
+ return update_option( 'sendgrid_content_type', $content_type );
1178
+ }
1179
+ }
1180
+
1181
  /**
1182
  * Returns decrypted string using the key or empty string in case of error
1183
  *
lib/class-sendgrid-virtual-pages.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( !class_exists( 'SGVirtualPage' ) )
3
  {
4
  class SGVirtualPage
5
  {
@@ -97,7 +97,7 @@ function sg_create_subscribe_general_error_page()
97
  {
98
  $args = array('slug' => 'sg-error',
99
  'title' => 'Subscribe error',
100
- 'content' => "Something went wrong while trying to send information.");
101
  $pg = new SGVirtualPage( $args );
102
  }
103
  }
@@ -115,7 +115,7 @@ function sg_create_subscribe_invalid_token_error_page()
115
  {
116
  $args = array( 'slug' => 'sg-subscription-invalid-token',
117
  'title' => 'Subscribe error',
118
- 'content' => "Token is invalid, you are not subscribed to our newsletter." );
119
  $pg = new SGVirtualPage( $args );
120
  }
121
  }
@@ -133,7 +133,7 @@ function sg_create_subscribe_missing_token_error_page()
133
  {
134
  $args = array( 'slug' => 'sg-subscription-missing-token',
135
  'title' => 'Subscribe error',
136
- 'content' => "Token is missing, you are not subscribed to our newsletter." );
137
  $pg = new SGVirtualPage( $args );
138
  }
139
  }
@@ -151,7 +151,7 @@ function sg_create_subscribe_success_page()
151
  {
152
  $args = array( 'slug' => 'sg-subscription-success',
153
  'title' => 'Subscribe success',
154
- 'content' => "You have been successfully subscribed to our newsletter." );
155
  $pg = new SGVirtualPage( $args );
156
  }
157
  }
1
  <?php
2
+ if ( ! class_exists( 'SGVirtualPage' ) )
3
  {
4
  class SGVirtualPage
5
  {
97
  {
98
  $args = array('slug' => 'sg-error',
99
  'title' => 'Subscribe error',
100
+ 'content' => 'Something went wrong while trying to send information.' );
101
  $pg = new SGVirtualPage( $args );
102
  }
103
  }
115
  {
116
  $args = array( 'slug' => 'sg-subscription-invalid-token',
117
  'title' => 'Subscribe error',
118
+ 'content' => 'Token is invalid, you are not subscribed to our newsletter.' );
119
  $pg = new SGVirtualPage( $args );
120
  }
121
  }
133
  {
134
  $args = array( 'slug' => 'sg-subscription-missing-token',
135
  'title' => 'Subscribe error',
136
+ 'content' => 'Token is missing, you are not subscribed to our newsletter.' );
137
  $pg = new SGVirtualPage( $args );
138
  }
139
  }
151
  {
152
  $args = array( 'slug' => 'sg-subscription-success',
153
  'title' => 'Subscribe success',
154
+ 'content' => 'You have been successfully subscribed to our newsletter.' );
155
  $pg = new SGVirtualPage( $args );
156
  }
157
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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: 4.2
6
  Tested up to: 4.6
7
- Stable tag: 1.9.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -28,6 +28,15 @@ SendGrid’s WordPress Subscription Widget makes it easy for people visiting you
28
 
29
  For more details, consult the official documentation for the Subscription Widget here : https://sendgrid.com/docs/Integrate/Tutorials/WordPress/subscription_widget.html
30
 
 
 
 
 
 
 
 
 
 
31
  == Installation ==
32
 
33
  Requirements:
@@ -46,10 +55,20 @@ To upload the SendGrid Plugin .ZIP file:
46
  To auto install the SendGrid Plugin from the WordPress admin:
47
 
48
  1. Navigate to "Plugins" -> "Add New"
49
- 2. Search for "SendGrid Plugin" and click "Install Now" for the "SendGrid Plugin" listing
50
  3. Activate the plugin from the "Plugins" menu in WordPress, or from the plugin installation screen.
51
  4. Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">http://sendgrid.com/partner/wordpress</a>
52
- 5. Navigate to "Settings" -> "SendGrid Settings" and enter your SendGrid credentials
 
 
 
 
 
 
 
 
 
 
53
 
54
  = Global Settings =
55
 
@@ -134,7 +153,7 @@ Yes. You can find it here : https://sendgrid.com/docs/Integrate/Tutorials/WordPr
134
 
135
  Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">https://sendgrid.com/partner/wordpress</a> and generate a new API key on <https://app.sendgrid.com/settings/api_keys>.
136
 
137
- = How can I define a plugin setting to be used for all sites =
138
 
139
  Add it into your wp-config.php file. Example: `define('SENDGRID_API_KEY', 'your_api_key');`.
140
 
@@ -213,6 +232,12 @@ You'll hear from us soon!`
213
 
214
  You need to enable the use of the First Name and Last Name fields from the settings page in order to use the shortcodes for them.
215
 
 
 
 
 
 
 
216
  == Screenshots ==
217
 
218
  1. Go to Admin Panel, section Plugins and activate the SendGrid plugin. If you want to send emails through SMTP you need to install also the 'Swift Mailer' plugin.
@@ -230,6 +255,10 @@ You need to enable the use of the First Name and Last Name fields from the setti
230
 
231
  == Changelog ==
232
 
 
 
 
 
233
  = 1.9.5 =
234
  * Fixed an issue with the Reply-To field
235
  = 1.9.4 =
@@ -354,6 +383,10 @@ You need to enable the use of the First Name and Last Name fields from the setti
354
 
355
  == Upgrade notice ==
356
 
 
 
 
 
357
  = 1.9.5 =
358
  * Fixed an issue with the Reply-To field
359
  = 1.9.4 =
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: 4.2
6
  Tested up to: 4.6
7
+ Stable tag: 1.10.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
28
 
29
  For more details, consult the official documentation for the Subscription Widget here : https://sendgrid.com/docs/Integrate/Tutorials/WordPress/subscription_widget.html
30
 
31
+ = Multisite (Beta) =
32
+
33
+ If you are using the SendGrid plugin in a Multisite environment, you need to Network Activate it. You can then access the settings page on the network dashboard and the configure settings will be used for all sites.
34
+
35
+ Configuration on a per-site basis is not currently supported. All configured settings will be applied to all sites.
36
+
37
+ If you already had the plugin installed in a Multisite environment and you update to versions after 1.9.0 you may need to reconfigure your plugin.
38
+
39
+
40
  == Installation ==
41
 
42
  Requirements:
55
  To auto install the SendGrid Plugin from the WordPress admin:
56
 
57
  1. Navigate to "Plugins" -> "Add New"
58
+ 2. Search for "SendGrid Plugin" and click "Install Now" for the "SendGrid Plugin" listing.
59
  3. Activate the plugin from the "Plugins" menu in WordPress, or from the plugin installation screen.
60
  4. Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">http://sendgrid.com/partner/wordpress</a>
61
+ 5. Navigate to "Settings" -> "SendGrid Settings" and enter your SendGrid credentials.
62
+
63
+ For Multisite:
64
+
65
+ 1. Navigate to "My Sites" -> "Network Admin" -> "Plugins"
66
+ 2. Click on "Add New"
67
+ 3. Search for "SendGrid Plugin" and click "Install Now" for the "SendGrid Plugin" listing.
68
+ 4. Network Activate the plugin from the "Plugins" menu in WordPress, or from the plugin installation screen.
69
+ 5. Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">http://sendgrid.com/partner/wordpress</a>
70
+ 6. Navigate to "My Sites" -> "Network Admin" -> "Dashboard"
71
+ 7. Click on the "SendGrid Settings" item in the menu on the left and enter your SendGrid credentials.
72
 
73
  = Global Settings =
74
 
153
 
154
  Create a SendGrid account at <a href="http://sendgrid.com/partner/wordpress" target="_blank">https://sendgrid.com/partner/wordpress</a> and generate a new API key on <https://app.sendgrid.com/settings/api_keys>.
155
 
156
+ = How can I define a plugin setting to be used for all sites ? =
157
 
158
  Add it into your wp-config.php file. Example: `define('SENDGRID_API_KEY', 'your_api_key');`.
159
 
232
 
233
  You need to enable the use of the First Name and Last Name fields from the settings page in order to use the shortcodes for them.
234
 
235
+ = Does this plugin support Multisite? =
236
+
237
+ Yes. This plugin has basic Multisite support. You need to Network Activate this plugin.
238
+
239
+ The settings for all sites in the network can be configured only by the Network Admin in the Network Admin Dashboard.
240
+
241
  == Screenshots ==
242
 
243
  1. Go to Admin Panel, section Plugins and activate the SendGrid plugin. If you want to send emails through SMTP you need to install also the 'Swift Mailer' plugin.
255
 
256
  == Changelog ==
257
 
258
+ = 1.10.0 =
259
+ * Added basic Multisite functionality
260
+ * WARNING: Multisite users need to network activate this plugin and reconfigure it.
261
+ * Fixed an issue where other users would see the SendGrid statistics widget on the dashboard.
262
  = 1.9.5 =
263
  * Fixed an issue with the Reply-To field
264
  = 1.9.4 =
383
 
384
  == Upgrade notice ==
385
 
386
+ = 1.10.0 =
387
+ * Added basic Multisite functionality
388
+ * WARNING: Multisite users need to network activate this plugin and reconfigure it.
389
+ * Fixed an issue where other users would see the SendGrid statistics widget on the dashboard.
390
  = 1.9.5 =
391
  * Fixed an issue with the Reply-To field
392
  = 1.9.4 =
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.9.5
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.10.0
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  Text Domain: sendgrid-email-delivery-simplified