GoDaddy Email Marketing - Version 1.1.4

Version Description

Download this release

Release Info

Developer jonathanbardo
Plugin Icon 128x128 GoDaddy Email Marketing
Version 1.1.4
Comparing to
See all releases

Code changes from version 1.1.3 to 1.1.4

godaddy-email-marketing.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: GoDaddy Email Marketing Signup Forms
4
  * Plugin URI: https://gem.godaddy.com/
5
  * Description: Add the GoDaddy Email Marketing signup form to your WordPress site! Easy to set up, the plugin allows your site visitors to subscribe to your email lists.
6
- * Version: 1.1.3
7
  * Author: GoDaddy
8
  * Author URI: https://gem.godaddy.com/
9
  * License: GPL-2.0
@@ -104,7 +104,7 @@ class GEM_Official {
104
 
105
  // Plugin's main directory.
106
  defined( 'GEM_VERSION' )
107
- or define( 'GEM_VERSION', '1.1.2' );
108
 
109
  // Set up the base name.
110
  isset( self::$basename ) || self::$basename = plugin_basename( __FILE__ );
@@ -206,6 +206,8 @@ class GEM_Official {
206
  * Adds the settings page to the action links.
207
  *
208
  * @param array $actions An array of plugin action links.
 
 
209
  */
210
  public function action_links( $actions ) {
211
  return array_merge(
@@ -234,7 +236,7 @@ class GEM_Official {
234
  public function action_admin_notices() {
235
  $screen = get_current_screen();
236
 
237
- if ( 'plugins' != $screen->id ) {
238
  return;
239
  }
240
 
3
  * Plugin Name: GoDaddy Email Marketing Signup Forms
4
  * Plugin URI: https://gem.godaddy.com/
5
  * Description: Add the GoDaddy Email Marketing signup form to your WordPress site! Easy to set up, the plugin allows your site visitors to subscribe to your email lists.
6
+ * Version: 1.1.4
7
  * Author: GoDaddy
8
  * Author URI: https://gem.godaddy.com/
9
  * License: GPL-2.0
104
 
105
  // Plugin's main directory.
106
  defined( 'GEM_VERSION' )
107
+ or define( 'GEM_VERSION', '1.1.3' );
108
 
109
  // Set up the base name.
110
  isset( self::$basename ) || self::$basename = plugin_basename( __FILE__ );
206
  * Adds the settings page to the action links.
207
  *
208
  * @param array $actions An array of plugin action links.
209
+ *
210
+ * @return array
211
  */
212
  public function action_links( $actions ) {
213
  return array_merge(
236
  public function action_admin_notices() {
237
  $screen = get_current_screen();
238
 
239
+ if ( 'plugins' !== $screen->id ) {
240
  return;
241
  }
242
 
includes/class-dispatcher.php CHANGED
@@ -29,9 +29,10 @@ class GEM_Dispatcher {
29
  /**
30
  * Gets and sets the forms.
31
  *
32
- * @param string $username The username.
 
 
33
  * @return string $api_key The API key.
34
- * @return array|false The form fields array or false.
35
  */
36
  public static function fetch_forms( $username = '', $api_key = '' ) {
37
  if ( ! $username && ! $api_key ) {
@@ -57,7 +58,7 @@ class GEM_Dispatcher {
57
  delete_transient( 'gem-' . $username . '-lists' );
58
 
59
  // Credentials are incorrect.
60
- if ( ! in_array( wp_remote_retrieve_response_code( $response ), self::$ok_codes ) ) {
61
  return false;
62
  }
63
 
@@ -70,7 +71,6 @@ class GEM_Dispatcher {
70
  /**
71
  * Add a default form.
72
  *
73
- * @param string $username The username.
74
  * @return bool True on success or false on failue.
75
  */
76
  public static function add_default_form() {
@@ -247,6 +247,6 @@ class GEM_Dispatcher {
247
  * @return bool
248
  */
249
  public static function is_response_ok( $request ) {
250
- return ( ! is_wp_error( $request ) && in_array( wp_remote_retrieve_response_code( $request ), self::$ok_codes ) );
251
  }
252
  }
29
  /**
30
  * Gets and sets the forms.
31
  *
32
+ * @param string $username The username.
33
+ * @param string $api_key
34
+ *
35
  * @return string $api_key The API key.
 
36
  */
37
  public static function fetch_forms( $username = '', $api_key = '' ) {
38
  if ( ! $username && ! $api_key ) {
58
  delete_transient( 'gem-' . $username . '-lists' );
59
 
60
  // Credentials are incorrect.
61
+ if ( ! in_array( wp_remote_retrieve_response_code( $response ), self::$ok_codes, true ) ) {
62
  return false;
63
  }
64
 
71
  /**
72
  * Add a default form.
73
  *
 
74
  * @return bool True on success or false on failue.
75
  */
76
  public static function add_default_form() {
247
  * @return bool
248
  */
249
  public static function is_response_ok( $request ) {
250
+ return ( ! is_wp_error( $request ) && in_array( wp_remote_retrieve_response_code( $request ), self::$ok_codes, true ) );
251
  }
252
  }
includes/class-shortcode.php CHANGED
@@ -16,6 +16,8 @@ class GEM_Shortcode {
16
  * Renders the shortcode.
17
  *
18
  * @param array $atts An array of shortcode attributes.
 
 
19
  */
20
  public function render( $atts ) {
21
  extract( shortcode_atts( array(
@@ -69,10 +71,12 @@ class GEM_Shortcode {
69
  * The main template tag. Pass on the ID and watch the magic happen.
70
  *
71
  * @since 1.0
72
- * @see GEM_Form_Renderer
73
  *
74
- * @param int $id The ID of the form you wish to output.
75
  * @param bool $echo Wether to echo the form field. Default true.
 
 
76
  */
77
  function gem_form( $id, $echo = true ) {
78
  if ( class_exists( 'GEM_Form_Renderer', false ) ) {
@@ -83,6 +87,6 @@ function gem_form( $id, $echo = true ) {
83
  return $form;
84
  }
85
 
86
- echo $form;
87
  }
88
  }
16
  * Renders the shortcode.
17
  *
18
  * @param array $atts An array of shortcode attributes.
19
+ *
20
+ * @return string|void
21
  */
22
  public function render( $atts ) {
23
  extract( shortcode_atts( array(
71
  * The main template tag. Pass on the ID and watch the magic happen.
72
  *
73
  * @since 1.0
74
+ * @see GEM_Form_Renderer
75
  *
76
+ * @param int $id The ID of the form you wish to output.
77
  * @param bool $echo Wether to echo the form field. Default true.
78
+ *
79
+ * @return string
80
  */
81
  function gem_form( $id, $echo = true ) {
82
  if ( class_exists( 'GEM_Form_Renderer', false ) ) {
87
  return $form;
88
  }
89
 
90
+ echo $form;//xss ok
91
  }
92
  }
includes/render.php CHANGED
@@ -23,7 +23,9 @@ class GEM_Form_Renderer {
23
  * Generates the form.
24
  *
25
  * @param string $form_id Form ID.
26
- * @param bool $echo Wether to echo the form field. Default false.
 
 
27
  */
28
  public function process( $form_id, $echo = false ) {
29
  $form = GEM_Dispatcher::get_fields( (int) $form_id );
@@ -38,7 +40,9 @@ class GEM_Form_Renderer {
38
 
39
  if ( ! empty( $form->fields ) && in_array( (int) $form_id, $form_ids, true ) ) :
40
 
41
- self::$loops++; ob_start(); ?>
 
 
42
 
43
  <div class="gem-form-wrapper" id="form-<?php echo absint( $form_id ); ?>">
44
  <form action="<?php echo esc_url( $form->submit ); ?>" method="post" class="gem-form">
@@ -338,7 +342,7 @@ class GEM_Form_Fields {
338
  <select fingerprint="date" data-id="<?php echo esc_attr( self::get_form_id( $args->name ) ); ?>" data-name="<?php echo esc_attr( $args->name ); ?>">
339
  <option value=""> <?php esc_html_e( 'Day', 'godaddy-email-marketing' ) ?> </option>
340
  <?php for ( $i = 1; $i < 32; $i++ ) : ?>
341
- <option value="<?php echo strlen( $i ) < 2 ? '0'.$i : $i; ?>"> <?php echo esc_attr( $i ); ?> </option>
342
  <?php endfor; ?>
343
  </select>
344
  </span>
23
  * Generates the form.
24
  *
25
  * @param string $form_id Form ID.
26
+ * @param bool $echo Wether to echo the form field. Default false.
27
+ *
28
+ * @return string
29
  */
30
  public function process( $form_id, $echo = false ) {
31
  $form = GEM_Dispatcher::get_fields( (int) $form_id );
40
 
41
  if ( ! empty( $form->fields ) && in_array( (int) $form_id, $form_ids, true ) ) :
42
 
43
+ self::$loops++;
44
+ ob_start();
45
+ ?>
46
 
47
  <div class="gem-form-wrapper" id="form-<?php echo absint( $form_id ); ?>">
48
  <form action="<?php echo esc_url( $form->submit ); ?>" method="post" class="gem-form">
342
  <select fingerprint="date" data-id="<?php echo esc_attr( self::get_form_id( $args->name ) ); ?>" data-name="<?php echo esc_attr( $args->name ); ?>">
343
  <option value=""> <?php esc_html_e( 'Day', 'godaddy-email-marketing' ) ?> </option>
344
  <?php for ( $i = 1; $i < 32; $i++ ) : ?>
345
+ <option value="<?php echo strlen( $i ) < 2 ? '0' . esc_attr( $i ) : esc_attr( $i ); ?>"> <?php echo esc_attr( $i ); ?> </option>
346
  <?php endfor; ?>
347
  </select>
348
  </span>
includes/settings.php CHANGED
@@ -104,6 +104,12 @@ class GEM_Settings {
104
  */
105
  public function page_load() {
106
 
 
 
 
 
 
 
107
  // Main switch for various maintenance processes.
108
  if ( isset( $_GET['action'] ) ) {
109
  $settings = get_option( $this->slug );
@@ -114,6 +120,8 @@ class GEM_Settings {
114
  return;
115
  }
116
 
 
 
117
  if ( isset( $settings['username'] ) ) {
118
 
119
  // Mass-removal of all forms.
@@ -135,7 +143,7 @@ class GEM_Settings {
135
  set_transient( 'debug-reset', true, 30 );
136
  // @codeCoverageIgnoreStart
137
  if ( 'cli' !== php_sapi_name() ) {
138
- wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated' ), add_query_arg( 'tab', 'settings' ) ) );
139
  exit;
140
  }
141
  // @codeCoverageIgnoreEnd
@@ -146,6 +154,8 @@ class GEM_Settings {
146
  return;
147
  }
148
 
 
 
149
  if ( isset( $settings['username'] ) ) {
150
 
151
  // Mass-removal of all forms.
@@ -163,7 +173,7 @@ class GEM_Settings {
163
  set_transient( 'debug-reset-transients', true, 30 );
164
  // @codeCoverageIgnoreStart
165
  if ( 'cli' !== php_sapi_name() ) {
166
- wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated' ), add_query_arg( 'tab', 'settings' ) ) );
167
  exit;
168
  }
169
  // @codeCoverageIgnoreEnd
@@ -172,6 +182,8 @@ class GEM_Settings {
172
  break;
173
  case 'refresh' :
174
 
 
 
175
  if ( isset( $settings['username'] ) ) {
176
 
177
  // Mass-removal of all forms.
@@ -189,26 +201,16 @@ class GEM_Settings {
189
  set_transient( 'gem-refresh', true, 30 );
190
  // @codeCoverageIgnoreStart
191
  if ( 'cli' !== php_sapi_name() ) {
192
- wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated' ) ) );
193
  exit;
194
  }
195
  // @codeCoverageIgnoreEnd
196
  }
197
 
198
- break;
199
- case 'dismiss' :
200
- $user_id = get_current_user_id();
201
-
202
- if ( ! $user_id ) {
203
- return;
204
- }
205
-
206
- update_user_meta( $user_id, 'gem-dismiss', 'show' );
207
-
208
  break;
209
  }
210
- } else if ( isset( $_GET['settings-updated'] ) && 'cli' !== php_sapi_name() ) { // @codeCoverageIgnoreStart
211
- wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated' ), add_query_arg( 'tab', 'settings' ) ) );
212
  exit;
213
  }
214
  // @codeCoverageIgnoreEnd
@@ -392,6 +394,7 @@ class GEM_Settings {
392
  );
393
 
394
  if ( $this->gem->debug ) {
 
395
  add_settings_field(
396
  'erase_transients',
397
  __( 'Cache Reset', 'godaddy-email-marketing' ),
@@ -399,7 +402,10 @@ class GEM_Settings {
399
  $this->slug,
400
  'debugging_section',
401
  array(
402
- 'url' => add_query_arg( 'action', 'debug-reset-transients' ),
 
 
 
403
  'label' => __( 'Erase Transients', 'godaddy-email-marketing' ),
404
  'description' => __( 'Purges only the cached data associated with this plugin, and should be attempted before a hard reset.', 'godaddy-email-marketing' ),
405
  )
@@ -412,7 +418,10 @@ class GEM_Settings {
412
  $this->slug,
413
  'debugging_section',
414
  array(
415
- 'url' => add_query_arg( 'action', 'debug-reset' ),
 
 
 
416
  'label' => __( 'Erase All Data', 'godaddy-email-marketing' ),
417
  'description' => __( 'Purges all saved data associated with this plugin.', 'godaddy-email-marketing' ),
418
  )
@@ -575,7 +584,7 @@ class GEM_Settings {
575
  <td data-colname="<?php esc_html_e( 'Shortcode', 'godaddy-email-marketing' ); ?>">
576
  <input type="text" id="form-<?php echo absint( $form->id ); ?>" class="code clipboard-value" value="[gem id=<?php echo absint( $form->id ); ?>]" readonly />
577
  <button data-copytarget="#form-<?php echo absint( $form->id ); ?>" class="button copy-to-clipboard">
578
- <img src="<?php echo plugins_url( 'images/clippy.svg', GEM_PLUGIN_BASE ); ?>" width="14" alt="Copy to clipboard">
579
  </button>
580
  </td>
581
  </tr>
@@ -633,7 +642,15 @@ class GEM_Settings {
633
  * Refresh forms button.
634
  */
635
  public function refresh_button() {
636
- $url = esc_url( add_query_arg( 'action', 'refresh', remove_query_arg( 'tab' ) ) );
 
 
 
 
 
 
 
 
637
  $this->link_button( __( 'Refresh Forms', 'godaddy-email-marketing' ), $url );
638
  }
639
 
104
  */
105
  public function page_load() {
106
 
107
+ if ( ! current_user_can( 'manage_options' ) ) {
108
+
109
+ return false;
110
+
111
+ }
112
+
113
  // Main switch for various maintenance processes.
114
  if ( isset( $_GET['action'] ) ) {
115
  $settings = get_option( $this->slug );
120
  return;
121
  }
122
 
123
+ check_admin_referer( 'gem_settings_hard_reset_nonce' );
124
+
125
  if ( isset( $settings['username'] ) ) {
126
 
127
  // Mass-removal of all forms.
143
  set_transient( 'debug-reset', true, 30 );
144
  // @codeCoverageIgnoreStart
145
  if ( 'cli' !== php_sapi_name() ) {
146
+ wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated', '_wpnonce' ), add_query_arg( 'tab', 'settings' ) ) );
147
  exit;
148
  }
149
  // @codeCoverageIgnoreEnd
154
  return;
155
  }
156
 
157
+ check_admin_referer( 'gem_settings_reset_transients_nonce' );
158
+
159
  if ( isset( $settings['username'] ) ) {
160
 
161
  // Mass-removal of all forms.
173
  set_transient( 'debug-reset-transients', true, 30 );
174
  // @codeCoverageIgnoreStart
175
  if ( 'cli' !== php_sapi_name() ) {
176
+ wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated', '_wpnonce' ), add_query_arg( 'tab', 'settings' ) ) );
177
  exit;
178
  }
179
  // @codeCoverageIgnoreEnd
182
  break;
183
  case 'refresh' :
184
 
185
+ check_admin_referer( 'gem_settings_refresh_nonce' );
186
+
187
  if ( isset( $settings['username'] ) ) {
188
 
189
  // Mass-removal of all forms.
201
  set_transient( 'gem-refresh', true, 30 );
202
  // @codeCoverageIgnoreStart
203
  if ( 'cli' !== php_sapi_name() ) {
204
+ wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated', '_wpnonce' ) ) );
205
  exit;
206
  }
207
  // @codeCoverageIgnoreEnd
208
  }
209
 
 
 
 
 
 
 
 
 
 
 
210
  break;
211
  }
212
+ } elseif ( isset( $_GET['settings-updated'] ) && 'cli' !== php_sapi_name() ) { // @codeCoverageIgnoreStart
213
+ wp_safe_redirect( remove_query_arg( array( 'action', 'settings-updated', '_wpnonce' ), add_query_arg( 'tab', 'settings' ) ) );
214
  exit;
215
  }
216
  // @codeCoverageIgnoreEnd
394
  );
395
 
396
  if ( $this->gem->debug ) {
397
+
398
  add_settings_field(
399
  'erase_transients',
400
  __( 'Cache Reset', 'godaddy-email-marketing' ),
402
  $this->slug,
403
  'debugging_section',
404
  array(
405
+ 'url' => add_query_arg( array(
406
+ 'action' => 'debug-reset-transients',
407
+ '_wpnonce' => wp_create_nonce( 'gem_settings_reset_transients_nonce' ),
408
+ ) ),
409
  'label' => __( 'Erase Transients', 'godaddy-email-marketing' ),
410
  'description' => __( 'Purges only the cached data associated with this plugin, and should be attempted before a hard reset.', 'godaddy-email-marketing' ),
411
  )
418
  $this->slug,
419
  'debugging_section',
420
  array(
421
+ 'url' => add_query_arg( array(
422
+ 'action' => 'debug-reset',
423
+ '_wpnonce' => wp_create_nonce( 'gem_settings_hard_reset_nonce' ),
424
+ ) ),
425
  'label' => __( 'Erase All Data', 'godaddy-email-marketing' ),
426
  'description' => __( 'Purges all saved data associated with this plugin.', 'godaddy-email-marketing' ),
427
  )
584
  <td data-colname="<?php esc_html_e( 'Shortcode', 'godaddy-email-marketing' ); ?>">
585
  <input type="text" id="form-<?php echo absint( $form->id ); ?>" class="code clipboard-value" value="[gem id=<?php echo absint( $form->id ); ?>]" readonly />
586
  <button data-copytarget="#form-<?php echo absint( $form->id ); ?>" class="button copy-to-clipboard">
587
+ <img src="<?php echo esc_url( plugins_url( 'images/clippy.svg', GEM_PLUGIN_BASE ) ); ?>" width="14" alt="Copy to clipboard">
588
  </button>
589
  </td>
590
  </tr>
642
  * Refresh forms button.
643
  */
644
  public function refresh_button() {
645
+ $url = esc_url(
646
+ add_query_arg(
647
+ array(
648
+ 'action' => 'refresh',
649
+ 'wp_nonce' => wp_create_nonce( 'gem_settings_refresh_nonce' ),
650
+ ),
651
+ remove_query_arg( 'tab' )
652
+ )
653
+ );
654
  $this->link_button( __( 'Refresh Forms', 'godaddy-email-marketing' ), $url );
655
  }
656
 
includes/widget.php CHANGED
@@ -153,7 +153,7 @@ class GEM_Form_Widget extends WP_Widget {
153
  <?php else : ?>
154
 
155
  <span><?php printf(
156
- _x( 'Please set up your GoDaddy Email Marketing account in the %s.', 'link to settings page', 'godaddy-email-marketing' ),
157
  sprintf(
158
  '<a href="%s">%s</a>',
159
  esc_url( admin_url( 'options-general.php?page=gem-settings' ) ),
153
  <?php else : ?>
154
 
155
  <span><?php printf(
156
+ esc_html_x( 'Please set up your GoDaddy Email Marketing account in the %s.', 'link to settings page', 'godaddy-email-marketing' ),
157
  sprintf(
158
  '<a href="%s">%s</a>',
159
  esc_url( admin_url( 'options-general.php?page=gem-settings' ) ),
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: godaddy, humanmade, xwp, fjarrett, jonathanbardo
3
  Tags: email, forms, godaddy, mailing list, marketing, newsletter, opt-in, signup, subscribe, widget, contacts
4
  Requires at least: 3.8
5
- Tested up to: 4.5
6
- Stable tag: 1.1.3
7
  License: GPL-2.0
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
2
  Contributors: godaddy, humanmade, xwp, fjarrett, jonathanbardo
3
  Tags: email, forms, godaddy, mailing list, marketing, newsletter, opt-in, signup, subscribe, widget, contacts
4
  Requires at least: 3.8
5
+ Tested up to: 4.7
6
+ Stable tag: 1.1.4
7
  License: GPL-2.0
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9