Subscribe2 - Version 10.35

Version Description

(15th March, 2021) =

  • Fix {UNSUBLINK} shortcode
  • WordPress 5.7 compatibility
Download this release

Release Info

Developer tareq1988
Plugin Icon 128x128 Subscribe2
Version 10.35
Comparing to
See all releases

Code changes from version 10.34 to 10.35

admin/settings.php CHANGED
@@ -38,7 +38,7 @@ 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' ), 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 ];
@@ -47,7 +47,7 @@ if ( isset( $_POST['s2_admin'] ) ) {
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 ) {
50
- $options = array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'js_ip_updater' );
51
  foreach ( $options as $option ) {
52
  if ( ! isset( $_POST[ $option ] ) ) {
53
  $this->subscribe2_options[ $option ] = '0';
@@ -454,6 +454,9 @@ switch ( $current_tab ) {
454
  // WordPress page ID where subscribe2 token is used
455
  echo esc_html__( 'Set default Subscribe2 page as', 'subscribe2' ) . ': ';
456
  $this->pages_dropdown( $this->subscribe2_options['s2page'] );
 
 
 
457
 
458
  // show link to WordPress page in meta
459
  echo '<br><br><label><input type="checkbox" name="show_meta" value="1"' . checked( $this->subscribe2_options['show_meta'], '1', false ) . ' /> ';
@@ -496,9 +499,9 @@ switch ( $current_tab ) {
496
  echo "\r\n" . '<br><textarea style="width: 98%;" rows="4" cols="60" name="barred">' . esc_textarea( $this->subscribe2_options['barred'] ) . '</textarea>';
497
  echo '</p>';
498
  echo '<h3>' . esc_html__( 'Links', 'subscribe2' ) . '</h3>' . "\r\n";
499
- echo '<a href="http://wordpress.org/plugins/subscribe2/">' . esc_html__( 'Plugin Site', 'subscribe2' ) . '</a><br>';
500
- echo '<a href="http://wordpress.org/support/plugin/subscribe2">' . esc_html__( 'Plugin Forum', 'subscribe2' ) . '</a><br>';
501
- echo '<a href="http://subscribe2.wordpress.com/">' . esc_html__( 'Plugin Blog', 'subscribe2' ) . '</a><br>';
502
  echo '</div>' . "\r\n";
503
  break;
504
 
38
  }
39
  } elseif ( isset( $_POST['submit'] ) ) {
40
  foreach ( $_POST as $key => $value ) {
41
+ if ( in_array( $key, array( 'bcclimit', 's2page', 's2_unsub_page' ), 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 ];
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 ) {
50
+ $options = array( 'show_meta', 'show_button', 'ajax', 'widget', 'counterwidget', 's2meta_default', 'js_ip_updater', 's2_unsub_page' );
51
  foreach ( $options as $option ) {
52
  if ( ! isset( $_POST[ $option ] ) ) {
53
  $this->subscribe2_options[ $option ] = '0';
454
  // WordPress page ID where subscribe2 token is used
455
  echo esc_html__( 'Set default Subscribe2 page as', 'subscribe2' ) . ': ';
456
  $this->pages_dropdown( $this->subscribe2_options['s2page'] );
457
+ echo "</br></br>";
458
+ echo esc_html__( 'Set Subscribe2 unsubscribe page', 'subscribe2' ) . ': ';
459
+ $this->pages_dropdown( isset($this->subscribe2_options['s2_unsub_page']) ? $this->subscribe2_options['s2_unsub_page'] : 0 , 's2_unsub_page');
460
 
461
  // show link to WordPress page in meta
462
  echo '<br><br><label><input type="checkbox" name="show_meta" value="1"' . checked( $this->subscribe2_options['show_meta'], '1', false ) . ' /> ';
499
  echo "\r\n" . '<br><textarea style="width: 98%;" rows="4" cols="60" name="barred">' . esc_textarea( $this->subscribe2_options['barred'] ) . '</textarea>';
500
  echo '</p>';
501
  echo '<h3>' . esc_html__( 'Links', 'subscribe2' ) . '</h3>' . "\r\n";
502
+ echo '<a href="https://wordpress.org/plugins/subscribe2/">' . esc_html__( 'Plugin Site', 'subscribe2' ) . '</a><br>';
503
+ echo '<a href="https://wordpress.org/support/plugin/subscribe2">' . esc_html__( 'Plugin Forum', 'subscribe2' ) . '</a><br>';
504
+ echo '<a href="https://getwemail.io/subscribe2/">' . esc_html__( 'Plugin Blog', 'subscribe2' ) . '</a><br>';
505
  echo '</div>' . "\r\n";
506
  break;
507
 
changelog.txt CHANGED
@@ -1,3 +1,8 @@
 
 
 
 
 
1
  = 10.34 (24th August, 2020) =
2
 
3
  * Fix gutenberg script loading issue
1
+ = 10.35 (15th March, 2021) =
2
+
3
+ * Fix {UNSUBLINK} shortcode
4
+ * WordPress 5.7 compatibility
5
+
6
  = 10.34 (24th August, 2020) =
7
 
8
  * Fix gutenberg script loading issue
classes/class-s2-admin.php CHANGED
@@ -850,13 +850,13 @@ class S2_Admin extends S2_Core {
850
  /**
851
  * Create and display a dropdown list of pages
852
  */
853
- public function pages_dropdown( $s2page ) {
854
  $pages = get_pages();
855
  if ( empty( $pages ) ) {
856
  return;
857
  }
858
 
859
- $option = '<select name="s2page">' . "\r\n";
860
  $option .= '<option value="0">' . __( 'Select a page', 'subscribe2' ) . '</option>' . "\r\n";
861
  foreach ( $pages as $page ) {
862
  $option .= '<option value="' . $page->ID . '"';
850
  /**
851
  * Create and display a dropdown list of pages
852
  */
853
+ public function pages_dropdown( $s2page, $name = 's2page' ) {
854
  $pages = get_pages();
855
  if ( empty( $pages ) ) {
856
  return;
857
  }
858
 
859
+ $option = '<select name="' . $name . '">' . "\r\n";
860
  $option .= '<option value="0">' . __( 'Select a page', 'subscribe2' ) . '</option>' . "\r\n";
861
  foreach ( $pages as $page ) {
862
  $option .= '<option value="' . $page->ID . '"';
classes/class-s2-core.php CHANGED
@@ -108,6 +108,9 @@ class S2_Core {
108
  if ( false === is_email( $recipient ) || empty( $recipient ) ) {
109
  continue;
110
  }
 
 
 
111
  // Use the mail queue provided we are not sending a preview
112
  if ( function_exists( 'wpmq_mail' ) && ! isset( $this->preview_email ) ) {
113
  $status = wp_mail( $recipient, $subject, $mailtext, $headers, $attachments, 0 );
@@ -232,6 +235,21 @@ class S2_Core {
232
  return $headers;
233
  }
234
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  /**
236
  * Function to set HTML Email in wp_mail()
237
  */
108
  if ( false === is_email( $recipient ) || empty( $recipient ) ) {
109
  continue;
110
  }
111
+ // Parse unsubscribe shortcode
112
+ $mailtext = $this->parse_unsubscribe_link( $mailtext, $recipient );
113
+
114
  // Use the mail queue provided we are not sending a preview
115
  if ( function_exists( 'wpmq_mail' ) && ! isset( $this->preview_email ) ) {
116
  $status = wp_mail( $recipient, $subject, $mailtext, $headers, $attachments, 0 );
235
  return $headers;
236
  }
237
 
238
+ /**
239
+ * Parse unsubscribe link
240
+ *
241
+ * @param $content
242
+ * @param $recipient
243
+ * @return string|string[]
244
+ */
245
+ public function parse_unsubscribe_link( $content, $recipient ) {
246
+ $page_url = get_page_link( $this->subscribe2_options['s2_unsub_page'] );
247
+ $query = parse_url( $page_url, PHP_URL_QUERY );
248
+ $page_url .= ( ( $query ? '&' : '?' ) . 's2_unsub=' . base64_encode( $recipient ) );
249
+
250
+ return str_replace('{UNSUBLINK}', $page_url, $content );
251
+ }
252
+
253
  /**
254
  * Function to set HTML Email in wp_mail()
255
  */
classes/class-s2-frontend.php CHANGED
@@ -43,8 +43,36 @@ class S2_Frontend extends S2_Core {
43
  $this->subscribe = __( 'subscribe', 'subscribe2' ); //ACTION replacement in subscribing confirmation email
44
 
45
  $this->unsubscribe = __( 'unsubscribe', 'subscribe2' ); //ACTION replacement in unsubscribing in confirmation email
 
 
 
 
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /* ===== template and filter functions ===== */
49
  /**
50
  * Display our form; also handles (un)subscribe requests
43
  $this->subscribe = __( 'subscribe', 'subscribe2' ); //ACTION replacement in subscribing confirmation email
44
 
45
  $this->unsubscribe = __( 'unsubscribe', 'subscribe2' ); //ACTION replacement in unsubscribing in confirmation email
46
+
47
+ if ( isset( $_GET['s2_unsub'] ) && ! empty( $_GET['s2_unsub'] ) ) {
48
+ $this->unsubscribe( $_GET['s2_unsub'] );
49
+ }
50
  }
51
 
52
+ /**
53
+ * Process unsubscribe
54
+ *
55
+ * @param $email
56
+ */
57
+ public function unsubscribe( $email ) {
58
+ global $wpdb;
59
+ $email = base64_decode( $email );
60
+
61
+ if (! filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
62
+ return;
63
+ }
64
+
65
+ $count = $wpdb->delete( $wpdb->subscribe2,
66
+ [
67
+ 'email' => $email
68
+ ]
69
+ );
70
+
71
+ if ( ! $count ) {
72
+ wp_safe_redirect( home_url() );
73
+ }
74
+ }
75
+
76
  /* ===== template and filter functions ===== */
77
  /**
78
  * Display our form; also handles (un)subscribe requests
include/options.php CHANGED
@@ -56,6 +56,10 @@ if ( ! isset( $mysubscribe2->subscribe2_options['s2page'] ) ) {
56
  $mysubscribe2->subscribe2_options['s2page'] = 0;
57
  } // option for default WordPress page for Subscribe2 to use
58
 
 
 
 
 
59
  if ( ! isset( $mysubscribe2->subscribe2_options['stylesheet'] ) ) {
60
  $mysubscribe2->subscribe2_options['stylesheet'] = 'yes';
61
  } // option to include link to theme stylesheet from HTML notifications
56
  $mysubscribe2->subscribe2_options['s2page'] = 0;
57
  } // option for default WordPress page for Subscribe2 to use
58
 
59
+ if ( ! isset( $mysubscribe2->subscribe2_options['s2_unsub_page'] ) ) {
60
+ $mysubscribe2->subscribe2_options['s2_unsub_page'] = 0;
61
+ } // option for default Subscribe2 unsubscribe page
62
+
63
  if ( ! isset( $mysubscribe2->subscribe2_options['stylesheet'] ) ) {
64
  $mysubscribe2->subscribe2_options['stylesheet'] = 'yes';
65
  } // option to include link to theme stylesheet from HTML notifications
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: tareq1988, nizamuddinbabu, wemail
3
  Donate link: https://getwemail.io
4
  Tags: posts, subscription, email, subscribe, notify, notification, newsletter, post notification, email marketing, optin, form
5
  Requires at least: 4.0
6
- Tested up to: 5.5
7
- Stable tag: 10.34
8
- Requires PHP: 5.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -72,6 +72,11 @@ This token will automatically be replaced by dynamic subscription information an
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
75
  = 10.34 (24th August, 2020) =
76
 
77
  * Fix gutenberg script loading issue
3
  Donate link: https://getwemail.io
4
  Tags: posts, subscription, email, subscribe, notify, notification, newsletter, post notification, email marketing, optin, form
5
  Requires at least: 4.0
6
+ Tested up to: 5.7
7
+ Stable tag: 10.35
8
+ Requires PHP: 5.4
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
72
 
73
  == Changelog ==
74
 
75
+ = 10.35 (15th March, 2021) =
76
+
77
+ * Fix {UNSUBLINK} shortcode
78
+ * WordPress 5.7 compatibility
79
+
80
  = 10.34 (24th August, 2020) =
81
 
82
  * Fix gutenberg script loading issue
subscribe2.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Subscribe2
4
  Plugin URI: https://getwemail.io
5
  Description: Notifies an email list when new entries are posted.
6
- Version: 10.34
7
  Author: weMail
8
  Author URI: https://getwemail.io
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.34' );
58
  define( 'S2PLUGIN', __FILE__ );
59
  define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
60
  define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
3
  Plugin Name: Subscribe2
4
  Plugin URI: https://getwemail.io
5
  Description: Notifies an email list when new entries are posted.
6
+ Version: 10.35
7
  Author: weMail
8
  Author URI: https://getwemail.io
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.35' );
58
  define( 'S2PLUGIN', __FILE__ );
59
  define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
60
  define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );