Subscribe2 - Version 10.27

Version Description

Download this release

Release Info

Developer Collizo4sky
Plugin Icon 128x128 Subscribe2
Version 10.27
Comparing to
See all releases

Code changes from version 10.26.1 to 10.27

ChangeLog.txt CHANGED
@@ -1,10 +1,21 @@
1
- = 10.26.1 =
2
 
3
- * Added Gutenberg support.
 
 
 
 
 
 
 
4
 
5
  = 10.26 =
6
 
7
  * Fixed a bug in barred domain checking
 
 
 
 
8
  * Updated to latest PHP Code sniff standards and cleansed files
9
  * Other minor bug fixes and enhancements
10
 
@@ -12,6 +23,7 @@
12
 
13
  * Dropped use of the 'Precedence' email header as use is controversial and not widely supported
14
  * Fix for date appearing in wrong language when authors use different language in WordPress admin to the main site language
 
15
  * Fixed warning message on Your Subscriptions page
16
  * Further Coding Standard improvements
17
  * Add GDPR warning to Settings page for certain settings
@@ -30,6 +42,7 @@
30
  = 10.23 =
31
 
32
  * Improve REGEX for the old Subscribe2 token - props @pik256
 
33
  * Applied Grunt to packing for distribution so files are minified differently
34
  * Load external javascripts asynchronously
35
  * Improve Bulk Management user experience
1
+ = 10.27 =
2
 
3
+ * Tightened checks for Coding Standards
4
+ * Fixed bug in category form display caused by tighter coding standards
5
+ * Save Editor content before sending preview email for better user experience
6
+ * Update Excerpt creation code for languages that don't use spaces - props Masatoshi Hakoshima
7
+ * Improved layout and efficiency of JavaScript files
8
+ * Enable Preview emails for Classic Editor users
9
+ * Update to use latest jQuery UI css library
10
+ * Tidied up unused globals
11
 
12
  = 10.26 =
13
 
14
  * Fixed a bug in barred domain checking
15
+ * Migrate email override meta box to a sidebar for the 'Gutenberg' block editor
16
+ * Migrate email preview meta box to a sidebar for the 'Gutenberg' block editor
17
+ * Moved new Block Editor code to separate class
18
+ * Fixed issue in transition of wrap parameter in the new Block when changing to and from the shortcode block
19
  * Updated to latest PHP Code sniff standards and cleansed files
20
  * Other minor bug fixes and enhancements
21
 
23
 
24
  * Dropped use of the 'Precedence' email header as use is controversial and not widely supported
25
  * Fix for date appearing in wrong language when authors use different language in WordPress admin to the main site language
26
+ * Gutenberg block updated for useOnce deprecation and transition to shortcode block improved from recently added and unsaved block
27
  * Fixed warning message on Your Subscriptions page
28
  * Further Coding Standard improvements
29
  * Add GDPR warning to Settings page for certain settings
42
  = 10.23 =
43
 
44
  * Improve REGEX for the old Subscribe2 token - props @pik256
45
+ * Introduce Gutenberg Block for testing
46
  * Applied Grunt to packing for distribution so files are minified differently
47
  * Load external javascripts asynchronously
48
  * Improve Bulk Management user experience
ReadMe.txt CHANGED
@@ -3,8 +3,7 @@ Contributors: collizo4sky
3
  Donate link: https://mailoptin.io
4
  Tags: posts, subscription, email, subscribe, notify, notification, newsletter, post notification, email marketing
5
  Requires at least: 4.0
6
- Tested up to: 5.0.3
7
- Stable tag: 10.26.1
8
  License: GPLv3
9
 
10
  Sends a list of subscribers an email notification when you publish new posts.
@@ -66,6 +65,17 @@ This token will automatically be replaced by dynamic subscription information an
66
 
67
  == Changelog ==
68
 
 
 
 
 
 
 
 
 
 
 
 
69
  = 10.26.1 =
70
 
71
  * Added Gutenberg support.
3
  Donate link: https://mailoptin.io
4
  Tags: posts, subscription, email, subscribe, notify, notification, newsletter, post notification, email marketing
5
  Requires at least: 4.0
6
+ Tested up to: 5.1
 
7
  License: GPLv3
8
 
9
  Sends a list of subscribers an email notification when you publish new posts.
65
 
66
  == Changelog ==
67
 
68
+ = 10.27 =
69
+
70
+ * Tightened checks for Coding Standards
71
+ * Fixed bug in category form display caused by tighter coding standards
72
+ * Save Editor content before sending preview email for better user experience
73
+ * Update Excerpt creation code for languages that don't use spaces - props Masatoshi Hakoshima
74
+ * Improved layout and efficiency of JavaScript files
75
+ * Enable Preview emails for Classic Editor users
76
+ * Update to use latest jQuery UI css library
77
+ * Tidied up unused globals
78
+
79
  = 10.26.1 =
80
 
81
  * Added Gutenberg support.
admin/send-email.php CHANGED
@@ -3,7 +3,7 @@ if ( ! function_exists( 'add_action' ) ) {
3
  exit();
4
  }
5
 
6
- global $wpdb, $current_user;
7
 
8
  // was anything POSTed?
9
  if ( isset( $_POST['s2_admin'] ) && 'mail' === $_POST['s2_admin'] ) {
@@ -27,8 +27,8 @@ if ( isset( $_POST['s2_admin'] ) && 'mail' === $_POST['s2_admin'] ) {
27
  $unconfirmed = $this->get_public( 0 );
28
  $recipients = array_merge( (array) $confirmed, (array) $unconfirmed );
29
  } elseif ( is_numeric( $_POST['what'] ) ) {
30
- $cat = intval( $_POST['what'] );
31
- $recipients = $this->get_registered( "cats=$cat" );
32
  } elseif ( 'all_users' === $_POST['what'] ) {
33
  $recipients = $this->get_all_registered();
34
  } elseif ( 'all' === $_POST['what'] ) {
@@ -57,7 +57,8 @@ if ( isset( $_POST['s2_admin'] ) && 'mail' === $_POST['s2_admin'] ) {
57
  );
58
 
59
  $uploads[] = wp_handle_upload(
60
- $file, array(
 
61
  'test_form' => false,
62
  )
63
  );
@@ -77,16 +78,16 @@ if ( isset( $_POST['s2_admin'] ) && 'mail' === $_POST['s2_admin'] ) {
77
 
78
  if ( empty( $body ) ) {
79
  $error_message = __( 'Your email was empty', 'subscribe2' );
80
- $status = false;
81
  } elseif ( isset( $upload_error ) ) {
82
  $error_message = $upload_error;
83
- $status = false;
84
  } else {
85
- $status = $this->mail( $recipients, $subject, $body, 'html', $attachments );
86
  $error_message = __( 'Check your settings and check with your hosting provider', 'subscribe2' );
87
  }
88
 
89
- if ( $status ) {
90
  if ( isset( $_POST['preview'] ) ) {
91
  $message = '<p class="s2_message">' . __( 'Preview message sent!', 'subscribe2' ) . '</p>';
92
  } elseif ( isset( $_POST['send'] ) ) {
3
  exit();
4
  }
5
 
6
+ global $current_user;
7
 
8
  // was anything POSTed?
9
  if ( isset( $_POST['s2_admin'] ) && 'mail' === $_POST['s2_admin'] ) {
27
  $unconfirmed = $this->get_public( 0 );
28
  $recipients = array_merge( (array) $confirmed, (array) $unconfirmed );
29
  } elseif ( is_numeric( $_POST['what'] ) ) {
30
+ $category = intval( $_POST['what'] );
31
+ $recipients = $this->get_registered( "cats=$category" );
32
  } elseif ( 'all_users' === $_POST['what'] ) {
33
  $recipients = $this->get_all_registered();
34
  } elseif ( 'all' === $_POST['what'] ) {
57
  );
58
 
59
  $uploads[] = wp_handle_upload(
60
+ $file,
61
+ array(
62
  'test_form' => false,
63
  )
64
  );
78
 
79
  if ( empty( $body ) ) {
80
  $error_message = __( 'Your email was empty', 'subscribe2' );
81
+ $success = false;
82
  } elseif ( isset( $upload_error ) ) {
83
  $error_message = $upload_error;
84
+ $success = false;
85
  } else {
86
+ $success = $this->mail( $recipients, $subject, $body, 'html', $attachments );
87
  $error_message = __( 'Check your settings and check with your hosting provider', 'subscribe2' );
88
  }
89
 
90
+ if ( $success ) {
91
  if ( isset( $_POST['preview'] ) ) {
92
  $message = '<p class="s2_message">' . __( 'Preview message sent!', 'subscribe2' ) . '</p>';
93
  } elseif ( isset( $_POST['send'] ) ) {
admin/settings.php CHANGED
@@ -21,9 +21,9 @@ if ( isset( $_POST['s2_admin'] ) ) {
21
  global $user_email, $post;
22
  $this->preview_email = true;
23
  if ( 'never' === $this->subscribe2_options['email_freq'] ) {
24
- $posts = get_posts( 'numberposts=1' );
25
- $post = $posts[0];
26
- $this->publish( $post, $user_email );
27
  } else {
28
  do_action( 's2_digest_preview', $user_email );
29
  }
@@ -38,12 +38,12 @@ if ( isset( $_POST['s2_admin'] ) ) {
38
  }
39
  } elseif ( isset( $_POST['submit'] ) ) {
40
  foreach ( $_POST as $key => $value ) {
41
- if ( in_array( $key, array( 'bcclimit', 's2page' ) ) ) {
42
  // numerical inputs fixed for old option names
43
  if ( is_numeric( $_POST[ $key ] ) && $_POST[ $key ] >= 0 ) {
44
  $this->subscribe2_options[ $key ] = (int) $_POST[ $key ];
45
  }
46
- } elseif ( in_array( $key, array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'reg_override' ) ) ) {
47
  // check box entries
48
  ( isset( $_POST[ $key ] ) && '1' === $_POST[ $key ] ) ? $this->subscribe2_options[ $key ] = '1' : $this->subscribe2_options[ $key ] = '0';
49
  } elseif ( 'appearance_tab' === $key ) {
@@ -53,10 +53,10 @@ if ( isset( $_POST['s2_admin'] ) ) {
53
  $this->subscribe2_options[ $option ] = '0';
54
  }
55
  }
56
- } elseif ( in_array( $key, array( 'notification_subject', 'mailtext', 'confirm_subject', 'confirm_email', 'remind_subject', 'remind_email', 's2_license_key' ) ) && ! empty( $_POST[ $key ] ) ) {
57
  // email subject and body templates
58
  $this->subscribe2_options[ $key ] = trim( $_POST[ $key ] );
59
- } elseif ( in_array( $key, array( 'compulsory', 'exclude', 'format' ) ) ) {
60
  sort( $_POST[ $key ] );
61
  $newvalue = implode( ',', $_POST[ $key ] );
62
 
@@ -123,14 +123,14 @@ if ( isset( $_POST['s2_admin'] ) ) {
123
  }
124
 
125
  // send error message if no WordPress page exists
126
- $id = $wpdb->get_var( "SELECT ID FROM `{$wpdb->prefix}posts` WHERE post_type='page' AND post_status='publish' LIMIT 1" );
127
- if ( empty( $id ) ) {
128
  echo '<div id="page_message" class="error"><p class="s2_error"><strong>' . __( 'You must create a WordPress page for this plugin to work correctly.', 'subscribe2' ) . '</strong></p></div>';
129
  }
130
 
131
  // display error message for GDPR
132
  if ( defined( 'S2GDPR' ) && true === S2GDPR ) {
133
- if ( 'yes' === $this->subscribe2_options['wpregdef'] || 'yes' === $this->subscribe2_options['autosub_def'] || 'yes' === $this->subscribe2_options['autosub_def'] || 'yes' === $this->subscribe2_options['comment_def'] ) {
134
  echo '<div id="gdpr_message" class="error"><p class="s2_error"><strong>' . __( 'Your Settings may breach GDPR', 'subscribe2' ) . '</strong></p></div>';
135
  }
136
  }
@@ -157,8 +157,8 @@ if ( false !== $disallowed ) {
157
  if ( 'blogname' === $this->subscribe2_options['sender'] ) {
158
  $sender = get_bloginfo( 'admin_email' );
159
  } else {
160
- $userdata = $this->get_userdata( $this->subscribe2_options['sender'] );
161
- $sender = $userdata->user_email;
162
  }
163
  list( $user, $domain ) = explode( '@', $sender, 2 );
164
  if ( ! stristr( esc_html( $_SERVER['SERVER_NAME'] ), $domain ) && 'author' !== $this->subscribe2_options['sender'] && '0' === $this->subscribe2_options['dismiss_sender_warning'] ) {
@@ -172,7 +172,7 @@ $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'email';
172
  // show our form
173
  echo '<div class="wrap">';
174
  echo '<h1>' . __( 'Settings', 'subscribe2' ) . '</h1>' . "\r\n";
175
- $tabs = array(
176
  'email' => __( 'Email Settings', 'subscribe2' ),
177
  'templates' => __( 'Templates', 'subscribe2' ),
178
  'registered' => __( 'Registered Users', 'subscribe2' ),
@@ -180,7 +180,7 @@ $tabs = array(
180
  'misc' => __( 'Miscellaneous', 'subscribe2' ),
181
  );
182
  echo '<h2 class="nav-tab-wrapper">';
183
- foreach ( $tabs as $tab_key => $tab_caption ) {
184
  $active = ( $current_tab === $tab_key ) ? 'nav-tab-active' : '';
185
  echo '<a class="nav-tab ' . $active . '" href="?page=s2_settings&amp;tab=' . $tab_key . '">' . $tab_caption . '</a>';
186
  }
@@ -231,8 +231,8 @@ switch ( $current_tab ) {
231
  if ( ! empty( $s2_post_types ) ) {
232
  $types = '';
233
  echo __( 'Subscribe2 will send email notifications for the following custom post types', 'subscribe2' ) . ': <strong>';
234
- foreach ( $s2_post_types as $type ) {
235
- ( '' === $types ) ? $types = ucwords( $type ) : $types .= ', ' . ucwords( $type );
236
  }
237
  echo $types . '</strong><br /><br />' . "\r\n";
238
  }
21
  global $user_email, $post;
22
  $this->preview_email = true;
23
  if ( 'never' === $this->subscribe2_options['email_freq'] ) {
24
+ $preview_posts = get_posts( 'numberposts=1' );
25
+ $preview_post = $preview_posts[0];
26
+ $this->publish( $preview_post, $user_email );
27
  } else {
28
  do_action( 's2_digest_preview', $user_email );
29
  }
38
  }
39
  } elseif ( isset( $_POST['submit'] ) ) {
40
  foreach ( $_POST as $key => $value ) {
41
+ if ( in_array( $key, array( 'bcclimit', 's2page' ), true ) ) {
42
  // numerical inputs fixed for old option names
43
  if ( is_numeric( $_POST[ $key ] ) && $_POST[ $key ] >= 0 ) {
44
  $this->subscribe2_options[ $key ] = (int) $_POST[ $key ];
45
  }
46
+ } elseif ( in_array( $key, array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'reg_override' ), true ) ) {
47
  // check box entries
48
  ( isset( $_POST[ $key ] ) && '1' === $_POST[ $key ] ) ? $this->subscribe2_options[ $key ] = '1' : $this->subscribe2_options[ $key ] = '0';
49
  } elseif ( 'appearance_tab' === $key ) {
53
  $this->subscribe2_options[ $option ] = '0';
54
  }
55
  }
56
+ } elseif ( in_array( $key, array( 'notification_subject', 'mailtext', 'confirm_subject', 'confirm_email', 'remind_subject', 'remind_email' ), true ) && ! empty( $_POST[ $key ] ) ) {
57
  // email subject and body templates
58
  $this->subscribe2_options[ $key ] = trim( $_POST[ $key ] );
59
+ } elseif ( in_array( $key, array( 'compulsory', 'exclude', 'format' ), true ) ) {
60
  sort( $_POST[ $key ] );
61
  $newvalue = implode( ',', $_POST[ $key ] );
62
 
123
  }
124
 
125
  // send error message if no WordPress page exists
126
+ $page_id = $wpdb->get_var( "SELECT ID FROM `{$wpdb->prefix}posts` WHERE post_type='page' AND post_status='publish' LIMIT 1" );
127
+ if ( empty( $page_id ) ) {
128
  echo '<div id="page_message" class="error"><p class="s2_error"><strong>' . __( 'You must create a WordPress page for this plugin to work correctly.', 'subscribe2' ) . '</strong></p></div>';
129
  }
130
 
131
  // display error message for GDPR
132
  if ( defined( 'S2GDPR' ) && true === S2GDPR ) {
133
+ if ( 'yes' === $this->subscribe2_options['autosub'] || 'yes' === $this->subscribe2_options['wpregdef'] || 'yes' === $this->subscribe2_options['autosub_def'] || 'yes' === $this->subscribe2_options['comment_def'] ) {
134
  echo '<div id="gdpr_message" class="error"><p class="s2_error"><strong>' . __( 'Your Settings may breach GDPR', 'subscribe2' ) . '</strong></p></div>';
135
  }
136
  }
157
  if ( 'blogname' === $this->subscribe2_options['sender'] ) {
158
  $sender = get_bloginfo( 'admin_email' );
159
  } else {
160
+ $user = $this->get_userdata( $this->subscribe2_options['sender'] );
161
+ $sender = $user->user_email;
162
  }
163
  list( $user, $domain ) = explode( '@', $sender, 2 );
164
  if ( ! stristr( esc_html( $_SERVER['SERVER_NAME'] ), $domain ) && 'author' !== $this->subscribe2_options['sender'] && '0' === $this->subscribe2_options['dismiss_sender_warning'] ) {
172
  // show our form
173
  echo '<div class="wrap">';
174
  echo '<h1>' . __( 'Settings', 'subscribe2' ) . '</h1>' . "\r\n";
175
+ $s2tabs = array(
176
  'email' => __( 'Email Settings', 'subscribe2' ),
177
  'templates' => __( 'Templates', 'subscribe2' ),
178
  'registered' => __( 'Registered Users', 'subscribe2' ),
180
  'misc' => __( 'Miscellaneous', 'subscribe2' ),
181
  );
182
  echo '<h2 class="nav-tab-wrapper">';
183
+ foreach ( $s2tabs as $tab_key => $tab_caption ) {
184
  $active = ( $current_tab === $tab_key ) ? 'nav-tab-active' : '';
185
  echo '<a class="nav-tab ' . $active . '" href="?page=s2_settings&amp;tab=' . $tab_key . '">' . $tab_caption . '</a>';
186
  }
231
  if ( ! empty( $s2_post_types ) ) {
232
  $types = '';
233
  echo __( 'Subscribe2 will send email notifications for the following custom post types', 'subscribe2' ) . ': <strong>';
234
+ foreach ( $s2_post_types as $s2_post_type ) {
235
+ ( '' === $types ) ? $types = ucwords( $s2_post_type ) : $types .= ', ' . ucwords( $s2_post_type );
236
  }
237
  echo $types . '</strong><br /><br />' . "\r\n";
238
  }
admin/subscribers.php CHANGED
@@ -3,7 +3,7 @@ if ( ! function_exists( 'add_action' ) ) {
3
  exit();
4
  }
5
 
6
- global $wpdb, $subscribers, $what, $current_tab;
7
 
8
  // detect or define which tab we are in
9
  $current_tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'public';
@@ -197,12 +197,12 @@ $s2_list_table->prepare_items();
197
  // show our form
198
  echo '<div class="wrap">';
199
  echo '<h1>' . __( 'Subscribers', 'subscribe2' ) . '</h1>' . "\r\n";
200
- $tabs = array(
201
  'public' => __( 'Public Subscribers', 'subscribe2' ),
202
  'registered' => __( 'Registered Subscribers', 'subscribe2' ),
203
  );
204
  echo '<h2 class="nav-tab-wrapper">';
205
- foreach ( $tabs as $tab_key => $tab_caption ) {
206
  $active = ( $current_tab === $tab_key ) ? 'nav-tab-active' : '';
207
  echo '<a class="nav-tab ' . $active . '" href="?page=s2_tools&amp;tab=' . $tab_key . '">' . $tab_caption . '</a>';
208
  }
@@ -228,8 +228,8 @@ switch ( $current_tab ) {
228
  echo '<br />';
229
  $cats = $this->all_cats();
230
  $cat_ids = array();
231
- foreach ( $cats as $cat ) {
232
- $cat_ids[] = $cat->term_id;
233
  }
234
  $exclude = array_merge( array( 'all', 'all_users', 'registered' ), $cat_ids );
235
  break;
3
  exit();
4
  }
5
 
6
+ global $subscribers, $what, $current_tab;
7
 
8
  // detect or define which tab we are in
9
  $current_tab = isset( $_GET['tab'] ) ? esc_attr( $_GET['tab'] ) : 'public';
197
  // show our form
198
  echo '<div class="wrap">';
199
  echo '<h1>' . __( 'Subscribers', 'subscribe2' ) . '</h1>' . "\r\n";
200
+ $s2tabs = array(
201
  'public' => __( 'Public Subscribers', 'subscribe2' ),
202
  'registered' => __( 'Registered Subscribers', 'subscribe2' ),
203
  );
204
  echo '<h2 class="nav-tab-wrapper">';
205
+ foreach ( $s2tabs as $tab_key => $tab_caption ) {
206
  $active = ( $current_tab === $tab_key ) ? 'nav-tab-active' : '';
207
  echo '<a class="nav-tab ' . $active . '" href="?page=s2_tools&amp;tab=' . $tab_key . '">' . $tab_caption . '</a>';
208
  }
228
  echo '<br />';
229
  $cats = $this->all_cats();
230
  $cat_ids = array();
231
+ foreach ( $cats as $category ) {
232
+ $cat_ids[] = $category->term_id;
233
  }
234
  $exclude = array_merge( array( 'all', 'all_users', 'registered' ), $cat_ids );
235
  break;
classes/class-s2-admin.php CHANGED
@@ -191,7 +191,7 @@ class S2_Admin extends S2_Core {
191
  * Insert Javascript and CSS into admin_headers
192
  */
193
  public function checkbox_form_js() {
194
- wp_register_script( 's2_checkbox', S2URL . 'include/s2-checkbox' . $this->script_debug . '.js', array( 'jquery' ), '1.4' );
195
  wp_enqueue_script( 's2_checkbox' );
196
  }
197
 
@@ -201,12 +201,12 @@ class S2_Admin extends S2_Core {
201
  }
202
 
203
  public function option_form_js() {
204
- wp_register_script( 's2_edit', S2URL . 'include/s2-edit' . $this->script_debug . '.js', array( 'jquery' ), '1.3' );
205
  wp_enqueue_script( 's2_edit' );
206
  if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
207
  wp_enqueue_script( 'jquery-ui-datepicker' );
208
- wp_enqueue_style( 'jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css' );
209
- wp_register_script( 's2_date_time', S2URL . 'include/s2-date-time' . $this->script_debug . '.js', array( 'jquery-ui-datepicker' ), '1.1' );
210
  wp_enqueue_script( 's2_date_time' );
211
  }
212
  }
@@ -231,7 +231,7 @@ class S2_Admin extends S2_Core {
231
  }
232
 
233
  public function subscribers_form_js() {
234
- wp_register_script( 's2_subscribers', S2URL . 'include/s2-subscribers' . $this->script_debug . '.js', array(), '1.5' );
235
  $translation_array = array(
236
  'registered_confirm_single' => __( 'You are about to delete a registered user account, any posts made by this user will be assigned to you. Are you sure?', 'subscribe2' ),
237
  'registered_confirm_plural' => __( 'You are about to delete registered user accounts, any posts made by these users will be assigned to you. Are you sure?', 'subscribe2' ),
@@ -297,7 +297,7 @@ class S2_Admin extends S2_Core {
297
  */
298
  public function button_init() {
299
  global $pagenow;
300
- if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ) ) && ! strpos( esc_url( $_SERVER['REQUEST_URI'] ), 'page=s2_posts' ) ) {
301
  return;
302
  }
303
  if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
@@ -308,7 +308,7 @@ class S2_Admin extends S2_Core {
308
  add_filter( 'mce_external_plugins', array( &$this, 'mce_plugin' ) );
309
  add_filter( 'mce_buttons', array( &$this, 'mce_button' ) );
310
  } else {
311
- wp_enqueue_script( 'subscribe2_button', S2URL . 'include/s2-button' . $this->script_debug . '.js', array( 'quicktags' ), '2.0' );
312
  }
313
  }
314
 
@@ -339,7 +339,7 @@ class S2_Admin extends S2_Core {
339
  if ( false !== stripos( esc_url( $_SERVER['REQUEST_URI'] ), 'widgets.php' ) ) {
340
  wp_enqueue_style( 'farbtastic' );
341
  wp_enqueue_script( 'farbtastic' );
342
- wp_register_script( 's2_colorpicker', S2URL . 'include/s2-colorpicker' . $this->script_debug . '.js', array( 'farbtastic' ), '1.3' );
343
  wp_enqueue_script( 's2_colorpicker' );
344
  }
345
  }
@@ -373,6 +373,17 @@ class S2_Admin extends S2_Core {
373
  '__block_editor_compatible_meta_box' => false,
374
  )
375
  );
 
 
 
 
 
 
 
 
 
 
 
376
  }
377
  }
378
 
@@ -416,6 +427,24 @@ class S2_Admin extends S2_Core {
416
  }
417
  }
418
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
419
  /* ===== WordPress menu helper functions ===== */
420
  /**
421
  * Collects the signup date for all public subscribers
@@ -504,7 +533,7 @@ class S2_Admin extends S2_Core {
504
  $cats = explode( ',', get_user_meta( $user_id, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
505
  $subscribed_cats = '';
506
  foreach ( $cat_ids as $cat ) {
507
- ( in_array( $cat, $cats ) ) ? $subscribed_cats .= ',Yes' : $subscribed_cats .= ',No';
508
  }
509
 
510
  $exportcsv .= $subscriber . ',';
@@ -543,13 +572,13 @@ class S2_Admin extends S2_Core {
543
 
544
  if ( 0 === $j ) {
545
  echo '<label><input class="checkall_format" type="checkbox" name="format[]" value="' . $format . '"';
546
- if ( in_array( $format, $selected ) ) {
547
  echo ' checked="checked"';
548
  }
549
  echo ' /> ' . ucwords( $format ) . '</label><br />' . "\r\n";
550
  } else {
551
  echo '<label><input class="checkall_format" type="checkbox" name="format[]" value="' . $format . '"';
552
- if ( in_array( $format, $selected ) ) {
553
  echo ' checked="checked"';
554
  }
555
  echo ' /> ' . ucwords( $format ) . '</label><br />' . "\r\n";
@@ -582,9 +611,9 @@ class S2_Admin extends S2_Core {
582
  // count the number of subscribers
583
  $count['confirmed'] = $wpdb->get_var( "SELECT COUNT(id) FROM $wpdb->subscribe2 WHERE active='1'" );
584
  $count['unconfirmed'] = $wpdb->get_var( "SELECT COUNT(id) FROM $wpdb->subscribe2 WHERE active='0'" );
585
- if ( in_array( 'unconfirmed', $exclude ) ) {
586
  $count['public'] = $count['confirmed'];
587
- } elseif ( in_array( 'confirmed', $exclude ) ) {
588
  $count['public'] = $count['unconfirmed'];
589
  } else {
590
  $count['public'] = ( $count['confirmed'] + $count['unconfirmed'] );
@@ -605,7 +634,7 @@ class S2_Admin extends S2_Core {
605
  $compulsory = explode( ',', $this->subscribe2_options['compulsory'] );
606
  if ( $this->s2_mu ) {
607
  foreach ( $all_cats as $cat ) {
608
- if ( in_array( $cat->term_id, $compulsory ) ) {
609
  $count[ $cat->name ] = $count['all_users'];
610
  } else {
611
  $count[ $cat->name ] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key=%s", $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id ) );
@@ -613,7 +642,7 @@ class S2_Admin extends S2_Core {
613
  }
614
  } else {
615
  foreach ( $all_cats as $cat ) {
616
- if ( in_array( $cat->term_id, $compulsory ) ) {
617
  $count[ $cat->name ] = $count['all_users'];
618
  } else {
619
  $count[ $cat->name ] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id ) );
@@ -624,7 +653,7 @@ class S2_Admin extends S2_Core {
624
 
625
  echo '<select name="what">' . "\r\n";
626
  foreach ( $who as $whom => $display ) {
627
- if ( in_array( $whom, $exclude ) ) {
628
  continue;
629
  }
630
 
@@ -637,7 +666,7 @@ class S2_Admin extends S2_Core {
637
 
638
  if ( $count['registered'] > 0 && 'never' === $this->subscribe2_options['email_freq'] ) {
639
  foreach ( $all_cats as $cat ) {
640
- if ( in_array( $cat->term_id, $exclude ) ) {
641
  continue;
642
  }
643
  echo '<option value="' . $cat->term_id . '"';
@@ -813,7 +842,7 @@ class S2_Admin extends S2_Core {
813
  $useremails = explode( ",\r\n", $emails );
814
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
815
 
816
- $user_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" );
817
 
818
  foreach ( $user_ids as $user_id ) {
819
  $old_cats = get_user_meta( $user_id, $this->get_usermeta_keyname( 's2_subscribed' ), true );
@@ -846,7 +875,7 @@ class S2_Admin extends S2_Core {
846
  $useremails = explode( ",\r\n", $emails );
847
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
848
 
849
- $user_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" ); // WPCS: unprepared SQL OK.
850
 
851
  foreach ( $user_ids as $user_id ) {
852
  $old_cats = explode( ',', get_user_meta( $user_id, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
@@ -879,10 +908,10 @@ class S2_Admin extends S2_Core {
879
  global $wpdb;
880
  $useremails = explode( ",\r\n", $emails );
881
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
882
- $ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" ); // WPCS: unprepared SQL OK.
883
  $ids = implode( ',', array_map( array( $this, 'prepare_in_data' ), $ids ) );
884
  $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname( 's2_format' ) . "' AND user_id IN ($ids)";
885
- $wpdb->query( $sql ); // WPCS: unprepared SQL OK.
886
  }
887
 
888
  /**
@@ -897,7 +926,7 @@ class S2_Admin extends S2_Core {
897
  $useremails = explode( ",\r\n", $emails );
898
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
899
 
900
- $user_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" ); // WPCS: unprepared SQL OK.
901
 
902
  if ( 'digest' === $digest ) {
903
  $exclude = explode( ',', $this->subscribe2_options['exclude'] );
191
  * Insert Javascript and CSS into admin_headers
192
  */
193
  public function checkbox_form_js() {
194
+ wp_register_script( 's2_checkbox', S2URL . 'include/s2-checkbox' . $this->script_debug . '.js', array( 'jquery' ), '1.4', true );
195
  wp_enqueue_script( 's2_checkbox' );
196
  }
197
 
201
  }
202
 
203
  public function option_form_js() {
204
+ wp_register_script( 's2_edit', S2URL . 'include/s2-edit' . $this->script_debug . '.js', array( 'jquery' ), '1.3', true );
205
  wp_enqueue_script( 's2_edit' );
206
  if ( 'never' !== $this->subscribe2_options['email_freq'] ) {
207
  wp_enqueue_script( 'jquery-ui-datepicker' );
208
+ wp_enqueue_style( 'jquery-style', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css', array(), '1.12.1' );
209
+ wp_register_script( 's2_date_time', S2URL . 'include/s2-date-time' . $this->script_debug . '.js', array( 'jquery-ui-datepicker' ), '1.1', true );
210
  wp_enqueue_script( 's2_date_time' );
211
  }
212
  }
231
  }
232
 
233
  public function subscribers_form_js() {
234
+ wp_register_script( 's2_subscribers', S2URL . 'include/s2-subscribers' . $this->script_debug . '.js', array(), '1.5', true );
235
  $translation_array = array(
236
  'registered_confirm_single' => __( 'You are about to delete a registered user account, any posts made by this user will be assigned to you. Are you sure?', 'subscribe2' ),
237
  'registered_confirm_plural' => __( 'You are about to delete registered user accounts, any posts made by these users will be assigned to you. Are you sure?', 'subscribe2' ),
297
  */
298
  public function button_init() {
299
  global $pagenow;
300
+ if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ), true ) && ! strpos( esc_url( $_SERVER['REQUEST_URI'] ), 'page=s2_posts' ) ) {
301
  return;
302
  }
303
  if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
308
  add_filter( 'mce_external_plugins', array( &$this, 'mce_plugin' ) );
309
  add_filter( 'mce_buttons', array( &$this, 'mce_button' ) );
310
  } else {
311
+ wp_enqueue_script( 'subscribe2_button', S2URL . 'include/s2-button' . $this->script_debug . '.js', array( 'quicktags' ), '2.0', true );
312
  }
313
  }
314
 
339
  if ( false !== stripos( esc_url( $_SERVER['REQUEST_URI'] ), 'widgets.php' ) ) {
340
  wp_enqueue_style( 'farbtastic' );
341
  wp_enqueue_script( 'farbtastic' );
342
+ wp_register_script( 's2_colorpicker', S2URL . 'include/s2-colorpicker' . $this->script_debug . '.js', array( 'farbtastic' ), '1.3', true );
343
  wp_enqueue_script( 's2_colorpicker' );
344
  }
345
  }
373
  '__block_editor_compatible_meta_box' => false,
374
  )
375
  );
376
+ add_meta_box(
377
+ 'subscribe2-preview',
378
+ __( 'Subscribe2 Preview', 'subscribe2' ),
379
+ array( &$this, 's2_preview_meta' ),
380
+ $s2_post_type,
381
+ 'side',
382
+ 'default',
383
+ array(
384
+ '__block_editor_compatible_meta_box' => false,
385
+ )
386
+ );
387
  }
388
  }
389
 
427
  }
428
  }
429
 
430
+ /**
431
+ * Meta preview box code
432
+ */
433
+ public function s2_preview_meta() {
434
+ echo '<p>' . __( 'Send preview email of this post to currently logged in user:', 'subscribe2' ) . '</p>' . "\r\n";
435
+ echo '<input class="button" name="s2_preview" type="submit" value="' . __( 'Send Preview', 'subscribe2' ) . '" />' . "\r\n";
436
+ }
437
+
438
+ /**
439
+ * Meta preview box handler
440
+ */
441
+ public function s2_preview_handler() {
442
+ if ( isset( $_POST['s2_preview'] ) ) {
443
+ global $post, $current_user;
444
+ $this->publish( $post, $current_user->user_email );
445
+ }
446
+ }
447
+
448
  /* ===== WordPress menu helper functions ===== */
449
  /**
450
  * Collects the signup date for all public subscribers
533
  $cats = explode( ',', get_user_meta( $user_id, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
534
  $subscribed_cats = '';
535
  foreach ( $cat_ids as $cat ) {
536
+ ( in_array( $cat, $cats, true ) ) ? $subscribed_cats .= ',Yes' : $subscribed_cats .= ',No';
537
  }
538
 
539
  $exportcsv .= $subscriber . ',';
572
 
573
  if ( 0 === $j ) {
574
  echo '<label><input class="checkall_format" type="checkbox" name="format[]" value="' . $format . '"';
575
+ if ( in_array( $format, $selected, true ) ) {
576
  echo ' checked="checked"';
577
  }
578
  echo ' /> ' . ucwords( $format ) . '</label><br />' . "\r\n";
579
  } else {
580
  echo '<label><input class="checkall_format" type="checkbox" name="format[]" value="' . $format . '"';
581
+ if ( in_array( $format, $selected, true ) ) {
582
  echo ' checked="checked"';
583
  }
584
  echo ' /> ' . ucwords( $format ) . '</label><br />' . "\r\n";
611
  // count the number of subscribers
612
  $count['confirmed'] = $wpdb->get_var( "SELECT COUNT(id) FROM $wpdb->subscribe2 WHERE active='1'" );
613
  $count['unconfirmed'] = $wpdb->get_var( "SELECT COUNT(id) FROM $wpdb->subscribe2 WHERE active='0'" );
614
+ if ( in_array( 'unconfirmed', $exclude, true ) ) {
615
  $count['public'] = $count['confirmed'];
616
+ } elseif ( in_array( 'confirmed', $exclude, true ) ) {
617
  $count['public'] = $count['unconfirmed'];
618
  } else {
619
  $count['public'] = ( $count['confirmed'] + $count['unconfirmed'] );
634
  $compulsory = explode( ',', $this->subscribe2_options['compulsory'] );
635
  if ( $this->s2_mu ) {
636
  foreach ( $all_cats as $cat ) {
637
+ if ( in_array( $cat->term_id, $compulsory, true ) ) {
638
  $count[ $cat->name ] = $count['all_users'];
639
  } else {
640
  $count[ $cat->name ] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(a.meta_key) FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS b ON a.user_id = b.user_id WHERE a.meta_key='" . $wpdb->prefix . "capabilities' AND b.meta_key=%s", $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id ) );
642
  }
643
  } else {
644
  foreach ( $all_cats as $cat ) {
645
+ if ( in_array( $cat->term_id, $compulsory, true ) ) {
646
  $count[ $cat->name ] = $count['all_users'];
647
  } else {
648
  $count[ $cat->name ] = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(meta_value) FROM $wpdb->usermeta WHERE meta_key=%s", $this->get_usermeta_keyname( 's2_cat' ) . $cat->term_id ) );
653
 
654
  echo '<select name="what">' . "\r\n";
655
  foreach ( $who as $whom => $display ) {
656
+ if ( in_array( $whom, $exclude, true ) ) {
657
  continue;
658
  }
659
 
666
 
667
  if ( $count['registered'] > 0 && 'never' === $this->subscribe2_options['email_freq'] ) {
668
  foreach ( $all_cats as $cat ) {
669
+ if ( in_array( $cat->term_id, $exclude, true ) ) {
670
  continue;
671
  }
672
  echo '<option value="' . $cat->term_id . '"';
842
  $useremails = explode( ",\r\n", $emails );
843
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
844
 
845
+ $user_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" ); // phpcs:ignore WordPress.DB.PreparedSQL
846
 
847
  foreach ( $user_ids as $user_id ) {
848
  $old_cats = get_user_meta( $user_id, $this->get_usermeta_keyname( 's2_subscribed' ), true );
875
  $useremails = explode( ",\r\n", $emails );
876
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
877
 
878
+ $user_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" ); // phpcs:ignore WordPress.DB.PreparedSQL
879
 
880
  foreach ( $user_ids as $user_id ) {
881
  $old_cats = explode( ',', get_user_meta( $user_id, $this->get_usermeta_keyname( 's2_subscribed' ), true ) );
908
  global $wpdb;
909
  $useremails = explode( ",\r\n", $emails );
910
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
911
+ $ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" ); // phpcs:ignore WordPress.DB.PreparedSQL
912
  $ids = implode( ',', array_map( array( $this, 'prepare_in_data' ), $ids ) );
913
  $sql = "UPDATE $wpdb->usermeta SET meta_value='{$format}' WHERE meta_key='" . $this->get_usermeta_keyname( 's2_format' ) . "' AND user_id IN ($ids)";
914
+ $wpdb->query( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL
915
  }
916
 
917
  /**
926
  $useremails = explode( ",\r\n", $emails );
927
  $useremails = implode( ', ', array_map( array( $this, 'prepare_in_data' ), $useremails ) );
928
 
929
+ $user_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_email IN ($useremails)" ); // phpcs:ignore WordPress.DB.PreparedSQL
930
 
931
  if ( 'digest' === $digest ) {
932
  $exclude = explode( ',', $this->subscribe2_options['exclude'] );
classes/class-s2-ajax.php CHANGED
@@ -33,9 +33,9 @@ class S2_Ajax {
33
  if ( is_ssl() ) {
34
  $css = str_replace( 'http:', 'https:', $css );
35
  }
36
- wp_register_style( 'jquery-ui-style', $css );
37
  wp_enqueue_style( 'jquery-ui-style' );
38
- wp_register_script( 's2-ajax', S2URL . 'include/s2-ajax' . $this->script_debug . '.js', array(), '1.3' );
39
  $translation_array = array(
40
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
41
  'title' => __( 'Subscribe to this blog', 'subscribe2' ),
@@ -88,7 +88,7 @@ class S2_Ajax {
88
  if ( is_int( $s2_frontend->lockout ) && $s2_frontend->lockout > 0 ) {
89
  $date = date( 'H:i:s.u', $s2_frontend->lockout );
90
  $ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
91
- if ( in_array( $s2_frontend->ip, $ips ) ) {
92
  echo '<p>' . __( 'Slow down, you move too fast.', 'subscribe2' ) . '</p>';
93
  }
94
  }
33
  if ( is_ssl() ) {
34
  $css = str_replace( 'http:', 'https:', $css );
35
  }
36
+ wp_register_style( 'jquery-ui-style', $css, array(), '1.11.4' );
37
  wp_enqueue_style( 'jquery-ui-style' );
38
+ wp_register_script( 's2-ajax', S2URL . 'include/s2-ajax' . $this->script_debug . '.js', array(), '1.3', true );
39
  $translation_array = array(
40
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
41
  'title' => __( 'Subscribe to this blog', 'subscribe2' ),
88
  if ( is_int( $s2_frontend->lockout ) && $s2_frontend->lockout > 0 ) {
89
  $date = date( 'H:i:s.u', $s2_frontend->lockout );
90
  $ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
91
+ if ( in_array( $s2_frontend->ip, $ips, true ) ) {
92
  echo '<p>' . __( 'Slow down, you move too fast.', 'subscribe2' ) . '</p>';
93
  }
94
  }
classes/class-s2-block-editor.php CHANGED
@@ -78,7 +78,7 @@ class S2_Block_Editor {
78
  */
79
  public function gutenberg_block_editor_assets() {
80
  global $pagenow;
81
- if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ) ) ) {
82
  return;
83
  }
84
 
@@ -86,7 +86,8 @@ class S2_Block_Editor {
86
  'subscribe2-shortcode',
87
  S2URL . 'gutenberg/shortcode' . $this->script_debug . '.js',
88
  array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
89
- '1.1'
 
90
  );
91
 
92
  register_block_type(
@@ -100,7 +101,8 @@ class S2_Block_Editor {
100
  'subscribe2-sidebar',
101
  S2URL . 'gutenberg/sidebar' . $this->script_debug . '.js',
102
  array( 'wp-plugins', 'wp-element', 'wp-i18n', 'wp-edit-post', 'wp-components', 'wp-data', 'wp-compose', 'wp-api-fetch' ),
103
- '1.0'
 
104
  );
105
  }
106
 
@@ -109,7 +111,7 @@ class S2_Block_Editor {
109
  */
110
  public function gutenberg_i18n() {
111
  global $pagenow;
112
- if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ) ) ) {
113
  return;
114
  }
115
 
78
  */
79
  public function gutenberg_block_editor_assets() {
80
  global $pagenow;
81
+ if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ), true ) ) {
82
  return;
83
  }
84
 
86
  'subscribe2-shortcode',
87
  S2URL . 'gutenberg/shortcode' . $this->script_debug . '.js',
88
  array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
89
+ '1.1',
90
+ true
91
  );
92
 
93
  register_block_type(
101
  'subscribe2-sidebar',
102
  S2URL . 'gutenberg/sidebar' . $this->script_debug . '.js',
103
  array( 'wp-plugins', 'wp-element', 'wp-i18n', 'wp-edit-post', 'wp-components', 'wp-data', 'wp-compose', 'wp-api-fetch' ),
104
+ '1.0',
105
+ true
106
  );
107
  }
108
 
111
  */
112
  public function gutenberg_i18n() {
113
  global $pagenow;
114
+ if ( ! in_array( $pagenow, array( 'post-new.php', 'post.php', 'page-new.php', 'page.php' ), true ) ) {
115
  return;
116
  }
117
 
classes/class-s2-core.php CHANGED
@@ -76,7 +76,7 @@ class S2_Core {
76
  remove_all_filters( 'wp_mail_content_type' );
77
  add_filter( 'wp_mail_content_type', array( $this, 'html_email' ) );
78
  if ( 'yes' === $this->subscribe2_options['stylesheet'] ) {
79
- $mailtext = apply_filters( 's2_html_email', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>' . $subject . '</title><link rel="stylesheet" href="' . get_stylesheet_directory_uri() . apply_filters( 's2_stylesheet_name', '/style.css' ) . '" type="text/css" media="screen" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>' . $message . '</body></html>', $subject, $message );
80
  } else {
81
  $mailtext = apply_filters( 's2_html_email', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>' . $subject . '</title></head><body>' . $message . '</body></html>', $subject, $message );
82
  }
@@ -298,7 +298,7 @@ class S2_Core {
298
  $s2_post_types = array( 'post' );
299
  }
300
  $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
301
- if ( ! in_array( $post->post_type, $s2_post_types ) ) {
302
  return $post;
303
  }
304
 
@@ -310,7 +310,7 @@ class S2_Core {
310
  // Is the post assigned to a format for which we should not be sending posts
311
  $post_format = get_post_format( $post->ID );
312
  $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
313
- if ( false !== $post_format && in_array( $post_format, $excluded_formats ) ) {
314
  return $post;
315
  }
316
 
@@ -331,7 +331,7 @@ class S2_Core {
331
  // is the current post assigned to any categories
332
  // which should not generate a notification email?
333
  foreach ( explode( ',', $this->subscribe2_options['exclude'] ) as $cat ) {
334
- if ( in_array( $cat, $post_cats ) ) {
335
  $check = true;
336
  }
337
  }
@@ -501,14 +501,8 @@ class S2_Core {
501
  // strip tags and trailing whitespace
502
  $excerpt = trim( wp_strip_all_tags( $excerpt ) );
503
  } else {
504
- // no <!--more-->, so grab the first 55 words
505
- $excerpt = trim( wp_strip_all_tags( $excerpttext ) );
506
- $words = explode( ' ', $excerpt, $this->excerpt_length + 1 );
507
- if ( count( $words ) > $this->excerpt_length ) {
508
- array_pop( $words );
509
- array_push( $words, '[...]' );
510
- $excerpt = implode( ' ', $words );
511
- }
512
  }
513
  }
514
  $html_excerpt = trim( $post->post_excerpt );
@@ -519,17 +513,8 @@ class S2_Core {
519
  // balance HTML tags and then strip leading and trailing whitespace
520
  $html_excerpt = trim( balanceTags( $html_excerpt, true ) );
521
  } else {
522
- // no <!--more-->, so grab the first 55 words
523
- $words = explode( ' ', $content, $this->excerpt_length + 1 );
524
- if ( count( $words ) > $this->excerpt_length ) {
525
- array_pop( $words );
526
- array_push( $words, '[...]' );
527
- $html_excerpt = implode( ' ', $words );
528
- // balance HTML tags and then strip leading and trailing whitespace
529
- $html_excerpt = trim( balanceTags( $html_excerpt, true ) );
530
- } else {
531
- $html_excerpt = $content;
532
- }
533
  }
534
  }
535
 
@@ -586,8 +571,45 @@ class S2_Core {
586
  }
587
 
588
  /**
589
- Send confirmation email to a public subscriber
590
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
  public function send_confirm( $action = '', $is_remind = false ) {
592
  if ( 1 === $this->filtered ) {
593
  return true;
@@ -901,7 +923,7 @@ class S2_Core {
901
  // collect all subscribers for compulsory categories
902
  $compulsory = explode( ',', $this->subscribe2_options['compulsory'] );
903
  foreach ( explode( ',', $r['cats'] ) as $cat ) {
904
- if ( in_array( $cat, $compulsory ) ) {
905
  $r['cats'] = '';
906
  }
907
  }
@@ -933,14 +955,14 @@ class S2_Core {
933
  if ( $this->s2_mu ) {
934
  $result = $wpdb->get_col(
935
  $wpdb->prepare(
936
- "SELECT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS e ON a.user_id = e.user_id " . $join . "WHERE a.meta_key='{$wpdb->prefix}capabilities' AND e.meta_key=%s AND e.meta_value <> ''" . $and,
937
  $this->get_usermeta_keyname( 's2_subscribed' )
938
  )
939
  );
940
  } else {
941
  $result = $wpdb->get_col(
942
  $wpdb->prepare(
943
- "SELECT a.user_id FROM $wpdb->usermeta AS a " . $join . "WHERE a.meta_key=%s AND a.meta_value <> ''" . $and,
944
  $this->get_usermeta_keyname( 's2_subscribed' )
945
  )
946
  );
@@ -953,9 +975,9 @@ class S2_Core {
953
  }
954
 
955
  if ( 'emailid' === $r['return'] ) {
956
- $registered = $wpdb->get_results( "SELECT user_email, ID FROM $wpdb->users WHERE ID IN ($ids)", ARRAY_A );
957
  } else {
958
- $registered = $wpdb->get_col( "SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)" );
959
  }
960
 
961
  if ( empty( $registered ) ) {
@@ -1043,7 +1065,7 @@ class S2_Core {
1043
  update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_authors' ), '' );
1044
  } else {
1045
  // create post format entries for all users
1046
- if ( in_array( $this->subscribe2_options['autoformat'], array( 'html', 'html_excerpt', 'post', 'excerpt' ) ) ) {
1047
  update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), $this->subscribe2_options['autoformat'] );
1048
  } else {
1049
  update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), 'excerpt' );
@@ -1152,7 +1174,7 @@ class S2_Core {
1152
  // need to use $id like this as this is a mixed array / object
1153
  $id = 0;
1154
  foreach ( $all_cats as $cat ) {
1155
- if ( in_array( $cat->term_id, $excluded ) ) {
1156
  unset( $all_cats[ $id ] );
1157
  }
1158
  $id++;
@@ -1346,7 +1368,7 @@ class S2_Core {
1346
  public function add_weekly_sched( $scheds ) {
1347
  $exists = false;
1348
  foreach ( $scheds as $sched ) {
1349
- if ( array_search( 604800, $sched ) ) {
1350
  $exists = true;
1351
  }
1352
  }
@@ -1375,7 +1397,7 @@ class S2_Core {
1375
  $s2_post_types = array( 'post' );
1376
  }
1377
  $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
1378
- if ( ! in_array( $post->post_type, $s2_post_types ) ) {
1379
  return;
1380
  }
1381
 
@@ -1390,7 +1412,7 @@ class S2_Core {
1390
  return;
1391
  }
1392
  define( 'DOING_S2_CRON', true );
1393
- global $wpdb, $post;
1394
 
1395
  if ( '' === $preview ) {
1396
  // set up SQL query based on options
@@ -1429,7 +1451,7 @@ class S2_Core {
1429
  } else {
1430
  $sql = "SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts AS a INNER JOIN $wpdb->postmeta AS b ON b.post_id = a.ID";
1431
  $sql .= " AND b.meta_key = '_s2_digest_post_status' AND b.meta_value = 'pending' WHERE post_status IN ($status) AND post_type IN ($type) ORDER BY post_date " . ( ( 'desc' === $this->subscribe2_options['cron_order'] ) ? 'DESC' : 'ASC' );
1432
- $posts = $wpdb->get_results( $sql );
1433
  }
1434
  } else {
1435
  // we are sending a preview
@@ -1480,7 +1502,7 @@ class S2_Core {
1480
 
1481
  foreach ( $posts as $post ) {
1482
  // keep an array of post ids and skip if we've already done it once
1483
- if ( in_array( $post->ID, $ids ) ) {
1484
  continue;
1485
  }
1486
  $ids[] = $post->ID;
@@ -1503,7 +1525,7 @@ class S2_Core {
1503
  // is the current post assigned to any categories
1504
  // which should not generate a notification email?
1505
  foreach ( explode( ',', $this->subscribe2_options['exclude'] ) as $cat ) {
1506
- if ( in_array( $cat, $post_cats ) ) {
1507
  $check = true;
1508
  }
1509
  }
@@ -1523,7 +1545,7 @@ class S2_Core {
1523
  // not be included in the notification email?
1524
  $post_format = get_post_format( $post->ID );
1525
  $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
1526
- if ( false !== $post_format && in_array( $post_format, $excluded_formats ) ) {
1527
  $check = true;
1528
  }
1529
  // if this post is excluded
@@ -1548,7 +1570,7 @@ class S2_Core {
1548
  // not be included in the notification email?
1549
  $post_format = get_post_format( $post->ID );
1550
  $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
1551
- if ( false !== $post_format && in_array( $post_format, $excluded_formats ) ) {
1552
  $check = true;
1553
  }
1554
  // if this post is excluded
@@ -1576,7 +1598,7 @@ class S2_Core {
1576
 
1577
  $message_posttime .= __( 'Posted on', 'subscribe2' ) . ': ' . mysql2date( $datetime, $post->post_date ) . "\r\n";
1578
  if ( strstr( $mailtext, '{TINYLINK}' ) ) {
1579
- $tinylink = file_get_contents( 'http://tinyurl.com/api-create.php?url=' . urlencode( $this->get_tracking_link( get_permalink( $post->ID ) ) ) );
1580
  } else {
1581
  $tinylink = false;
1582
  }
@@ -1592,8 +1614,11 @@ class S2_Core {
1592
 
1593
  if ( strstr( $mailtext, '{CATS}' ) ) {
1594
  $post_cat_names = implode(
1595
- ', ', wp_get_object_terms(
1596
- $post->ID, $s2_taxonomies, array(
 
 
 
1597
  'fields' => 'names',
1598
  )
1599
  )
@@ -1603,8 +1628,10 @@ class S2_Core {
1603
  }
1604
  if ( strstr( $mailtext, '{TAGS}' ) ) {
1605
  $post_tag_names = implode(
1606
- ', ', wp_get_post_tags(
1607
- $post->ID, array(
 
 
1608
  'fields' => 'names',
1609
  )
1610
  )
@@ -1623,17 +1650,10 @@ class S2_Core {
1623
  // no excerpt, is there a <!--more--> ?
1624
  if ( false !== strpos( $post->post_content, '<!--more-->' ) ) {
1625
  list($excerpt, $more) = explode( '<!--more-->', $post->post_content, 2 );
1626
- $excerpt = strip_tags( $excerpt );
1627
  $excerpt = strip_shortcodes( $excerpt );
1628
  } else {
1629
- $excerpt = strip_tags( $post->post_content );
1630
- $excerpt = strip_shortcodes( $excerpt );
1631
- $words = explode( ' ', $excerpt, $this->excerpt_length + 1 );
1632
- if ( count( $words ) > $this->excerpt_length ) {
1633
- array_pop( $words );
1634
- array_push( $words, '[...]' );
1635
- $excerpt = implode( ' ', $words );
1636
- }
1637
  }
1638
  // strip leading and trailing whitespace
1639
  $excerpt = trim( $excerpt );
@@ -1645,7 +1665,7 @@ class S2_Core {
1645
  // we are not sending a preview so update post_meta data for sent ids but not sticky posts
1646
  if ( '' === $preview ) {
1647
  foreach ( $ids as $id ) {
1648
- if ( ! empty( $sticky_ids ) && ! in_array( $id, $sticky_ids ) ) {
1649
  update_post_meta( $id, '_s2_digest_post_status', 'done' );
1650
  } else {
1651
  update_post_meta( $id, '_s2_digest_post_status', 'done' );
@@ -1898,6 +1918,7 @@ class S2_Core {
1898
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
1899
  add_action( 'admin_menu', array( &$this, 's2_meta_init' ) );
1900
  add_action( 'save_post', array( &$this, 's2_meta_handler' ) );
 
1901
  add_action( 'create_category', array( &$this, 'new_category' ) );
1902
  add_action( 'delete_category', array( &$this, 'delete_category' ) );
1903
 
76
  remove_all_filters( 'wp_mail_content_type' );
77
  add_filter( 'wp_mail_content_type', array( $this, 'html_email' ) );
78
  if ( 'yes' === $this->subscribe2_options['stylesheet'] ) {
79
+ $mailtext = apply_filters( 's2_html_email', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>' . $subject . '</title><link rel="stylesheet" href="' . get_stylesheet_directory_uri() . apply_filters( 's2_stylesheet_name', '/style.css' ) . '" type="text/css" media="screen" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>' . $message . '</body></html>', $subject, $message ); // phpcs:ignore WordPress.WP.EnqueuedResources
80
  } else {
81
  $mailtext = apply_filters( 's2_html_email', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>' . $subject . '</title></head><body>' . $message . '</body></html>', $subject, $message );
82
  }
298
  $s2_post_types = array( 'post' );
299
  }
300
  $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
301
+ if ( ! in_array( $post->post_type, $s2_post_types, true ) ) {
302
  return $post;
303
  }
304
 
310
  // Is the post assigned to a format for which we should not be sending posts
311
  $post_format = get_post_format( $post->ID );
312
  $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
313
+ if ( false !== $post_format && in_array( $post_format, $excluded_formats, true ) ) {
314
  return $post;
315
  }
316
 
331
  // is the current post assigned to any categories
332
  // which should not generate a notification email?
333
  foreach ( explode( ',', $this->subscribe2_options['exclude'] ) as $cat ) {
334
+ if ( in_array( $cat, $post_cats, true ) ) {
335
  $check = true;
336
  }
337
  }
501
  // strip tags and trailing whitespace
502
  $excerpt = trim( wp_strip_all_tags( $excerpt ) );
503
  } else {
504
+ // no <!--more-->, so create excerpt
505
+ $excerpt = $this->create_excerpt( $excerpttext );
 
 
 
 
 
 
506
  }
507
  }
508
  $html_excerpt = trim( $post->post_excerpt );
513
  // balance HTML tags and then strip leading and trailing whitespace
514
  $html_excerpt = trim( balanceTags( $html_excerpt, true ) );
515
  } else {
516
+ // no <!--more-->, so create excerpt
517
+ $html_excerpt = $this->create_excerpt( $content, true );
 
 
 
 
 
 
 
 
 
518
  }
519
  }
520
 
571
  }
572
 
573
  /**
574
+ * Function to create excerpts for emailing
575
+ */
576
+ public function create_excerpt( $text, $html = false ) {
577
+ $excerpt_on_words = apply_filters( 's2_excerpt_on_words', true );
578
+
579
+ if ( false === $html ) {
580
+ $excerpt = trim( wp_strip_all_tags( $text ) );
581
+ } else {
582
+ $excerpt = strip_shortcodes( $text );
583
+ }
584
+
585
+ if ( true !== $excerpt_on_words ) {
586
+ $words = preg_split( '//u', $excerpt, $this->excerpt_length + 1 );
587
+ } else {
588
+ $words = explode( ' ', $excerpt, $this->excerpt_length + 1 );
589
+ }
590
+
591
+ if ( count( $words ) > $this->excerpt_length ) {
592
+ array_pop( $words );
593
+ array_push( $words, '[...]' );
594
+ }
595
+
596
+ if ( true !== $excerpt_on_words ) {
597
+ $excerpt = implode( '', $words );
598
+ } else {
599
+ $excerpt = implode( ' ', $words );
600
+ }
601
+
602
+ if ( true === $html ) {
603
+ // balance HTML tags and then strip leading and trailing whitespace
604
+ $excerpt = trim( balanceTags( $excerpt, true ) );
605
+ }
606
+
607
+ return $excerpt;
608
+ }
609
+
610
+ /**
611
+ * Send confirmation email to a public subscriber
612
+ */
613
  public function send_confirm( $action = '', $is_remind = false ) {
614
  if ( 1 === $this->filtered ) {
615
  return true;
923
  // collect all subscribers for compulsory categories
924
  $compulsory = explode( ',', $this->subscribe2_options['compulsory'] );
925
  foreach ( explode( ',', $r['cats'] ) as $cat ) {
926
+ if ( in_array( $cat, $compulsory, true ) ) {
927
  $r['cats'] = '';
928
  }
929
  }
955
  if ( $this->s2_mu ) {
956
  $result = $wpdb->get_col(
957
  $wpdb->prepare(
958
+ "SELECT a.user_id FROM $wpdb->usermeta AS a INNER JOIN $wpdb->usermeta AS e ON a.user_id = e.user_id " . $join . "WHERE a.meta_key='{$wpdb->prefix}capabilities' AND e.meta_key=%s AND e.meta_value <> ''" . $and, // phpcs:ignore WordPress.DB.PreparedSQL, WordPress.DB.PreparedSQLPlaceholders
959
  $this->get_usermeta_keyname( 's2_subscribed' )
960
  )
961
  );
962
  } else {
963
  $result = $wpdb->get_col(
964
  $wpdb->prepare(
965
+ "SELECT a.user_id FROM $wpdb->usermeta AS a " . $join . "WHERE a.meta_key=%s AND a.meta_value <> ''" . $and, // phpcs:ignore WordPress.DB.PreparedSQL, WordPress.DB.PreparedSQLPlaceholders
966
  $this->get_usermeta_keyname( 's2_subscribed' )
967
  )
968
  );
975
  }
976
 
977
  if ( 'emailid' === $r['return'] ) {
978
+ $registered = $wpdb->get_results( "SELECT user_email, ID FROM $wpdb->users WHERE ID IN ($ids)", ARRAY_A ); // phpcs:ignore WordPress.DB.PreparedSQL
979
  } else {
980
+ $registered = $wpdb->get_col( "SELECT user_email FROM $wpdb->users WHERE ID IN ($ids)" ); // phpcs:ignore WordPress.DB.PreparedSQL
981
  }
982
 
983
  if ( empty( $registered ) ) {
1065
  update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_authors' ), '' );
1066
  } else {
1067
  // create post format entries for all users
1068
+ if ( in_array( $this->subscribe2_options['autoformat'], array( 'html', 'html_excerpt', 'post', 'excerpt' ), true ) ) {
1069
  update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), $this->subscribe2_options['autoformat'] );
1070
  } else {
1071
  update_user_meta( $user_ID, $this->get_usermeta_keyname( 's2_format' ), 'excerpt' );
1174
  // need to use $id like this as this is a mixed array / object
1175
  $id = 0;
1176
  foreach ( $all_cats as $cat ) {
1177
+ if ( in_array( $cat->term_id, $excluded, true ) ) {
1178
  unset( $all_cats[ $id ] );
1179
  }
1180
  $id++;
1368
  public function add_weekly_sched( $scheds ) {
1369
  $exists = false;
1370
  foreach ( $scheds as $sched ) {
1371
+ if ( array_search( 604800, $sched, true ) ) {
1372
  $exists = true;
1373
  }
1374
  }
1397
  $s2_post_types = array( 'post' );
1398
  }
1399
  $s2_post_types = apply_filters( 's2_post_types', $s2_post_types );
1400
+ if ( ! in_array( $post->post_type, $s2_post_types, true ) ) {
1401
  return;
1402
  }
1403
 
1412
  return;
1413
  }
1414
  define( 'DOING_S2_CRON', true );
1415
+ global $wpdb;
1416
 
1417
  if ( '' === $preview ) {
1418
  // set up SQL query based on options
1451
  } else {
1452
  $sql = "SELECT ID, post_title, post_excerpt, post_content, post_type, post_password, post_date, post_author FROM $wpdb->posts AS a INNER JOIN $wpdb->postmeta AS b ON b.post_id = a.ID";
1453
  $sql .= " AND b.meta_key = '_s2_digest_post_status' AND b.meta_value = 'pending' WHERE post_status IN ($status) AND post_type IN ($type) ORDER BY post_date " . ( ( 'desc' === $this->subscribe2_options['cron_order'] ) ? 'DESC' : 'ASC' );
1454
+ $posts = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL
1455
  }
1456
  } else {
1457
  // we are sending a preview
1502
 
1503
  foreach ( $posts as $post ) {
1504
  // keep an array of post ids and skip if we've already done it once
1505
+ if ( in_array( $post->ID, $ids, true ) ) {
1506
  continue;
1507
  }
1508
  $ids[] = $post->ID;
1525
  // is the current post assigned to any categories
1526
  // which should not generate a notification email?
1527
  foreach ( explode( ',', $this->subscribe2_options['exclude'] ) as $cat ) {
1528
+ if ( in_array( $cat, $post_cats, true ) ) {
1529
  $check = true;
1530
  }
1531
  }
1545
  // not be included in the notification email?
1546
  $post_format = get_post_format( $post->ID );
1547
  $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
1548
+ if ( false !== $post_format && in_array( $post_format, $excluded_formats, true ) ) {
1549
  $check = true;
1550
  }
1551
  // if this post is excluded
1570
  // not be included in the notification email?
1571
  $post_format = get_post_format( $post->ID );
1572
  $excluded_formats = explode( ',', $this->subscribe2_options['exclude_formats'] );
1573
+ if ( false !== $post_format && in_array( $post_format, $excluded_formats, true ) ) {
1574
  $check = true;
1575
  }
1576
  // if this post is excluded
1598
 
1599
  $message_posttime .= __( 'Posted on', 'subscribe2' ) . ': ' . mysql2date( $datetime, $post->post_date ) . "\r\n";
1600
  if ( strstr( $mailtext, '{TINYLINK}' ) ) {
1601
+ $tinylink = wp_safe_remote_get( 'http://tinyurl.com/api-create.php?url=' . rawurlencode( $this->get_tracking_link( get_permalink( $post->ID ) ) ) );
1602
  } else {
1603
  $tinylink = false;
1604
  }
1614
 
1615
  if ( strstr( $mailtext, '{CATS}' ) ) {
1616
  $post_cat_names = implode(
1617
+ ', ',
1618
+ wp_get_object_terms(
1619
+ $post->ID,
1620
+ $s2_taxonomies,
1621
+ array(
1622
  'fields' => 'names',
1623
  )
1624
  )
1628
  }
1629
  if ( strstr( $mailtext, '{TAGS}' ) ) {
1630
  $post_tag_names = implode(
1631
+ ', ',
1632
+ wp_get_post_tags(
1633
+ $post->ID,
1634
+ array(
1635
  'fields' => 'names',
1636
  )
1637
  )
1650
  // no excerpt, is there a <!--more--> ?
1651
  if ( false !== strpos( $post->post_content, '<!--more-->' ) ) {
1652
  list($excerpt, $more) = explode( '<!--more-->', $post->post_content, 2 );
1653
+ $excerpt = wp_strip_all_tags( $excerpt );
1654
  $excerpt = strip_shortcodes( $excerpt );
1655
  } else {
1656
+ $excerpt = $this->create_excerpt( $excerpt, true );
 
 
 
 
 
 
 
1657
  }
1658
  // strip leading and trailing whitespace
1659
  $excerpt = trim( $excerpt );
1665
  // we are not sending a preview so update post_meta data for sent ids but not sticky posts
1666
  if ( '' === $preview ) {
1667
  foreach ( $ids as $id ) {
1668
+ if ( ! empty( $sticky_ids ) && ! in_array( $id, $sticky_ids, true ) ) {
1669
  update_post_meta( $id, '_s2_digest_post_status', 'done' );
1670
  } else {
1671
  update_post_meta( $id, '_s2_digest_post_status', 'done' );
1918
  add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
1919
  add_action( 'admin_menu', array( &$this, 's2_meta_init' ) );
1920
  add_action( 'save_post', array( &$this, 's2_meta_handler' ) );
1921
+ add_action( 'save_post', array( &$this, 's2_preview_handler' ) );
1922
  add_action( 'create_category', array( &$this, 'new_category' ) );
1923
  add_action( 'delete_category', array( &$this, 'delete_category' ) );
1924
 
classes/class-s2-forms.php CHANGED
@@ -114,7 +114,7 @@ class S2_Forms {
114
 
115
  // list of subscribed blogs on WordPress mu
116
  if ( $mysubscribe2->s2_mu && ! isset( $_GET['email'] ) ) {
117
- global $blog_id, $current_user, $s2class_multisite;
118
  $s2blog_id = $blog_id;
119
  $current_user = wp_get_current_user();
120
  $blogs = $s2class_multisite->get_mu_blog_list();
@@ -131,7 +131,7 @@ class S2_Forms {
131
  if ( ! is_array( $current_plugins ) ) {
132
  $current_plugins = (array) $current_plugins;
133
  }
134
- if ( ! in_array( S2DIR . 'subscribe2.php', $current_plugins ) ) {
135
  continue;
136
  }
137
 
@@ -323,19 +323,19 @@ class S2_Forms {
323
 
324
  if ( 0 === $j ) {
325
  echo '<label><input class="checkall_' . $name . '" type="checkbox" name="' . $name . '[]" value="' . $cat->term_id . '"';
326
- if ( in_array( $cat->term_id, $selected ) || in_array( $cat->term_id, $compulsory ) ) {
327
  echo ' checked="checked"';
328
  }
329
- if ( in_array( $cat->term_id, $compulsory ) && 'category' === $name ) {
330
  echo ' DISABLED';
331
  }
332
  echo ' /> <abbr title="' . $cat->slug . '">' . $cat_name . '</abbr></label><br />' . "\r\n";
333
  } else {
334
  echo '<label><input class="checkall_' . $name . '" type="checkbox" name="' . $name . '[]" value="' . $cat->term_id . '"';
335
- if ( in_array( $cat->term_id, $selected ) || in_array( $cat->term_id, $compulsory ) ) {
336
  echo ' checked="checked"';
337
  }
338
- if ( in_array( $cat->term_id, $compulsory ) && 'category' === $name ) {
339
  echo ' DISABLED';
340
  }
341
  echo ' /> <abbr title="' . $cat->slug . '">' . $cat_name . '</abbr></label><br />' . "\r\n";
@@ -373,13 +373,13 @@ class S2_Forms {
373
  }
374
  if ( 0 === $j ) {
375
  echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . $author->ID . '"';
376
- if ( in_array( $author->ID, $selected ) ) {
377
  echo ' checked="checked"';
378
  }
379
  echo ' /> ' . $author->display_name . '</label><br />' . "\r\n";
380
  } else {
381
  echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . $author->ID . '"';
382
- if ( in_array( $author->ID, $selected ) ) {
383
  echo ' checked="checked"';
384
  }
385
  echo ' /> ' . $author->display_name . '</label><br />' . "\r\n";
114
 
115
  // list of subscribed blogs on WordPress mu
116
  if ( $mysubscribe2->s2_mu && ! isset( $_GET['email'] ) ) {
117
+ global $blog_id, $s2class_multisite;
118
  $s2blog_id = $blog_id;
119
  $current_user = wp_get_current_user();
120
  $blogs = $s2class_multisite->get_mu_blog_list();
131
  if ( ! is_array( $current_plugins ) ) {
132
  $current_plugins = (array) $current_plugins;
133
  }
134
+ if ( ! in_array( S2DIR . 'subscribe2.php', $current_plugins, true ) ) {
135
  continue;
136
  }
137
 
323
 
324
  if ( 0 === $j ) {
325
  echo '<label><input class="checkall_' . $name . '" type="checkbox" name="' . $name . '[]" value="' . $cat->term_id . '"';
326
+ if ( in_array( (string) $cat->term_id, $selected, true ) || in_array( (string) $cat->term_id, $compulsory, true ) ) {
327
  echo ' checked="checked"';
328
  }
329
+ if ( in_array( (string) $cat->term_id, $compulsory, true ) && 'category' === $name ) {
330
  echo ' DISABLED';
331
  }
332
  echo ' /> <abbr title="' . $cat->slug . '">' . $cat_name . '</abbr></label><br />' . "\r\n";
333
  } else {
334
  echo '<label><input class="checkall_' . $name . '" type="checkbox" name="' . $name . '[]" value="' . $cat->term_id . '"';
335
+ if ( in_array( (string) $cat->term_id, $selected, true ) || in_array( (string) $cat->term_id, $compulsory, true ) ) {
336
  echo ' checked="checked"';
337
  }
338
+ if ( in_array( (string) $cat->term_id, $compulsory, true ) && 'category' === $name ) {
339
  echo ' DISABLED';
340
  }
341
  echo ' /> <abbr title="' . $cat->slug . '">' . $cat_name . '</abbr></label><br />' . "\r\n";
373
  }
374
  if ( 0 === $j ) {
375
  echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . $author->ID . '"';
376
+ if ( in_array( $author->ID, $selected, true ) ) {
377
  echo ' checked="checked"';
378
  }
379
  echo ' /> ' . $author->display_name . '</label><br />' . "\r\n";
380
  } else {
381
  echo '<label><input class="checkall_author" type="checkbox" name="author[]" value="' . $author->ID . '"';
382
+ if ( in_array( $author->ID, $selected, true ) ) {
383
  echo ' checked="checked"';
384
  }
385
  echo ' /> ' . $author->display_name . '</label><br />' . "\r\n";
classes/class-s2-frontend.php CHANGED
@@ -189,7 +189,7 @@ class S2_Frontend extends S2_Core {
189
  if ( is_int( $this->lockout ) && $this->lockout > 0 ) {
190
  $date = date( 'H:i:s.u', $this->lockout );
191
  $ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
192
- if ( in_array( $this->ip, $ips ) ) {
193
  return __( 'Slow down, you move too fast.', 'subscribe2' );
194
  }
195
  }
@@ -367,7 +367,7 @@ class S2_Frontend extends S2_Core {
367
  * Prepare and send emails to admins on new subscriptions and unsubsriptions
368
  */
369
  public function admin_email( $action ) {
370
- if ( ! in_array( $action, array( 'subscribe', 'unsubscribe' ) ) ) {
371
  return false;
372
  }
373
 
@@ -525,7 +525,7 @@ class S2_Frontend extends S2_Core {
525
  * Add ip updater library to footer
526
  */
527
  public function js_ip_library_script() {
528
- echo '<script async="async" src="https://api.ipify.org?format=jsonp&callback=getip"></script>' . "\r\n";
529
  }
530
 
531
  /* ===== define some variables ===== */
189
  if ( is_int( $this->lockout ) && $this->lockout > 0 ) {
190
  $date = date( 'H:i:s.u', $this->lockout );
191
  $ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
192
+ if ( in_array( $this->ip, $ips, true ) ) {
193
  return __( 'Slow down, you move too fast.', 'subscribe2' );
194
  }
195
  }
367
  * Prepare and send emails to admins on new subscriptions and unsubsriptions
368
  */
369
  public function admin_email( $action ) {
370
+ if ( ! in_array( $action, array( 'subscribe', 'unsubscribe' ), true ) ) {
371
  return false;
372
  }
373
 
525
  * Add ip updater library to footer
526
  */
527
  public function js_ip_library_script() {
528
+ echo '<script async="async" src="https://api.ipify.org?format=jsonp&callback=getip"></script>' . "\r\n"; // phpcs:ignore WordPress.WP.EnqueuedResources
529
  }
530
 
531
  /* ===== define some variables ===== */
classes/class-s2-list-table-legacy.php CHANGED
@@ -137,7 +137,7 @@ class S2_List_Table_Legacy extends WP_List_Table {
137
  $class = array( 'manage-column', "column-$column_key" );
138
 
139
  $style = '';
140
- if ( in_array( $column_key, $hidden ) ) {
141
  $style = 'display:none;';
142
  }
143
 
@@ -193,7 +193,7 @@ class S2_List_Table_Legacy extends WP_List_Table {
193
  }
194
 
195
  public function process_bulk_action() {
196
- if ( in_array( $this->current_action(), array( 'delete', 'toggle' ) ) ) {
197
  if ( ! isset( $_REQUEST['subscriber'] ) ) {
198
  echo '<div id="message" class="error"><p><strong>' . __( 'No users were selected.', 'subscribe2' ) . '</strong></p></div>';
199
  return;
@@ -206,7 +206,7 @@ class S2_List_Table_Legacy extends WP_List_Table {
206
  $address = trim( stripslashes( $address ) );
207
  if ( false !== $mysubscribe2->is_public( $address ) ) {
208
  $mysubscribe2->delete( $address );
209
- $key = array_search( $address, $subscribers );
210
  unset( $subscribers[ $key ] );
211
  $message['public_deleted'] = __( 'Address(es) deleted!', 'subscribe2' );
212
  } else {
@@ -217,7 +217,7 @@ class S2_List_Table_Legacy extends WP_List_Table {
217
  } else {
218
  $message['reg_deleted'] = __( 'Registered user(s) deleted! Any posts made by these users were assigned to you.', 'subscribe2' );
219
  foreach ( $subscribers as $key => $data ) {
220
- if ( in_array( $address, $data ) ) {
221
  unset( $subscribers[ $key ] );
222
  }
223
  }
@@ -235,7 +235,7 @@ class S2_List_Table_Legacy extends WP_List_Table {
235
  $address = trim( stripslashes( $address ) );
236
  $mysubscribe2->toggle( $address );
237
  if ( 'confirmed' === $_POST['what'] || 'unconfirmed' === $_POST['what'] ) {
238
- $key = array_search( $address, $subscribers );
239
  unset( $subscribers[ $key ] );
240
  }
241
  }
137
  $class = array( 'manage-column', "column-$column_key" );
138
 
139
  $style = '';
140
+ if ( in_array( $column_key, $hidden, true ) ) {
141
  $style = 'display:none;';
142
  }
143
 
193
  }
194
 
195
  public function process_bulk_action() {
196
+ if ( in_array( $this->current_action(), array( 'delete', 'toggle' ), true ) ) {
197
  if ( ! isset( $_REQUEST['subscriber'] ) ) {
198
  echo '<div id="message" class="error"><p><strong>' . __( 'No users were selected.', 'subscribe2' ) . '</strong></p></div>';
199
  return;
206
  $address = trim( stripslashes( $address ) );
207
  if ( false !== $mysubscribe2->is_public( $address ) ) {
208
  $mysubscribe2->delete( $address );
209
+ $key = array_search( $address, $subscribers, true );
210
  unset( $subscribers[ $key ] );
211
  $message['public_deleted'] = __( 'Address(es) deleted!', 'subscribe2' );
212
  } else {
217
  } else {
218
  $message['reg_deleted'] = __( 'Registered user(s) deleted! Any posts made by these users were assigned to you.', 'subscribe2' );
219
  foreach ( $subscribers as $key => $data ) {
220
+ if ( in_array( $address, $data, true ) ) {
221
  unset( $subscribers[ $key ] );
222
  }
223
  }
235
  $address = trim( stripslashes( $address ) );
236
  $mysubscribe2->toggle( $address );
237
  if ( 'confirmed' === $_POST['what'] || 'unconfirmed' === $_POST['what'] ) {
238
+ $key = array_search( $address, $subscribers, true );
239
  unset( $subscribers[ $key ] );
240
  }
241
  }
classes/class-s2-list-table.php CHANGED
@@ -136,7 +136,7 @@ class S2_List_Table extends WP_List_Table {
136
  foreach ( $columns as $column_key => $column_display_name ) {
137
  $class = array( 'manage-column', "column-$column_key" );
138
 
139
- if ( in_array( $column_key, $hidden ) ) {
140
  $class[] = 'hidden';
141
  }
142
 
@@ -196,7 +196,7 @@ class S2_List_Table extends WP_List_Table {
196
  }
197
 
198
  public function process_bulk_action() {
199
- if ( in_array( $this->current_action(), array( 'delete', 'toggle' ) ) ) {
200
  if ( ! isset( $_REQUEST['subscriber'] ) ) {
201
  echo '<div id="message" class="error"><p><strong>' . __( 'No users were selected.', 'subscribe2' ) . '</strong></p></div>';
202
  return;
@@ -209,7 +209,7 @@ class S2_List_Table extends WP_List_Table {
209
  $address = trim( stripslashes( $address ) );
210
  if ( false !== $mysubscribe2->is_public( $address ) ) {
211
  $mysubscribe2->delete( $address );
212
- $key = array_search( $address, $subscribers );
213
  unset( $subscribers[ $key ] );
214
  $message['public_deleted'] = __( 'Address(es) deleted!', 'subscribe2' );
215
  } else {
@@ -220,7 +220,7 @@ class S2_List_Table extends WP_List_Table {
220
  } else {
221
  $message['reg_deleted'] = __( 'Registered user(s) deleted! Any posts made by these users were assigned to you.', 'subscribe2' );
222
  foreach ( $subscribers as $key => $data ) {
223
- if ( in_array( $address, $data ) ) {
224
  unset( $subscribers[ $key ] );
225
  }
226
  }
@@ -238,7 +238,7 @@ class S2_List_Table extends WP_List_Table {
238
  $address = trim( stripslashes( $address ) );
239
  $mysubscribe2->toggle( $address );
240
  if ( 'confirmed' === $_POST['what'] || 'unconfirmed' === $_POST['what'] ) {
241
- $key = array_search( $address, $subscribers );
242
  unset( $subscribers[ $key ] );
243
  }
244
  }
136
  foreach ( $columns as $column_key => $column_display_name ) {
137
  $class = array( 'manage-column', "column-$column_key" );
138
 
139
+ if ( in_array( $column_key, $hidden, true ) ) {
140
  $class[] = 'hidden';
141
  }
142
 
196
  }
197
 
198
  public function process_bulk_action() {
199
+ if ( in_array( $this->current_action(), array( 'delete', 'toggle' ), true ) ) {
200
  if ( ! isset( $_REQUEST['subscriber'] ) ) {
201
  echo '<div id="message" class="error"><p><strong>' . __( 'No users were selected.', 'subscribe2' ) . '</strong></p></div>';
202
  return;
209
  $address = trim( stripslashes( $address ) );
210
  if ( false !== $mysubscribe2->is_public( $address ) ) {
211
  $mysubscribe2->delete( $address );
212
+ $key = array_search( $address, $subscribers, true );
213
  unset( $subscribers[ $key ] );
214
  $message['public_deleted'] = __( 'Address(es) deleted!', 'subscribe2' );
215
  } else {
220
  } else {
221
  $message['reg_deleted'] = __( 'Registered user(s) deleted! Any posts made by these users were assigned to you.', 'subscribe2' );
222
  foreach ( $subscribers as $key => $data ) {
223
+ if ( in_array( $address, $data, true ) ) {
224
  unset( $subscribers[ $key ] );
225
  }
226
  }
238
  $address = trim( stripslashes( $address ) );
239
  $mysubscribe2->toggle( $address );
240
  if ( 'confirmed' === $_POST['what'] || 'unconfirmed' === $_POST['what'] ) {
241
+ $key = array_search( $address, $subscribers, true );
242
  unset( $subscribers[ $key ] );
243
  }
244
  }
classes/class-s2-upgrade.php CHANGED
@@ -152,7 +152,7 @@ class S2_Upgrade {
152
 
153
  $mysubscribe2->subscribe2_options['version'] = S2VERSION;
154
  update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
155
- } // end upgrade()
156
 
157
  private function upgrade_core() {
158
  // let's take the time to double check data for registered users
@@ -276,7 +276,7 @@ class S2_Upgrade {
276
  if ( strstr( $subscribed, '-1' ) ) {
277
  // make sure we remove '-1' from any settings
278
  $old_cats = explode( ',', $subscribed );
279
- $pos = array_search( '-1', $old_cats );
280
  unset( $old_cats[ $pos ] );
281
  $cats = implode( ',', $old_cats );
282
  update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
@@ -348,7 +348,7 @@ class S2_Upgrade {
348
  foreach ( $users as $user ) {
349
  $subscribed = get_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
350
  $old_cats = explode( ',', $subscribed );
351
- $pos = array_search( '-1', $old_cats );
352
  unset( $old_cats[ $pos ] );
353
  $cats = implode( ',', $old_cats );
354
  update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
@@ -370,7 +370,7 @@ class S2_Upgrade {
370
 
371
  // load blogs of user (only if we need them)
372
  $blogs = array();
373
- if ( count( $categories ) > 0 && ! in_array( '-1', $categories ) ) {
374
  $blogs = get_blogs_of_user( $user_ID, true );
375
  }
376
 
152
 
153
  $mysubscribe2->subscribe2_options['version'] = S2VERSION;
154
  update_option( 'subscribe2_options', $mysubscribe2->subscribe2_options );
155
+ }
156
 
157
  private function upgrade_core() {
158
  // let's take the time to double check data for registered users
276
  if ( strstr( $subscribed, '-1' ) ) {
277
  // make sure we remove '-1' from any settings
278
  $old_cats = explode( ',', $subscribed );
279
+ $pos = array_search( '-1', $old_cats, true );
280
  unset( $old_cats[ $pos ] );
281
  $cats = implode( ',', $old_cats );
282
  update_user_meta( $user_ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
348
  foreach ( $users as $user ) {
349
  $subscribed = get_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), true );
350
  $old_cats = explode( ',', $subscribed );
351
+ $pos = array_search( '-1', $old_cats, true );
352
  unset( $old_cats[ $pos ] );
353
  $cats = implode( ',', $old_cats );
354
  update_user_meta( $user->ID, $mysubscribe2->get_usermeta_keyname( 's2_subscribed' ), $cats );
370
 
371
  // load blogs of user (only if we need them)
372
  $blogs = array();
373
+ if ( count( $categories ) > 0 && ! in_array( '-1', $categories, true ) ) {
374
  $blogs = get_blogs_of_user( $user_ID, true );
375
  }
376
 
gutenberg/shortcode.js CHANGED
@@ -4,20 +4,20 @@
4
  // Version 1.1 - eslinted and fixed bug in transformation of wrap attribute
5
 
6
  ( function( blocks, i18n, element, components, editor ) {
7
- var el = element.createElement,
8
- TextControl = components.TextControl,
9
  CheckboxControl = components.CheckboxControl,
10
- RadioControl = components.RadioControl;
11
 
12
  function s2shortcode( props, control, newVal ) {
13
  var attributes = props.attributes || '';
14
- var hide = '',
15
- id = '',
16
- nojs = '',
17
- antispam = '',
18
- size = '',
19
- wrap = '',
20
- link = '';
21
 
22
  // First we define the shortcode parameters from known Control values
23
  if ( 'subscribe' === attributes.hide ) {
@@ -106,203 +106,209 @@
106
  return props.attributes.shortcode;
107
  }
108
 
109
- blocks.registerBlockType( 'subscribe2-html/shortcode', {
110
- title: i18n.__( 'Subscribe2 HTML', 'subscribe2' ),
111
- icon: 'email',
112
- category: 'widgets',
113
- keywords: [
114
- i18n.__( 'email', 'subscribe2' ),
115
- i18n.__( 'notification', 'subscribe2' )
116
- ],
117
- supports: {
118
- customClassName: false,
119
- className: false,
120
- multiple: false,
121
- html: false
122
- },
123
- attributes: {
124
- shortcode: {
125
- type: 'text',
126
- selector: 'p'
127
- },
128
- hide: {
129
- type: 'string'
130
- },
131
- id: {
132
- type: 'string'
133
- },
134
- nojs: {
135
- type: 'boolean'
136
- },
137
- antispam: {
138
- type: 'boolean'
139
- },
140
- size: {
141
- type: 'number'
142
  },
143
- wrap: {
144
- type: 'boolean'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  },
146
- link: {
147
- type: 'string'
148
- }
149
- },
150
- transforms: {
151
- to: [
152
- {
153
- type: 'block',
154
- blocks: [ 'core/shortcode' ],
155
- transform: function( content ) {
156
- if ( undefined === content.shortcode || '' === content.shortcode ) {
157
- content.shortcode = '[subscribe2]';
158
  }
159
- return blocks.createBlock( 'core/shortcode', { text: content.shortcode } );
160
  }
161
- }
162
- ],
163
- from: [
164
- {
165
- type: 'block',
166
- blocks: [ 'core/shortcode' ],
167
- transform: function( content ) {
168
- var shortcode, params, param, hide, id, nojs, antispam, size, wrap, link, i;
169
- if ( 'subscribe2' === content.text.substr( 1, 10 ) ) {
170
- shortcode = content.text;
171
- params = content.text.replace( /^\[subscribe2|\]$/g, '' ).replace( /^\s+|\s+$/g, '' ).split( /['"]\s/g );
172
 
173
- for ( i = 0; i < params.length; i++ ) {
174
- param = params[i].split( '=' );
175
- if ( 'hide' === param[0] ) {
176
- hide = param[1].replace( /['"]+/g, '' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
178
- if ( 'id' === param[0] ) {
179
- id = param[1].replace( /['"]+/g, '' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  }
181
- if ( 'nojs' === param[0] ) {
182
- nojs = 'true' === param[1].replace( /['"]+/g, '' );
 
 
 
183
  }
184
- if ( 'antispam' === param[0] ) {
185
- antispam = 'true' === param[1].replace( /['"]+/g, '' );
 
 
 
186
  }
187
- if ( 'size' === param[0] ) {
188
- size = param[1].replace( /['"]+/g, '' );
 
 
 
189
  }
190
- if ( 'wrap' === param[0] ) {
191
- wrap = 'false' === param[1].replace( /['"]+/g, '' );
 
 
 
192
  }
193
- if ( 'link' === param[0] ) {
194
- link = param[1].replace( /^['"]|['"]$/g, '' );
 
 
 
 
 
 
 
 
 
195
  }
196
- }
197
-
198
- return blocks.createBlock( 'subscribe2-html/shortcode', {
199
- shortcode: shortcode,
200
- hide: hide,
201
- id: id,
202
- nojs: nojs,
203
- antispam: antispam,
204
- size: size,
205
- wrap: wrap,
206
- link: link
207
- } );
208
- }
209
- }
210
- },
211
- {
212
- type: 'shortcode',
213
- tag: 'subscribe2',
214
- attributes: {
215
- shortcode: {
216
- type: 'string',
217
- selector: 'p'
218
- },
219
- hide: {
220
- type: 'string',
221
- shortcode: function( content ) {
222
- return content.named.hide || 'none';
223
- }
224
- },
225
- id: {
226
- type: 'string',
227
- shortcode: function( content ) {
228
- return content.named.id || '';
229
- }
230
- },
231
- nojs: {
232
- type: 'boolean',
233
- shortcode: function( content ) {
234
- return content.named.nojs || false;
235
- }
236
- },
237
- antispam: {
238
- type: 'boolean',
239
- shortcode: function( content ) {
240
- return content.named.antispam || false;
241
- }
242
- },
243
- size: {
244
- type: 'number',
245
- shortcode: function( content ) {
246
- return content.named.size || '20';
247
- }
248
- },
249
- wrap: {
250
- type: 'boolean',
251
- shortcode: function( content ) {
252
- return content.named.wrap || false;
253
- }
254
- },
255
- link: {
256
- type: 'string',
257
- shortcode: function( content ) {
258
- return content.named.link || '';
259
  }
260
  }
261
  }
262
- }
263
- ]
264
- },
265
- edit: function( props ) {
266
- var hide = props.attributes.hide || 'none',
267
- id = props.attributes.id || '',
268
- nojs = props.attributes.nojs || false,
269
- antispam = props.attributes.antispam || false,
270
- size = props.attributes.size || '20',
271
- wrap = props.attributes.wrap || false,
272
- link = props.attributes.link || '',
273
  isSelected = props.isSelected;
274
 
275
- function onChangeHide( newHide ) {
276
- props.attributes.shortcode = s2shortcode( props, 'hide', newHide );
277
- props.setAttributes( { hide: newHide } );
278
- }
279
- function onChangeId( newId ) {
280
- props.attributes.shortcode = s2shortcode( props, 'id', newId );
281
- props.setAttributes( { id: newId } );
282
- }
283
- function onChangeNojs( newNojs ) {
284
- props.attributes.shortcode = s2shortcode( props, 'nojs', newNojs );
285
- props.setAttributes( { nojs: newNojs } );
286
- }
287
- function onChangeAntispam( newAntispam ) {
288
- props.attributes.shortcode = s2shortcode( props, 'antispam', newAntispam );
289
- props.setAttributes( { antispam: newAntispam } );
290
- }
291
- function onChangeSize( newSize ) {
292
- props.attributes.shortcode = s2shortcode( props, 'size', newSize );
293
- props.setAttributes( { size: newSize } );
294
- }
295
- function onChangeWrap( newWrap ) {
296
- props.attributes.shortcode = s2shortcode( props, 'wrap', newWrap );
297
- props.setAttributes( { wrap: newWrap } );
298
- }
299
- function onChangeLink( newLink ) {
300
- props.attributes.shortcode = s2shortcode( props, 'link', newLink );
301
- props.setAttributes( { link: newLink } );
302
- }
303
 
304
- return [
305
- isSelected && el(
306
  editor.InspectorControls,
307
  { key: 'subscribe2-html/inspector' },
308
  el( 'h3', {}, i18n.__( 'Subscribe2 Shortcode Parameters', 'subscribe2' ) ),
@@ -317,7 +323,7 @@
317
  { value: 'subscribe', label: i18n.__( 'Hide Subscribe Button', 'subscribe2' ) },
318
  { value: 'unsubscribe', label: i18n.__( 'Hide Unsubscribe Button', 'subscribe2' ) }
319
  ]
320
- }
321
  ),
322
  el(
323
  TextControl,
@@ -326,7 +332,7 @@
326
  label: i18n.__( 'Page ID', 'subscribe2' ),
327
  value: id,
328
  onChange: onChangeId
329
- }
330
  ),
331
  el(
332
  CheckboxControl,
@@ -334,7 +340,7 @@
334
  label: i18n.__( 'Disable Javascript', 'subscribe2' ),
335
  checked: nojs,
336
  onChange: onChangeNojs
337
- }
338
  ),
339
  el(
340
  CheckboxControl,
@@ -342,7 +348,7 @@
342
  label: i18n.__( 'Disable Simple Anti-Spam Measures', 'subscribe2' ),
343
  checked: antispam,
344
  onChange: onChangeAntispam
345
- }
346
  ),
347
  el(
348
  TextControl,
@@ -351,7 +357,7 @@
351
  label: i18n.__( 'Textbox size', 'subscribe2' ),
352
  value: size,
353
  onChange: onChangeSize
354
- }
355
  ),
356
  el(
357
  CheckboxControl,
@@ -359,7 +365,7 @@
359
  label: i18n.__( 'Disable wrapping of form buttons', 'subscribe2' ),
360
  checked: wrap,
361
  onChange: onChangeWrap
362
- }
363
  ),
364
  el(
365
  TextControl,
@@ -368,21 +374,24 @@
368
  label: i18n.__( 'Link Text', 'subscribe2' ),
369
  value: link,
370
  onChange: onChangeLink
371
- }
372
  )
373
  ),
374
- el(
375
- 'div', {
376
- key: 'subscribe2-html/block',
377
- style: { backgroundColor: '#ff0', color: '#000', padding: '2px', 'textAlign': 'center' }
378
- }, i18n.__( 'Subscribe2 HTML Shortcode', 'subscribe2' )
379
- )
380
- ];
381
- },
382
- save: function( props ) {
383
- return el( element.RawHTML, null, '<p>' + props.attributes.shortcode + '</p>' );
 
 
 
384
  }
385
- } );
386
  } (
387
  window.wp.blocks,
388
  window.wp.i18n,
4
  // Version 1.1 - eslinted and fixed bug in transformation of wrap attribute
5
 
6
  ( function( blocks, i18n, element, components, editor ) {
7
+ var el = element.createElement,
8
+ TextControl = components.TextControl,
9
  CheckboxControl = components.CheckboxControl,
10
+ RadioControl = components.RadioControl;
11
 
12
  function s2shortcode( props, control, newVal ) {
13
  var attributes = props.attributes || '';
14
+ var hide = '',
15
+ id = '',
16
+ nojs = '',
17
+ antispam = '',
18
+ size = '',
19
+ wrap = '',
20
+ link = '';
21
 
22
  // First we define the shortcode parameters from known Control values
23
  if ( 'subscribe' === attributes.hide ) {
106
  return props.attributes.shortcode;
107
  }
108
 
109
+ blocks.registerBlockType(
110
+ 'subscribe2-html/shortcode',
111
+ {
112
+ title: i18n.__( 'Subscribe2 HTML', 'subscribe2' ),
113
+ icon: 'email',
114
+ category: 'widgets',
115
+ keywords: [
116
+ i18n.__( 'email', 'subscribe2' ),
117
+ i18n.__( 'notification', 'subscribe2' )
118
+ ],
119
+ supports: {
120
+ customClassName: false,
121
+ className: false,
122
+ multiple: false,
123
+ html: false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  },
125
+ attributes: {
126
+ shortcode: {
127
+ type: 'text',
128
+ selector: 'p'
129
+ },
130
+ hide: {
131
+ type: 'string'
132
+ },
133
+ id: {
134
+ type: 'string'
135
+ },
136
+ nojs: {
137
+ type: 'boolean'
138
+ },
139
+ antispam: {
140
+ type: 'boolean'
141
+ },
142
+ size: {
143
+ type: 'number'
144
+ },
145
+ wrap: {
146
+ type: 'boolean'
147
+ },
148
+ link: {
149
+ type: 'string'
150
+ }
151
  },
152
+ transforms: {
153
+ to: [
154
+ {
155
+ type: 'block',
156
+ blocks: [ 'core/shortcode' ],
157
+ transform: function( content ) {
158
+ if ( undefined === content.shortcode || '' === content.shortcode ) {
159
+ content.shortcode = '[subscribe2]';
160
+ }
161
+ return blocks.createBlock( 'core/shortcode', { text: content.shortcode } );
 
 
162
  }
 
163
  }
164
+ ],
165
+ from: [
166
+ {
167
+ type: 'block',
168
+ blocks: [ 'core/shortcode' ],
169
+ transform: function( content ) {
170
+ var shortcode, params, param, hide, id, nojs, antispam, size, wrap, link, i, l;
171
+ if ( 'subscribe2' === content.text.substr( 1, 10 ) ) {
172
+ shortcode = content.text;
173
+ params = content.text.replace( /^\[subscribe2|\]$/g, '' ).replace( /^\s+|\s+$/g, '' ).split( /['"]\s/g );
174
+ l = params.length;
175
 
176
+ for ( i = 0; i < l; i++ ) {
177
+ param = params[i].split( '=' );
178
+ if ( 'hide' === param[0] ) {
179
+ hide = param[1].replace( /['"]+/g, '' );
180
+ }
181
+ if ( 'id' === param[0] ) {
182
+ id = param[1].replace( /['"]+/g, '' );
183
+ }
184
+ if ( 'nojs' === param[0] ) {
185
+ nojs = 'true' === param[1].replace( /['"]+/g, '' );
186
+ }
187
+ if ( 'antispam' === param[0] ) {
188
+ antispam = 'true' === param[1].replace( /['"]+/g, '' );
189
+ }
190
+ if ( 'size' === param[0] ) {
191
+ size = param[1].replace( /['"]+/g, '' );
192
+ }
193
+ if ( 'wrap' === param[0] ) {
194
+ wrap = 'false' === param[1].replace( /['"]+/g, '' );
195
+ }
196
+ if ( 'link' === param[0] ) {
197
+ link = param[1].replace( /^['"]|['"]$/g, '' );
198
+ }
199
  }
200
+
201
+ return blocks.createBlock(
202
+ 'subscribe2-html/shortcode',
203
+ {
204
+ shortcode: shortcode,
205
+ hide: hide,
206
+ id: id,
207
+ nojs: nojs,
208
+ antispam: antispam,
209
+ size: size,
210
+ wrap: wrap,
211
+ link: link
212
+ }
213
+ );
214
+ }
215
+ }
216
+ },
217
+ {
218
+ type: 'shortcode',
219
+ tag: 'subscribe2',
220
+ attributes: {
221
+ shortcode: {
222
+ type: 'string',
223
+ selector: 'p'
224
+ },
225
+ hide: {
226
+ type: 'string',
227
+ shortcode: function( content ) {
228
+ return content.named.hide || 'none';
229
  }
230
+ },
231
+ id: {
232
+ type: 'string',
233
+ shortcode: function( content ) {
234
+ return content.named.id || '';
235
  }
236
+ },
237
+ nojs: {
238
+ type: 'boolean',
239
+ shortcode: function( content ) {
240
+ return content.named.nojs || false;
241
  }
242
+ },
243
+ antispam: {
244
+ type: 'boolean',
245
+ shortcode: function( content ) {
246
+ return content.named.antispam || false;
247
  }
248
+ },
249
+ size: {
250
+ type: 'number',
251
+ shortcode: function( content ) {
252
+ return content.named.size || '20';
253
  }
254
+ },
255
+ wrap: {
256
+ type: 'boolean',
257
+ shortcode: function( content ) {
258
+ return content.named.wrap || false;
259
+ }
260
+ },
261
+ link: {
262
+ type: 'string',
263
+ shortcode: function( content ) {
264
+ return content.named.link || '';
265
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
  }
268
  }
269
+ ]
270
+ },
271
+ edit: function( props ) {
272
+ var hide = props.attributes.hide || 'none',
273
+ id = props.attributes.id || '',
274
+ nojs = props.attributes.nojs || false,
275
+ antispam = props.attributes.antispam || false,
276
+ size = props.attributes.size || '20',
277
+ wrap = props.attributes.wrap || false,
278
+ link = props.attributes.link || '',
 
279
  isSelected = props.isSelected;
280
 
281
+ function onChangeHide( newHide ) {
282
+ props.attributes.shortcode = s2shortcode( props, 'hide', newHide );
283
+ props.setAttributes( { hide: newHide } );
284
+ }
285
+ function onChangeId( newId ) {
286
+ props.attributes.shortcode = s2shortcode( props, 'id', newId );
287
+ props.setAttributes( { id: newId } );
288
+ }
289
+ function onChangeNojs( newNojs ) {
290
+ props.attributes.shortcode = s2shortcode( props, 'nojs', newNojs );
291
+ props.setAttributes( { nojs: newNojs } );
292
+ }
293
+ function onChangeAntispam( newAntispam ) {
294
+ props.attributes.shortcode = s2shortcode( props, 'antispam', newAntispam );
295
+ props.setAttributes( { antispam: newAntispam } );
296
+ }
297
+ function onChangeSize( newSize ) {
298
+ props.attributes.shortcode = s2shortcode( props, 'size', newSize );
299
+ props.setAttributes( { size: newSize } );
300
+ }
301
+ function onChangeWrap( newWrap ) {
302
+ props.attributes.shortcode = s2shortcode( props, 'wrap', newWrap );
303
+ props.setAttributes( { wrap: newWrap } );
304
+ }
305
+ function onChangeLink( newLink ) {
306
+ props.attributes.shortcode = s2shortcode( props, 'link', newLink );
307
+ props.setAttributes( { link: newLink } );
308
+ }
309
 
310
+ return [
311
+ isSelected && el(
312
  editor.InspectorControls,
313
  { key: 'subscribe2-html/inspector' },
314
  el( 'h3', {}, i18n.__( 'Subscribe2 Shortcode Parameters', 'subscribe2' ) ),
323
  { value: 'subscribe', label: i18n.__( 'Hide Subscribe Button', 'subscribe2' ) },
324
  { value: 'unsubscribe', label: i18n.__( 'Hide Unsubscribe Button', 'subscribe2' ) }
325
  ]
326
+ }
327
  ),
328
  el(
329
  TextControl,
332
  label: i18n.__( 'Page ID', 'subscribe2' ),
333
  value: id,
334
  onChange: onChangeId
335
+ }
336
  ),
337
  el(
338
  CheckboxControl,
340
  label: i18n.__( 'Disable Javascript', 'subscribe2' ),
341
  checked: nojs,
342
  onChange: onChangeNojs
343
+ }
344
  ),
345
  el(
346
  CheckboxControl,
348
  label: i18n.__( 'Disable Simple Anti-Spam Measures', 'subscribe2' ),
349
  checked: antispam,
350
  onChange: onChangeAntispam
351
+ }
352
  ),
353
  el(
354
  TextControl,
357
  label: i18n.__( 'Textbox size', 'subscribe2' ),
358
  value: size,
359
  onChange: onChangeSize
360
+ }
361
  ),
362
  el(
363
  CheckboxControl,
365
  label: i18n.__( 'Disable wrapping of form buttons', 'subscribe2' ),
366
  checked: wrap,
367
  onChange: onChangeWrap
368
+ }
369
  ),
370
  el(
371
  TextControl,
374
  label: i18n.__( 'Link Text', 'subscribe2' ),
375
  value: link,
376
  onChange: onChangeLink
377
+ }
378
  )
379
  ),
380
+ el(
381
+ 'div',
382
+ {
383
+ key: 'subscribe2-html/block',
384
+ style: { backgroundColor: '#ff0', color: '#000', padding: '2px', 'textAlign': 'center' }
385
+ },
386
+ i18n.__( 'Subscribe2 HTML Shortcode', 'subscribe2' )
387
+ )
388
+ ];
389
+ },
390
+ save: function( props ) {
391
+ return el( element.RawHTML, null, '<p>' + props.attributes.shortcode + '</p>' );
392
+ }
393
  }
394
+ );
395
  } (
396
  window.wp.blocks,
397
  window.wp.i18n,
gutenberg/shortcode.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,s,i,r){var n=s.createElement,o=i.TextControl,a=i.CheckboxControl,c=i.RadioControl;function b(e,t,s){var i=e.attributes||"",r="",n="",o="",a="",c="",b="",u="";switch("subscribe"===i.hide?r=' hide="subscribe"':"unsubscribe"===i.hide&&(r=' hide="unsubscribe"'),""!==i.id&&undefined!==i.id&&(n=' id="'+i.id+'"'),!0===i.nojs&&(o=' nojs="true"'),!0===i.antispam&&(a=' antispam="true"'),""!==i.size&&undefined!==i.size&&"20"!==i.size&&(c=' size="'+i.size+'"'),!0===i.wrap&&(b=' wrap="false"'),""!==i.link&&undefined!==i.link&&(u=' link="'+i.link+'"'),t){case"hide":"none"===s?r="":"subscribe"===s?r=' hide="subscribe"':"unsubscribe"===s&&(r=' hide="unsubscribe"');break;case"id":n=""===s?"":' id="'+s+'"';break;case"nojs":!0===s?o=' nojs="true"':!1===s&&(o="");break;case"antispam":!0===s?a=' antispam="true"':!1===s&&(a="");break;case"size":c="20"===s?"":' size="'+s+'"';break;case"wrap":!0===s?b=' wrap="false"':!1===s&&(b="");break;case"link":u=""===s?"":' link="'+s+'"'}return e.attributes.shortcode="[subscribe2"+r+n+o+a+c+b+u+"]",e.attributes.shortcode}e.registerBlockType("subscribe2-html/shortcode",{title:t.__("Subscribe2 HTML","subscribe2"),icon:"email",category:"widgets",keywords:[t.__("email","subscribe2"),t.__("notification","subscribe2")],supports:{customClassName:!1,className:!1,multiple:!1,html:!1},attributes:{shortcode:{type:"text",selector:"p"},hide:{type:"string"},id:{type:"string"},nojs:{type:"boolean"},antispam:{type:"boolean"},size:{type:"number"},wrap:{type:"boolean"},link:{type:"string"}},transforms:{to:[{type:"block",blocks:["core/shortcode"],transform:function(t){return undefined!==t.shortcode&&""!==t.shortcode||(t.shortcode="[subscribe2]"),e.createBlock("core/shortcode",{text:t.shortcode})}}],from:[{type:"block",blocks:["core/shortcode"],transform:function(t){var s,i,r,n,o,a,c,b,u,l,d;if("subscribe2"===t.text.substr(1,10)){for(s=t.text,i=t.text.replace(/^\[subscribe2|\]$/g,"").replace(/^\s+|\s+$/g,"").split(/['"]\s/g),d=0;d<i.length;d++)"hide"===(r=i[d].split("="))[0]&&(n=r[1].replace(/['"]+/g,"")),"id"===r[0]&&(o=r[1].replace(/['"]+/g,"")),"nojs"===r[0]&&(a="true"===r[1].replace(/['"]+/g,"")),"antispam"===r[0]&&(c="true"===r[1].replace(/['"]+/g,"")),"size"===r[0]&&(b=r[1].replace(/['"]+/g,"")),"wrap"===r[0]&&(u="false"===r[1].replace(/['"]+/g,"")),"link"===r[0]&&(l=r[1].replace(/^['"]|['"]$/g,""));return e.createBlock("subscribe2-html/shortcode",{shortcode:s,hide:n,id:o,nojs:a,antispam:c,size:b,wrap:u,link:l})}}},{type:"shortcode",tag:"subscribe2",attributes:{shortcode:{type:"string",selector:"p"},hide:{type:"string",shortcode:function(e){return e.named.hide||"none"}},id:{type:"string",shortcode:function(e){return e.named.id||""}},nojs:{type:"boolean",shortcode:function(e){return e.named.nojs||!1}},antispam:{type:"boolean",shortcode:function(e){return e.named.antispam||!1}},size:{type:"number",shortcode:function(e){return e.named.size||"20"}},wrap:{type:"boolean",shortcode:function(e){return e.named.wrap||!1}},link:{type:"string",shortcode:function(e){return e.named.link||""}}}}]},edit:function(e){var s=e.attributes.hide||"none",i=e.attributes.id||"",u=e.attributes.nojs||!1,l=e.attributes.antispam||!1,d=e.attributes.size||"20",p=e.attributes.wrap||!1,h=e.attributes.link||"";return[e.isSelected&&n(r.InspectorControls,{key:"subscribe2-html/inspector"},n("h3",{},t.__("Subscribe2 Shortcode Parameters","subscribe2")),n(c,{label:t.__("Button Display Options","subscribe2"),selected:s,onChange:function(t){e.attributes.shortcode=b(e,"hide",t),e.setAttributes({hide:t})},options:[{value:"none",label:t.__("Show Both Buttons","subscribe2")},{value:"subscribe",label:t.__("Hide Subscribe Button","subscribe2")},{value:"unsubscribe",label:t.__("Hide Unsubscribe Button","subscribe2")}]}),n(o,{type:"number",label:t.__("Page ID","subscribe2"),value:i,onChange:function(t){e.attributes.shortcode=b(e,"id",t),e.setAttributes({id:t})}}),n(a,{label:t.__("Disable Javascript","subscribe2"),checked:u,onChange:function(t){e.attributes.shortcode=b(e,"nojs",t),e.setAttributes({nojs:t})}}),n(a,{label:t.__("Disable Simple Anti-Spam Measures","subscribe2"),checked:l,onChange:function(t){e.attributes.shortcode=b(e,"antispam",t),e.setAttributes({antispam:t})}}),n(o,{type:"number",label:t.__("Textbox size","subscribe2"),value:d,onChange:function(t){e.attributes.shortcode=b(e,"size",t),e.setAttributes({size:t})}}),n(a,{label:t.__("Disable wrapping of form buttons","subscribe2"),checked:p,onChange:function(t){e.attributes.shortcode=b(e,"wrap",t),e.setAttributes({wrap:t})}}),n(o,{type:"string",label:t.__("Link Text","subscribe2"),value:h,onChange:function(t){e.attributes.shortcode=b(e,"link",t),e.setAttributes({link:t})}})),n("div",{key:"subscribe2-html/block",style:{backgroundColor:"#ff0",color:"#000",padding:"2px",textAlign:"center"}},t.__("Subscribe2 HTML Shortcode","subscribe2"))]},save:function(e){return n(s.RawHTML,null,"<p>"+e.attributes.shortcode+"</p>")}})}(window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,window.wp.editor);
1
+ !function(e,t,s,i,r){var n=s.createElement,o=i.TextControl,a=i.CheckboxControl,c=i.RadioControl;function b(e,t,s){var i=e.attributes||"",r="",n="",o="",a="",c="",b="",u="";switch("subscribe"===i.hide?r=' hide="subscribe"':"unsubscribe"===i.hide&&(r=' hide="unsubscribe"'),""!==i.id&&undefined!==i.id&&(n=' id="'+i.id+'"'),!0===i.nojs&&(o=' nojs="true"'),!0===i.antispam&&(a=' antispam="true"'),""!==i.size&&undefined!==i.size&&"20"!==i.size&&(c=' size="'+i.size+'"'),!0===i.wrap&&(b=' wrap="false"'),""!==i.link&&undefined!==i.link&&(u=' link="'+i.link+'"'),t){case"hide":"none"===s?r="":"subscribe"===s?r=' hide="subscribe"':"unsubscribe"===s&&(r=' hide="unsubscribe"');break;case"id":n=""===s?"":' id="'+s+'"';break;case"nojs":!0===s?o=' nojs="true"':!1===s&&(o="");break;case"antispam":!0===s?a=' antispam="true"':!1===s&&(a="");break;case"size":c="20"===s?"":' size="'+s+'"';break;case"wrap":!0===s?b=' wrap="false"':!1===s&&(b="");break;case"link":u=""===s?"":' link="'+s+'"'}return e.attributes.shortcode="[subscribe2"+r+n+o+a+c+b+u+"]",e.attributes.shortcode}e.registerBlockType("subscribe2-html/shortcode",{title:t.__("Subscribe2 HTML","subscribe2"),icon:"email",category:"widgets",keywords:[t.__("email","subscribe2"),t.__("notification","subscribe2")],supports:{customClassName:!1,className:!1,multiple:!1,html:!1},attributes:{shortcode:{type:"text",selector:"p"},hide:{type:"string"},id:{type:"string"},nojs:{type:"boolean"},antispam:{type:"boolean"},size:{type:"number"},wrap:{type:"boolean"},link:{type:"string"}},transforms:{to:[{type:"block",blocks:["core/shortcode"],transform:function(t){return undefined!==t.shortcode&&""!==t.shortcode||(t.shortcode="[subscribe2]"),e.createBlock("core/shortcode",{text:t.shortcode})}}],from:[{type:"block",blocks:["core/shortcode"],transform:function(t){var s,i,r,n,o,a,c,b,u,l,d,p;if("subscribe2"===t.text.substr(1,10)){for(s=t.text,p=(i=t.text.replace(/^\[subscribe2|\]$/g,"").replace(/^\s+|\s+$/g,"").split(/['"]\s/g)).length,d=0;d<p;d++)"hide"===(r=i[d].split("="))[0]&&(n=r[1].replace(/['"]+/g,"")),"id"===r[0]&&(o=r[1].replace(/['"]+/g,"")),"nojs"===r[0]&&(a="true"===r[1].replace(/['"]+/g,"")),"antispam"===r[0]&&(c="true"===r[1].replace(/['"]+/g,"")),"size"===r[0]&&(b=r[1].replace(/['"]+/g,"")),"wrap"===r[0]&&(u="false"===r[1].replace(/['"]+/g,"")),"link"===r[0]&&(l=r[1].replace(/^['"]|['"]$/g,""));return e.createBlock("subscribe2-html/shortcode",{shortcode:s,hide:n,id:o,nojs:a,antispam:c,size:b,wrap:u,link:l})}}},{type:"shortcode",tag:"subscribe2",attributes:{shortcode:{type:"string",selector:"p"},hide:{type:"string",shortcode:function(e){return e.named.hide||"none"}},id:{type:"string",shortcode:function(e){return e.named.id||""}},nojs:{type:"boolean",shortcode:function(e){return e.named.nojs||!1}},antispam:{type:"boolean",shortcode:function(e){return e.named.antispam||!1}},size:{type:"number",shortcode:function(e){return e.named.size||"20"}},wrap:{type:"boolean",shortcode:function(e){return e.named.wrap||!1}},link:{type:"string",shortcode:function(e){return e.named.link||""}}}}]},edit:function(e){var s=e.attributes.hide||"none",i=e.attributes.id||"",u=e.attributes.nojs||!1,l=e.attributes.antispam||!1,d=e.attributes.size||"20",p=e.attributes.wrap||!1,h=e.attributes.link||"";return[e.isSelected&&n(r.InspectorControls,{key:"subscribe2-html/inspector"},n("h3",{},t.__("Subscribe2 Shortcode Parameters","subscribe2")),n(c,{label:t.__("Button Display Options","subscribe2"),selected:s,onChange:function(t){e.attributes.shortcode=b(e,"hide",t),e.setAttributes({hide:t})},options:[{value:"none",label:t.__("Show Both Buttons","subscribe2")},{value:"subscribe",label:t.__("Hide Subscribe Button","subscribe2")},{value:"unsubscribe",label:t.__("Hide Unsubscribe Button","subscribe2")}]}),n(o,{type:"number",label:t.__("Page ID","subscribe2"),value:i,onChange:function(t){e.attributes.shortcode=b(e,"id",t),e.setAttributes({id:t})}}),n(a,{label:t.__("Disable Javascript","subscribe2"),checked:u,onChange:function(t){e.attributes.shortcode=b(e,"nojs",t),e.setAttributes({nojs:t})}}),n(a,{label:t.__("Disable Simple Anti-Spam Measures","subscribe2"),checked:l,onChange:function(t){e.attributes.shortcode=b(e,"antispam",t),e.setAttributes({antispam:t})}}),n(o,{type:"number",label:t.__("Textbox size","subscribe2"),value:d,onChange:function(t){e.attributes.shortcode=b(e,"size",t),e.setAttributes({size:t})}}),n(a,{label:t.__("Disable wrapping of form buttons","subscribe2"),checked:p,onChange:function(t){e.attributes.shortcode=b(e,"wrap",t),e.setAttributes({wrap:t})}}),n(o,{type:"string",label:t.__("Link Text","subscribe2"),value:h,onChange:function(t){e.attributes.shortcode=b(e,"link",t),e.setAttributes({link:t})}})),n("div",{key:"subscribe2-html/block",style:{backgroundColor:"#ff0",color:"#000",padding:"2px",textAlign:"center"}},t.__("Subscribe2 HTML Shortcode","subscribe2"))]},save:function(e){return n(s.RawHTML,null,"<p>"+e.attributes.shortcode+"</p>")}})}(window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,window.wp.editor);
gutenberg/sidebar.js CHANGED
@@ -1,53 +1,60 @@
1
  // Version 1.0 - Initial version
2
 
3
  ( function( plugins, element, i18n, editPost, components, data, compose, apiFetch ) {
4
- var registerPlugin = plugins.registerPlugin,
5
- el = element.createElement,
6
- __ = i18n.__,
7
- Fragment = element.Fragment,
8
- PluginSidebar = editPost.PluginSidebar,
9
  PluginSidebarMoreMenuItem = editPost.PluginSidebarMoreMenuItem,
10
- PanelBody = components.PanelBody,
11
- PanelRow = components.PanelRow,
12
- CheckboxControl = components.CheckboxControl,
13
- Button = components.Button,
14
- select = data.select,
15
- dispatch = data.dispatch,
16
- withSelect = data.withSelect,
17
- withDispatch = data.withDispatch,
18
- Compose = compose.compose;
19
 
20
  var CheckboxControlMeta = Compose(
21
- withSelect( function( select, props ) {
22
- var s2mail = select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ props.fieldName ];
23
- return {
24
- metaChecked: ( 'no' === s2mail ? true : false )
25
- };
26
- } ),
27
- withDispatch( function( dispatch, props ) {
28
- return {
29
- setMetaChecked: function( value ) {
30
- var s2mail = ( true === value ? 'no' : 'yes' );
31
- dispatch( 'core/editor' ).editPost( { meta: { [props.fieldName]: s2mail } } );
32
- dispatch( 'core/editor' ).savePost();
33
- }
34
- };
35
- } )
36
- ) ( function( props ) {
37
- return el(
38
- CheckboxControl,
39
- {
40
- label: __( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' ),
41
- checked: props.metaChecked,
42
- onChange: function( content ) {
43
- props.setMetaChecked( content );
44
- }
45
  }
46
- );
47
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  var buttonClick = function() {
50
  var postid = select( 'core/editor' ).getCurrentPostId();
 
51
  apiFetch( { path: '/s2/v1/preview/' + postid } );
52
  dispatch( 'core/notices' ).createInfoNotice( __( 'Attempt made to send email preview', 'subscribe2' ) );
53
  };
@@ -124,9 +131,12 @@
124
  );
125
  };
126
 
127
- registerPlugin( 'subscribe2-sidebar', {
128
- render: s2sidebar
129
- } );
 
 
 
130
  } (
131
  wp.plugins,
132
  wp.element,
1
  // Version 1.0 - Initial version
2
 
3
  ( function( plugins, element, i18n, editPost, components, data, compose, apiFetch ) {
4
+ var registerPlugin = plugins.registerPlugin,
5
+ el = element.createElement,
6
+ __ = i18n.__,
7
+ Fragment = element.Fragment,
8
+ PluginSidebar = editPost.PluginSidebar,
9
  PluginSidebarMoreMenuItem = editPost.PluginSidebarMoreMenuItem,
10
+ PanelBody = components.PanelBody,
11
+ PanelRow = components.PanelRow,
12
+ CheckboxControl = components.CheckboxControl,
13
+ Button = components.Button,
14
+ select = data.select,
15
+ dispatch = data.dispatch,
16
+ withSelect = data.withSelect,
17
+ withDispatch = data.withDispatch,
18
+ Compose = compose.compose;
19
 
20
  var CheckboxControlMeta = Compose(
21
+ withSelect(
22
+ function( select, props ) {
23
+ var s2mail = select( 'core/editor' ).getEditedPostAttribute( 'meta' )[ props.fieldName ];
24
+ return {
25
+ metaChecked: ( 'no' === s2mail ? true : false )
26
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  }
28
+ ),
29
+ withDispatch(
30
+ function( dispatch, props ) {
31
+ return {
32
+ setMetaChecked: function( value ) {
33
+ var s2mail = ( true === value ? 'no' : 'yes' );
34
+ dispatch( 'core/editor' ).editPost( { meta: { [props.fieldName]: s2mail } } );
35
+ dispatch( 'core/editor' ).savePost();
36
+ }
37
+ };
38
+ }
39
+ )
40
+ )(
41
+ function( props ) {
42
+ return el(
43
+ CheckboxControl,
44
+ {
45
+ label: __( 'Check here to disable sending of an email notification for this post/page', 'subscribe2' ),
46
+ checked: props.metaChecked,
47
+ onChange: function( content ) {
48
+ props.setMetaChecked( content );
49
+ }
50
+ }
51
+ );
52
+ }
53
+ );
54
 
55
  var buttonClick = function() {
56
  var postid = select( 'core/editor' ).getCurrentPostId();
57
+ dispatch( 'core/editor' ).savePost();
58
  apiFetch( { path: '/s2/v1/preview/' + postid } );
59
  dispatch( 'core/notices' ).createInfoNotice( __( 'Attempt made to send email preview', 'subscribe2' ) );
60
  };
131
  );
132
  };
133
 
134
+ registerPlugin(
135
+ 'subscribe2-sidebar',
136
+ {
137
+ render: s2sidebar
138
+ }
139
+ );
140
  } (
141
  wp.plugins,
142
  wp.element,
gutenberg/sidebar.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,i,t,n,r,s,o,a){var c=e.registerPlugin,b=i.createElement,d=t.__,l=i.Fragment,u=n.PluginSidebar,p=n.PluginSidebarMoreMenuItem,m=r.PanelBody,g=r.PanelRow,f=r.CheckboxControl,h=r.Button,w=s.select,P=s.dispatch,v=s.withSelect,S=s.withDispatch,C=(0,o.compose)(v(function(e,i){return{metaChecked:"no"===e("core/editor").getEditedPostAttribute("meta")[i.fieldName]}}),S(function(e,i){return{setMetaChecked:function(t){var n=!0===t?"no":"yes";e("core/editor").editPost({meta:{[i.fieldName]:n}}),e("core/editor").savePost()}}}))(function(e){return b(f,{label:d("Check here to disable sending of an email notification for this post/page","subscribe2"),checked:e.metaChecked,onChange:function(i){e.setMetaChecked(i)}})}),k=function(){var e=w("core/editor").getCurrentPostId();a({path:"/s2/v1/preview/"+e}),P("core/notices").createInfoNotice(d("Attempt made to send email preview","subscribe2"))};c("subscribe2-sidebar",{render:function(){return b(l,{},b(p,{target:"s2-sidebar",icon:"email"},d("Subscribe2 Sidebar","subscribe2")),b(u,{name:"s2-sidebar",title:d("Subscribe2 Sidebar","subscribe2"),icon:"email",isPinned:!0,isPinnable:!0,togglePin:!0,togglesidebar:!1},b(m,{title:d("Subscribe2 Override","subscribe2"),initialOpen:!0},b(g,{},b(C,{fieldName:"_s2mail"}))),b(m,{title:d("Subscribe2 Preview","subscribe2"),initialOpen:!0},b(g,{},b("div",null,d("Send preview email of this post to currently logged in user:","subscribe2"))),b(g,{},b(h,{isDefault:!0,onClick:k},d("Send Preview","subscribe2"))))))}})}(wp.plugins,wp.element,wp.i18n,wp.editPost,wp.components,wp.data,wp.compose,wp.apiFetch);
1
+ !function(e,i,t,r,n,s,o,a){var c=e.registerPlugin,d=i.createElement,b=t.__,l=i.Fragment,u=r.PluginSidebar,p=r.PluginSidebarMoreMenuItem,m=n.PanelBody,g=n.PanelRow,f=n.CheckboxControl,h=n.Button,w=s.select,P=s.dispatch,v=s.withSelect,S=s.withDispatch,C=(0,o.compose)(v(function(e,i){return{metaChecked:"no"===e("core/editor").getEditedPostAttribute("meta")[i.fieldName]}}),S(function(e,i){return{setMetaChecked:function(t){var r=!0===t?"no":"yes";e("core/editor").editPost({meta:{[i.fieldName]:r}}),e("core/editor").savePost()}}}))(function(e){return d(f,{label:b("Check here to disable sending of an email notification for this post/page","subscribe2"),checked:e.metaChecked,onChange:function(i){e.setMetaChecked(i)}})}),k=function(){var e=w("core/editor").getCurrentPostId();P("core/editor").savePost(),a({path:"/s2/v1/preview/"+e}),P("core/notices").createInfoNotice(b("Attempt made to send email preview","subscribe2"))};c("subscribe2-sidebar",{render:function(){return d(l,{},d(p,{target:"s2-sidebar",icon:"email"},b("Subscribe2 Sidebar","subscribe2")),d(u,{name:"s2-sidebar",title:b("Subscribe2 Sidebar","subscribe2"),icon:"email",isPinned:!0,isPinnable:!0,togglePin:!0,togglesidebar:!1},d(m,{title:b("Subscribe2 Override","subscribe2"),initialOpen:!0},d(g,{},d(C,{fieldName:"_s2mail"}))),d(m,{title:b("Subscribe2 Preview","subscribe2"),initialOpen:!0},d(g,{},d("div",null,b("Send preview email of this post to currently logged in user:","subscribe2"))),d(g,{},d(h,{isDefault:!0,onClick:k},b("Send Preview","subscribe2"))))))}})}(wp.plugins,wp.element,wp.i18n,wp.editPost,wp.components,wp.data,wp.compose,wp.apiFetch);
include/s2-ajax.js CHANGED
@@ -5,77 +5,102 @@
5
  // Version 1.3 - eslinted
6
 
7
  var s2jQuery = jQuery.noConflict();
8
- s2jQuery( document ).ready( function() {
9
- var dialog = s2jQuery( '<div></div>' );
10
- var ajaxurl = s2AjaxScriptStrings.ajaxurl;
11
- s2jQuery( 'a.s2popup' ).click( function( event ) {
12
- var data = {
13
- 'action': 'subscribe2_form',
14
- 'data': s2jQuery( 'a.s2popup' ).attr( 'id' )
15
- };
16
- event.preventDefault();
17
- jQuery.post( ajaxurl, data, function( response ) {
18
- dialog.html( response );
19
- } );
20
- dialog.dialog( {
21
- modal: true,
22
- zIndex: 10000,
23
- minWidth: 350,
24
- minHeight: 300,
25
- title: s2AjaxScriptStrings.title
26
- } );
27
- dialog.dialog( 'open' );
28
- } );
29
- s2jQuery( document ).on( 'submit', '#s2ajaxform', function( event ) {
30
- var email = s2jQuery( '#s2ajaxform input[name=email]' ).val();
31
- var ip = s2jQuery( '#s2ajaxform input[name=ip]' ).val();
32
- var firstname = s2jQuery( '#s2ajaxform input[name=firstname]' ).val();
33
- var lastname = s2jQuery( '#s2ajaxform input[name=lastname]' ).val();
34
- var uri = s2jQuery( '#s2ajaxform input[name=uri]' ).val();
35
- var btn = s2jQuery( this ).find( 'input[type=submit][clicked=true]' );
36
- var data;
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
- event.preventDefault();
39
 
40
- if ( 'undefined' === typeof firstname ) {
41
- firstname = '';
42
- }
43
 
44
- if ( 'undefined' === typeof lastname ) {
45
- lastname = '';
46
- }
47
 
48
- if ( 'undefined' === typeof uri ) {
49
- uri = 'http://';
50
- }
51
 
52
- if ( btn.length && s2jQuery( '#s2ajaxform' ).has( btn ) ) {
53
- data = {
54
- 'action': 'subscribe2_submit',
55
- 'nonce': s2AjaxScriptStrings.nonce,
56
- 'data': {
57
- 'email': email,
58
- 'ip': ip,
59
- 'firstname': firstname,
60
- 'lastname': lastname,
61
- 'uri': uri,
62
- 'button': btn.attr( 'name' )
 
 
 
 
 
 
 
 
 
 
63
  }
64
- };
65
- jQuery.post( ajaxurl, data, function( response ) {
66
- dialog.html( response );
67
- } );
68
- }
69
- } );
70
 
71
- // Allows detection of which button was clicked
72
- s2jQuery( document ).on( 'click', '#s2ajaxform input[type=submit]', function() {
73
- s2jQuery( '#s2ajaxform input[type=submit]' ).removeAttr( 'clicked' );
74
- s2jQuery( this ).attr( 'clicked', 'true' );
75
- } );
 
 
 
 
76
 
77
- // when form is closed return to default
78
- s2jQuery( document ).on( 'dialogclose', function() {
79
- dialog.html( dialog );
80
- } );
81
- } );
 
 
 
 
5
  // Version 1.3 - eslinted
6
 
7
  var s2jQuery = jQuery.noConflict();
8
+ s2jQuery( document ).ready(
9
+ function() {
10
+ var dialog = s2jQuery( '<div></div>' );
11
+ var ajaxurl = s2AjaxScriptStrings.ajaxurl;
12
+ s2jQuery( 'a.s2popup' ).click(
13
+ function( event ) {
14
+ var data = {
15
+ 'action': 'subscribe2_form',
16
+ 'data': s2jQuery( 'a.s2popup' ).attr( 'id' )
17
+ };
18
+ event.preventDefault();
19
+ jQuery.post(
20
+ ajaxurl,
21
+ data,
22
+ function( response ) {
23
+ dialog.html( response );
24
+ }
25
+ );
26
+ dialog.dialog(
27
+ {
28
+ modal: true,
29
+ zIndex: 10000,
30
+ minWidth: 350,
31
+ minHeight: 300,
32
+ title: s2AjaxScriptStrings.title
33
+ }
34
+ );
35
+ dialog.dialog( 'open' );
36
+ }
37
+ );
38
+ s2jQuery( document ).on(
39
+ 'submit',
40
+ '#s2ajaxform',
41
+ function( event ) {
42
+ var email = s2jQuery( '#s2ajaxform input[name=email]' ).val();
43
+ var ip = s2jQuery( '#s2ajaxform input[name=ip]' ).val();
44
+ var firstname = s2jQuery( '#s2ajaxform input[name=firstname]' ).val();
45
+ var lastname = s2jQuery( '#s2ajaxform input[name=lastname]' ).val();
46
+ var uri = s2jQuery( '#s2ajaxform input[name=uri]' ).val();
47
+ var btn = s2jQuery( this ).find( 'input[type=submit][clicked=true]' );
48
+ var data;
49
 
50
+ event.preventDefault();
51
 
52
+ if ( 'undefined' === typeof firstname ) {
53
+ firstname = '';
54
+ }
55
 
56
+ if ( 'undefined' === typeof lastname ) {
57
+ lastname = '';
58
+ }
59
 
60
+ if ( 'undefined' === typeof uri ) {
61
+ uri = 'http://';
62
+ }
63
 
64
+ if ( btn.length && s2jQuery( '#s2ajaxform' ).has( btn ) ) {
65
+ data = {
66
+ 'action': 'subscribe2_submit',
67
+ 'nonce': s2AjaxScriptStrings.nonce,
68
+ 'data': {
69
+ 'email': email,
70
+ 'ip': ip,
71
+ 'firstname': firstname,
72
+ 'lastname': lastname,
73
+ 'uri': uri,
74
+ 'button': btn.attr( 'name' )
75
+ }
76
+ };
77
+ jQuery.post(
78
+ ajaxurl,
79
+ data,
80
+ function( response ) {
81
+ dialog.html( response );
82
+ }
83
+ );
84
+ }
85
  }
86
+ );
 
 
 
 
 
87
 
88
+ // Allows detection of which button was clicked
89
+ s2jQuery( document ).on(
90
+ 'click',
91
+ '#s2ajaxform input[type=submit]',
92
+ function() {
93
+ s2jQuery( '#s2ajaxform input[type=submit]' ).removeAttr( 'clicked' );
94
+ s2jQuery( this ).attr( 'clicked', 'true' );
95
+ }
96
+ );
97
 
98
+ // when form is closed return to default
99
+ s2jQuery( document ).on(
100
+ 'dialogclose',
101
+ function() {
102
+ dialog.html( dialog );
103
+ }
104
+ );
105
+ }
106
+ );
include/s2-checkbox.js CHANGED
@@ -4,41 +4,53 @@
4
  // Version 1.3 - Update for Subscribe2 9.0 to remove unecessary code now WordPress 3.3 is minimum requirement
5
  // Version 1.4 - eslinted
6
 
7
- jQuery( document ).ready( function() {
 
8
 
9
- // function to check or uncheck all when 'checkall' box it toggled
10
- jQuery( 'input[name="checkall"]' ).click( function() {
11
- var checkedStatus = this.checked;
12
- jQuery( 'input[class="' + this.value + '"]' ).each( function() {
13
- if ( false === jQuery( this ).prop( 'disabled' ) ) {
14
- this.checked = checkedStatus;
15
- }
16
- } );
17
- } );
 
 
 
 
18
 
19
- // function to check or uncheck 'checkall' box when individual boxes are toggled
20
- jQuery( 'input[class^="checkall"]' ).click( function() {
21
- var checkedStatus = true;
22
- jQuery( 'input[class="' + this.className + '"]' ).each( function() {
23
- if ( ( true === this.checked ) && ( true === checkedStatus ) ) {
24
- checkedStatus = true;
25
- } else {
26
- checkedStatus = false;
27
- }
28
- jQuery( 'input[value="' + this.className + '"]' )
29
- .prop( 'checked', checkedStatus );
30
- } );
31
- } );
 
 
 
 
32
 
33
- // function to check or uncheck 'checkall' box when page is loaded
34
- jQuery( 'input[class^="checkall"]' ).each( function() {
35
- var checkedStatus = true;
36
- if ( ( true === this.checked ) && ( true === checkedStatus ) ) {
37
- checkedStatus = true;
38
- } else {
39
- checkedStatus = false;
40
- }
41
- jQuery( 'input[value="' + this.className + '"]' )
42
- .prop( 'checked', checkedStatus );
43
- } );
44
- } );
 
 
 
4
  // Version 1.3 - Update for Subscribe2 9.0 to remove unecessary code now WordPress 3.3 is minimum requirement
5
  // Version 1.4 - eslinted
6
 
7
+ jQuery( document ).ready(
8
+ function() {
9
 
10
+ // function to check or uncheck all when 'checkall' box it toggled
11
+ jQuery( 'input[name="checkall"]' ).click(
12
+ function() {
13
+ var checkedStatus = this.checked;
14
+ jQuery( 'input[class="' + this.value + '"]' ).each(
15
+ function() {
16
+ if ( false === jQuery( this ).prop( 'disabled' ) ) {
17
+ this.checked = checkedStatus;
18
+ }
19
+ }
20
+ );
21
+ }
22
+ );
23
 
24
+ // function to check or uncheck 'checkall' box when individual boxes are toggled
25
+ jQuery( 'input[class^="checkall"]' ).click(
26
+ function() {
27
+ var checkedStatus = true;
28
+ jQuery( 'input[class="' + this.className + '"]' ).each(
29
+ function() {
30
+ if ( ( true === this.checked ) && ( true === checkedStatus ) ) {
31
+ checkedStatus = true;
32
+ } else {
33
+ checkedStatus = false;
34
+ }
35
+ jQuery( 'input[value="' + this.className + '"]' )
36
+ .prop( 'checked', checkedStatus );
37
+ }
38
+ );
39
+ }
40
+ );
41
 
42
+ // function to check or uncheck 'checkall' box when page is loaded
43
+ jQuery( 'input[class^="checkall"]' ).each(
44
+ function() {
45
+ var checkedStatus = true;
46
+ if ( ( true === this.checked ) && ( true === checkedStatus ) ) {
47
+ checkedStatus = true;
48
+ } else {
49
+ checkedStatus = false;
50
+ }
51
+ jQuery( 'input[value="' + this.className + '"]' )
52
+ .prop( 'checked', checkedStatus );
53
+ }
54
+ );
55
+ }
56
+ );
include/s2-colorpicker.js CHANGED
@@ -3,37 +3,53 @@
3
  // Version 1.2 - Initialise the colour fields on page load so they are the correct colour
4
  // Version 1.3 - eslinted
5
 
6
- jQuery( document ).ready( function() {
7
- jQuery( document ).on( 'focus', '.colorpickerField', function() {
8
- var picker,
9
- field = this.id.substr( 0, 20 );
 
 
 
 
10
 
11
- if ( jQuery( this ).is( '.s2_initialised' ) || -1 !== this.id.search( '__i__' ) ) {
12
- return; // exit early, already initialized or not activated
13
- }
14
 
15
- jQuery( this ).addClass( 's2_initialised' );
16
 
17
- jQuery( '.s2_colorpicker' ).each( function() {
18
- if ( -1 !== this.id.search( field ) ) {
19
- picker = this.id;
20
- return false; // stop looping
21
- }
22
- } );
 
 
23
 
24
- jQuery( this ).on( 'focusin', function() {
25
- jQuery( '.s2_colorpicker' ).slideUp();
26
- jQuery.farbtastic( '#' + picker ).linkTo( this );
27
- jQuery( '#' + picker ).slideDown();
28
- } );
 
 
 
29
 
30
- jQuery( this ).on( 'focusout', function() {
31
- jQuery( '#' + picker ).slideUp();
32
- } );
 
 
 
33
 
34
- jQuery( this ).trigger( 'focus' );
35
- } );
36
- jQuery( '.colorpickerField' ).each( function() {
37
- jQuery.farbtastic( '#' + this.id ).linkTo( this );
38
- } );
39
- } );
 
 
 
 
3
  // Version 1.2 - Initialise the colour fields on page load so they are the correct colour
4
  // Version 1.3 - eslinted
5
 
6
+ jQuery( document ).ready(
7
+ function() {
8
+ jQuery( document ).on(
9
+ 'focus',
10
+ '.colorpickerField',
11
+ function() {
12
+ var picker,
13
+ field = this.id.substr( 0, 20 );
14
 
15
+ if ( jQuery( this ).is( '.s2_initialised' ) || -1 !== this.id.search( '__i__' ) ) {
16
+ return; // exit early, already initialized or not activated
17
+ }
18
 
19
+ jQuery( this ).addClass( 's2_initialised' );
20
 
21
+ jQuery( '.s2_colorpicker' ).each(
22
+ function() {
23
+ if ( -1 !== this.id.search( field ) ) {
24
+ picker = this.id;
25
+ return false; // stop looping
26
+ }
27
+ }
28
+ );
29
 
30
+ jQuery( this ).on(
31
+ 'focusin',
32
+ function() {
33
+ jQuery( '.s2_colorpicker' ).slideUp();
34
+ jQuery.farbtastic( '#' + picker ).linkTo( this );
35
+ jQuery( '#' + picker ).slideDown();
36
+ }
37
+ );
38
 
39
+ jQuery( this ).on(
40
+ 'focusout',
41
+ function() {
42
+ jQuery( '#' + picker ).slideUp();
43
+ }
44
+ );
45
 
46
+ jQuery( this ).trigger( 'focus' );
47
+ }
48
+ );
49
+ jQuery( '.colorpickerField' ).each(
50
+ function() {
51
+ jQuery.farbtastic( '#' + this.id ).linkTo( this );
52
+ }
53
+ );
54
+ }
55
+ );
include/s2-date-time.js CHANGED
@@ -1,8 +1,12 @@
1
  // Version 1.0 - original version
2
  // Version 1.1 - eslinted
3
 
4
- jQuery( document ).ready( function() {
5
- jQuery( '#s2datepicker' ).datepicker( {
6
- dateFormat: 'MM d, yy'
7
- } );
8
- } );
 
 
 
 
1
  // Version 1.0 - original version
2
  // Version 1.1 - eslinted
3
 
4
+ jQuery( document ).ready(
5
+ function() {
6
+ jQuery( '#s2datepicker' ).datepicker(
7
+ {
8
+ dateFormat: 'MM d, yy'
9
+ }
10
+ );
11
+ }
12
+ );
include/s2-dismiss.js CHANGED
@@ -2,12 +2,16 @@
2
  // Version 1.0 - original version
3
  // Version 1.1 - eslinted
4
 
5
- jQuery( document ).on( 'click', '#sender_message .notice-dismiss', function() {
6
- var ajaxurl = s2DismissScriptStrings.ajaxurl;
7
- var data = {
8
- 'action': 's2_dismiss_notice',
9
- 'nonce': s2DismissScriptStrings.nonce
 
 
 
10
 
11
- };
12
- jQuery.post( ajaxurl, data );
13
- } );
 
2
  // Version 1.0 - original version
3
  // Version 1.1 - eslinted
4
 
5
+ jQuery( document ).on(
6
+ 'click',
7
+ '#sender_message .notice-dismiss',
8
+ function() {
9
+ var ajaxurl = s2DismissScriptStrings.ajaxurl;
10
+ var data = {
11
+ 'action': 's2_dismiss_notice',
12
+ 'nonce': s2DismissScriptStrings.nonce
13
 
14
+ };
15
+ jQuery.post( ajaxurl, data );
16
+ }
17
+ );
include/s2-edit.js CHANGED
@@ -5,11 +5,13 @@
5
  // Version 1.3 - eslinted
6
 
7
  // hide our span before page loads
8
- jQuery( document ).ready( function() {
9
- jQuery( '#s2bcclimit_2' ).hide();
10
- jQuery( '#s2entries_2' ).hide();
11
- jQuery( '#s2cron_2' ).hide();
12
- } );
 
 
13
 
14
  //show span on clicking the edit link
15
  function s2Show( id ) {
@@ -53,9 +55,11 @@ function s2CronRevert( id ) {
53
  jQuery( 'input[name="' + id + 'date"]' ).val( date );
54
  jQuery( '#s2' + id + 'date' ).html( date );
55
  time = jQuery( '#js' + id + 'time' ).val();
56
- jQuery( '[name=' + id + 'time] option' ).filter( function() {
57
- return ( this.text === time );
58
- } ).prop( 'selected', true ).parent().focus();
 
 
59
  jQuery( '#s2' + id + 'time' ).html( time );
60
  s2Hide( id );
61
  }
5
  // Version 1.3 - eslinted
6
 
7
  // hide our span before page loads
8
+ jQuery( document ).ready(
9
+ function() {
10
+ jQuery( '#s2bcclimit_2' ).hide();
11
+ jQuery( '#s2entries_2' ).hide();
12
+ jQuery( '#s2cron_2' ).hide();
13
+ }
14
+ );
15
 
16
  //show span on clicking the edit link
17
  function s2Show( id ) {
55
  jQuery( 'input[name="' + id + 'date"]' ).val( date );
56
  jQuery( '#s2' + id + 'date' ).html( date );
57
  time = jQuery( '#js' + id + 'time' ).val();
58
+ jQuery( '[name=' + id + 'time] option' ).filter(
59
+ function() {
60
+ return ( this.text === time );
61
+ }
62
+ ).prop( 'selected', true ).parent().focus();
63
  jQuery( '#s2' + id + 'time' ).html( time );
64
  s2Hide( id );
65
  }
include/s2-ip-updater.js CHANGED
@@ -3,10 +3,11 @@
3
  // Version 1.1 - eslinted and fixed for Widget form name change
4
 
5
  function getip( json ) {
6
- var ip, i;
7
  if ( true === document.body.contains( document.forms.s2form ) || true === document.body.contains( document.forms.s2formwidget ) ) {
8
  ip = document.getElementsByName( 'ip' );
9
- for ( i = 0; i < ip.length; i++ ) {
 
10
  if ( 's2form' === ip[i].parentElement.name ) {
11
  ip[i].value = json.ip;
12
  }
3
  // Version 1.1 - eslinted and fixed for Widget form name change
4
 
5
  function getip( json ) {
6
+ var ip, i, l;
7
  if ( true === document.body.contains( document.forms.s2form ) || true === document.body.contains( document.forms.s2formwidget ) ) {
8
  ip = document.getElementsByName( 'ip' );
9
+ l = ip.length;
10
+ for ( i = 0; i < l; i++ ) {
11
  if ( 's2form' === ip[i].parentElement.name ) {
12
  ip[i].value = json.ip;
13
  }
include/s2-ip-updater.min.js CHANGED
@@ -1 +1 @@
1
- function getip(e){var n,o;if(!0===document.body.contains(document.forms.s2form)||!0===document.body.contains(document.forms.s2formwidget))for(n=document.getElementsByName("ip"),o=0;o<n.length;o++)"s2form"===n[o].parentElement.name&&(n[o].value=e.ip)}
1
+ function getip(e){var n,o,t;if(!0===document.body.contains(document.forms.s2form)||!0===document.body.contains(document.forms.s2formwidget))for(t=(n=document.getElementsByName("ip")).length,o=0;o<t;o++)"s2form"===n[o].parentElement.name&&(n[o].value=e.ip)}
include/s2-subscribers.js CHANGED
@@ -9,16 +9,16 @@
9
 
10
  function s2BulkActionCheck() {
11
  if ( null !== document.getElementById( 'doaction' ) ) {
12
- document.getElementById( 'doaction' ).onclick = submitHandler;
13
  document.getElementById( 'doaction2' ).onclick = submitHandler;
14
  }
15
  }
16
  function submitHandler() {
17
  var location, action1, action2, agree, selected;
18
  location = document.getElementById( 's2_location' );
19
- action1 = document.getElementById( 'bulk-action-selector-top' );
20
- action2 = document.getElementById( 'bulk-action-selector-bottom' );
21
- agree = false;
22
  selected = document.querySelectorAll( 'input[name="subscriber[]"]:checked' ).length;
23
  if ( 0 === selected ) {
24
  return true;
@@ -44,7 +44,7 @@ function submitHandler() {
44
  }
45
  function bmCheck() {
46
  var agree, selected;
47
- agree = false;
48
  selected = document.querySelectorAll( 'input[name="subscriber[]"]:checked' ).length;
49
  if ( 0 === selected ) {
50
  agree = window.confirm( s2ScriptStrings.bulk_manage_all );
9
 
10
  function s2BulkActionCheck() {
11
  if ( null !== document.getElementById( 'doaction' ) ) {
12
+ document.getElementById( 'doaction' ).onclick = submitHandler;
13
  document.getElementById( 'doaction2' ).onclick = submitHandler;
14
  }
15
  }
16
  function submitHandler() {
17
  var location, action1, action2, agree, selected;
18
  location = document.getElementById( 's2_location' );
19
+ action1 = document.getElementById( 'bulk-action-selector-top' );
20
+ action2 = document.getElementById( 'bulk-action-selector-bottom' );
21
+ agree = false;
22
  selected = document.querySelectorAll( 'input[name="subscriber[]"]:checked' ).length;
23
  if ( 0 === selected ) {
24
  return true;
44
  }
45
  function bmCheck() {
46
  var agree, selected;
47
+ agree = false;
48
  selected = document.querySelectorAll( 'input[name="subscriber[]"]:checked' ).length;
49
  if ( 0 === selected ) {
50
  agree = window.confirm( s2ScriptStrings.bulk_manage_all );
subscribe2.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Subscribe2
4
  Plugin URI: https://subscribe2.wordpress.com/
5
  Description: Notifies an email list when new entries are posted.
6
- Version: 10.26.1
7
  Author: Subscribe2
8
  Author URI: https://subscribe2.wordpress.com/
9
  Licence: GPLv3
@@ -54,7 +54,7 @@ if ( is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
54
 
55
  // our version number. Don't touch this or any line below
56
  // unless you know exactly what you are doing
57
- define( 'S2VERSION', '10.26.1' );
58
  define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
59
  define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
60
  define( 'S2URL', plugin_dir_url( dirname( __FILE__ ) ) . S2DIR );
3
  Plugin Name: Subscribe2
4
  Plugin URI: https://subscribe2.wordpress.com/
5
  Description: Notifies an email list when new entries are posted.
6
+ Version: 10.27
7
  Author: Subscribe2
8
  Author URI: https://subscribe2.wordpress.com/
9
  Licence: GPLv3
54
 
55
  // our version number. Don't touch this or any line below
56
  // unless you know exactly what you are doing
57
+ define( 'S2VERSION', '10.27' );
58
  define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
59
  define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
60
  define( 'S2URL', plugin_dir_url( dirname( __FILE__ ) ) . S2DIR );
subscribe2.pot CHANGED
@@ -1,75 +1,79 @@
1
- #, fuzzy
 
2
  msgid ""
3
  msgstr ""
4
- "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
- "Project-Id-Version: Subscribe2\n"
6
- "POT-Creation-Date: 2019-02-03 14:02+0100\n"
7
- "PO-Revision-Date: 2019-01-25 22:54+0100\n"
8
- "Last-Translator: \n"
9
- "Language-Team: \n"
10
  "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.8.12\n"
14
- "X-Poedit-Basepath: .\n"
15
- "X-Poedit-WPHeader: subscribe2.php\n"
 
 
 
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
- "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
- "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
19
- "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
 
20
  "X-Poedit-SearchPath-0: .\n"
21
- "X-Poedit-SearchPathExcluded-0: *.js\n"
 
 
22
 
23
  #: admin/send-email.php:11 admin/settings.php:11 admin/subscribers.php:32
24
  #: admin/your-subscriptions.php:13
25
  msgid "Security error! Your request cannot be completed."
26
  msgstr ""
27
 
28
- #: admin/send-email.php:79
29
  msgid "Your email was empty"
30
  msgstr ""
31
 
32
- #: admin/send-email.php:86
33
  msgid "Check your settings and check with your hosting provider"
34
  msgstr ""
35
 
36
- #: admin/send-email.php:91
37
  msgid "Preview message sent!"
38
  msgstr ""
39
 
40
- #: admin/send-email.php:93
41
  msgid "Message sent!"
42
  msgstr ""
43
 
44
- #: admin/send-email.php:97
45
  msgid "Message failed!"
46
  msgstr ""
47
 
48
- #: admin/send-email.php:104
49
  msgid "Send an email to subscribers"
50
  msgstr ""
51
 
52
- #: admin/send-email.php:112
53
  msgid "A message from"
54
  msgstr ""
55
 
56
- #: admin/send-email.php:117
57
  msgid "Subject"
58
  msgstr ""
59
 
60
- #: admin/send-email.php:120
61
  msgid "Add More Files"
62
  msgstr ""
63
 
64
- #: admin/send-email.php:122
65
  msgid "Recipients:"
66
  msgstr ""
67
 
68
- #: admin/send-email.php:125
69
  msgid "Preview"
70
  msgstr ""
71
 
72
- #: admin/send-email.php:125
73
  msgid "Send"
74
  msgstr ""
75
 
@@ -114,7 +118,7 @@ msgid ""
114
  msgstr ""
115
 
116
  #: admin/settings.php:166
117
- #, php-format
118
  msgid ""
119
  "You appear to be sending notifications from %1$s, which has a different "
120
  "domain name than your blog server %2$s. This may result in failed emails."
@@ -210,8 +214,7 @@ msgid "Send Emails for Pages"
210
  msgstr ""
211
 
212
  #: admin/settings.php:233
213
- msgid ""
214
- "Subscribe2 will send email notifications for the following custom post types"
215
  msgstr ""
216
 
217
  #: admin/settings.php:239
@@ -252,8 +255,9 @@ msgstr ""
252
 
253
  #: admin/settings.php:271
254
  msgid ""
255
- "eg. utm_source=subscribe2&amp;utm_medium=email&amp;"
256
- "utm_campaign=postnotify&amp;utm_id={ID}&amp;utm_title={TITLE}"
 
257
  msgstr ""
258
 
259
  #: admin/settings.php:282
@@ -273,8 +277,7 @@ msgid "Message substitutions"
273
  msgstr ""
274
 
275
  #: admin/settings.php:291
276
- msgid ""
277
- "IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED"
278
  msgstr ""
279
 
280
  #: admin/settings.php:294
@@ -385,8 +388,7 @@ msgid "Compulsory Categories"
385
  msgstr ""
386
 
387
  #: admin/settings.php:338
388
- msgid ""
389
- "Compulsory categories will be checked by default for Registered Subscribers"
390
  msgstr ""
391
 
392
  #: admin/settings.php:345
@@ -529,8 +531,8 @@ msgstr ""
529
 
530
  #: admin/settings.php:479
531
  msgid ""
532
- "Use javascript to update IP address in Subscribe2 HTML form data? (useful if "
533
- "caching is enabled)"
534
  msgstr ""
535
 
536
  #: admin/settings.php:487
@@ -545,8 +547,8 @@ msgstr ""
545
 
546
  #: admin/settings.php:490
547
  msgid ""
548
- "Use a new line for each entry and omit the \"@\" symbol, for example !email."
549
- "com, hotmail.com, yahoo.*"
550
  msgstr ""
551
 
552
  #: admin/settings.php:493
@@ -579,8 +581,8 @@ msgstr ""
579
 
580
  #: admin/settings.php:508
581
  msgid ""
582
- "Use this to reset all options to their defaults. This <strong><em>will not</"
583
- "em></strong> modify your list of subscribers."
584
  msgstr ""
585
 
586
  #: admin/settings.php:510
@@ -602,8 +604,7 @@ msgid ""
602
  msgstr ""
603
 
604
  #: admin/subscribers.php:72
605
- msgid ""
606
- "Some emails were not processed, the following are already Public Subscribers"
607
  msgstr ""
608
 
609
  #: admin/subscribers.php:75
@@ -611,8 +612,7 @@ msgid "Some emails were not processed, the following were not in the database"
611
  msgstr ""
612
 
613
  #: admin/subscribers.php:78
614
- msgid ""
615
- "Some emails were not processed, the following were invalid email addresses"
616
  msgstr ""
617
 
618
  #: admin/subscribers.php:86
@@ -746,8 +746,6 @@ msgid "Update Preferences"
746
  msgstr ""
747
 
748
  #. Plugin Name of the plugin/theme
749
- #. Author of the plugin/theme
750
- #: classes/class-s2-admin.php:8 classes/class-s2-form-widget.php:24
751
  msgid "Subscribe2"
752
  msgstr ""
753
 
@@ -774,9 +772,9 @@ msgstr ""
774
  #: classes/class-s2-admin.php:51
775
  msgid ""
776
  "From this page you can control your subscription preferences. Choose the "
777
- "email format you wish to receive, which categories you would like to receive "
778
- "notification for and depending on the site settings which authors you would "
779
- "like to read."
780
  msgstr ""
781
 
782
  #: classes/class-s2-admin.php:63
@@ -813,7 +811,8 @@ msgid ""
813
  "On this page registered subscribers can be viewed and searched. User "
814
  "accounts can be deleted from here with any posts created by those users "
815
  "being assigned to the currently logged in user. Bulk changes can be applied "
816
- "to all user settings changing their subscription email format and categories."
 
817
  msgstr ""
818
 
819
  #: classes/class-s2-admin.php:88
@@ -858,7 +857,8 @@ msgstr ""
858
 
859
  #: classes/class-s2-admin.php:127
860
  msgid ""
861
- "This section allows you to customise the content of your notification emails."
 
862
  msgstr ""
863
 
864
  #: classes/class-s2-admin.php:128
@@ -899,9 +899,9 @@ msgstr ""
899
 
900
  #: classes/class-s2-admin.php:139
901
  msgid ""
902
- "A set of default settings for new users can also be specified using the Auto "
903
- "Subscribe section. Settings specified here will be applied to any newly "
904
- "created user accounts while Subscribe2 is activated."
905
  msgstr ""
906
 
907
  #: classes/class-s2-admin.php:146
@@ -1017,13 +1017,7 @@ msgid "Subscribe2 Notification Override"
1017
  msgstr ""
1018
 
1019
  #: classes/class-s2-admin.php:386 gutenberg/gutenberg-translations.php:20
1020
- msgid ""
1021
- "Check here to disable sending of an email notification for this post/page"
1022
- msgstr ""
1023
-
1024
- #: classes/class-s2-admin.php:490
1025
- msgctxt "Comma Separated Column Header names for CSV Export"
1026
- msgid "User Email,User Type,User Name,Confirm Date,IP"
1027
  msgstr ""
1028
 
1029
  #: classes/class-s2-admin.php:511
@@ -1106,8 +1100,7 @@ msgid "Receive notifications"
1106
  msgstr ""
1107
 
1108
  #: classes/class-s2-admin.php:1049
1109
- msgid ""
1110
- "Check if you want to receive email notification when new posts are published"
1111
  msgstr ""
1112
 
1113
  #: classes/class-s2-ajax.php:41
@@ -1138,14 +1131,13 @@ msgid "Slow down, you move too fast."
1138
  msgstr ""
1139
 
1140
  #: classes/class-s2-ajax.php:98 classes/class-s2-frontend.php:8
1141
- #, php-format
1142
  msgid "To manage your subscription options please <a href=\"%1$s\">login.</a>"
1143
  msgstr ""
1144
 
1145
  #: classes/class-s2-ajax.php:108 classes/class-s2-ajax.php:122
1146
  #: classes/class-s2-frontend.php:34
1147
- msgid ""
1148
- "Sorry, there seems to be an error on the server. Please try again later."
1149
  msgstr ""
1150
 
1151
  #: classes/class-s2-ajax.php:112 classes/class-s2-frontend.php:26
@@ -1156,61 +1148,61 @@ msgstr ""
1156
  msgid "That email address is not subscribed."
1157
  msgstr ""
1158
 
1159
- #: classes/class-s2-core.php:552
1160
  msgid "Plain Text Excerpt Preview"
1161
  msgstr ""
1162
 
1163
- #: classes/class-s2-core.php:554
1164
  msgid "Plain Text Full Preview"
1165
  msgstr ""
1166
 
1167
- #: classes/class-s2-core.php:556
1168
  msgid "HTML Excerpt Preview"
1169
  msgstr ""
1170
 
1171
- #: classes/class-s2-core.php:558
1172
  msgid "HTML Full Preview"
1173
  msgstr ""
1174
 
1175
- #: classes/class-s2-core.php:1205
1176
  msgid "Check here to Subscribe to email notifications for new posts"
1177
  msgstr ""
1178
 
1179
- #: classes/class-s2-core.php:1210
1180
  msgid ""
1181
  "By registering with this blog you are also agreeing to receive email "
1182
  "notifications for new posts but you can unsubscribe at anytime"
1183
  msgstr ""
1184
 
1185
- #: classes/class-s2-core.php:1238
1186
  msgid "Check here to Subscribe to notifications for new posts"
1187
  msgstr ""
1188
 
1189
- #: classes/class-s2-core.php:1357
1190
  msgid "Weekly"
1191
  msgstr ""
1192
 
1193
- #: classes/class-s2-core.php:1570 classes/class-s2-core.php:1571
1194
  msgid "Author"
1195
  msgstr ""
1196
 
1197
- #: classes/class-s2-core.php:1577
1198
  msgid "Posted on"
1199
  msgstr ""
1200
 
1201
- #: classes/class-s2-core.php:1601 classes/class-s2-core.php:1602
1202
  msgid "Posted in"
1203
  msgstr ""
1204
 
1205
- #: classes/class-s2-core.php:1613 classes/class-s2-core.php:1614
1206
  msgid "Tagged as"
1207
  msgstr ""
1208
 
1209
- #: classes/class-s2-core.php:1692
1210
  msgid "Digest Email"
1211
  msgstr ""
1212
 
1213
- #: classes/class-s2-core.php:1705
1214
  msgid "Digest Preview"
1215
  msgstr ""
1216
 
@@ -1403,14 +1395,14 @@ msgid "Subscription preferences updated."
1403
  msgstr ""
1404
 
1405
  #: classes/class-s2-frontend.php:12
1406
- #, php-format
1407
  msgid ""
1408
- "You may manage your subscription options from your <a href=\"%1$s\">profile</"
1409
- "a>"
1410
  msgstr ""
1411
 
1412
  #: classes/class-s2-frontend.php:20
1413
- #, php-format
1414
  msgid ""
1415
  "<a href=\"%1$s\">Subscribe</a> to email notifications when this blog posts "
1416
  "new content."
@@ -1472,18 +1464,6 @@ msgstr ""
1472
  msgid "[Un]Subscribe to Posts"
1473
  msgstr ""
1474
 
1475
- #: classes/class-s2-list-table-legacy.php:75
1476
- #: classes/class-s2-list-table-legacy.php:80 classes/class-s2-list-table.php:75
1477
- #: classes/class-s2-list-table.php:80
1478
- msgctxt "column name"
1479
- msgid "Email"
1480
- msgstr ""
1481
-
1482
- #: classes/class-s2-list-table-legacy.php:81 classes/class-s2-list-table.php:81
1483
- msgctxt "column name"
1484
- msgid "Date"
1485
- msgstr ""
1486
-
1487
  #: classes/class-s2-list-table-legacy.php:131
1488
  #: classes/class-s2-list-table.php:131
1489
  msgid "Select All"
@@ -1529,7 +1509,7 @@ msgstr ""
1529
 
1530
  #: classes/class-s2-list-table-legacy.php:259
1531
  #: classes/class-s2-list-table.php:266
1532
- #, php-format
1533
  msgid "%s item"
1534
  msgid_plural "%s items"
1535
  msgstr[0] ""
@@ -1547,13 +1527,6 @@ msgstr ""
1547
  msgid "Current page"
1548
  msgstr ""
1549
 
1550
- #: classes/class-s2-list-table-legacy.php:333
1551
- #: classes/class-s2-list-table.php:357
1552
- #, php-format
1553
- msgctxt "paging"
1554
- msgid "%1$s of %2$s"
1555
- msgstr ""
1556
-
1557
  #: classes/class-s2-list-table-legacy.php:338
1558
  msgid "Go to the next page"
1559
  msgstr ""
@@ -1582,25 +1555,6 @@ msgstr ""
1582
  msgid "Last page"
1583
  msgstr ""
1584
 
1585
- #: classes/mo-notice.php:60
1586
- #, php-format
1587
- msgid ""
1588
- "Free optin form plugin that will %1$sincrease your email list subscribers"
1589
- "%2$s and keep them engaged with %1$sautomated and schedule newsletters%2$s."
1590
- msgstr ""
1591
-
1592
- #: classes/mo-notice.php:69
1593
- msgid "Install MailOptin Now for Free!"
1594
- msgstr ""
1595
-
1596
- #: classes/mo-notice.php:74
1597
- msgid "Activate MailOptin Now!"
1598
- msgstr ""
1599
-
1600
- #: classes/mo-notice.php:83
1601
- msgid "Dismiss this notice"
1602
- msgstr ""
1603
-
1604
  #: gutenberg/gutenberg-translations.php:5
1605
  msgid "Subscribe2 HTML"
1606
  msgstr ""
@@ -1701,9 +1655,14 @@ msgstr ""
1701
  #: include/options.php:148
1702
  msgid ""
1703
  "{BLOGNAME} has received a request to {ACTION} for this email address. To "
1704
- "complete your request please click on the link below:\\n\\n{LINK}\\n\\nIf "
1705
- "you did not request this, please feel free to disregard this notice!\\n"
1706
- "\\nThank you,\\n{MYNAME}."
 
 
 
 
 
1707
  msgstr ""
1708
 
1709
  #: include/options.php:152
@@ -1713,10 +1672,17 @@ msgstr ""
1713
  #: include/options.php:156
1714
  msgid ""
1715
  "This email address was subscribed for notifications at {BLOGNAME} "
1716
- "({BLOGLINK}) but the subscription remains incomplete.\\n\\nIf you wish to "
1717
- "complete your subscription please click on the link below:\\n\\n{LINK}\\n"
1718
- "\\nIf you do not wish to complete your subscription please ignore this email "
1719
- "and your address will be removed from our database.\\n\\nRegards,\\n{MYNAME}"
 
 
 
 
 
 
 
1720
  msgstr ""
1721
 
1722
  #: include/options.php:160
@@ -1728,7 +1694,8 @@ msgid "I'm just a plugin, please don't call me directly"
1728
  msgstr ""
1729
 
1730
  #: subscribe2.php:39
1731
- #, php-format
 
1732
  msgid ""
1733
  "This version of Subscribe2 requires WordPress 3.3 or greater. Please update "
1734
  "%1$s or use an older version of %2$s."
@@ -1740,7 +1707,6 @@ msgid ""
1740
  "on a site level"
1741
  msgstr ""
1742
 
1743
- #. Plugin URI of the plugin/theme
1744
  #. Author URI of the plugin/theme
1745
  msgid "https://subscribe2.wordpress.com/"
1746
  msgstr ""
@@ -1748,3 +1714,31 @@ msgstr ""
1748
  #. Description of the plugin/theme
1749
  msgid "Notifies an email list when new entries are posted."
1750
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2019 Matthew Robinson, Tanay Lakhani, Bryan Hadaway
2
+ # This file is distributed under the same license as the Subscribe2 package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Subscribe2 10.27\n"
6
+ "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/subscribe2\n"
7
+ "POT-Creation-Date: 2019-02-24 11:49:50+00:00\n"
 
 
 
8
  "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=utf-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+ "Language: en\n"
15
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
+ "X-Poedit-Country: United States\n"
17
  "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: "
19
+ "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
20
+ "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
21
+ "X-Poedit-Basepath: ../\n"
22
  "X-Poedit-SearchPath-0: .\n"
23
+ "X-Poedit-Bookmarks: \n"
24
+ "X-Textdomain-Support: yes\n"
25
+ "X-Generator: grunt-wp-i18n 1.0.3\n"
26
 
27
  #: admin/send-email.php:11 admin/settings.php:11 admin/subscribers.php:32
28
  #: admin/your-subscriptions.php:13
29
  msgid "Security error! Your request cannot be completed."
30
  msgstr ""
31
 
32
+ #: admin/send-email.php:80
33
  msgid "Your email was empty"
34
  msgstr ""
35
 
36
+ #: admin/send-email.php:87
37
  msgid "Check your settings and check with your hosting provider"
38
  msgstr ""
39
 
40
+ #: admin/send-email.php:92
41
  msgid "Preview message sent!"
42
  msgstr ""
43
 
44
+ #: admin/send-email.php:94
45
  msgid "Message sent!"
46
  msgstr ""
47
 
48
+ #: admin/send-email.php:98
49
  msgid "Message failed!"
50
  msgstr ""
51
 
52
+ #: admin/send-email.php:105
53
  msgid "Send an email to subscribers"
54
  msgstr ""
55
 
56
+ #: admin/send-email.php:113
57
  msgid "A message from"
58
  msgstr ""
59
 
60
+ #: admin/send-email.php:118
61
  msgid "Subject"
62
  msgstr ""
63
 
64
+ #: admin/send-email.php:121
65
  msgid "Add More Files"
66
  msgstr ""
67
 
68
+ #: admin/send-email.php:123
69
  msgid "Recipients:"
70
  msgstr ""
71
 
72
+ #: admin/send-email.php:126
73
  msgid "Preview"
74
  msgstr ""
75
 
76
+ #: admin/send-email.php:126
77
  msgid "Send"
78
  msgstr ""
79
 
118
  msgstr ""
119
 
120
  #: admin/settings.php:166
121
+ #. Translators: Warning message
122
  msgid ""
123
  "You appear to be sending notifications from %1$s, which has a different "
124
  "domain name than your blog server %2$s. This may result in failed emails."
214
  msgstr ""
215
 
216
  #: admin/settings.php:233
217
+ msgid "Subscribe2 will send email notifications for the following custom post types"
 
218
  msgstr ""
219
 
220
  #: admin/settings.php:239
255
 
256
  #: admin/settings.php:271
257
  msgid ""
258
+ "eg. "
259
+ "utm_source=subscribe2&amp;utm_medium=email&amp;utm_campaign=postnotify&"
260
+ "amp;utm_id={ID}&amp;utm_title={TITLE}"
261
  msgstr ""
262
 
263
  #: admin/settings.php:282
277
  msgstr ""
278
 
279
  #: admin/settings.php:291
280
+ msgid "IF THE FOLLOWING KEYWORDS ARE ALSO IN YOUR POST THEY WILL BE SUBSTITUTED"
 
281
  msgstr ""
282
 
283
  #: admin/settings.php:294
388
  msgstr ""
389
 
390
  #: admin/settings.php:338
391
+ msgid "Compulsory categories will be checked by default for Registered Subscribers"
 
392
  msgstr ""
393
 
394
  #: admin/settings.php:345
531
 
532
  #: admin/settings.php:479
533
  msgid ""
534
+ "Use javascript to update IP address in Subscribe2 HTML form data? (useful "
535
+ "if caching is enabled)"
536
  msgstr ""
537
 
538
  #: admin/settings.php:487
547
 
548
  #: admin/settings.php:490
549
  msgid ""
550
+ "Use a new line for each entry and omit the \"@\" symbol, for example "
551
+ "!email.com, hotmail.com, yahoo.*"
552
  msgstr ""
553
 
554
  #: admin/settings.php:493
581
 
582
  #: admin/settings.php:508
583
  msgid ""
584
+ "Use this to reset all options to their defaults. This <strong><em>will "
585
+ "not</em></strong> modify your list of subscribers."
586
  msgstr ""
587
 
588
  #: admin/settings.php:510
604
  msgstr ""
605
 
606
  #: admin/subscribers.php:72
607
+ msgid "Some emails were not processed, the following are already Public Subscribers"
 
608
  msgstr ""
609
 
610
  #: admin/subscribers.php:75
612
  msgstr ""
613
 
614
  #: admin/subscribers.php:78
615
+ msgid "Some emails were not processed, the following were invalid email addresses"
 
616
  msgstr ""
617
 
618
  #: admin/subscribers.php:86
746
  msgstr ""
747
 
748
  #. Plugin Name of the plugin/theme
 
 
749
  msgid "Subscribe2"
750
  msgstr ""
751
 
772
  #: classes/class-s2-admin.php:51
773
  msgid ""
774
  "From this page you can control your subscription preferences. Choose the "
775
+ "email format you wish to receive, which categories you would like to "
776
+ "receive notification for and depending on the site settings which authors "
777
+ "you would like to read."
778
  msgstr ""
779
 
780
  #: classes/class-s2-admin.php:63
811
  "On this page registered subscribers can be viewed and searched. User "
812
  "accounts can be deleted from here with any posts created by those users "
813
  "being assigned to the currently logged in user. Bulk changes can be applied "
814
+ "to all user settings changing their subscription email format and "
815
+ "categories."
816
  msgstr ""
817
 
818
  #: classes/class-s2-admin.php:88
857
 
858
  #: classes/class-s2-admin.php:127
859
  msgid ""
860
+ "This section allows you to customise the content of your notification "
861
+ "emails."
862
  msgstr ""
863
 
864
  #: classes/class-s2-admin.php:128
899
 
900
  #: classes/class-s2-admin.php:139
901
  msgid ""
902
+ "A set of default settings for new users can also be specified using the "
903
+ "Auto Subscribe section. Settings specified here will be applied to any "
904
+ "newly created user accounts while Subscribe2 is activated."
905
  msgstr ""
906
 
907
  #: classes/class-s2-admin.php:146
1017
  msgstr ""
1018
 
1019
  #: classes/class-s2-admin.php:386 gutenberg/gutenberg-translations.php:20
1020
+ msgid "Check here to disable sending of an email notification for this post/page"
 
 
 
 
 
 
1021
  msgstr ""
1022
 
1023
  #: classes/class-s2-admin.php:511
1100
  msgstr ""
1101
 
1102
  #: classes/class-s2-admin.php:1049
1103
+ msgid "Check if you want to receive email notification when new posts are published"
 
1104
  msgstr ""
1105
 
1106
  #: classes/class-s2-ajax.php:41
1131
  msgstr ""
1132
 
1133
  #: classes/class-s2-ajax.php:98 classes/class-s2-frontend.php:8
1134
+ #. Translators: Link to login page
1135
  msgid "To manage your subscription options please <a href=\"%1$s\">login.</a>"
1136
  msgstr ""
1137
 
1138
  #: classes/class-s2-ajax.php:108 classes/class-s2-ajax.php:122
1139
  #: classes/class-s2-frontend.php:34
1140
+ msgid "Sorry, there seems to be an error on the server. Please try again later."
 
1141
  msgstr ""
1142
 
1143
  #: classes/class-s2-ajax.php:112 classes/class-s2-frontend.php:26
1148
  msgid "That email address is not subscribed."
1149
  msgstr ""
1150
 
1151
+ #: classes/class-s2-core.php:537
1152
  msgid "Plain Text Excerpt Preview"
1153
  msgstr ""
1154
 
1155
+ #: classes/class-s2-core.php:539
1156
  msgid "Plain Text Full Preview"
1157
  msgstr ""
1158
 
1159
+ #: classes/class-s2-core.php:541
1160
  msgid "HTML Excerpt Preview"
1161
  msgstr ""
1162
 
1163
+ #: classes/class-s2-core.php:543
1164
  msgid "HTML Full Preview"
1165
  msgstr ""
1166
 
1167
+ #: classes/class-s2-core.php:1227
1168
  msgid "Check here to Subscribe to email notifications for new posts"
1169
  msgstr ""
1170
 
1171
+ #: classes/class-s2-core.php:1232
1172
  msgid ""
1173
  "By registering with this blog you are also agreeing to receive email "
1174
  "notifications for new posts but you can unsubscribe at anytime"
1175
  msgstr ""
1176
 
1177
+ #: classes/class-s2-core.php:1260
1178
  msgid "Check here to Subscribe to notifications for new posts"
1179
  msgstr ""
1180
 
1181
+ #: classes/class-s2-core.php:1379
1182
  msgid "Weekly"
1183
  msgstr ""
1184
 
1185
+ #: classes/class-s2-core.php:1592 classes/class-s2-core.php:1593
1186
  msgid "Author"
1187
  msgstr ""
1188
 
1189
+ #: classes/class-s2-core.php:1599
1190
  msgid "Posted on"
1191
  msgstr ""
1192
 
1193
+ #: classes/class-s2-core.php:1626 classes/class-s2-core.php:1627
1194
  msgid "Posted in"
1195
  msgstr ""
1196
 
1197
+ #: classes/class-s2-core.php:1640 classes/class-s2-core.php:1641
1198
  msgid "Tagged as"
1199
  msgstr ""
1200
 
1201
+ #: classes/class-s2-core.php:1712
1202
  msgid "Digest Email"
1203
  msgstr ""
1204
 
1205
+ #: classes/class-s2-core.php:1725
1206
  msgid "Digest Preview"
1207
  msgstr ""
1208
 
1395
  msgstr ""
1396
 
1397
  #: classes/class-s2-frontend.php:12
1398
+ #. Translators: Link to Profile page
1399
  msgid ""
1400
+ "You may manage your subscription options from your <a "
1401
+ "href=\"%1$s\">profile</a>"
1402
  msgstr ""
1403
 
1404
  #: classes/class-s2-frontend.php:20
1405
+ #. Translators: Link to Profile page
1406
  msgid ""
1407
  "<a href=\"%1$s\">Subscribe</a> to email notifications when this blog posts "
1408
  "new content."
1464
  msgid "[Un]Subscribe to Posts"
1465
  msgstr ""
1466
 
 
 
 
 
 
 
 
 
 
 
 
 
1467
  #: classes/class-s2-list-table-legacy.php:131
1468
  #: classes/class-s2-list-table.php:131
1469
  msgid "Select All"
1509
 
1510
  #: classes/class-s2-list-table-legacy.php:259
1511
  #: classes/class-s2-list-table.php:266
1512
+ #. Translators: Pagination
1513
  msgid "%s item"
1514
  msgid_plural "%s items"
1515
  msgstr[0] ""
1527
  msgid "Current page"
1528
  msgstr ""
1529
 
 
 
 
 
 
 
 
1530
  #: classes/class-s2-list-table-legacy.php:338
1531
  msgid "Go to the next page"
1532
  msgstr ""
1555
  msgid "Last page"
1556
  msgstr ""
1557
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1558
  #: gutenberg/gutenberg-translations.php:5
1559
  msgid "Subscribe2 HTML"
1560
  msgstr ""
1655
  #: include/options.php:148
1656
  msgid ""
1657
  "{BLOGNAME} has received a request to {ACTION} for this email address. To "
1658
+ "complete your request please click on the link below:\\n"
1659
+ "\\n"
1660
+ "{LINK}\\n"
1661
+ "\\n"
1662
+ "If you did not request this, please feel free to disregard this notice!\\n"
1663
+ "\\n"
1664
+ "Thank you,\\n"
1665
+ "{MYNAME}."
1666
  msgstr ""
1667
 
1668
  #: include/options.php:152
1672
  #: include/options.php:156
1673
  msgid ""
1674
  "This email address was subscribed for notifications at {BLOGNAME} "
1675
+ "({BLOGLINK}) but the subscription remains incomplete.\\n"
1676
+ "\\n"
1677
+ "If you wish to complete your subscription please click on the link below:\\n"
1678
+ "\\n"
1679
+ "{LINK}\\n"
1680
+ "\\n"
1681
+ "If you do not wish to complete your subscription please ignore this email "
1682
+ "and your address will be removed from our database.\\n"
1683
+ "\\n"
1684
+ "Regards,\\n"
1685
+ "{MYNAME}"
1686
  msgstr ""
1687
 
1688
  #: include/options.php:160
1694
  msgstr ""
1695
 
1696
  #: subscribe2.php:39
1697
+ #. Translators: Subscribe2 needs WordPress 3.3 or above, exit if not on a
1698
+ #. compatible version
1699
  msgid ""
1700
  "This version of Subscribe2 requires WordPress 3.3 or greater. Please update "
1701
  "%1$s or use an older version of %2$s."
1707
  "on a site level"
1708
  msgstr ""
1709
 
 
1710
  #. Author URI of the plugin/theme
1711
  msgid "https://subscribe2.wordpress.com/"
1712
  msgstr ""
1714
  #. Description of the plugin/theme
1715
  msgid "Notifies an email list when new entries are posted."
1716
  msgstr ""
1717
+
1718
+ #. Author of the plugin/theme
1719
+ msgid "Matthew Robinson, Tanay Lakhani, Bryan Hadaway"
1720
+ msgstr ""
1721
+
1722
+ #: classes/class-s2-admin.php:490
1723
+ msgctxt "Comma Separated Column Header names for CSV Export"
1724
+ msgid "User Email,User Type,User Name,Confirm Date,IP"
1725
+ msgstr ""
1726
+
1727
+ #: classes/class-s2-list-table-legacy.php:75
1728
+ #: classes/class-s2-list-table-legacy.php:80 classes/class-s2-list-table.php:75
1729
+ #: classes/class-s2-list-table.php:80
1730
+ msgctxt "column name"
1731
+ msgid "Email"
1732
+ msgstr ""
1733
+
1734
+ #: classes/class-s2-list-table-legacy.php:81 classes/class-s2-list-table.php:81
1735
+ msgctxt "column name"
1736
+ msgid "Date"
1737
+ msgstr ""
1738
+
1739
+ #: classes/class-s2-list-table-legacy.php:333
1740
+ #: classes/class-s2-list-table.php:357
1741
+ #. Translators: Pagination
1742
+ msgctxt "paging"
1743
+ msgid "%1$s of %2$s"
1744
+ msgstr ""
tinymce/editor-plugin3.js CHANGED
@@ -1,94 +1,120 @@
1
  /* global tinymce */
2
 
3
  ( function() {
4
- tinymce.create( 'tinymce.plugins.Subscribe2Plugin', {
5
- init: function( ed, url ) {
6
- var i = 0,
7
- pb = '<img src="' + url + '/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" />',
8
- cls = 'mceSubscribe2',
9
- shortcode = '[subscribe2]',
10
- pbreplaced = [],
11
- pbRE = new RegExp( /(\[|<!--)subscribe2.*?(\]|-->)/g ),
12
- replacer = function( str ) {
13
- if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
14
- str = pbreplaced[i];
15
- }
16
- return str;
17
- };
 
 
 
18
 
19
- // Register commands
20
- ed.addCommand( 'mceSubscribe2', function() {
21
- ed.execCommand( 'mceInsertContent', 0, pb );
22
- } );
 
 
 
23
 
24
- // Register buttons
25
- ed.addButton( 'subscribe2', {
26
- title: 'Insert Subscribe2 Token',
27
- image: url + '/../include/s2-button.png',
28
- cmd: cls
29
- } );
 
 
 
30
 
31
- // load the CSS and enable it on the right class
32
- ed.onInit.add( function() {
33
- ed.dom.loadCSS( url + '/css/content.css' );
34
- if ( ed.theme.onResolveName ) {
35
- ed.theme.onResolveName.add( function( th, o ) {
36
- if ( 'IMG' === o.node.nodeName && ed.dom.hasClass( o.node, cls ) ) {
37
- o.name = 'subscribe2';
 
 
 
 
 
38
  }
39
- } );
40
- }
41
- } );
42
 
43
- // allow selection of the image placeholder
44
- ed.onClick.add( function( ed, e ) {
45
- e = e.target;
46
- if ( 'IMG' === e.nodeName && ed.dom.hasClass( e, cls ) ) {
47
- ed.selection.select( e );
48
- }
49
- } );
 
 
50
 
51
- // re-enable the CSS when the node changes
52
- ed.onNodeChange.add( function( ed, cm, n ) {
53
- cm.setActive( 'subscribe2', 'IMG' === n.nodeName && ed.dom.hasClass( n, cls ) );
54
- } );
 
 
55
 
56
- // create an array of replaced shortcodes so we have additional parameters
57
- // then swap in the graphic
58
- ed.onBeforeSetContent.add( function( ed, o ) {
59
- pbreplaced = o.content.match( pbRE );
60
- o.content = o.content.replace( pbRE, pb );
61
- } );
 
 
62
 
63
- // swap back the array of shortcodes to preserve parameters
64
- // replace any other instances with the default shortcode
65
- ed.onPostProcess.add( function( ed, o ) {
66
- if ( o.get ) {
67
- if ( null !== pbreplaced ) {
68
- for ( i = 0; i < pbreplaced.length; i++ ) {
69
- o.content = o.content.replace( /<img[^>]+>/, replacer );
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
  }
72
- o.content = o.content.replace( /<img[^>]+>/g, function( im ) {
73
- if ( -1 !== im.indexOf( 'class="mceSubscribe2' ) ) {
74
- im = shortcode;
75
- }
76
- return im;
77
- } );
78
- }
79
- } );
80
- },
81
 
82
- getInfo: function() {
83
- return {
84
- longname: 'Insert Subscribe2 Token',
85
- author: 'Matthew Robinson',
86
- authorurl: 'http://subscribe2.wordpress.com',
87
- infourl: 'http://subscribe2.wordpress.com',
88
- version: tinymce.majorVersion + '.' + tinymce.minorVersion
89
- };
 
90
  }
91
- } );
92
 
93
  // Register plugin
94
  tinymce.PluginManager.add( 'subscribe2', tinymce.plugins.Subscribe2Plugin );
1
  /* global tinymce */
2
 
3
  ( function() {
4
+ tinymce.create(
5
+ 'tinymce.plugins.Subscribe2Plugin',
6
+ {
7
+ init: function( ed, url ) {
8
+ var i = 0,
9
+ pb = '<img src="' + url + '/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" />',
10
+ cls = 'mceSubscribe2',
11
+ shortcode = '[subscribe2]',
12
+ pbreplaced = [],
13
+ pbreplacedcount,
14
+ pbRE = new RegExp( /(\[|<!--)subscribe2.*?(\]|-->)/g ),
15
+ replacer = function( str ) {
16
+ if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
17
+ str = pbreplaced[i];
18
+ }
19
+ return str;
20
+ };
21
 
22
+ // Register commands
23
+ ed.addCommand(
24
+ 'mceSubscribe2',
25
+ function() {
26
+ ed.execCommand( 'mceInsertContent', 0, pb );
27
+ }
28
+ );
29
 
30
+ // Register buttons
31
+ ed.addButton(
32
+ 'subscribe2',
33
+ {
34
+ title: 'Insert Subscribe2 Token',
35
+ image: url + '/../include/s2-button.png',
36
+ cmd: cls
37
+ }
38
+ );
39
 
40
+ // load the CSS and enable it on the right class
41
+ ed.onInit.add(
42
+ function() {
43
+ ed.dom.loadCSS( url + '/css/content.css' );
44
+ if ( ed.theme.onResolveName ) {
45
+ ed.theme.onResolveName.add(
46
+ function( th, o ) {
47
+ if ( 'IMG' === o.node.nodeName && ed.dom.hasClass( o.node, cls ) ) {
48
+ o.name = 'subscribe2';
49
+ }
50
+ }
51
+ );
52
  }
53
+ }
54
+ );
 
55
 
56
+ // allow selection of the image placeholder
57
+ ed.onClick.add(
58
+ function( ed, e ) {
59
+ e = e.target;
60
+ if ( 'IMG' === e.nodeName && ed.dom.hasClass( e, cls ) ) {
61
+ ed.selection.select( e );
62
+ }
63
+ }
64
+ );
65
 
66
+ // re-enable the CSS when the node changes
67
+ ed.onNodeChange.add(
68
+ function( ed, cm, n ) {
69
+ cm.setActive( 'subscribe2', 'IMG' === n.nodeName && ed.dom.hasClass( n, cls ) );
70
+ }
71
+ );
72
 
73
+ // create an array of replaced shortcodes so we have additional parameters
74
+ // then swap in the graphic
75
+ ed.onBeforeSetContent.add(
76
+ function( ed, o ) {
77
+ pbreplaced = o.content.match( pbRE );
78
+ o.content = o.content.replace( pbRE, pb );
79
+ }
80
+ );
81
 
82
+ // swap back the array of shortcodes to preserve parameters
83
+ // replace any other instances with the default shortcode
84
+ ed.onPostProcess.add(
85
+ function( ed, o ) {
86
+ if ( o.get ) {
87
+ if ( null !== pbreplaced ) {
88
+ pbreplacedcount = pbreplaced.length;
89
+ for ( i = 0; i < pbreplacedcount; i++ ) {
90
+ o.content = o.content.replace( /<img[^>]+>/, replacer );
91
+ }
92
+ }
93
+ o.content = o.content.replace(
94
+ /<img[^>]+>/g,
95
+ function( im ) {
96
+ if ( -1 !== im.indexOf( 'class="mceSubscribe2' ) ) {
97
+ im = shortcode;
98
+ }
99
+ return im;
100
+ }
101
+ );
102
  }
103
  }
104
+ );
105
+ },
 
 
 
 
 
 
 
106
 
107
+ getInfo: function() {
108
+ return {
109
+ longname: 'Insert Subscribe2 Token',
110
+ author: 'Matthew Robinson',
111
+ authorurl: 'http://subscribe2.wordpress.com',
112
+ infourl: 'http://subscribe2.wordpress.com',
113
+ version: tinymce.majorVersion + '.' + tinymce.minorVersion
114
+ };
115
+ }
116
  }
117
+ );
118
 
119
  // Register plugin
120
  tinymce.PluginManager.add( 'subscribe2', tinymce.plugins.Subscribe2Plugin );
tinymce/editor-plugin3.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(e,n){var t=0,c='<img src="'+n+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" />',o="mceSubscribe2",s=[],i=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),r=function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e=s[t]),e};e.addCommand("mceSubscribe2",function(){e.execCommand("mceInsertContent",0,c)}),e.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:n+"/../include/s2-button.png",cmd:o}),e.onInit.add(function(){e.dom.loadCSS(n+"/css/content.css"),e.theme.onResolveName&&e.theme.onResolveName.add(function(n,t){"IMG"===t.node.nodeName&&e.dom.hasClass(t.node,o)&&(t.name="subscribe2")})}),e.onClick.add(function(e,n){"IMG"===(n=n.target).nodeName&&e.dom.hasClass(n,o)&&e.selection.select(n)}),e.onNodeChange.add(function(e,n,t){n.setActive("subscribe2","IMG"===t.nodeName&&e.dom.hasClass(t,o))}),e.onBeforeSetContent.add(function(e,n){s=n.content.match(i),n.content=n.content.replace(i,c)}),e.onPostProcess.add(function(e,n){if(n.get){if(null!==s)for(t=0;t<s.length;t++)n.content=n.content.replace(/<img[^>]+>/,r);n.content=n.content.replace(/<img[^>]+>/g,function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e="[subscribe2]"),e})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin);
1
+ tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(e,n){var t,c=0,o='<img src="'+n+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" />',s="mceSubscribe2",i=[],r=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),u=function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e=i[c]),e};e.addCommand("mceSubscribe2",function(){e.execCommand("mceInsertContent",0,o)}),e.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:n+"/../include/s2-button.png",cmd:s}),e.onInit.add(function(){e.dom.loadCSS(n+"/css/content.css"),e.theme.onResolveName&&e.theme.onResolveName.add(function(n,t){"IMG"===t.node.nodeName&&e.dom.hasClass(t.node,s)&&(t.name="subscribe2")})}),e.onClick.add(function(e,n){"IMG"===(n=n.target).nodeName&&e.dom.hasClass(n,s)&&e.selection.select(n)}),e.onNodeChange.add(function(e,n,t){n.setActive("subscribe2","IMG"===t.nodeName&&e.dom.hasClass(t,s))}),e.onBeforeSetContent.add(function(e,n){i=n.content.match(r),n.content=n.content.replace(r,o)}),e.onPostProcess.add(function(e,n){if(n.get){if(null!==i)for(t=i.length,c=0;c<t;c++)n.content=n.content.replace(/<img[^>]+>/,u);n.content=n.content.replace(/<img[^>]+>/g,function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e="[subscribe2]"),e})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin);
tinymce/editor-plugin4.js CHANGED
@@ -1,82 +1,107 @@
1
  /* global tinymce */
2
 
3
  ( function() {
4
- tinymce.create( 'tinymce.plugins.Subscribe2Plugin', {
5
- init: function( ed, url ) {
6
- var i = 0,
7
- pb = '<p><img src="' + url + '/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',
8
- cls = 'mceSubscribe2',
9
- shortcode = '[subscribe2]',
10
- pbreplaced = [],
11
- pbRE = new RegExp( /(\[|<!--)subscribe2.*?(\]|-->)/g ),
12
- replacer = function( str ) {
13
- if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
14
- str = pbreplaced[i];
15
- }
16
- return str;
17
- };
 
 
 
18
 
19
- // Register commands
20
- ed.addCommand( 'mceSubscribe2', function() {
21
- ed.execCommand( 'mceInsertContent', 0, pb );
22
- } );
 
 
 
23
 
24
- // Register buttons
25
- ed.addButton( 'subscribe2', {
26
- title: 'Insert Subscribe2 Token',
27
- image: url + '/../include/s2-button.png',
28
- cmd: cls
29
- } );
 
 
 
30
 
31
- // load the CSS and enable it on the right class
32
- ed.on( 'init', function() {
33
- ed.dom.loadCSS( url + '/css/content.css' );
 
 
34
 
35
- if ( ed.theme.onResolveName ) {
36
- ed.theme.onResolveName.add( function( th, o ) {
37
- if ( 'IMG' === o.node.nodeName && ed.dom.hasClass( o.node, cls ) ) {
38
- o.name = 'subscribe2';
 
 
 
 
39
  }
40
- } );
41
- }
42
- } );
43
 
44
- // create an array of replaced shortcodes so we have additional parameters
45
- // then swap in the graphic
46
- ed.on( 'BeforeSetContent', function( ed ) {
47
- pbreplaced = ed.content.match( pbRE );
48
- ed.content = ed.content.replace( pbRE, pb );
49
- } );
 
 
 
50
 
51
- // swap back the array of shortcodes to preserve parameters
52
- // replace any other instances with the default shortcode
53
- ed.on( 'PostProcess', function( ed ) {
54
- if ( ed.get ) {
55
- if ( null !== pbreplaced ) {
56
- for ( i = 0; i < pbreplaced.length; i++ ) {
57
- ed.content = ed.content.replace( /<img[^>]+>/, replacer );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  }
59
  }
60
- ed.content = ed.content.replace( /<img[^>]+>/g, function( im ) {
61
- if ( -1 !== im.indexOf( 'class="mceSubscribe2' ) ) {
62
- im = shortcode;
63
- }
64
- return im;
65
- } );
66
- }
67
- } );
68
- },
69
 
70
- getInfo: function() {
71
- return {
72
- longname: 'Insert Subscribe2 Token',
73
- author: 'Matthew Robinson',
74
- authorurl: 'http://subscribe2.wordpress.com',
75
- infourl: 'http://subscribe2.wordpress.com',
76
- version: tinymce.majorVersion + '.' + tinymce.minorVersion
77
- };
 
78
  }
79
- } );
80
 
81
  // Register plugin
82
  tinymce.PluginManager.add( 'subscribe2', tinymce.plugins.Subscribe2Plugin );
1
  /* global tinymce */
2
 
3
  ( function() {
4
+ tinymce.create(
5
+ 'tinymce.plugins.Subscribe2Plugin',
6
+ {
7
+ init: function( ed, url ) {
8
+ var i = 0,
9
+ pb = '<p><img src="' + url + '/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',
10
+ cls = 'mceSubscribe2',
11
+ shortcode = '[subscribe2]',
12
+ pbreplaced = [],
13
+ pbreplacedcount,
14
+ pbRE = new RegExp( /(\[|<!--)subscribe2.*?(\]|-->)/g ),
15
+ replacer = function( str ) {
16
+ if ( -1 !== str.indexOf( 'class="mceSubscribe2' ) ) {
17
+ str = pbreplaced[i];
18
+ }
19
+ return str;
20
+ };
21
 
22
+ // Register commands
23
+ ed.addCommand(
24
+ 'mceSubscribe2',
25
+ function() {
26
+ ed.execCommand( 'mceInsertContent', 0, pb );
27
+ }
28
+ );
29
 
30
+ // Register buttons
31
+ ed.addButton(
32
+ 'subscribe2',
33
+ {
34
+ title: 'Insert Subscribe2 Token',
35
+ image: url + '/../include/s2-button.png',
36
+ cmd: cls
37
+ }
38
+ );
39
 
40
+ // load the CSS and enable it on the right class
41
+ ed.on(
42
+ 'init',
43
+ function() {
44
+ ed.dom.loadCSS( url + '/css/content.css' );
45
 
46
+ if ( ed.theme.onResolveName ) {
47
+ ed.theme.onResolveName.add(
48
+ function( th, o ) {
49
+ if ( 'IMG' === o.node.nodeName && ed.dom.hasClass( o.node, cls ) ) {
50
+ o.name = 'subscribe2';
51
+ }
52
+ }
53
+ );
54
  }
55
+ }
56
+ );
 
57
 
58
+ // create an array of replaced shortcodes so we have additional parameters
59
+ // then swap in the graphic
60
+ ed.on(
61
+ 'BeforeSetContent',
62
+ function( ed ) {
63
+ pbreplaced = ed.content.match( pbRE );
64
+ ed.content = ed.content.replace( pbRE, pb );
65
+ }
66
+ );
67
 
68
+ // swap back the array of shortcodes to preserve parameters
69
+ // replace any other instances with the default shortcode
70
+ ed.on(
71
+ 'PostProcess',
72
+ function( ed ) {
73
+ if ( ed.get ) {
74
+ if ( null !== pbreplaced ) {
75
+ pbreplacedcount = pbreplaced.length;
76
+ for ( i = 0; i < pbreplacedcount; i++ ) {
77
+ ed.content = ed.content.replace( /<img[^>]+>/, replacer );
78
+ }
79
+ }
80
+ ed.content = ed.content.replace(
81
+ /<img[^>]+>/g,
82
+ function( im ) {
83
+ if ( -1 !== im.indexOf( 'class="mceSubscribe2' ) ) {
84
+ im = shortcode;
85
+ }
86
+ return im;
87
+ }
88
+ );
89
  }
90
  }
91
+ );
92
+ },
 
 
 
 
 
 
 
93
 
94
+ getInfo: function() {
95
+ return {
96
+ longname: 'Insert Subscribe2 Token',
97
+ author: 'Matthew Robinson',
98
+ authorurl: 'http://subscribe2.wordpress.com',
99
+ infourl: 'http://subscribe2.wordpress.com',
100
+ version: tinymce.majorVersion + '.' + tinymce.minorVersion
101
+ };
102
+ }
103
  }
104
+ );
105
 
106
  // Register plugin
107
  tinymce.PluginManager.add( 'subscribe2', tinymce.plugins.Subscribe2Plugin );
tinymce/editor-plugin4.min.js CHANGED
@@ -1 +1 @@
1
- tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(e,n){var t=0,c='<p><img src="'+n+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',i="mceSubscribe2",o=[],s=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),r=function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e=o[t]),e};e.addCommand("mceSubscribe2",function(){e.execCommand("mceInsertContent",0,c)}),e.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:n+"/../include/s2-button.png",cmd:i}),e.on("init",function(){e.dom.loadCSS(n+"/css/content.css"),e.theme.onResolveName&&e.theme.onResolveName.add(function(n,t){"IMG"===t.node.nodeName&&e.dom.hasClass(t.node,i)&&(t.name="subscribe2")})}),e.on("BeforeSetContent",function(e){o=e.content.match(s),e.content=e.content.replace(s,c)}),e.on("PostProcess",function(e){if(e.get){if(null!==o)for(t=0;t<o.length;t++)e.content=e.content.replace(/<img[^>]+>/,r);e.content=e.content.replace(/<img[^>]+>/g,function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e="[subscribe2]"),e})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin);
1
+ tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(e,n){var t,c=0,i='<p><img src="'+n+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',o="mceSubscribe2",s=[],r=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),u=function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e=s[c]),e};e.addCommand("mceSubscribe2",function(){e.execCommand("mceInsertContent",0,i)}),e.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:n+"/../include/s2-button.png",cmd:o}),e.on("init",function(){e.dom.loadCSS(n+"/css/content.css"),e.theme.onResolveName&&e.theme.onResolveName.add(function(n,t){"IMG"===t.node.nodeName&&e.dom.hasClass(t.node,o)&&(t.name="subscribe2")})}),e.on("BeforeSetContent",function(e){s=e.content.match(r),e.content=e.content.replace(r,i)}),e.on("PostProcess",function(e){if(e.get){if(null!==s)for(t=s.length,c=0;c<t;c++)e.content=e.content.replace(/<img[^>]+>/,u);e.content=e.content.replace(/<img[^>]+>/g,function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e="[subscribe2]"),e})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin);
uninstall.php CHANGED
@@ -48,4 +48,4 @@ function s2_uninstall() {
48
 
49
  // drop the subscribe2 table
50
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe2" );
51
- } // end s2_uninstall()
48
 
49
  // drop the subscribe2 table
50
  $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}subscribe2" );
51
+ }