Version Description
(30th September, 2021) =
- WordPress 5.8 compatibility
- Fix form preview on widgets
- Fix pop up form
- Fix send schedule email options
- Fix one click subscription
- Fix some PHP warnings
Download this release
Release Info
Developer | tareq1988 |
Plugin | Subscribe2 |
Version | 10.36 |
Comparing to | |
See all releases |
Code changes from version 10.35 to 10.36
- admin/settings.php +7 -1
- admin/subscribers.php +8 -4
- changelog.txt +9 -0
- classes/class-s2-admin.php +4 -1
- classes/class-s2-ajax.php +1 -1
- classes/class-s2-core.php +4 -1
- classes/class-s2-form-widget.php +11 -0
- classes/class-s2-frontend.php +8 -223
- include/s2-ajax.js +2 -1
- include/s2-checkbox.js +8 -12
- readme.txt +12 -3
- subscribe2.php +3 -2
- traits/ShortcodeTrait.php +221 -0
admin/settings.php
CHANGED
@@ -161,7 +161,13 @@ if ( 'blogname' === $this->subscribe2_options['sender'] ) {
|
|
161 |
$sender = $user->user_email;
|
162 |
}
|
163 |
list( $user, $sender_domain ) = explode( '@', $sender, 2 );
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
// Translators: Warning message
|
166 |
echo wp_kses_post( '<div id="sender_message" class="error notice is-dismissible"><p class="s2_error"><strong>' . sprintf( __( 'You appear to be sending notifications from %1$s, which has a different domain name than your blog server %2$s. This may result in failed emails.', 'subscribe2' ), $sender, $_SERVER['SERVER_NAME'] ) . '</strong></p></div>' );
|
167 |
}
|
161 |
$sender = $user->user_email;
|
162 |
}
|
163 |
list( $user, $sender_domain ) = explode( '@', $sender, 2 );
|
164 |
+
|
165 |
+
$dismis_sender_worning = '';
|
166 |
+
if(isset($this->subscribe2_options['dismiss_sender_warning'])) {
|
167 |
+
$dismis_sender_worning = $this->subscribe2_options['dismiss_sender_warning'];
|
168 |
+
}
|
169 |
+
|
170 |
+
if ( ! stristr( esc_html( $_SERVER['SERVER_NAME'] ), $sender_domain ) && 'author' !== $this->subscribe2_options['sender'] && '0' === (isset($this->subscribe2_options['dismiss_sender_warning']) ? $this->subscribe2_options['dismiss_sender_warning'] : '0') ) {
|
171 |
// Translators: Warning message
|
172 |
echo wp_kses_post( '<div id="sender_message" class="error notice is-dismissible"><p class="s2_error"><strong>' . sprintf( __( 'You appear to be sending notifications from %1$s, which has a different domain name than your blog server %2$s. This may result in failed emails.', 'subscribe2' ), $sender, $_SERVER['SERVER_NAME'] ) . '</strong></p></div>' );
|
173 |
}
|
admin/subscribers.php
CHANGED
@@ -23,6 +23,10 @@ if ( ! class_exists( 'Subscribe2_List_Table' ) ) {
|
|
23 |
|
24 |
// was anything POSTed ?
|
25 |
if ( isset( $_POST['s2_admin'] ) ) {
|
|
|
|
|
|
|
|
|
26 |
if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $s2_list_table->_args['plural'] ) ) {
|
27 |
die( '<p>' . esc_html__( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
|
28 |
}
|
@@ -81,16 +85,16 @@ if ( isset( $_POST['s2_admin'] ) ) {
|
|
81 |
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Reminder Email(s) Sent!', 'subscribe2' ) . '</strong></p></div>';
|
82 |
} elseif ( isset( $_POST['sub_categories'] ) && 'subscribe' === $_POST['manage'] ) {
|
83 |
if ( isset( $_REQUEST['subscriber'] ) ) {
|
84 |
-
$this->subscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $
|
85 |
} else {
|
86 |
-
$this->subscribe_registered_users( $_POST['exportcsv'], $
|
87 |
}
|
88 |
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Registered Users Subscribed!', 'subscribe2' ) . '</strong></p></div>';
|
89 |
} elseif ( isset( $_POST['sub_categories'] ) && 'unsubscribe' === $_POST['manage'] ) {
|
90 |
if ( isset( $_REQUEST['subscriber'] ) ) {
|
91 |
-
$this->unsubscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $
|
92 |
} else {
|
93 |
-
$this->unsubscribe_registered_users( $_POST['exportcsv'], $
|
94 |
}
|
95 |
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Registered Users Unsubscribed!', 'subscribe2' ) . '</strong></p></div>';
|
96 |
} elseif ( isset( $_POST['sub_format'] ) ) {
|
23 |
|
24 |
// was anything POSTed ?
|
25 |
if ( isset( $_POST['s2_admin'] ) ) {
|
26 |
+
$s2_request_category = '';
|
27 |
+
if (isset($_REQUEST['category']) && $_REQUEST['category']) {
|
28 |
+
$s2_request_category = $_REQUEST['category'];
|
29 |
+
}
|
30 |
if ( false === wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-' . $s2_list_table->_args['plural'] ) ) {
|
31 |
die( '<p>' . esc_html__( 'Security error! Your request cannot be completed.', 'subscribe2' ) . '</p>' );
|
32 |
}
|
85 |
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Reminder Email(s) Sent!', 'subscribe2' ) . '</strong></p></div>';
|
86 |
} elseif ( isset( $_POST['sub_categories'] ) && 'subscribe' === $_POST['manage'] ) {
|
87 |
if ( isset( $_REQUEST['subscriber'] ) ) {
|
88 |
+
$this->subscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $s2_request_category );
|
89 |
} else {
|
90 |
+
$this->subscribe_registered_users( $_POST['exportcsv'], $s2_request_category );
|
91 |
}
|
92 |
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Registered Users Subscribed!', 'subscribe2' ) . '</strong></p></div>';
|
93 |
} elseif ( isset( $_POST['sub_categories'] ) && 'unsubscribe' === $_POST['manage'] ) {
|
94 |
if ( isset( $_REQUEST['subscriber'] ) ) {
|
95 |
+
$this->unsubscribe_registered_users( implode( ",\r\n", $_REQUEST['subscriber'] ), $s2_request_category );
|
96 |
} else {
|
97 |
+
$this->unsubscribe_registered_users( $_POST['exportcsv'], $s2_request_category );
|
98 |
}
|
99 |
echo '<div id="message" class="updated fade"><p><strong>' . esc_html__( 'Registered Users Unsubscribed!', 'subscribe2' ) . '</strong></p></div>';
|
100 |
} elseif ( isset( $_POST['sub_format'] ) ) {
|
changelog.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
= 10.35 (15th March, 2021) =
|
2 |
|
3 |
* Fix {UNSUBLINK} shortcode
|
1 |
+
= 10.36 (30th September, 2021) =
|
2 |
+
|
3 |
+
* WordPress 5.8 compatibility
|
4 |
+
* Fix form preview on widgets
|
5 |
+
* Fix pop up form
|
6 |
+
* Fix send schedule email options
|
7 |
+
* Fix one click subscription
|
8 |
+
* Fix some PHP warnings
|
9 |
+
|
10 |
= 10.35 (15th March, 2021) =
|
11 |
|
12 |
* Fix {UNSUBLINK} shortcode
|
classes/class-s2-admin.php
CHANGED
@@ -804,6 +804,9 @@ class S2_Admin extends S2_Core {
|
|
804 |
asort( $sort );
|
805 |
$schedule_sorted = array();
|
806 |
foreach ( $sort as $key => $value ) {
|
|
|
|
|
|
|
807 |
$schedule_sorted[ $key ] = $schedule[ $key ];
|
808 |
}
|
809 |
foreach ( $schedule_sorted as $key => $value ) {
|
@@ -1144,7 +1147,7 @@ class S2_Admin extends S2_Core {
|
|
1144 |
return false;
|
1145 |
}
|
1146 |
|
1147 |
-
if ( isset( $_POST['sub2-one-click-subscribe'] ) && 1 === $_POST['sub2-one-click-subscribe'] ) {
|
1148 |
// Subscribe
|
1149 |
$this->one_click_handler( $user_id, 'subscribe' );
|
1150 |
} else {
|
804 |
asort( $sort );
|
805 |
$schedule_sorted = array();
|
806 |
foreach ( $sort as $key => $value ) {
|
807 |
+
if (! preg_match('/never|weekly|monthly|twicedaily|hourly/', $key)) {
|
808 |
+
continue;
|
809 |
+
}
|
810 |
$schedule_sorted[ $key ] = $schedule[ $key ];
|
811 |
}
|
812 |
foreach ( $schedule_sorted as $key => $value ) {
|
1147 |
return false;
|
1148 |
}
|
1149 |
|
1150 |
+
if ( isset( $_POST['sub2-one-click-subscribe'] ) && 1 === (int)$_POST['sub2-one-click-subscribe'] ) {
|
1151 |
// Subscribe
|
1152 |
$this->one_click_handler( $user_id, 'subscribe' );
|
1153 |
} else {
|
classes/class-s2-ajax.php
CHANGED
@@ -57,7 +57,7 @@ class S2_Ajax {
|
|
57 |
wp_parse_str( $response, $atts );
|
58 |
|
59 |
global $s2_frontend;
|
60 |
-
$content = $s2_frontend->
|
61 |
$content = apply_filters( 's2_ajax_form', $content );
|
62 |
|
63 |
$allowed_tags = array(
|
57 |
wp_parse_str( $response, $atts );
|
58 |
|
59 |
global $s2_frontend;
|
60 |
+
$content = $s2_frontend->widget_shortcode( $atts );
|
61 |
$content = apply_filters( 's2_ajax_form', $content );
|
62 |
|
63 |
$allowed_tags = array(
|
classes/class-s2-core.php
CHANGED
@@ -1,5 +1,8 @@
|
|
1 |
<?php
|
|
|
|
|
2 |
class S2_Core {
|
|
|
3 |
// variables and constructor are declared at the end
|
4 |
/**
|
5 |
* Load translations
|
@@ -2041,7 +2044,6 @@ class S2_Core {
|
|
2041 |
}
|
2042 |
|
2043 |
// add the frontend filters
|
2044 |
-
add_shortcode( 'subscribe2', array( &$this, 'shortcode' ) );
|
2045 |
add_filter( 'the_content', array( &$this, 'filter' ), 10 );
|
2046 |
|
2047 |
// add actions for other plugins
|
@@ -2055,6 +2057,7 @@ class S2_Core {
|
|
2055 |
add_action( 'wp_footer', array( &$this, 'js_ip_library_script' ), 20 );
|
2056 |
}
|
2057 |
}
|
|
|
2058 |
}
|
2059 |
|
2060 |
/* ===== define some variables ===== */
|
1 |
<?php
|
2 |
+
require_once S2PATH . 'traits/ShortcodeTrait.php';
|
3 |
+
|
4 |
class S2_Core {
|
5 |
+
use Shortcode;
|
6 |
// variables and constructor are declared at the end
|
7 |
/**
|
8 |
* Load translations
|
2044 |
}
|
2045 |
|
2046 |
// add the frontend filters
|
|
|
2047 |
add_filter( 'the_content', array( &$this, 'filter' ), 10 );
|
2048 |
|
2049 |
// add actions for other plugins
|
2057 |
add_action( 'wp_footer', array( &$this, 'js_ip_library_script' ), 20 );
|
2058 |
}
|
2059 |
}
|
2060 |
+
add_shortcode( 'subscribe2', array( &$this, 'widget_shortcode' ) );
|
2061 |
}
|
2062 |
|
2063 |
/* ===== define some variables ===== */
|
classes/class-s2-form-widget.php
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
<?php
|
2 |
class S2_Form_Widget extends WP_Widget {
|
|
|
|
|
|
|
|
|
3 |
/**
|
4 |
* Declares the Subscribe2 widget class.
|
5 |
*/
|
@@ -8,8 +12,12 @@ class S2_Form_Widget extends WP_Widget {
|
|
8 |
'classname' => 's2_form_widget',
|
9 |
'description' => esc_html__( 'Sidebar Widget for Subscribe2', 'subscribe2' ),
|
10 |
'customize_selective_refresh' => true,
|
|
|
11 |
);
|
12 |
|
|
|
|
|
|
|
13 |
$control_ops = array(
|
14 |
'width' => 250,
|
15 |
'height' => 300,
|
@@ -57,11 +65,13 @@ class S2_Form_Widget extends WP_Widget {
|
|
57 |
if ( ! empty( $title ) ) {
|
58 |
echo wp_kses_post( $args['before_title'] ) . esc_attr( $title ) . wp_kses_post( $args['after_title'] );
|
59 |
}
|
|
|
60 |
echo '<div class="' . esc_attr( $div ) . '">';
|
61 |
if ( ! empty( $widgetprecontent ) ) {
|
62 |
echo wp_kses_post( $widgetprecontent );
|
63 |
}
|
64 |
echo do_shortcode( $shortcode );
|
|
|
65 |
if ( ! empty( $widgetpostcontent ) ) {
|
66 |
echo wp_kses_post( $widgetpostcontent );
|
67 |
}
|
@@ -184,4 +194,5 @@ class S2_Form_Widget extends WP_Widget {
|
|
184 |
echo '</label></p>' . "\r\n";
|
185 |
echo '</div>' . "\r\n";
|
186 |
}
|
|
|
187 |
} // End S2_Form_widget class
|
1 |
<?php
|
2 |
class S2_Form_Widget extends WP_Widget {
|
3 |
+
|
4 |
+
// Display the widget’s instance in the REST API
|
5 |
+
public $show_instance_in_rest = true;
|
6 |
+
|
7 |
/**
|
8 |
* Declares the Subscribe2 widget class.
|
9 |
*/
|
12 |
'classname' => 's2_form_widget',
|
13 |
'description' => esc_html__( 'Sidebar Widget for Subscribe2', 'subscribe2' ),
|
14 |
'customize_selective_refresh' => true,
|
15 |
+
'show_instance_in_rest' => true,
|
16 |
);
|
17 |
|
18 |
+
// add_filter( 'widget_text', 'shortcode_unautop' );
|
19 |
+
// add_filter( 'widget_text', 'do_shortcode' );
|
20 |
+
|
21 |
$control_ops = array(
|
22 |
'width' => 250,
|
23 |
'height' => 300,
|
65 |
if ( ! empty( $title ) ) {
|
66 |
echo wp_kses_post( $args['before_title'] ) . esc_attr( $title ) . wp_kses_post( $args['after_title'] );
|
67 |
}
|
68 |
+
|
69 |
echo '<div class="' . esc_attr( $div ) . '">';
|
70 |
if ( ! empty( $widgetprecontent ) ) {
|
71 |
echo wp_kses_post( $widgetprecontent );
|
72 |
}
|
73 |
echo do_shortcode( $shortcode );
|
74 |
+
|
75 |
if ( ! empty( $widgetpostcontent ) ) {
|
76 |
echo wp_kses_post( $widgetpostcontent );
|
77 |
}
|
194 |
echo '</label></p>' . "\r\n";
|
195 |
echo '</div>' . "\r\n";
|
196 |
}
|
197 |
+
|
198 |
} // End S2_Form_widget class
|
classes/class-s2-frontend.php
CHANGED
@@ -73,198 +73,6 @@ class S2_Frontend extends S2_Core {
|
|
73 |
}
|
74 |
}
|
75 |
|
76 |
-
/* ===== template and filter functions ===== */
|
77 |
-
/**
|
78 |
-
* Display our form; also handles (un)subscribe requests
|
79 |
-
*/
|
80 |
-
public function shortcode( $atts ) {
|
81 |
-
$args = shortcode_atts(
|
82 |
-
array(
|
83 |
-
'hide' => '',
|
84 |
-
'id' => '',
|
85 |
-
'nojs' => 'false',
|
86 |
-
'noantispam' => 'false',
|
87 |
-
'link' => '',
|
88 |
-
'size' => 20,
|
89 |
-
'wrap' => 'true',
|
90 |
-
'widget' => 'false',
|
91 |
-
),
|
92 |
-
$atts
|
93 |
-
);
|
94 |
-
|
95 |
-
// if link is true return a link to the page with the ajax class
|
96 |
-
if ( '1' === $this->subscribe2_options['ajax'] && '' !== $args['link'] && ! is_user_logged_in() ) {
|
97 |
-
$id = '';
|
98 |
-
foreach ( $args as $arg_name => $arg_value ) {
|
99 |
-
if ( ! empty( $arg_value ) && 'link' !== $arg_name && 'id' !== $arg_name ) {
|
100 |
-
if ( 'nojs' === $arg_name ) {
|
101 |
-
$arg_value = 'true';
|
102 |
-
}
|
103 |
-
( '' === $id ) ? $id .= $arg_name . '-' . $arg_value : $id .= ':' . $arg_name . '-' . $arg_value;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
$this->s2form = '<a href="#" class="s2popup" id="' . esc_attr( $id ) . '">' . esc_html( $args['link'] ) . '</a>' . "\r\n";
|
107 |
-
return $this->s2form;
|
108 |
-
}
|
109 |
-
|
110 |
-
// Apply filters to button text
|
111 |
-
$unsubscribe_button_value = apply_filters( 's2_unsubscribe_button', __( 'Unsubscribe', 'subscribe2' ) );
|
112 |
-
$subscribe_button_value = apply_filters( 's2_subscribe_button', __( 'Subscribe', 'subscribe2' ) );
|
113 |
-
|
114 |
-
// if a button is hidden, show only other
|
115 |
-
$hide = strtolower( $args['hide'] );
|
116 |
-
if ( 'subscribe' === $hide ) {
|
117 |
-
$this->input_form_action = '<input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
|
118 |
-
} elseif ( 'unsubscribe' === $hide ) {
|
119 |
-
$this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" />';
|
120 |
-
} else {
|
121 |
-
// both form input actions
|
122 |
-
$this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" /> <input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
|
123 |
-
}
|
124 |
-
|
125 |
-
// if ID is provided, get permalink
|
126 |
-
$action = '';
|
127 |
-
if ( is_numeric( $args['id'] ) ) {
|
128 |
-
$action = ' action="' . get_permalink( $args['id'] ) . '"';
|
129 |
-
} elseif ( 'home' === $args['id'] ) {
|
130 |
-
$action = ' action="' . get_site_url() . '"';
|
131 |
-
} elseif ( 'self' === $args['id'] ) {
|
132 |
-
// Correct for Static front page redirect behaviour
|
133 |
-
if ( 'page' === get_option( 'show_on_front' ) && is_front_page() ) {
|
134 |
-
$post = get_post( get_option( 'page_on_front' ) );
|
135 |
-
$action = ' action="' . get_option( 'home' ) . '/' . $post->post_name . '/"';
|
136 |
-
} else {
|
137 |
-
$action = '';
|
138 |
-
}
|
139 |
-
} elseif ( $this->subscribe2_options['s2page'] > 0 ) {
|
140 |
-
$action = ' action="' . get_permalink( $this->subscribe2_options['s2page'] ) . '"';
|
141 |
-
}
|
142 |
-
|
143 |
-
// allow remote setting of email in form
|
144 |
-
if ( isset( $_REQUEST['email'] ) ) {
|
145 |
-
$email = $this->sanitize_email( $_REQUEST['email'] );
|
146 |
-
}
|
147 |
-
if ( isset( $_REQUEST['email'] ) && false !== $this->validate_email( $email ) ) {
|
148 |
-
$value = $email;
|
149 |
-
} elseif ( 'true' === strtolower( $args['nojs'] ) ) {
|
150 |
-
$value = '';
|
151 |
-
} else {
|
152 |
-
$value = __( 'Enter email address...', 'subscribe2' );
|
153 |
-
}
|
154 |
-
|
155 |
-
// if wrap is true add paragraph html tags
|
156 |
-
$wrap_text = '';
|
157 |
-
if ( 'true' === strtolower( $args['wrap'] ) ) {
|
158 |
-
$wrap_text = '</p><p>';
|
159 |
-
}
|
160 |
-
|
161 |
-
// deploy some anti-spam measures
|
162 |
-
$antispam_text = '';
|
163 |
-
if ( 'true' !== strtolower( $args['noantispam'] ) ) {
|
164 |
-
$antispam_text = '<span style="display:none !important">';
|
165 |
-
$antispam_text .= '<label for="firstname">Leave This Blank:</label><input type="text" id="firstname" name="firstname" />';
|
166 |
-
$antispam_text .= '<label for="lastname">Leave This Blank Too:</label><input type="text" id="lastname" name="lastname" />';
|
167 |
-
$antispam_text .= '<label for="uri">Do Not Change This:</label><input type="text" id="uri" name="uri" value="http://" />';
|
168 |
-
$antispam_text .= '</span>';
|
169 |
-
}
|
170 |
-
|
171 |
-
// get remote IP address
|
172 |
-
$remote_ip = $this->get_remote_ip();
|
173 |
-
|
174 |
-
// form name
|
175 |
-
if ( 'true' === $args['widget'] ) {
|
176 |
-
$form_name = 's2formwidget';
|
177 |
-
} else {
|
178 |
-
$form_name = 's2form';
|
179 |
-
}
|
180 |
-
|
181 |
-
// build default form
|
182 |
-
if ( 'true' === strtolower( $args['nojs'] ) ) {
|
183 |
-
$this->form = '<form name="' . $form_name . '" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br><input type="email" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" />' . $wrap_text . $this->input_form_action . '</p></form>';
|
184 |
-
} else {
|
185 |
-
$this->form = '<form name="' . $form_name . '" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br><input type="email" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" onfocus="if (this.value === \'' . $value . '\') {this.value = \'\';}" onblur="if (this.value === \'\') {this.value = \'' . $value . '\';}" />' . $wrap_text . $this->input_form_action . '</p></form>' . "\r\n";
|
186 |
-
}
|
187 |
-
$this->s2form = apply_filters( 's2_form', $this->form, $args );
|
188 |
-
|
189 |
-
global $user_ID;
|
190 |
-
if ( 0 !== $user_ID ) {
|
191 |
-
return $this->profile;
|
192 |
-
}
|
193 |
-
|
194 |
-
if ( isset( $_POST['subscribe'] ) || isset( $_POST['unsubscribe'] ) ) {
|
195 |
-
// anti spam sign up measure
|
196 |
-
if ( ( isset( $_POST['firstname'] ) && '' !== $_POST['firstname'] ) || ( isset( $_POST['lastname'] ) && '' !== $_POST['lastname'] ) || ( isset( $_POST['uri'] ) && 'http://' !== $_POST['uri'] ) ) {
|
197 |
-
// looks like some invisible-to-user fields were changed; falsely report success
|
198 |
-
return $this->confirmation_sent;
|
199 |
-
}
|
200 |
-
$validation = apply_filters( 's2_form_submission', true );
|
201 |
-
if ( true !== $validation ) {
|
202 |
-
return apply_filters( 's2_form_failed_validation', $this->s2form );
|
203 |
-
}
|
204 |
-
global $wpdb;
|
205 |
-
$this->email = $this->sanitize_email( $_POST['email'] );
|
206 |
-
if ( false === $this->validate_email( $this->email ) ) {
|
207 |
-
$this->s2form = $this->s2form . $this->not_an_email;
|
208 |
-
} elseif ( $this->is_barred( $this->email ) ) {
|
209 |
-
$this->s2form = $this->s2form . $this->barred_domain;
|
210 |
-
} else {
|
211 |
-
$this->ip = $_POST['ip'];
|
212 |
-
if ( is_int( $this->lockout ) && $this->lockout > 0 ) {
|
213 |
-
$date = gmdate( 'H:i:s.u', $this->lockout );
|
214 |
-
$ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
|
215 |
-
if ( in_array( $this->ip, $ips, true ) ) {
|
216 |
-
return __( 'Slow down, you move too fast.', 'subscribe2' );
|
217 |
-
}
|
218 |
-
}
|
219 |
-
// does the supplied email belong to a registered user?
|
220 |
-
$check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email = %s", $this->email ) );
|
221 |
-
if ( null !== $check ) {
|
222 |
-
// this is a registered email
|
223 |
-
$this->s2form = $this->please_log_in;
|
224 |
-
} else {
|
225 |
-
// this is not a registered email
|
226 |
-
// what should we do?
|
227 |
-
if ( isset( $_POST['subscribe'] ) ) {
|
228 |
-
// someone is trying to subscribe
|
229 |
-
// lets see if they've tried to subscribe previously
|
230 |
-
if ( '1' !== $this->is_public( $this->email ) ) {
|
231 |
-
// the user is unknown or inactive
|
232 |
-
$this->add( $this->email );
|
233 |
-
$status = $this->send_confirm( 'add' );
|
234 |
-
// set a variable to denote that we've already run, and shouldn't run again
|
235 |
-
$this->filtered = 1;
|
236 |
-
if ( $status ) {
|
237 |
-
$this->s2form = $this->confirmation_sent;
|
238 |
-
} else {
|
239 |
-
$this->s2form = $this->error;
|
240 |
-
}
|
241 |
-
} else {
|
242 |
-
// they're already subscribed
|
243 |
-
$this->s2form = $this->already_subscribed;
|
244 |
-
}
|
245 |
-
$this->action = 'subscribe';
|
246 |
-
} elseif ( isset( $_POST['unsubscribe'] ) ) {
|
247 |
-
// is this email a subscriber?
|
248 |
-
if ( false === $this->is_public( $this->email ) ) {
|
249 |
-
$this->s2form = $this->s2form . $this->not_subscribed;
|
250 |
-
} else {
|
251 |
-
$status = $this->send_confirm( 'del' );
|
252 |
-
// set a variable to denote that we've already run, and shouldn't run again
|
253 |
-
$this->filtered = 1;
|
254 |
-
if ( $status ) {
|
255 |
-
$this->s2form = $this->confirmation_sent;
|
256 |
-
} else {
|
257 |
-
$this->s2form = $this->error;
|
258 |
-
}
|
259 |
-
}
|
260 |
-
$this->action = 'unsubscribe';
|
261 |
-
}
|
262 |
-
}
|
263 |
-
}
|
264 |
-
}
|
265 |
-
return $this->s2form;
|
266 |
-
}
|
267 |
-
|
268 |
/**
|
269 |
* Display form when deprecated <!--subscribe2--> is used
|
270 |
*/
|
@@ -505,37 +313,6 @@ class S2_Frontend extends S2_Core {
|
|
505 |
return false;
|
506 |
}
|
507 |
|
508 |
-
/**
|
509 |
-
* Collect and return the IP address of the remote client machine
|
510 |
-
*/
|
511 |
-
public function get_remote_ip() {
|
512 |
-
$remote_ip = false;
|
513 |
-
|
514 |
-
// In order of preference, with the best ones for this purpose first
|
515 |
-
$address_headers = array(
|
516 |
-
'HTTP_CLIENT_IP',
|
517 |
-
'HTTP_X_FORWARDED_FOR',
|
518 |
-
'HTTP_X_FORWARDED',
|
519 |
-
'HTTP_X_CLUSTER_CLIENT_IP',
|
520 |
-
'HTTP_FORWARDED_FOR',
|
521 |
-
'HTTP_FORWARDED',
|
522 |
-
'REMOTE_ADDR',
|
523 |
-
);
|
524 |
-
|
525 |
-
foreach ( $address_headers as $header ) {
|
526 |
-
if ( array_key_exists( $header, $_SERVER ) ) {
|
527 |
-
// HTTP_X_FORWARDED_FOR can contain a chain of comma-separated
|
528 |
-
// addresses. The first one is the original client. It can't be
|
529 |
-
// trusted for authenticity, but we don't need to for this purpose.
|
530 |
-
$address_chain = explode( ',', $_SERVER[ $header ] );
|
531 |
-
$remote_ip = trim( $address_chain[0] );
|
532 |
-
break;
|
533 |
-
}
|
534 |
-
}
|
535 |
-
|
536 |
-
return $remote_ip;
|
537 |
-
}
|
538 |
-
|
539 |
/**
|
540 |
* Enqueue javascript ip updater code
|
541 |
*/
|
@@ -568,4 +345,12 @@ class S2_Frontend extends S2_Core {
|
|
568 |
|
569 |
/* ===== define some variables ===== */
|
570 |
public $profile = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
}
|
73 |
}
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
/**
|
77 |
* Display form when deprecated <!--subscribe2--> is used
|
78 |
*/
|
313 |
return false;
|
314 |
}
|
315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
316 |
/**
|
317 |
* Enqueue javascript ip updater code
|
318 |
*/
|
345 |
|
346 |
/* ===== define some variables ===== */
|
347 |
public $profile = '';
|
348 |
+
|
349 |
+
|
350 |
+
/**
|
351 |
+
* Create and display a dropdown list of pages
|
352 |
+
*/
|
353 |
+
public function pages_dropdown( $s2page, $name = 's2page' ) {
|
354 |
+
//
|
355 |
+
}
|
356 |
}
|
include/s2-ajax.js
CHANGED
@@ -29,7 +29,8 @@ s2jQuery( document ).ready(
|
|
29 |
zIndex: 10000,
|
30 |
minWidth: 350,
|
31 |
minHeight: 300,
|
32 |
-
title: s2AjaxScriptStrings.title
|
|
|
33 |
}
|
34 |
);
|
35 |
dialog.dialog( 'open' );
|
29 |
zIndex: 10000,
|
30 |
minWidth: 350,
|
31 |
minHeight: 300,
|
32 |
+
title: s2AjaxScriptStrings.title,
|
33 |
+
closeText: ""
|
34 |
}
|
35 |
);
|
36 |
dialog.dialog( 'open' );
|
include/s2-checkbox.js
CHANGED
@@ -27,9 +27,7 @@ jQuery( document ).ready(
|
|
27 |
var checkedStatus = true;
|
28 |
jQuery( 'input[class="' + this.className + '"]' ).each(
|
29 |
function() {
|
30 |
-
if ( (
|
31 |
-
checkedStatus = true;
|
32 |
-
} else {
|
33 |
checkedStatus = false;
|
34 |
}
|
35 |
jQuery( 'input[value="' + this.className + '"]' )
|
@@ -40,16 +38,14 @@ jQuery( document ).ready(
|
|
40 |
);
|
41 |
|
42 |
// function to check or uncheck 'checkall' box when page is loaded
|
43 |
-
jQuery( 'input[
|
44 |
-
function() {
|
45 |
var checkedStatus = true;
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
}
|
51 |
-
jQuery(
|
52 |
-
.prop( 'checked', checkedStatus );
|
53 |
}
|
54 |
);
|
55 |
}
|
27 |
var checkedStatus = true;
|
28 |
jQuery( 'input[class="' + this.className + '"]' ).each(
|
29 |
function() {
|
30 |
+
if ( ( ! this.checked ) ) {
|
|
|
|
|
31 |
checkedStatus = false;
|
32 |
}
|
33 |
jQuery( 'input[value="' + this.className + '"]' )
|
38 |
);
|
39 |
|
40 |
// function to check or uncheck 'checkall' box when page is loaded
|
41 |
+
jQuery( 'input[name^="checkall"]' ).each(function(value, item) {
|
|
|
42 |
var checkedStatus = true;
|
43 |
+
jQuery('input[class='+item.value).each(function () {
|
44 |
+
if ( ( ! this.checked ) ) {
|
45 |
+
checkedStatus = false;
|
46 |
+
}
|
47 |
+
});
|
48 |
+
jQuery(this).prop( 'checked', checkedStatus );
|
|
|
49 |
}
|
50 |
);
|
51 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ 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.
|
7 |
-
Stable tag: 10.
|
8 |
Requires PHP: 5.4
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
@@ -72,6 +72,15 @@ This token will automatically be replaced by dynamic subscription information an
|
|
72 |
|
73 |
== Changelog ==
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
= 10.35 (15th March, 2021) =
|
76 |
|
77 |
* Fix {UNSUBLINK} shortcode
|
@@ -86,4 +95,4 @@ This token will automatically be replaced by dynamic subscription information an
|
|
86 |
* Bump tested upto version 4.4
|
87 |
* Minimum PHP version set to 5.4
|
88 |
|
89 |
-
See complete [changelog](https://github.com/weMail/Subscribe2/blob/develop/
|
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.8
|
7 |
+
Stable tag: 10.36
|
8 |
Requires PHP: 5.4
|
9 |
License: GPLv3
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
72 |
|
73 |
== Changelog ==
|
74 |
|
75 |
+
= 10.36 (30th September, 2021) =
|
76 |
+
|
77 |
+
* WordPress 5.8 compatibility
|
78 |
+
* Fix form preview on widgets
|
79 |
+
* Fix pop up form
|
80 |
+
* Fix send schedule email options
|
81 |
+
* Fix one click subscription
|
82 |
+
* Fix some PHP warnings
|
83 |
+
|
84 |
= 10.35 (15th March, 2021) =
|
85 |
|
86 |
* Fix {UNSUBLINK} shortcode
|
95 |
* Bump tested upto version 4.4
|
96 |
* Minimum PHP version set to 5.4
|
97 |
|
98 |
+
See complete [changelog](https://github.com/weMail/Subscribe2/blob/develop/changelog.txt).
|
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.
|
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.
|
58 |
define( 'S2PLUGIN', __FILE__ );
|
59 |
define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
|
60 |
define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
|
@@ -65,6 +65,7 @@ if ( function_exists( 'set_time_limit' ) ) {
|
|
65 |
set_time_limit( 300 );
|
66 |
}
|
67 |
|
|
|
68 |
global $mysubscribe2;
|
69 |
|
70 |
require_once S2PATH . 'classes/class-s2-core.php';
|
3 |
Plugin Name: Subscribe2
|
4 |
Plugin URI: https://getwemail.io
|
5 |
Description: Notifies an email list when new entries are posted.
|
6 |
+
Version: 10.36
|
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.36' );
|
58 |
define( 'S2PLUGIN', __FILE__ );
|
59 |
define( 'S2PATH', trailingslashit( dirname( __FILE__ ) ) );
|
60 |
define( 'S2DIR', trailingslashit( dirname( plugin_basename( __FILE__ ) ) ) );
|
65 |
set_time_limit( 300 );
|
66 |
}
|
67 |
|
68 |
+
|
69 |
global $mysubscribe2;
|
70 |
|
71 |
require_once S2PATH . 'classes/class-s2-core.php';
|
traits/ShortcodeTrait.php
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
trait Shortcode {
|
4 |
+
/* ===== template and filter functions ===== */
|
5 |
+
/**
|
6 |
+
* Display our form; also handles (un)subscribe requests
|
7 |
+
*/
|
8 |
+
public function widget_shortcode( $atts ) {
|
9 |
+
$args = shortcode_atts(
|
10 |
+
array(
|
11 |
+
'hide' => '',
|
12 |
+
'id' => '',
|
13 |
+
'nojs' => 'false',
|
14 |
+
'noantispam' => 'false',
|
15 |
+
'link' => '',
|
16 |
+
'size' => 20,
|
17 |
+
'wrap' => 'true',
|
18 |
+
'widget' => 'false',
|
19 |
+
),
|
20 |
+
$atts
|
21 |
+
);
|
22 |
+
|
23 |
+
// if link is true return a link to the page with the ajax class
|
24 |
+
if ( '1' === $this->subscribe2_options['ajax'] && '' !== $args['link'] && ! is_user_logged_in() ) {
|
25 |
+
$id = '';
|
26 |
+
foreach ( $args as $arg_name => $arg_value ) {
|
27 |
+
if ( ! empty( $arg_value ) && 'link' !== $arg_name && 'id' !== $arg_name ) {
|
28 |
+
if ( 'nojs' === $arg_name ) {
|
29 |
+
$arg_value = 'true';
|
30 |
+
}
|
31 |
+
( '' === $id ) ? $id .= $arg_name . '-' . $arg_value : $id .= ':' . $arg_name . '-' . $arg_value;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
$this->s2form = '<a href="#" class="s2popup" id="' . esc_attr( $id ) . '">' . esc_html( $args['link'] ) . '</a>' . "\r\n";
|
35 |
+
return $this->s2form;
|
36 |
+
}
|
37 |
+
|
38 |
+
// Apply filters to button text
|
39 |
+
$unsubscribe_button_value = apply_filters( 's2_unsubscribe_button', __( 'Unsubscribe', 'subscribe2' ) );
|
40 |
+
$subscribe_button_value = apply_filters( 's2_subscribe_button', __( 'Subscribe', 'subscribe2' ) );
|
41 |
+
|
42 |
+
// if a button is hidden, show only other
|
43 |
+
$hide = strtolower( $args['hide'] );
|
44 |
+
if ( 'subscribe' === $hide ) {
|
45 |
+
$this->input_form_action = '<input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
|
46 |
+
} elseif ( 'unsubscribe' === $hide ) {
|
47 |
+
$this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" />';
|
48 |
+
} else {
|
49 |
+
// both form input actions
|
50 |
+
$this->input_form_action = '<input type="submit" name="subscribe" value="' . esc_attr( $subscribe_button_value ) . '" /> <input type="submit" name="unsubscribe" value="' . esc_attr( $unsubscribe_button_value ) . '" />';
|
51 |
+
}
|
52 |
+
|
53 |
+
// if ID is provided, get permalink
|
54 |
+
$action = '';
|
55 |
+
if ( is_numeric( $args['id'] ) ) {
|
56 |
+
$action = ' action="' . get_permalink( $args['id'] ) . '"';
|
57 |
+
} elseif ( 'home' === $args['id'] ) {
|
58 |
+
$action = ' action="' . get_site_url() . '"';
|
59 |
+
} elseif ( 'self' === $args['id'] ) {
|
60 |
+
// Correct for Static front page redirect behaviour
|
61 |
+
if ( 'page' === get_option( 'show_on_front' ) && is_front_page() ) {
|
62 |
+
$post = get_post( get_option( 'page_on_front' ) );
|
63 |
+
$action = ' action="' . get_option( 'home' ) . '/' . $post->post_name . '/"';
|
64 |
+
} else {
|
65 |
+
$action = '';
|
66 |
+
}
|
67 |
+
} elseif ( $this->subscribe2_options['s2page'] > 0 ) {
|
68 |
+
$action = ' action="' . get_permalink( $this->subscribe2_options['s2page'] ) . '"';
|
69 |
+
}
|
70 |
+
|
71 |
+
// allow remote setting of email in form
|
72 |
+
if ( isset( $_REQUEST['email'] ) ) {
|
73 |
+
$email = $this->sanitize_email( $_REQUEST['email'] );
|
74 |
+
}
|
75 |
+
if ( isset( $_REQUEST['email'] ) && false !== $this->validate_email( $email ) ) {
|
76 |
+
$value = $email;
|
77 |
+
} elseif ( 'true' === strtolower( $args['nojs'] ) ) {
|
78 |
+
$value = '';
|
79 |
+
} else {
|
80 |
+
$value = __( 'Enter email address...', 'subscribe2' );
|
81 |
+
}
|
82 |
+
|
83 |
+
// if wrap is true add paragraph html tags
|
84 |
+
$wrap_text = '';
|
85 |
+
if ( 'true' === strtolower( $args['wrap'] ) ) {
|
86 |
+
$wrap_text = '</p><p>';
|
87 |
+
}
|
88 |
+
|
89 |
+
// deploy some anti-spam measures
|
90 |
+
$antispam_text = '';
|
91 |
+
if ( 'true' !== strtolower( $args['noantispam'] ) ) {
|
92 |
+
$antispam_text = '<span style="display:none !important">';
|
93 |
+
$antispam_text .= '<label for="firstname">Leave This Blank:</label><input type="text" id="firstname" name="firstname" />';
|
94 |
+
$antispam_text .= '<label for="lastname">Leave This Blank Too:</label><input type="text" id="lastname" name="lastname" />';
|
95 |
+
$antispam_text .= '<label for="uri">Do Not Change This:</label><input type="text" id="uri" name="uri" value="http://" />';
|
96 |
+
$antispam_text .= '</span>';
|
97 |
+
}
|
98 |
+
|
99 |
+
// get remote IP address
|
100 |
+
$remote_ip = $this->get_remote_ip();
|
101 |
+
|
102 |
+
// form name
|
103 |
+
if ( 'true' === $args['widget'] ) {
|
104 |
+
$form_name = 's2formwidget';
|
105 |
+
} else {
|
106 |
+
$form_name = 's2form';
|
107 |
+
}
|
108 |
+
|
109 |
+
// build default form
|
110 |
+
if ( 'true' === strtolower( $args['nojs'] ) ) {
|
111 |
+
$this->form = '<form name="' . $form_name . '" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br><input type="email" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" />' . $wrap_text . $this->input_form_action . '</p></form>';
|
112 |
+
} else {
|
113 |
+
$this->form = '<form name="' . $form_name . '" method="post"' . $action . '><input type="hidden" name="ip" value="' . esc_attr( $_SERVER['REMOTE_ADDR'] ) . '" />' . $antispam_text . '<p><label for="s2email">' . __( 'Your email:', 'subscribe2' ) . '</label><br><input type="email" name="email" id="s2email" value="' . $value . '" size="' . $args['size'] . '" onfocus="if (this.value === \'' . $value . '\') {this.value = \'\';}" onblur="if (this.value === \'\') {this.value = \'' . $value . '\';}" />' . $wrap_text . $this->input_form_action . '</p></form>' . "\r\n";
|
114 |
+
}
|
115 |
+
$this->s2form = apply_filters( 's2_form', $this->form, $args );
|
116 |
+
|
117 |
+
if ( isset( $_POST['subscribe'] ) || isset( $_POST['unsubscribe'] ) ) {
|
118 |
+
// anti spam sign up measure
|
119 |
+
if ( ( isset( $_POST['firstname'] ) && '' !== $_POST['firstname'] ) || ( isset( $_POST['lastname'] ) && '' !== $_POST['lastname'] ) || ( isset( $_POST['uri'] ) && 'http://' !== $_POST['uri'] ) ) {
|
120 |
+
// looks like some invisible-to-user fields were changed; falsely report success
|
121 |
+
return $this->confirmation_sent;
|
122 |
+
}
|
123 |
+
$validation = apply_filters( 's2_form_submission', true );
|
124 |
+
if ( true !== $validation ) {
|
125 |
+
return apply_filters( 's2_form_failed_validation', $this->s2form );
|
126 |
+
}
|
127 |
+
global $wpdb;
|
128 |
+
$this->email = $this->sanitize_email( $_POST['email'] );
|
129 |
+
if ( false === $this->validate_email( $this->email ) ) {
|
130 |
+
$this->s2form = $this->s2form . $this->not_an_email;
|
131 |
+
} elseif ( $this->is_barred( $this->email ) ) {
|
132 |
+
$this->s2form = $this->s2form . $this->barred_domain;
|
133 |
+
} else {
|
134 |
+
$this->ip = $_POST['ip'];
|
135 |
+
if ( is_int( $this->lockout ) && $this->lockout > 0 ) {
|
136 |
+
$date = gmdate( 'H:i:s.u', $this->lockout );
|
137 |
+
$ips = $wpdb->get_col( $wpdb->prepare( "SELECT ip FROM $wpdb->subscribe2 WHERE date = CURDATE() AND time > SUBTIME(CURTIME(), %s)", $date ) );
|
138 |
+
if ( in_array( $this->ip, $ips, true ) ) {
|
139 |
+
return __( 'Slow down, you move too fast.', 'subscribe2' );
|
140 |
+
}
|
141 |
+
}
|
142 |
+
// does the supplied email belong to a registered user?
|
143 |
+
$check = $wpdb->get_var( $wpdb->prepare( "SELECT user_email FROM $wpdb->users WHERE user_email = %s", $this->email ) );
|
144 |
+
if ( null !== $check ) {
|
145 |
+
// this is a registered email
|
146 |
+
$this->s2form = $this->please_log_in;
|
147 |
+
} else {
|
148 |
+
// this is not a registered email
|
149 |
+
// what should we do?
|
150 |
+
if ( isset( $_POST['subscribe'] ) ) {
|
151 |
+
// someone is trying to subscribe
|
152 |
+
// lets see if they've tried to subscribe previously
|
153 |
+
if ( '1' !== $this->is_public( $this->email ) ) {
|
154 |
+
// the user is unknown or inactive
|
155 |
+
$this->add( $this->email );
|
156 |
+
$status = $this->send_confirm( 'add' );
|
157 |
+
// set a variable to denote that we've already run, and shouldn't run again
|
158 |
+
$this->filtered = 1;
|
159 |
+
if ( $status ) {
|
160 |
+
$this->s2form = $this->confirmation_sent;
|
161 |
+
} else {
|
162 |
+
$this->s2form = $this->error;
|
163 |
+
}
|
164 |
+
} else {
|
165 |
+
// they're already subscribed
|
166 |
+
$this->s2form = $this->already_subscribed;
|
167 |
+
}
|
168 |
+
$this->action = 'subscribe';
|
169 |
+
} elseif ( isset( $_POST['unsubscribe'] ) ) {
|
170 |
+
// is this email a subscriber?
|
171 |
+
if ( false === $this->is_public( $this->email ) ) {
|
172 |
+
$this->s2form = $this->s2form . $this->not_subscribed;
|
173 |
+
} else {
|
174 |
+
$status = $this->send_confirm( 'del' );
|
175 |
+
// set a variable to denote that we've already run, and shouldn't run again
|
176 |
+
$this->filtered = 1;
|
177 |
+
if ( $status ) {
|
178 |
+
$this->s2form = $this->confirmation_sent;
|
179 |
+
} else {
|
180 |
+
$this->s2form = $this->error;
|
181 |
+
}
|
182 |
+
}
|
183 |
+
$this->action = 'unsubscribe';
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
return $this->s2form;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Collect and return the IP address of the remote client machine
|
193 |
+
*/
|
194 |
+
public function get_remote_ip() {
|
195 |
+
$remote_ip = false;
|
196 |
+
|
197 |
+
// In order of preference, with the best ones for this purpose first
|
198 |
+
$address_headers = array(
|
199 |
+
'HTTP_CLIENT_IP',
|
200 |
+
'HTTP_X_FORWARDED_FOR',
|
201 |
+
'HTTP_X_FORWARDED',
|
202 |
+
'HTTP_X_CLUSTER_CLIENT_IP',
|
203 |
+
'HTTP_FORWARDED_FOR',
|
204 |
+
'HTTP_FORWARDED',
|
205 |
+
'REMOTE_ADDR',
|
206 |
+
);
|
207 |
+
|
208 |
+
foreach ( $address_headers as $header ) {
|
209 |
+
if ( array_key_exists( $header, $_SERVER ) ) {
|
210 |
+
// HTTP_X_FORWARDED_FOR can contain a chain of comma-separated
|
211 |
+
// addresses. The first one is the original client. It can't be
|
212 |
+
// trusted for authenticity, but we don't need to for this purpose.
|
213 |
+
$address_chain = explode( ',', $_SERVER[ $header ] );
|
214 |
+
$remote_ip = trim( $address_chain[0] );
|
215 |
+
break;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
return $remote_ip;
|
220 |
+
}
|
221 |
+
}
|