SendGrid - Version 1.10.2

Version Description

  • Add options to configure subscription widget form (labels, padding)
Download this release

Release Info

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

Code changes from version 1.10.1 to 1.10.2

lib/class-sendgrid-nlvx-widget.php CHANGED
@@ -239,37 +239,78 @@ class SendGrid_NLVX_Widget extends WP_Widget {
239
  * @return void
240
  */
241
  private function display_form() {
242
- echo '<form method="post" id="sendgrid_mc_email_form" class="mc_email_form" action="#sendgrid_mc_email_subscribe">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
  if ( 'true' == Sendgrid_Tools::get_mc_opt_incl_fname_lname() ) {
245
  if ( 'true' == Sendgrid_Tools::get_mc_opt_req_fname_lname() ) {
246
- echo '<div class="sendgrid-mc-field">';
247
- echo '<label for="sendgrid_mc_first_name">First Name<sup>*</sup> : </label>';
248
- echo '<input id="sendgrid_mc_first_name" name="sendgrid_mc_first_name" type="text" value="" required/>';
249
- echo '</div>';
250
- echo '<div class="sendgrid-mc-field">';
251
- echo '<label for="sendgrid_mc_last_name">Last Name<sup>*</sup> : </label>';
252
- echo '<input id="sendgrid_mc_last_name" name="sendgrid_mc_last_name" type="text" value="" required/>';
253
- echo '</div>';
254
- } else {
255
- echo '<div class="sendgrid-mc-field">';
256
- echo '<label for="sendgrid_mc_first_name">First Name : </label>';
257
- echo '<input id="sendgrid_mc_first_name" name="sendgrid_mc_first_name" type="text" value=""/>';
258
- echo '</div>';
259
- echo '<div class="sendgrid-mc-field">';
260
- echo '<label for="sendgrid_mc_last_name">Last Name : </label>';
261
- echo '<input id="sendgrid_mc_last_name" name="sendgrid_mc_last_name" type="text" value=""/>';
262
- echo '</div>';
263
- }
 
 
 
264
  }
265
 
266
- echo '<div class="sendgrid-mc-field">';
267
- echo '<label for="sendgrid_mc_email">Email<sup>*</sup> :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </label>';
268
- echo '<input id="sendgrid_mc_email" name="sendgrid_mc_email" value="" required/>';
 
 
 
 
269
  echo '</div>';
270
 
271
- echo '<div class="sendgrid-mc-button">';
272
- echo '<input type="submit" id="sendgrid_mc_email_submit" value="Subscribe" />';
273
  echo '</div>';
274
  echo '</form>';
275
  }
239
  * @return void
240
  */
241
  private function display_form() {
242
+ $email_label = htmlspecialchars( Sendgrid_Tools::get_mc_email_label() );
243
+ if ( false == $email_label ) {
244
+ $email_label = Sendgrid_Settings::DEFAULT_EMAIL_LABEL;
245
+ }
246
+
247
+ $first_name_label = htmlspecialchars( Sendgrid_Tools::get_mc_first_name_label() );
248
+ if ( false == $first_name_label ) {
249
+ $first_name_label = Sendgrid_Settings::DEFAULT_FIRST_NAME_LABEL;
250
+ }
251
+
252
+ $last_name_label = htmlspecialchars( Sendgrid_Tools::get_mc_last_name_label() );
253
+ if ( false == $last_name_label ) {
254
+ $last_name_label = Sendgrid_Settings::DEFAULT_LAST_NAME_LABEL;
255
+ }
256
+
257
+ $subscribe_label = htmlspecialchars( Sendgrid_Tools::get_mc_subscribe_label() );
258
+ if ( false == $subscribe_label ) {
259
+ $subscribe_label = Sendgrid_Settings::DEFAULT_SUBSCRIBE_LABEL;
260
+ }
261
+
262
+ $input_padding = "padding: ";
263
+ $input_padding .= Sendgrid_Tools::get_mc_input_padding_by_position( 'top' ) . 'px ';
264
+ $input_padding .= Sendgrid_Tools::get_mc_input_padding_by_position( 'right' ) . 'px ';
265
+ $input_padding .= Sendgrid_Tools::get_mc_input_padding_by_position( 'bottom' ) . 'px ';
266
+ $input_padding .= Sendgrid_Tools::get_mc_input_padding_by_position( 'left' ) . 'px;';
267
+
268
+ $button_padding = "margin: ";
269
+ $button_padding .= Sendgrid_Tools::get_mc_button_padding_by_position( 'top' ) . 'px ';
270
+ $button_padding .= Sendgrid_Tools::get_mc_button_padding_by_position( 'right' ) . 'px ';
271
+ $button_padding .= Sendgrid_Tools::get_mc_button_padding_by_position( 'bottom' ) . 'px ';
272
+ $button_padding .= Sendgrid_Tools::get_mc_button_padding_by_position( 'left' ) . 'px;';
273
+
274
+ $require_fname_lname = '';
275
+
276
+ echo '<form method="post" id="sendgrid_mc_email_form" class="mc_email_form" action="#sendgrid_mc_email_subscribe" style="padding-top: 10px;">';
277
 
278
  if ( 'true' == Sendgrid_Tools::get_mc_opt_incl_fname_lname() ) {
279
  if ( 'true' == Sendgrid_Tools::get_mc_opt_req_fname_lname() ) {
280
+ $require_fname_lname = "required";
281
+ $first_name_label .= "<sup>*</sup>";
282
+ $last_name_label .= "<sup>*</sup>";
283
+ }
284
+
285
+ echo '<div class="sendgrid_mc_fields" style="' . $input_padding . '">';
286
+ echo ' <div class="sendgrid_mc_label_div">';
287
+ echo ' <label for="sendgrid_mc_first_name" class="sendgrid_mc_label sendgrid_mc_label_first_name">' . $first_name_label . ' : </label>';
288
+ echo ' </div>';
289
+ echo ' <div class="sendgrid_mc_input_div">';
290
+ echo ' <input class="sendgrid_mc_input sendgrid_mc_input_first_name" id="sendgrid_mc_first_name" name="sendgrid_mc_first_name" type="text" value=""' . $require_fname_lname . ' />';
291
+ echo ' </div>';
292
+ echo '</div>';
293
+ echo '<div class="sendgrid_mc_fields" style="' . $input_padding . '">';
294
+ echo ' <div class="sendgrid_mc_label_div">';
295
+ echo ' <label for="sendgrid_mc_last_name" class="sendgrid_mc_label sendgrid_mc_label_last_name">' . $last_name_label . ' : </label>';
296
+ echo ' </div>';
297
+ echo ' <div class="sendgrid_mc_input_div">';
298
+ echo ' <input class="sendgrid_mc_input sendgrid_mc_input_last_name" id="sendgrid_mc_last_name" name="sendgrid_mc_last_name" type="text" value="" ' . $require_fname_lname . '/>';
299
+ echo ' </div>';
300
+ echo '</div>';
301
  }
302
 
303
+ echo '<div class="sendgrid_mc_fields" style="' . $input_padding . '">';
304
+ echo ' <div class="sendgrid_mc_label_div">';
305
+ echo ' <label for="sendgrid_mc_email" class="sendgrid_mc_label sendgrid_mc_label_email">' . $email_label . '<sup>*</sup> :</label>';
306
+ echo ' </div>';
307
+ echo ' <div class="sendgrid_mc_input_div">';
308
+ echo ' <input class="sendgrid_mc_input sendgrid_mc_input_email" id="sendgrid_mc_email" name="sendgrid_mc_email" type="text" value="" required/>';
309
+ echo ' </div>';
310
  echo '</div>';
311
 
312
+ echo '<div class="sendgrid_mc_button_div">';
313
+ echo ' <input style="' . $button_padding . '" class="sendgrid_mc_button" type="submit" id="sendgrid_mc_email_submit" value="' . $subscribe_label . '" />';
314
  echo '</div>';
315
  echo '</form>';
316
  }
lib/class-sendgrid-settings.php CHANGED
@@ -10,6 +10,10 @@ class Sendgrid_Settings {
10
  const DEFAULT_SIGNUP_EMAIL_SUBJECT = 'Confirm your subscription to ';
11
  const DEFAULT_SIGNUP_EMAIL_CONTENT = '&lt;p&gt;Greetings!&lt;/p&gt;&#13;&#10;&#13;&#10;&lt;p&gt;Please click &lt;a href=&quot;%confirmation_link%&quot;&gt;here&lt;/a&gt; in order to subscribe to our newsletter!&lt;/p&gt;&#13;&#10;&#13;&#10;&lt;p&gt;Thank you,&lt;/p&gt;&#13;&#10;&lt;p&gt;';
12
  const DEFAULT_SIGNUP_EMAIL_CONTENT_TEXT = 'Greetings!&#13;&#10;&#13;&#10;Please open %confirmation_link% in order to subscribe to our newsletter!&#13;&#10;&#13;&#10;Thank you,&#13;&#10;';
 
 
 
 
13
 
14
  public static $plugin_directory;
15
 
@@ -166,6 +170,17 @@ class Sendgrid_Settings {
166
  $mc_opt_req_fname_lname = Sendgrid_Tools::get_mc_opt_req_fname_lname();
167
  $mc_signup_confirmation_page = Sendgrid_Tools::get_mc_signup_confirmation_page();
168
 
 
 
 
 
 
 
 
 
 
 
 
169
  $mc_signup_email_subject = Sendgrid_Tools::get_mc_signup_email_subject();
170
  if ( false == $mc_signup_email_subject ) {
171
  $mc_signup_email_subject = self::DEFAULT_SIGNUP_EMAIL_SUBJECT . get_bloginfo('name');
@@ -302,6 +317,24 @@ class Sendgrid_Settings {
302
  $no_permission_on_unsubscribe_groups = true;
303
  }
304
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
  $is_env_auth_method = defined( 'SENDGRID_AUTH_METHOD' );
306
  $is_env_send_method = defined( 'SENDGRID_SEND_METHOD' );
307
  $is_env_username = defined( 'SENDGRID_USERNAME' );
@@ -319,6 +352,10 @@ class Sendgrid_Settings {
319
  $is_env_mc_signup_email_content = defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT' );
320
  $is_env_mc_signup_email_content_text = defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT_TEXT' );
321
  $is_env_mc_signup_confirmation_page = defined( 'SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE' );
 
 
 
 
322
 
323
  if ( $response and $status != 'error' ) {
324
  $message = $response['message'];
@@ -479,6 +516,47 @@ class Sendgrid_Settings {
479
  Sendgrid_Tools::set_mc_signup_confirmation_page( $params['sendgrid_mc_signup_page'] );
480
  }
481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
482
  if ( isset( $response ) and $response['status'] == 'error' ) {
483
  return $response;
484
  }
10
  const DEFAULT_SIGNUP_EMAIL_SUBJECT = 'Confirm your subscription to ';
11
  const DEFAULT_SIGNUP_EMAIL_CONTENT = '&lt;p&gt;Greetings!&lt;/p&gt;&#13;&#10;&#13;&#10;&lt;p&gt;Please click &lt;a href=&quot;%confirmation_link%&quot;&gt;here&lt;/a&gt; in order to subscribe to our newsletter!&lt;/p&gt;&#13;&#10;&#13;&#10;&lt;p&gt;Thank you,&lt;/p&gt;&#13;&#10;&lt;p&gt;';
12
  const DEFAULT_SIGNUP_EMAIL_CONTENT_TEXT = 'Greetings!&#13;&#10;&#13;&#10;Please open %confirmation_link% in order to subscribe to our newsletter!&#13;&#10;&#13;&#10;Thank you,&#13;&#10;';
13
+ const DEFAULT_EMAIL_LABEL = 'Email';
14
+ const DEFAULT_FIRST_NAME_LABEL = 'First Name';
15
+ const DEFAULT_LAST_NAME_LABEL = 'Last Name';
16
+ const DEFAULT_SUBSCRIBE_LABEL = 'SUBSCRIBE';
17
 
18
  public static $plugin_directory;
19
 
170
  $mc_opt_req_fname_lname = Sendgrid_Tools::get_mc_opt_req_fname_lname();
171
  $mc_signup_confirmation_page = Sendgrid_Tools::get_mc_signup_confirmation_page();
172
 
173
+ // input padding
174
+ $mc_signup_input_padding_top = Sendgrid_Tools::get_mc_input_padding_by_position( 'top' );
175
+ $mc_signup_input_padding_right = Sendgrid_Tools::get_mc_input_padding_by_position( 'right' );
176
+ $mc_signup_input_padding_bottom = Sendgrid_Tools::get_mc_input_padding_by_position( 'bottom' );
177
+ $mc_signup_input_padding_left = Sendgrid_Tools::get_mc_input_padding_by_position( 'left' );
178
+ // button padding
179
+ $mc_signup_button_padding_top = Sendgrid_Tools::get_mc_button_padding_by_position( 'top' );
180
+ $mc_signup_button_padding_right = Sendgrid_Tools::get_mc_button_padding_by_position( 'right' );
181
+ $mc_signup_button_padding_bottom = Sendgrid_Tools::get_mc_button_padding_by_position( 'bottom' );
182
+ $mc_signup_button_padding_left = Sendgrid_Tools::get_mc_button_padding_by_position( 'left' );
183
+
184
  $mc_signup_email_subject = Sendgrid_Tools::get_mc_signup_email_subject();
185
  if ( false == $mc_signup_email_subject ) {
186
  $mc_signup_email_subject = self::DEFAULT_SIGNUP_EMAIL_SUBJECT . get_bloginfo('name');
317
  $no_permission_on_unsubscribe_groups = true;
318
  }
319
 
320
+ // get form configuration
321
+ $mc_signup_email_label = Sendgrid_Tools::get_mc_email_label();
322
+ if ( false == $mc_signup_email_label ) {
323
+ $mc_signup_email_label = self::DEFAULT_EMAIL_LABEL;
324
+ }
325
+ $mc_signup_first_name_label = Sendgrid_Tools::get_mc_first_name_label();
326
+ if ( false == $mc_signup_first_name_label ) {
327
+ $mc_signup_first_name_label = self::DEFAULT_FIRST_NAME_LABEL;
328
+ }
329
+ $mc_signup_last_name_label = Sendgrid_Tools::get_mc_last_name_label();
330
+ if ( false == $mc_signup_last_name_label ) {
331
+ $mc_signup_last_name_label = self::DEFAULT_LAST_NAME_LABEL;
332
+ }
333
+ $mc_signup_subscribe_label = Sendgrid_Tools::get_mc_subscribe_label();
334
+ if ( false == $mc_signup_subscribe_label ) {
335
+ $mc_signup_subscribe_label = self::DEFAULT_SUBSCRIBE_LABEL;
336
+ }
337
+
338
  $is_env_auth_method = defined( 'SENDGRID_AUTH_METHOD' );
339
  $is_env_send_method = defined( 'SENDGRID_SEND_METHOD' );
340
  $is_env_username = defined( 'SENDGRID_USERNAME' );
352
  $is_env_mc_signup_email_content = defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT' );
353
  $is_env_mc_signup_email_content_text = defined( 'SENDGRID_MC_SIGNUP_EMAIL_CONTENT_TEXT' );
354
  $is_env_mc_signup_confirmation_page = defined( 'SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE' );
355
+ $is_env_mc_email_label = defined( 'SENDGRID_MC_EMAIL_LABEL' );
356
+ $is_env_mc_first_name_label = defined( 'SENDGRID_MC_FIRST_NAME_LABEL' );
357
+ $is_env_mc_last_name_label = defined( 'SENDGRID_MC_LAST_NAME_LABEL' );
358
+ $is_env_mc_subscribe_label = defined( 'SENDGRID_MC_SUBSCRIBE_LABEL' );
359
 
360
  if ( $response and $status != 'error' ) {
361
  $message = $response['message'];
516
  Sendgrid_Tools::set_mc_signup_confirmation_page( $params['sendgrid_mc_signup_page'] );
517
  }
518
 
519
+ // form configuration
520
+ // labels
521
+ if ( isset( $params['sendgrid_mc_email_label'] ) and ! defined( 'SENDGRID_MC_EMAIL_LABEL' ) ) {
522
+ Sendgrid_Tools::set_mc_email_label( $params['sendgrid_mc_email_label'] );
523
+ }
524
+ if ( isset( $params['sendgrid_mc_first_name_label'] ) and ! defined( 'SENDGRID_MC_FIRST_NAME_LABEL' ) ) {
525
+ Sendgrid_Tools::set_mc_first_name_label( $params['sendgrid_mc_first_name_label'] );
526
+ }
527
+ if ( isset( $params['sendgrid_mc_last_name_label'] ) and ! defined( 'SENDGRID_MC_LAST_NAME_LABEL' ) ) {
528
+ Sendgrid_Tools::set_mc_last_name_label( $params['sendgrid_mc_last_name_label'] );
529
+ }
530
+ if ( isset( $params['sendgrid_mc_subscribe_label'] ) and ! defined( 'SENDGRID_MC_SUBSCRIBE_LABEL' ) ) {
531
+ Sendgrid_Tools::set_mc_subscribe_label( $params['sendgrid_mc_subscribe_label'] );
532
+ }
533
+ // input padding
534
+ if ( isset( $params['sendgrid_mc_input_padding_top'] ) ) {
535
+ Sendgrid_Tools::set_mc_input_padding( 'top', $params['sendgrid_mc_input_padding_top'] );
536
+ }
537
+ if ( isset( $params['sendgrid_mc_input_padding_right'] ) ) {
538
+ Sendgrid_Tools::set_mc_input_padding( 'right', $params['sendgrid_mc_input_padding_right'] );
539
+ }
540
+ if ( isset( $params['sendgrid_mc_input_padding_bottom'] ) ) {
541
+ Sendgrid_Tools::set_mc_input_padding( 'bottom', $params['sendgrid_mc_input_padding_bottom'] );
542
+ }
543
+ if ( isset( $params['sendgrid_mc_input_padding_left'] ) ) {
544
+ Sendgrid_Tools::set_mc_input_padding( 'left', $params['sendgrid_mc_input_padding_left'] );
545
+ }
546
+ // button padding
547
+ if ( isset( $params['sendgrid_mc_button_padding_top'] ) ) {
548
+ Sendgrid_Tools::set_mc_button_padding( 'top', $params['sendgrid_mc_button_padding_top'] );
549
+ }
550
+ if ( isset( $params['sendgrid_mc_button_padding_right'] ) ) {
551
+ Sendgrid_Tools::set_mc_button_padding( 'right', $params['sendgrid_mc_button_padding_right'] );
552
+ }
553
+ if ( isset( $params['sendgrid_mc_button_padding_bottom'] ) ) {
554
+ Sendgrid_Tools::set_mc_button_padding( 'bottom', $params['sendgrid_mc_button_padding_bottom'] );
555
+ }
556
+ if ( isset( $params['sendgrid_mc_button_padding_left'] ) ) {
557
+ Sendgrid_Tools::set_mc_button_padding( 'left', $params['sendgrid_mc_button_padding_left'] );
558
+ }
559
+
560
  if ( isset( $response ) and $response['status'] == 'error' ) {
561
  return $response;
562
  }
lib/class-sendgrid-tools.php CHANGED
@@ -1178,6 +1178,288 @@ class Sendgrid_Tools
1178
  }
1179
  }
1180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1181
  /**
1182
  * Returns decrypted string using the key or empty string in case of error
1183
  *
1178
  }
1179
  }
1180
 
1181
+ /**
1182
+ * Sets email label in the database
1183
+ *
1184
+ * @param type string $email_label
1185
+ *
1186
+ * @return bool
1187
+ */
1188
+ public static function set_mc_email_label( $email_label )
1189
+ {
1190
+ if ( is_multisite() ) {
1191
+ return update_site_option( 'sendgrid_mc_email_label', $email_label );
1192
+ } else {
1193
+ return update_option( 'sendgrid_mc_email_label', $email_label );
1194
+ }
1195
+ }
1196
+
1197
+ /**
1198
+ * Return email label from the database or global variable
1199
+ *
1200
+ * @return mixed email, false if the value is not found
1201
+ */
1202
+ public static function get_mc_email_label()
1203
+ {
1204
+ if ( defined( 'SENDGRID_MC_EMAIL_LABEL' ) ) {
1205
+ return SENDGRID_MC_EMAIL_LABEL;
1206
+ } elseif ( is_multisite() ) {
1207
+ return get_site_option( 'sendgrid_mc_email_label' );
1208
+ } else {
1209
+ return get_option( 'sendgrid_mc_email_label' );
1210
+ }
1211
+ }
1212
+
1213
+ /**
1214
+ * Sets first name label in the database
1215
+ *
1216
+ * @param type string $first_name_label
1217
+ *
1218
+ * @return bool
1219
+ */
1220
+ public static function set_mc_first_name_label( $first_name_label )
1221
+ {
1222
+ if ( is_multisite() ) {
1223
+ return update_site_option( 'sendgrid_mc_first_name_label', $first_name_label );
1224
+ } else {
1225
+ return update_option( 'sendgrid_mc_first_name_label', $first_name_label );
1226
+ }
1227
+ }
1228
+
1229
+ /**
1230
+ * Return first name label from the database or global variable
1231
+ *
1232
+ * @return mixed label, false if the value is not found
1233
+ */
1234
+ public static function get_mc_first_name_label()
1235
+ {
1236
+ if ( defined( 'SENDGRID_MC_FIRST_NAME_LABEL' ) ) {
1237
+ return SENDGRID_MC_FIRST_NAME_LABEL;
1238
+ } elseif ( is_multisite() ) {
1239
+ return get_site_option( 'sendgrid_mc_first_name_label' );
1240
+ } else {
1241
+ return get_option( 'sendgrid_mc_first_name_label' );
1242
+ }
1243
+ }
1244
+
1245
+ /**
1246
+ * Sets last name label in the database
1247
+ *
1248
+ * @param type string $last_name_label
1249
+ *
1250
+ * @return bool
1251
+ */
1252
+ public static function set_mc_last_name_label( $last_name_label )
1253
+ {
1254
+ if ( is_multisite() ) {
1255
+ return update_site_option( 'sendgrid_mc_last_name_label', $last_name_label );
1256
+ } else {
1257
+ return update_option( 'sendgrid_mc_last_name_label', $last_name_label );
1258
+ }
1259
+ }
1260
+
1261
+ /**
1262
+ * Return last name label from the database or global variable
1263
+ *
1264
+ * @return mixed label, false if the value is not found
1265
+ */
1266
+ public static function get_mc_last_name_label()
1267
+ {
1268
+ if ( defined( 'SENDGRID_MC_LAST_NAME_LABEL' ) ) {
1269
+ return SENDGRID_MC_LAST_NAME_LABEL;
1270
+ } elseif ( is_multisite() ) {
1271
+ return get_site_option( 'sendgrid_mc_last_name_label' );
1272
+ } else {
1273
+ return get_option( 'sendgrid_mc_last_name_label' );
1274
+ }
1275
+ }
1276
+
1277
+ /**
1278
+ * Sets subscribe label in the database
1279
+ *
1280
+ * @param type string $subscribe_label
1281
+ *
1282
+ * @return bool
1283
+ */
1284
+ public static function set_mc_subscribe_label( $subscribe_label )
1285
+ {
1286
+ if ( is_multisite() ) {
1287
+ return update_site_option( 'sendgrid_mc_subscribe_label', $subscribe_label );
1288
+ } else {
1289
+ return update_option( 'sendgrid_mc_subscribe_label', $subscribe_label );
1290
+ }
1291
+ }
1292
+
1293
+ /**
1294
+ * Return subscribe label from the database or global variable
1295
+ *
1296
+ * @return mixed label, false if the value is not found
1297
+ */
1298
+ public static function get_mc_subscribe_label()
1299
+ {
1300
+ if ( defined( 'SENDGRID_MC_SUBSCRIBE_LABEL' ) ) {
1301
+ return SENDGRID_MC_SUBSCRIBE_LABEL;
1302
+ } elseif ( is_multisite() ) {
1303
+ return get_site_option( 'sendgrid_mc_subscribe_label' );
1304
+ } else {
1305
+ return get_option( 'sendgrid_mc_subscribe_label' );
1306
+ }
1307
+ }
1308
+
1309
+ /**
1310
+ * Sets input padding in the database
1311
+ *
1312
+ * @param type string $position
1313
+ * @param type int $value
1314
+ *
1315
+ * @return bool
1316
+ */
1317
+ public static function set_mc_input_padding( $position, $value = 0 )
1318
+ {
1319
+ if ( "" == $value ) {
1320
+ $value = 0;
1321
+ }
1322
+ $values = json_decode( self::get_mc_input_padding(), true ) ;
1323
+ if ( !isset( $values ) or !is_array($values) ) {
1324
+ $values = array(
1325
+ 'top' => 10,
1326
+ 'right' => 0,
1327
+ 'bottom' => 0,
1328
+ 'left' => 0
1329
+ );
1330
+ }
1331
+
1332
+ // set the new value
1333
+ $values[$position] = $value;
1334
+
1335
+ if ( is_multisite() ) {
1336
+ return update_site_option( 'sendgrid_mc_input_padding', json_encode( $values ) );
1337
+ } else {
1338
+ return update_option( 'sendgrid_mc_input_padding', json_encode( $values ) );
1339
+ }
1340
+ }
1341
+
1342
+ /**
1343
+ * Return input padding by from the database
1344
+ *
1345
+ * @return mixed json with the padding value, false if the value is not found
1346
+ */
1347
+ public static function get_mc_input_padding()
1348
+ {
1349
+ if ( is_multisite() ) {
1350
+ return get_site_option( 'sendgrid_mc_input_padding' );
1351
+ } else {
1352
+ return get_option( 'sendgrid_mc_input_padding' );
1353
+ }
1354
+ }
1355
+
1356
+ /**
1357
+ * Return input padding by position from the database
1358
+ *
1359
+ * @param string $position position
1360
+ * @return integer padding value
1361
+ */
1362
+ public static function get_mc_input_padding_by_position( $position )
1363
+ {
1364
+ if ( is_multisite() ) {
1365
+ $padding = get_site_option( 'sendgrid_mc_input_padding' );
1366
+ } else {
1367
+ $padding = get_option( 'sendgrid_mc_input_padding' );
1368
+ }
1369
+
1370
+ if ( false == $padding ) {
1371
+ if ( $position == "top" )
1372
+ {
1373
+ return 10;
1374
+ }
1375
+
1376
+ return 0;
1377
+ }
1378
+ $padding = json_decode( $padding, true );
1379
+ if ( !isset( $padding[$position] ) ) {
1380
+ return 0;
1381
+ }
1382
+
1383
+ return $padding[$position];
1384
+ }
1385
+
1386
+ /**
1387
+ * Sets button padding in the database
1388
+ *
1389
+ * @param type string $position
1390
+ * @param type int $value
1391
+ *
1392
+ * @return bool
1393
+ */
1394
+ public static function set_mc_button_padding( $position, $value = 0 )
1395
+ {
1396
+ if ( "" == $value ) {
1397
+ $value = 0;
1398
+ }
1399
+ $values = json_decode( self::get_mc_button_padding(), true );
1400
+ if ( !isset( $values ) or !is_array($values) ) {
1401
+ $values = array(
1402
+ 'top' => 10,
1403
+ 'right' => 0,
1404
+ 'bottom' => 0,
1405
+ 'left' => 0
1406
+ );
1407
+ }
1408
+
1409
+ // set the new value
1410
+ $values[$position] = $value;
1411
+
1412
+ if ( is_multisite() ) {
1413
+ return update_site_option( 'sendgrid_mc_button_padding', json_encode( $values ) );
1414
+ } else {
1415
+ return update_option( 'sendgrid_mc_button_padding', json_encode( $values ) );
1416
+ }
1417
+ }
1418
+
1419
+ /**
1420
+ * Return button padding by from the database
1421
+ *
1422
+ * @return mixed json with the padding value, false if the value is not found
1423
+ */
1424
+ public static function get_mc_button_padding()
1425
+ {
1426
+ if ( is_multisite() ) {
1427
+ return get_site_option( 'sendgrid_mc_button_padding' );
1428
+ } else {
1429
+ return get_option( 'sendgrid_mc_button_padding' );
1430
+ }
1431
+ }
1432
+
1433
+ /**
1434
+ * Return button padding by position from the database
1435
+ *
1436
+ * @param string $position position
1437
+ * @return integer padding value
1438
+ */
1439
+ public static function get_mc_button_padding_by_position( $position )
1440
+ {
1441
+ if ( is_multisite() ) {
1442
+ $padding = get_site_option( 'sendgrid_mc_button_padding' );
1443
+ } else {
1444
+ $padding = get_option( 'sendgrid_mc_button_padding' );
1445
+ }
1446
+
1447
+ if ( false == $padding ) {
1448
+ if ( $position == "top" )
1449
+ {
1450
+ return 10;
1451
+ }
1452
+
1453
+ return 0;
1454
+ }
1455
+ $padding = json_decode( $padding, true );
1456
+ if ( !isset( $padding[$position] ) ) {
1457
+ return 0;
1458
+ }
1459
+
1460
+ return $padding[$position];
1461
+ }
1462
+
1463
  /**
1464
  * Returns decrypted string using the key or empty string in case of error
1465
  *
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.10.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -255,6 +255,8 @@ The settings for all sites in the network can be configured only by the Network
255
 
256
  == Changelog ==
257
 
 
 
258
  = 1.10.1 =
259
  * Fixed a javascript error and a PHP warning
260
  = 1.10.0 =
@@ -385,6 +387,8 @@ The settings for all sites in the network can be configured only by the Network
385
 
386
  == Upgrade notice ==
387
 
 
 
388
  = 1.10.1 =
389
  * Fixed a javascript error and a PHP warning
390
  = 1.10.0 =
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.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
255
 
256
  == Changelog ==
257
 
258
+ = 1.10.2 =
259
+ * Add options to configure subscription widget form (labels, padding)
260
  = 1.10.1 =
261
  * Fixed a javascript error and a PHP warning
262
  = 1.10.0 =
387
 
388
  == Upgrade notice ==
389
 
390
+ = 1.10.2 =
391
+ * Add options to configure subscription widget form (labels, padding)
392
  = 1.10.1 =
393
  * Fixed a javascript error and a PHP warning
394
  = 1.10.0 =
view/css/sendgrid.css CHANGED
@@ -238,6 +238,10 @@
238
  display: block;
239
  }
240
 
 
 
 
 
241
  /*
242
  Responsive
243
  */
238
  display: block;
239
  }
240
 
241
+ .sendgrid_settings_mc_input_padding_label {
242
+ padding-left: 5px;
243
+ }
244
+
245
  /*
246
  Responsive
247
  */
view/sendgrid_settings_nlvx.php CHANGED
@@ -113,9 +113,80 @@
113
  </td>
114
  </tr>
115
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  <?php if ( $is_env_mc_api_key or $is_env_mc_opt_use_transactional or $is_env_mc_opt_incl_fname_lname or
117
  $is_env_mc_opt_req_fname_lname or $is_env_mc_signup_email_subject or $is_env_mc_signup_email_content or
118
- $is_env_mc_signup_confirmation_page ) : ?>
 
119
  <tr valign="top">
120
  <td colspan="2">
121
  <p>
113
  </td>
114
  </tr>
115
 
116
+ <tr valign="top">
117
+ <td colspan="2">
118
+ <h3><?php echo _e('Form Customization') ?></h3>
119
+ </td>
120
+ </tr>
121
+ <tr valign="top" class="signup_email_label">
122
+ <th scope="row"> <?php _e("Email Label:"); ?></th>
123
+ <td>
124
+ <input type="text" id="signup_email_label" name="sendgrid_mc_email_label" size="50" value="<?php echo $mc_signup_email_label; ?>" <?php disabled( $is_env_mc_email_label ); ?>>
125
+ <p class="description"><?php _e('The label for \'Email\' field on the subscription form.') ?></p>
126
+ </td>
127
+ </tr>
128
+ <tr valign="top" class="signup_first_name_label">
129
+ <th scope="row"> <?php _e("First Name Label:"); ?></th>
130
+ <td>
131
+ <input type="text" id="signup_first_name_label" name="sendgrid_mc_first_name_label" size="50" value="<?php echo $mc_signup_first_name_label; ?>" <?php disabled( $is_env_mc_first_name_label ); ?>>
132
+ <p class="description"><?php _e('The label for \'First Name\' field on the subscription form.') ?></p>
133
+ </td>
134
+ </tr>
135
+ <tr valign="top" class="signup_last_name_label">
136
+ <th scope="row"> <?php _e("Last Name Label:"); ?></th>
137
+ <td>
138
+ <input type="text" id="signup_last_name_label" name="sendgrid_mc_last_name_label" size="50" value="<?php echo $mc_signup_last_name_label; ?>" <?php disabled( $is_env_mc_last_name_label ); ?>>
139
+ <p class="description"><?php _e('The label for \'Last Name\' field on the subscription form.') ?></p>
140
+ </td>
141
+ </tr>
142
+ <tr valign="top" class="signup_subscribe_label">
143
+ <th scope="row"> <?php _e("Subscribe Label:"); ?></th>
144
+ <td>
145
+ <input type="text" id="signup_subscribe_label" name="sendgrid_mc_subscribe_label" size="50" value="<?php echo $mc_signup_subscribe_label; ?>" <?php disabled( $is_env_mc_subscribe_label ); ?>>
146
+ <p class="description"><?php _e('The label for \'Subscribe\' button on the subscription form.') ?></p>
147
+ </td>
148
+ </tr>
149
+
150
+ <tr valign="top">
151
+ <th scope="row"> <?php _e("Input Padding (in px):"); ?></th>
152
+ <td>
153
+ <label><?php _e("Top:"); ?></label>
154
+ <input type="text" name="sendgrid_mc_input_padding_top" size="4" value="<?php echo $mc_signup_input_padding_top; ?>" />
155
+
156
+ <label class="sendgrid_settings_mc_input_padding_label"><?php _e("Right:"); ?></label>
157
+ <input type="text" name="sendgrid_mc_input_padding_right" size="4" value="<?php echo $mc_signup_input_padding_right; ?>" />
158
+
159
+ <label class="sendgrid_settings_mc_input_padding_label"><?php _e("Bottom:"); ?></label>
160
+ <input type="text" name="sendgrid_mc_input_padding_bottom" size="4" value="<?php echo $mc_signup_input_padding_bottom; ?>" />
161
+
162
+ <label class="sendgrid_settings_mc_input_padding_label"><?php _e("Left:"); ?></label>
163
+ <input type="text" name="sendgrid_mc_input_padding_left" size="4" value="<?php echo $mc_signup_input_padding_left; ?>" />
164
+ <p class="description"><?php _e('The padding values for the input fields on the subscription form.') ?></p>
165
+ </td>
166
+ </tr>
167
+
168
+ <tr valign="top">
169
+ <th scope="row"> <?php _e("Button Padding (in px):"); ?></th>
170
+ <td>
171
+ <label><?php _e("Top:"); ?></label>
172
+ <input type="text" name="sendgrid_mc_button_padding_top" size="4" value="<?php echo $mc_signup_button_padding_top; ?>" />
173
+
174
+ <label class="sendgrid_settings_mc_input_padding_label"><?php _e("Right:"); ?></label>
175
+ <input type="text" name="sendgrid_mc_button_padding_right" size="4" value="<?php echo $mc_signup_button_padding_right; ?>" />
176
+
177
+ <label class="sendgrid_settings_mc_input_padding_label"><?php _e("Bottom:"); ?></label>
178
+ <input type="text" name="sendgrid_mc_button_padding_bottom" size="4" value="<?php echo $mc_signup_button_padding_bottom; ?>" />
179
+
180
+ <label class="sendgrid_settings_mc_input_padding_label"><?php _e("Left:"); ?></label>
181
+ <input type="text" name="sendgrid_mc_button_padding_left" size="4" value="<?php echo $mc_signup_button_padding_left; ?>" />
182
+ <p class="description"><?php _e('The padding values for the button on the subscription form.') ?></p>
183
+ </td>
184
+ </tr>
185
+
186
  <?php if ( $is_env_mc_api_key or $is_env_mc_opt_use_transactional or $is_env_mc_opt_incl_fname_lname or
187
  $is_env_mc_opt_req_fname_lname or $is_env_mc_signup_email_subject or $is_env_mc_signup_email_content or
188
+ $is_env_mc_signup_confirmation_page or $is_env_mc_email_label or $is_env_mc_first_name_label or
189
+ $is_env_mc_last_name_label or $is_env_mc_subscribe_label) : ?>
190
  <tr valign="top">
191
  <td colspan="2">
192
  <p>
wpsendgrid.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: SendGrid
4
  Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
5
  Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
6
- Version: 1.10.1
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.2
7
  Author: SendGrid
8
  Author URI: http://sendgrid.com
9
  Text Domain: sendgrid-email-delivery-simplified