PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 9.2
Jetpack – WP Security, Backup, Speed, & Growth v9.2
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
← All changes | modules/subscriptions.php +222 -407 13.6.29.2 View file →
@@ -1,35 +1,22 @@
1 -<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName)
1 +<?php
2 2 /**
3 - * Module Name: Newsletter
3 + * Module Name: Subscriptions
4 4 * Module Description: Let visitors subscribe to new posts and comments via email
5 5 * Sort Order: 9
6 6 * Recommendation Order: 8
7 7 * First Introduced: 1.2
8 8 * Requires Connection: Yes
9 - * Requires User Connection: Yes
10 9 * Auto Activate: No
11 10 * Module Tags: Social
12 11 * Feature: Engagement
13 - * Additional Search Queries: subscriptions, subscription, email, follow, followers, subscribers, signup, newsletter, creator
12 + * Additional Search Queries: subscriptions, subscription, email, follow, followers, subscribers, signup
14 13 */
15 14
16 -// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
17 -
18 -use Automattic\Jetpack\Connection\Manager as Connection_Manager;
19 15 use Automattic\Jetpack\Connection\XMLRPC_Async_Call;
20 -use Automattic\Jetpack\Redirect;
21 -use Automattic\Jetpack\Status;
22 -use Automattic\Jetpack\Status\Host;
23 16
24 17 add_action( 'jetpack_modules_loaded', 'jetpack_subscriptions_load' );
25 18
26 -// Loads the User Content Link Redirection feature.
27 -require_once __DIR__ . '/subscriptions/jetpack-user-content-link-redirection.php';
28 -
29 -/**
30 - * Loads the Subscriptions module.
31 - */
32 19 function jetpack_subscriptions_load() {
33 20 Jetpack::enable_module_configurable( __FILE__ );
34 21 }
35 22
@@ -43,13 +30,13 @@
43 30 function jetpack_subscriptions_cherry_pick_server_data() {
44 31 $data = array();
45 32
46 33 foreach ( $_SERVER as $key => $value ) {
47 - if ( ! is_string( $value ) || str_starts_with( $key, 'HTTP_COOKIE' ) ) {
34 + if ( ! is_string( $value ) || 0 === strpos( $key, 'HTTP_COOKIE' ) ) {
48 35 continue;
49 36 }
50 37
51 - if ( str_starts_with( $key, 'HTTP_' ) || in_array( $key, array( 'REMOTE_ADDR', 'REQUEST_URI', 'DOCUMENT_URI' ), true ) ) {
38 + if ( 0 === strpos( $key, 'HTTP_' ) || in_array( $key, array( 'REMOTE_ADDR', 'REQUEST_URI', 'DOCUMENT_URI' ), true ) ) {
52 39 $data[ $key ] = $value;
53 40 }
54 41 }
55 42
@@ -55,49 +42,32 @@
55 42
56 43 return $data;
57 44 }
58 45
59 -/**
60 - * Main class file for the Subscriptions module.
61 - */
62 46 class Jetpack_Subscriptions {
63 - /**
64 - * Whether Jetpack has been instantiated or not.
65 - *
66 - * @var bool
67 - */
68 47 public $jetpack = false;
69 48
70 - /**
71 - * Hash of the siteurl option.
72 - *
73 - * @var string
74 - */
75 49 public static $hash;
76 50
77 51 /**
78 52 * Singleton
79 - *
80 53 * @static
81 54 */
82 - public static function init() {
55 + static function init() {
83 56 static $instance = false;
84 57
85 - if ( ! $instance ) {
86 - $instance = new Jetpack_Subscriptions();
58 + if ( !$instance ) {
59 + $instance = new Jetpack_Subscriptions;
87 60 }
88 61
89 62 return $instance;
90 63 }
91 64
92 - /**
93 - * Jetpack_Subscriptions constructor.
94 - */
95 - public function __construct() {
65 + function __construct() {
96 66 $this->jetpack = Jetpack::init();
97 67
98 68 // Don't use COOKIEHASH as it could be shared across installs && is non-unique in multisite.
99 - // @see: https://twitter.com/nacin/status/378246957451333632 .
69 + // @see: https://twitter.com/nacin/status/378246957451333632
100 70 self::$hash = md5( get_option( 'siteurl' ) );
101 71
102 72 add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
103 73
@@ -102,23 +72,22 @@
102 72 add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
103 73
104 74 // @todo remove sync from subscriptions and move elsewhere...
105 75
106 - // Add Configuration Page.
76 + // Add Configuration Page
107 77 add_action( 'admin_init', array( $this, 'configure' ) );
108 78
109 - // Catch subscription widget submits.
110 - if ( isset( $_REQUEST['jetpack_subscriptions_widget'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce checked in widget_submit() for logged in users.
79 + // Catch subscription widget submits
80 + if ( isset( $_REQUEST['jetpack_subscriptions_widget'] ) )
111 81 add_action( 'template_redirect', array( $this, 'widget_submit' ) );
112 - }
113 82
114 - // Set up the comment subscription checkboxes.
83 + // Set up the comment subscription checkboxes
115 84 add_filter( 'comment_form_submit_field', array( $this, 'comment_subscribe_init' ), 10, 2 );
116 85
117 86 // Catch comment posts and check for subscriptions.
118 87 add_action( 'comment_post', array( $this, 'comment_subscribe_submit' ), 50, 2 );
119 88
120 - // Adds post meta checkbox in the post submit metabox.
89 + // Adds post meta checkbox in the post submit metabox
121 90 add_action( 'post_submitbox_misc_actions', array( $this, 'subscription_post_page_metabox' ) );
122 91
123 92 add_action( 'transition_post_status', array( $this, 'maybe_send_subscription_email' ), 10, 3 );
124 93
@@ -126,27 +95,9 @@
126 95
127 96 add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 18, 1 );
128 97
129 98 // Set "social_notifications_subscribe" option during the first-time activation.
130 - add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_social_notifications_subscribe' ) );
131 -
132 - // Hide subscription messaging in Publish panel for posts that were published in the past
133 - add_action( 'init', array( $this, 'register_post_meta' ), 20 );
134 - add_action( 'transition_post_status', array( $this, 'maybe_set_first_published_status' ), 10, 3 );
135 -
136 - // Add Subscribers menu to Jetpack navigation.
137 - add_action( 'jetpack_admin_menu', array( $this, 'add_subscribers_menu' ) );
138 -
139 - // Customize the configuration URL to lead to the Subscriptions settings.
140 - add_filter(
141 - 'jetpack_module_configuration_url_subscriptions',
142 - function () {
143 - return Jetpack::admin_url( array( 'page' => 'jetpack#/newsletter' ) );
144 - }
145 - );
146 -
147 - // Track categories created through the category editor page
148 - add_action( 'wp_ajax_add-tag', array( $this, 'track_newsletter_category_creation' ), 1 );
99 + add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_social_notifications_subscribe' ) );
149 100 }
150 101
151 102 /**
152 103 * Jetpack_Subscriptions::xmlrpc_methods()
@@ -151,12 +102,11 @@
151 102 /**
152 103 * Jetpack_Subscriptions::xmlrpc_methods()
153 104 *
154 105 * Register subscriptions methods with the Jetpack XML-RPC server.
155 - *
156 - * @param array $methods Methods being registered.
106 + * @param array $methods
157 107 */
158 - public function xmlrpc_methods( $methods ) {
108 + function xmlrpc_methods( $methods ) {
159 109 return array_merge(
160 110 $methods,
161 111 array(
162 112 'jetpack.subscriptions.subscribe' => array( $this, 'subscribe' ),
@@ -163,13 +113,13 @@
163 113 )
164 114 );
165 115 }
166 116
167 - /**
117 + /*
168 118 * Disable Subscribe on Single Post
169 119 * Register post meta
170 120 */
171 - public function subscription_post_page_metabox() {
121 + function subscription_post_page_metabox() {
172 122 if (
173 123 /**
174 124 * Filter whether or not to show the per-post subscription option.
175 125 *
@@ -178,9 +128,10 @@
178 128 * @since 3.7.0
179 129 *
180 130 * @param bool true = show checkbox option on all new posts | false = hide the option.
181 131 */
182 - ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) ) {
132 + ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) )
133 + {
183 134 return;
184 135 }
185 136
186 137 if ( has_filter( 'jetpack_subscriptions_exclude_these_categories' ) || has_filter( 'jetpack_subscriptions_include_only_these_categories' ) ) {
@@ -189,19 +140,18 @@
189 140
190 141 global $post;
191 142 $disable_subscribe_value = get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true );
192 143 // only show checkbox if post hasn't been published and is a 'post' post type.
193 - if ( get_post_status( $post->ID ) !== 'publish' && get_post_type( $post->ID ) === 'post' ) :
194 - // Nonce it.
144 + if ( get_post_status( $post->ID ) !== 'publish' && get_post_type( $post->ID ) == 'post' ) :
145 + // Nonce it
195 146 wp_nonce_field( 'disable_subscribe', 'disable_subscribe_nonce' );
196 147 ?>
197 148 <div class="misc-pub-section">
198 - <label for="_jetpack_dont_email_post_to_subs"><?php esc_html_e( 'Jetpack Subscriptions:', 'jetpack' ); ?></label><br>
149 + <label for="_jetpack_dont_email_post_to_subs"><?php _e( 'Jetpack Subscriptions:', 'jetpack' ); ?></label><br>
199 150 <input type="checkbox" name="_jetpack_dont_email_post_to_subs" id="jetpack-per-post-subscribe" value="1" <?php checked( $disable_subscribe_value, 1, true ); ?> />
200 - <?php esc_html_e( 'Don&#8217;t send this to subscribers', 'jetpack' ); ?>
151 + <?php _e( 'Don&#8217;t send this to subscribers', 'jetpack' ); ?>
201 152 </div>
202 - <?php
203 - endif;
153 + <?php endif;
204 154 }
205 155
206 156 /**
207 157 * Checks whether or not the post should be emailed to subscribers
@@ -212,38 +162,32 @@
212 162 * - Existence of the per-post checkbox option
213 163 *
214 164 * Only one of these can be used at any given time.
215 165 *
216 - * @param string $new_status Tthe "new" post status of the transition when saved.
217 - * @param string $old_status The "old" post status of the transition when saved.
218 - * @param object $post obj The post object.
166 + * @param $new_status string - the "new" post status of the transition when saved
167 + * @param $old_status string - the "old" post status of the transition when saved
168 + * @param $post obj - The post object
219 169 */
220 - public function maybe_send_subscription_email( $new_status, $old_status, $post ) {
170 + function maybe_send_subscription_email( $new_status, $old_status, $post ) {
221 171
222 172 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
223 173 return;
224 174 }
225 175
226 - // Make sure that the checkbox is preseved.
227 - if ( ! empty( $_POST['disable_subscribe_nonce'] ) && wp_verify_nonce( $_POST['disable_subscribe_nonce'], 'disable_subscribe' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- WP Core doesn't unslash or sanitize nonces either.
176 + // Make sure that the checkbox is preseved
177 + if ( ! empty( $_POST['disable_subscribe_nonce'] ) && wp_verify_nonce( $_POST['disable_subscribe_nonce'], 'disable_subscribe' ) ) {
228 178 $set_checkbox = isset( $_POST['_jetpack_dont_email_post_to_subs'] ) ? 1 : 0;
229 179 update_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', $set_checkbox );
230 180 }
231 181 }
232 182
233 - /**
234 - * Message used when publishing a post.
235 - *
236 - * @param array $messages Message array for a post.
237 - */
238 - public function update_published_message( $messages ) {
183 + function update_published_message( $messages ) {
239 184 global $post;
240 185 if ( ! $this->should_email_post_to_subscribers( $post ) ) {
241 186 return $messages;
242 187 }
243 188
244 - $view_post_link_html = sprintf(
245 - ' <a href="%1$s">%2$s</a>',
189 + $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
246 190 esc_url( get_permalink( $post ) ),
247 191 __( 'View post', 'jetpack' )
248 192 );
249 193
@@ -249,17 +193,12 @@
249 193
250 194 $messages['post'][6] = sprintf(
251 195 /* translators: Message shown after a post is published */
252 196 esc_html__( 'Post published and sending emails to subscribers.', 'jetpack' )
253 - ) . $view_post_link_html;
197 + ) . $view_post_link_html;
254 198 return $messages;
255 199 }
256 200
257 - /**
258 - * Determine if a post should notifiy subscribers via email.
259 - *
260 - * @param object $post The post.
261 - */
262 201 public function should_email_post_to_subscribers( $post ) {
263 202 $should_email = true;
264 203 if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
265 204 return false;
@@ -264,10 +203,10 @@
264 203 if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
265 204 return false;
266 205 }
267 206
268 - // Only posts are currently supported.
269 - if ( 'post' !== $post->post_type ) {
207 + // Only posts are currently supported
208 + if ( $post->post_type !== 'post' ) {
270 209 return false;
271 210 }
272 211
273 212 // Private posts are not sent to subscribers.
@@ -287,9 +226,9 @@
287 226 * @param array $args Array of category slugs or ID's.
288 227 */
289 228 $excluded_categories = apply_filters( 'jetpack_subscriptions_exclude_these_categories', array() );
290 229
291 - // Never email posts from these categories.
230 + // Never email posts from these categories
292 231 if ( ! empty( $excluded_categories ) && in_category( $excluded_categories, $post->ID ) ) {
293 232 $should_email = false;
294 233 }
295 234
@@ -305,9 +244,9 @@
305 244 * @param array $args Array of category slugs or ID's.
306 245 */
307 246 $only_these_categories = apply_filters( 'jetpack_subscriptions_exclude_all_categories_except', array() );
308 247
309 - // Only emails posts from these categories.
248 + // Only emails posts from these categories
310 249 if ( ! empty( $only_these_categories ) && ! in_category( $only_these_categories, $post->ID ) ) {
311 250 $should_email = false;
312 251 }
313 252
@@ -313,15 +252,9 @@
313 252
314 253 return $should_email;
315 254 }
316 255
317 - /**
318 - * Retrieve which flags should be added to a particular post.
319 - *
320 - * @param array $flags Flags to be added.
321 - * @param object $post A post object.
322 - */
323 - public function set_post_flags( $flags, $post ) {
256 + function set_post_flags( $flags, $post ) {
324 257 $flags['send_subscription'] = $this->should_email_post_to_subscribers( $post );
325 258 return $flags;
326 259 }
327 260
@@ -329,10 +262,10 @@
329 262 * Jetpack_Subscriptions::configure()
330 263 *
331 264 * Jetpack Subscriptions configuration screen.
332 265 */
333 - public function configure() {
334 - // Create the section.
266 + function configure() {
267 + // Create the section
335 268 add_settings_section(
336 269 'jetpack_subscriptions',
337 270 __( 'Jetpack Subscriptions Settings', 'jetpack' ),
338 271 array( $this, 'subscriptions_settings_section' ),
@@ -338,9 +271,9 @@
338 271 array( $this, 'subscriptions_settings_section' ),
339 272 'discussion'
340 273 );
341 274
342 - /** Subscribe to Posts */
275 + /** Subscribe to Posts ***************************************************/
343 276
344 277 add_settings_field(
345 278 'jetpack_subscriptions_post_subscribe',
346 279 __( 'Follow Blog', 'jetpack' ),
@@ -353,9 +286,9 @@
353 286 'discussion',
354 287 'stb_enabled'
355 288 );
356 289
357 - /** Subscribe to Comments */
290 + /** Subscribe to Comments ******************************************************/
358 291
359 292 add_settings_field(
360 293 'jetpack_subscriptions_comment_subscribe',
361 294 __( 'Follow Comments', 'jetpack' ),
@@ -368,29 +301,14 @@
368 301 'discussion',
369 302 'stc_enabled'
370 303 );
371 304
372 - /** Enable Subscribe Modal */
373 -
374 - add_settings_field(
375 - 'jetpack_subscriptions_comment_subscribe',
376 - __( 'Enable Subscribe Modal', 'jetpack' ),
377 - array( $this, 'subscribe_modal_setting' ),
378 - 'discussion',
379 - 'jetpack_subscriptions'
380 - );
381 -
382 - register_setting(
383 - 'discussion',
384 - 'sm_enabled'
385 - );
386 -
387 - /** Email me whenever: Someone subscribes to my blog */
305 + /** Email me whenever: Someone follows my blog ***************************************************/
388 306 /* @since 8.1 */
389 307
390 308 add_settings_section(
391 309 'notifications_section',
392 - __( 'Someone subscribes to my blog', 'jetpack' ),
310 + __( 'Someone follows my blog', 'jetpack' ),
393 311 array( $this, 'social_notifications_subscribe_section' ),
394 312 'discussion'
395 313 );
396 314
@@ -406,90 +324,90 @@
406 324 'discussion',
407 325 'social_notifications_subscribe',
408 326 array( $this, 'social_notifications_subscribe_validate' )
409 327 );
328 +
329 + /** Subscription Messaging Options ******************************************************/
330 +
331 + register_setting(
332 + 'reading',
333 + 'subscription_options',
334 + array( $this, 'validate_settings' )
335 + );
336 +
337 + add_settings_section(
338 + 'email_settings',
339 + __( 'Follower Settings', 'jetpack' ),
340 + array( $this, 'reading_section' ),
341 + 'reading'
342 + );
343 +
344 + add_settings_field(
345 + 'invitation',
346 + __( 'Blog follow email text', 'jetpack' ),
347 + array( $this, 'setting_invitation' ),
348 + 'reading',
349 + 'email_settings'
350 + );
351 +
352 + add_settings_field(
353 + 'comment-follow',
354 + __( 'Comment follow email text', 'jetpack' ),
355 + array( $this, 'setting_comment_follow' ),
356 + 'reading',
357 + 'email_settings'
358 + );
410 359 }
411 360
412 361 /**
413 - * Discussions setting section blurb.
362 + * Discussions setting section blurb
363 + *
414 364 */
415 - public function subscriptions_settings_section() {
416 - ?>
417 - <p id="jetpack-subscriptions-settings"><?php esc_html_e( 'Change whether your visitors can subscribe to your posts or comments or both.', 'jetpack' ); ?></p>
365 + function subscriptions_settings_section() {
366 + ?>
367 + <p id="jetpack-subscriptions-settings"><?php _e( 'Change whether your visitors can subscribe to your posts or comments or both.', 'jetpack' ); ?></p>
418 368
419 - <?php
369 + <?php
420 370 }
421 371
422 372 /**
423 - * Post Subscriptions Toggle.
373 + * Post Subscriptions Toggle
374 + *
424 375 */
425 - public function subscription_post_subscribe_setting() {
376 + function subscription_post_subscribe_setting() {
426 377
427 - $stb_enabled = get_option( 'stb_enabled', 1 );
428 - ?>
378 + $stb_enabled = get_option( 'stb_enabled', 1 ); ?>
429 379
430 380 <p class="description">
431 381 <input type="checkbox" name="stb_enabled" id="jetpack-post-subscribe" value="1" <?php checked( $stb_enabled, 1 ); ?> />
432 - <?php
433 - echo wp_kses(
434 - __(
435 - "Show a <em>'follow blog'</em> option in the comment form",
436 - 'jetpack'
437 - ),
438 - array( 'em' => array() )
439 - );
440 - ?>
382 + <?php _e( "Show a <em>'follow blog'</em> option in the comment form", 'jetpack' ); ?>
441 383 </p>
442 - <?php
384 + <?php
443 385 }
444 386
445 387 /**
446 - * Comments Subscriptions Toggle.
388 + * Comments Subscriptions Toggle
389 + *
447 390 */
448 - public function subscription_comment_subscribe_setting() {
391 + function subscription_comment_subscribe_setting() {
449 392
450 - $stc_enabled = get_option( 'stc_enabled', 1 );
451 - ?>
393 + $stc_enabled = get_option( 'stc_enabled', 1 ); ?>
452 394
453 395 <p class="description">
454 396 <input type="checkbox" name="stc_enabled" id="jetpack-comment-subscribe" value="1" <?php checked( $stc_enabled, 1 ); ?> />
455 - <?php
456 - echo wp_kses(
457 - __(
458 - "Show a <em>'follow comments'</em> option in the comment form",
459 - 'jetpack'
460 - ),
461 - array( 'em' => array() )
462 - );
463 - ?>
397 + <?php _e( "Show a <em>'follow comments'</em> option in the comment form", 'jetpack' ); ?>
464 398 </p>
465 399
466 - <?php
400 + <?php
467 401 }
468 402
469 403 /**
470 - * Subscribe Modal Toggle.
471 - */
472 - public function subscribe_modal_setting() {
473 -
474 - $sm_enabled = get_option( 'sm_enabled', 1 );
475 - ?>
476 -
477 - <p class="description">
478 - <input type="checkbox" name="sm_enabled" id="jetpack-subscribe-modal" value="1" <?php checked( $sm_enabled, 1 ); ?> />
479 - <?php esc_html_e( 'Show a popup subscribe modal to readers.', 'jetpack' ); ?>
480 - </p>
481 -
482 - <?php
483 - }
484 -
485 - /**
486 - * Someone subscribes to my blog section
404 + * Someone follows my blog section
487 405 *
488 406 * @since 8.1
489 407 */
490 408 public function social_notifications_subscribe_section() {
491 - // Atypical usage here. We emit jquery to move subscribe notification checkbox to be with the rest of the email notification settings.
409 + // Atypical usage here. We emit jquery to move subscribe notification checkbox to be with the rest of the email notification settings
492 410 ?>
493 411 <script type="text/javascript">
494 412 jQuery( function( $ ) {
495 413 var table = $( '#social_notifications_subscribe' ).parents( 'table:first' ),
@@ -508,9 +426,9 @@
508 426 <?php
509 427 }
510 428
511 429 /**
512 - * Someone subscribes to my blog Toggle
430 + * Someone follows my blog Toggle
513 431 *
514 432 * @since 8.1
515 433 */
516 434 public function social_notifications_subscribe_field() {
@@ -520,9 +438,9 @@
520 438 <label>
521 439 <input type="checkbox" name="social_notifications_subscribe" id="social_notifications_subscribe" value="1" <?php checked( $checked ); ?> />
522 440 <?php
523 441 /* translators: this is a label for a setting that starts with "Email me whenever" */
524 - esc_html_e( 'Someone subscribes to my blog', 'jetpack' );
442 + esc_html_e( 'Someone follows my blog', 'jetpack' );
525 443 ?>
526 444 </label>
527 445 <?php
528 446 }
@@ -527,9 +445,9 @@
527 445 <?php
528 446 }
529 447
530 448 /**
531 - * Validate "Someone subscribes to my blog" option
449 + * Validate "Someone follows my blog" option
532 450 *
533 451 * @since 8.1
534 452 *
535 453 * @param String $input the input string to be validated.
@@ -544,35 +462,81 @@
544 462 // Otherwise we return 'on'.
545 463 return 'on';
546 464 }
547 465
466 + function validate_settings( $settings ) {
467 + global $allowedposttags;
468 +
469 + $default = $this->get_default_settings();
470 +
471 + // Blog Follow
472 + $settings['invitation'] = trim( wp_kses( $settings['invitation'], $allowedposttags ) );
473 + if ( empty( $settings['invitation'] ) )
474 + $settings['invitation'] = $default['invitation'];
475 +
476 + // Comments Follow (single post)
477 + $settings['comment_follow'] = trim( wp_kses( $settings['comment_follow'], $allowedposttags ) );
478 + if ( empty( $settings['comment_follow'] ) )
479 + $settings['comment_follow'] = $default['comment_follow'];
480 +
481 + return $settings;
482 + }
483 +
484 + public function reading_section() {
485 + echo '<p id="follower-settings">';
486 + _e( 'These settings change emails sent from your blog to followers.', 'jetpack' );
487 + echo '</p>';
488 + }
489 +
490 + public function setting_invitation() {
491 + $settings = $this->get_settings();
492 + echo '<textarea name="subscription_options[invitation]" class="large-text" cols="50" rows="5">' . esc_textarea( $settings['invitation'] ) . '</textarea>';
493 + echo '<p><span class="description">'.__( 'Introduction text sent when someone follows your blog. (Site and confirmation details will be automatically added for you.)', 'jetpack' ).'</span></p>';
494 + }
495 +
496 + public function setting_comment_follow() {
497 + $settings = $this->get_settings();
498 + echo '<textarea name="subscription_options[comment_follow]" class="large-text" cols="50" rows="5">' . esc_textarea( $settings['comment_follow'] ) . '</textarea>';
499 + echo '<p><span class="description">'.__( 'Introduction text sent when someone follows a post on your blog. (Site and confirmation details will be automatically added for you.)', 'jetpack' ).'</span></p>';
500 + }
501 +
502 + function get_default_settings() {
503 + return array(
504 + 'invitation' => __( "Howdy.\n\nYou recently followed this blog's posts. This means you will receive each new post by email.\n\nTo activate, click confirm below. If you believe this is an error, ignore this message and we'll never bother you again.", 'jetpack' ),
505 + 'comment_follow' => __( "Howdy.\n\nYou recently followed one of my posts. This means you will receive an email when new comments are posted.\n\nTo activate, click confirm below. If you believe this is an error, ignore this message and we'll never bother you again.", 'jetpack' )
506 + );
507 + }
508 +
509 + function get_settings() {
510 + return wp_parse_args( (array) get_option( 'subscription_options', array() ), $this->get_default_settings() );
511 + }
512 +
548 513 /**
549 514 * Jetpack_Subscriptions::subscribe()
550 515 *
551 516 * Send a synchronous XML-RPC subscribe to blog posts or subscribe to post comments request.
552 517 *
553 - * @param string $email being subscribed.
554 - * @param array $post_ids (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts.
518 + * @param string $email
519 + * @param array $post_ids (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts
555 520 * @param bool $async (optional) Should the subscription be performed asynchronously? Defaults to true.
556 - * @param array $extra_data Additional data passed to the `jetpack.subscribeToSite` call.
557 521 *
558 522 * @return true|WP_Error true on success
559 - * invalid_email : not a valid email address
560 - * invalid_post_id : not a valid post ID
561 - * unknown_post_id : unknown post
562 - * not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email.
563 - * disabled : Site owner has disabled subscriptions.
564 - * active : Already subscribed.
565 - * pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent.
566 - * unknown : strange error. Jetpack servers at WordPress.com returned something malformed.
567 - * unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
523 + * invalid_email : not a valid email address
524 + * invalid_post_id : not a valid post ID
525 + * unknown_post_id : unknown post
526 + * not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email.
527 + * disabled : Site owner has disabled subscriptions.
528 + * active : Already subscribed.
529 + * pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent.
530 + * unknown : strange error. Jetpack servers at WordPress.com returned something malformed.
531 + * unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
568 532 */
569 - public function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
570 - if ( ! is_email( $email ) ) {
533 + function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
534 + if ( !is_email( $email ) ) {
571 535 return new WP_Error( 'invalid_email' );
572 536 }
573 537
574 - if ( ! $async ) {
538 + if ( !$async ) {
575 539 $xml = new Jetpack_IXR_ClientMulticall();
576 540 }
577 541
578 542 foreach ( (array) $post_ids as $post_id ) {
@@ -578,9 +542,9 @@
578 542 foreach ( (array) $post_ids as $post_id ) {
579 543 $post_id = (int) $post_id;
580 544 if ( $post_id < 0 ) {
581 545 return new WP_Error( 'invalid_post_id' );
582 - } elseif ( $post_id && ! get_post( $post_id ) ) {
546 + } else if ( $post_id && !$post = get_post( $post_id ) ) {
583 547 return new WP_Error( 'unknown_post_id' );
584 548 }
585 549
586 550 if ( $async ) {
@@ -585,9 +549,9 @@
585 549
586 550 if ( $async ) {
587 551 XMLRPC_Async_Call::add_call( 'jetpack.subscribeToSite', 0, $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
588 552 } else {
589 - $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
553 + $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) );
590 554 }
591 555 }
592 556
593 557 if ( $async ) {
@@ -593,9 +557,9 @@
593 557 if ( $async ) {
594 558 return;
595 559 }
596 560
597 - // Call.
561 + // Call
598 562 $xml->query();
599 563
600 564 if ( $xml->isError() ) {
601 565 return $xml->get_jetpack_error();
@@ -609,9 +573,9 @@
609 573 $r[] = $xml->get_jetpack_error( $response['faultCode'], $response['faultString'] );
610 574 continue;
611 575 }
612 576
613 - if ( ! is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
577 + if ( !is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
614 578 $r[] = new WP_Error( 'unknown' );
615 579 continue;
616 580 }
617 581
@@ -644,36 +608,35 @@
644 608 * Jetpack_Subscriptions::widget_submit()
645 609 *
646 610 * When a user submits their email via the blog subscription widget, check the details and call the subsribe() method.
647 611 */
648 - public function widget_submit() {
612 + function widget_submit() {
649 613 // Check the nonce.
650 - if ( ! wp_verify_nonce( isset( $_REQUEST['_wpnonce'] ) ? sanitize_key( $_REQUEST['_wpnonce'] ) : '', 'blogsub_subscribe_' . \Jetpack_Options::get_option( 'id' ) ) ) {
651 - return false;
614 + if ( is_user_logged_in() ) {
615 + check_admin_referer( 'blogsub_subscribe_' . get_current_blog_id() );
652 616 }
653 617
654 - if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) ) {
618 + if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) )
655 619 return false;
656 - }
657 620
658 621 $redirect_fragment = false;
659 622 if ( isset( $_REQUEST['redirect_fragment'] ) ) {
660 - $redirect_fragment = preg_replace( '/[^a-z0-9_-]/i', '', $_REQUEST['redirect_fragment'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is manually unslashing and sanitizing.
623 + $redirect_fragment = preg_replace( '/[^a-z0-9_-]/i', '', $_REQUEST['redirect_fragment'] );
661 624 }
662 - if ( ! $redirect_fragment || ! is_string( $redirect_fragment ) ) {
625 + if ( !$redirect_fragment || ! is_string( $redirect_fragment ) ) {
663 626 $redirect_fragment = 'subscribe-blog';
664 627 }
665 628
666 - $subscribe = self::subscribe(
667 - isset( $_REQUEST['email'] ) ? wp_unslash( $_REQUEST['email'] ) : null, // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated inside self::subscribe().
668 - 0,
669 - false,
670 - array(
671 - 'source' => 'widget',
672 - 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
673 - 'comment_status' => '',
674 - 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
675 - )
629 + $subscribe = Jetpack_Subscriptions::subscribe(
630 + $_REQUEST['email'],
631 + 0,
632 + false,
633 + array(
634 + 'source' => 'widget',
635 + 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
636 + 'comment_status' => '',
637 + 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
638 + )
676 639 );
677 640
678 641 if ( is_wp_error( $subscribe ) ) {
679 642 $error = $subscribe->get_error_code();
@@ -733,17 +696,13 @@
733 696 *
734 697 * Set up and add the comment subscription checkbox to the comment form.
735 698 *
736 699 * @param string $submit_button HTML markup for the submit field.
700 + * @param array $args Arguments passed to `comment_form()`.
737 701 */
738 - public function comment_subscribe_init( $submit_button ) {
702 + function comment_subscribe_init( $submit_button, $args ) {
739 703 global $post;
740 704
741 - // Subscriptions are only available for posts so far.
742 - if ( ! $post || 'post' !== $post->post_type ) {
743 - return $submit_button;
744 - }
745 -
746 705 $comments_checked = '';
747 706 $blog_checked = '';
748 707
749 708 // Check for a comment / blog submission and set a cookie to retain the setting and check the boxes.
@@ -754,20 +713,20 @@
754 713 if ( isset( $_COOKIE[ 'jetpack_blog_subscribe_' . self::$hash ] ) ) {
755 714 $blog_checked = ' checked="checked"';
756 715 }
757 716
758 - // Some themes call this function, don't show the checkbox again.
717 + // Some themes call this function, don't show the checkbox again
759 718 remove_action( 'comment_form', 'subscription_comment_form' );
760 719
761 - // Check if Mark Jaquith's Subscribe to Comments plugin is active - if so, suppress Jetpack checkbox.
720 + // Check if Mark Jaquith's Subscribe to Comments plugin is active - if so, suppress Jetpack checkbox
762 721
763 722 $str = '';
764 723
765 - if ( false === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 === (int) get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) && 'post' === get_post_type() ) {
766 - // Subscribe to comments checkbox.
767 - $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_comments" id="subscribe_comments" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $comments_checked . ' /> ';
724 + if ( FALSE === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 == get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) && 'post' == get_post_type() ) {
725 + // Subscribe to comments checkbox
726 + $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_comments" id="subscribe_comments" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $comments_checked . ' /> ';
768 727 $comment_sub_text = __( 'Notify me of follow-up comments by email.', 'jetpack' );
769 - $str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . esc_html(
728 + $str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . esc_html(
770 729 /**
771 730 * Filter the Subscribe to comments text appearing below the comment form.
772 731 *
773 732 * @module subscriptions
@@ -780,13 +739,13 @@
780 739 ) . '</label>';
781 740 $str .= '</p>';
782 741 }
783 742
784 - if ( 1 === (int) get_option( 'stb_enabled', 1 ) ) {
785 - // Subscribe to blog checkbox.
786 - $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_blog" id="subscribe_blog" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $blog_checked . ' /> ';
743 + if ( 1 == get_option( 'stb_enabled', 1 ) ) {
744 + // Subscribe to blog checkbox
745 + $str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_blog" id="subscribe_blog" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $blog_checked . ' /> ';
787 746 $blog_sub_text = __( 'Notify me of new posts by email.', 'jetpack' );
788 - $str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . esc_html(
747 + $str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . esc_html(
789 748 /**
790 749 * Filter the Subscribe to blog text appearing below the comment form.
791 750 *
792 751 * @module subscriptions
@@ -817,49 +776,40 @@
817 776 /**
818 777 * Jetpack_Subscriptions::comment_subscribe_init()
819 778 *
820 779 * When a user checks the comment subscribe box and submits a comment, subscribe them to the comment thread.
821 - *
822 - * @param int|string $comment_id Comment thread being subscribed to.
823 - * @param string $approved Comment status.
824 780 */
825 - public function comment_subscribe_submit( $comment_id, $approved ) {
781 + function comment_subscribe_submit( $comment_id, $approved ) {
826 782 if ( 'spam' === $approved ) {
827 783 return;
828 784 }
829 785
830 786 $comment = get_comment( $comment_id );
831 - if ( ! $comment ) {
832 - return;
833 - }
834 787
835 - // Set cookies for this post/comment.
836 - $this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), $comment->comment_post_ID, isset( $_REQUEST['subscribe_blog'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
788 + // Set cookies for this post/comment
789 + $this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), $comment->comment_post_ID, isset( $_REQUEST['subscribe_blog'] ) );
837 790
838 - if ( ! isset( $_REQUEST['subscribe_comments'] ) && ! isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
791 + if ( !isset( $_REQUEST['subscribe_comments'] ) && !isset( $_REQUEST['subscribe_blog'] ) )
839 792 return;
840 - }
841 793
842 794 $post_ids = array();
843 795
844 - if ( isset( $_REQUEST['subscribe_comments'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
796 + if ( isset( $_REQUEST['subscribe_comments'] ) )
845 797 $post_ids[] = $comment->comment_post_ID;
846 - }
847 798
848 - if ( isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
799 + if ( isset( $_REQUEST['subscribe_blog'] ) )
849 800 $post_ids[] = 0;
850 - }
851 801
852 - $result = self::subscribe(
853 - $comment->comment_author_email,
854 - $post_ids,
855 - true,
856 - array(
857 - 'source' => 'comment-form',
858 - 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
859 - 'comment_status' => $approved,
860 - 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
861 - )
802 + $result = Jetpack_Subscriptions::subscribe(
803 + $comment->comment_author_email,
804 + $post_ids,
805 + true,
806 + array(
807 + 'source' => 'comment-form',
808 + 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
809 + 'comment_status' => $approved,
810 + 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
811 + )
862 812 );
863 813
864 814 /**
865 815 * Fires on each comment subscription form submission.
@@ -879,16 +829,16 @@
879 829 *
880 830 * Set a cookie to save state on the comment and post subscription checkboxes.
881 831 *
882 832 * @param bool $subscribe_to_post Whether the user chose to subscribe to subsequent comments on this post.
883 - * @param int $post_id If $subscribe_to_post is true, the post ID they've subscribed to.
833 + * @param int $post_id If $subscribe_to_post is true, the post ID they've subscribed to.
884 834 * @param bool $subscribe_to_blog Whether the user chose to subscribe to all new posts on the blog.
885 835 */
886 - public function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) {
836 + function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) {
887 837 $post_id = (int) $post_id;
888 838
889 839 /** This filter is already documented in core/wp-includes/comment-functions.php */
890 - $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
840 + $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
891 841
892 842 /**
893 843 * Filter the Jetpack Comment cookie path.
894 844 *
@@ -897,9 +847,9 @@
897 847 * @since 2.5.0
898 848 *
899 849 * @param string COOKIEPATH Cookie path.
900 850 */
901 - $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
851 + $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
902 852
903 853 /**
904 854 * Filter the Jetpack Comment cookie domain.
905 855 *
@@ -908,20 +858,20 @@
908 858 * @since 2.5.0
909 859 *
910 860 * @param string COOKIE_DOMAIN Cookie domain.
911 861 */
912 - $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
862 + $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
913 863
914 864 if ( $subscribe_to_post && $post_id >= 0 ) {
915 - setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain, is_ssl(), true );
865 + setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain );
916 866 } else {
917 - setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
867 + setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '', time() - 3600, $cookie_path, $cookie_domain );
918 868 }
919 869
920 870 if ( $subscribe_to_blog ) {
921 - setcookie( 'jetpack_blog_subscribe_' . self::$hash, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain, is_ssl(), true );
871 + setcookie( 'jetpack_blog_subscribe_' . self::$hash, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain );
922 872 } else {
923 - setcookie( 'jetpack_blog_subscribe_' . self::$hash, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
873 + setcookie( 'jetpack_blog_subscribe_' . self::$hash, '', time() - 3600, $cookie_path, $cookie_domain );
924 874 }
925 875 }
926 876
927 877 /**
@@ -928,152 +878,17 @@
928 878 * Set the social_notifications_subscribe option to `off` when the Subscriptions module is activated in the first time.
929 879 *
930 880 * @since 8.1
931 881 *
932 - * @return void
882 + * @return null
933 883 */
934 - public function set_social_notifications_subscribe() {
884 + function set_social_notifications_subscribe() {
935 885 if ( false === get_option( 'social_notifications_subscribe' ) ) {
936 886 add_option( 'social_notifications_subscribe', 'off' );
937 887 }
938 888 }
939 889
940 - /**
941 - * Save a flag when a post was ever published.
942 - *
943 - * It saves the post meta when the post was published and becomes a draft.
944 - * Then this meta is used to hide subscription messaging in Publish panel.
945 - *
946 - * @param string $new_status Tthe "new" post status of the transition when saved.
947 - * @param string $old_status The "old" post status of the transition when saved.
948 - * @param object $post obj The post object.
949 - */
950 - public function maybe_set_first_published_status( $new_status, $old_status, $post ) {
951 - $was_post_ever_published = get_post_meta( $post->ID, '_jetpack_post_was_ever_published', true );
952 - if ( ! $was_post_ever_published && 'publish' === $old_status && 'draft' === $new_status ) {
953 - update_post_meta( $post->ID, '_jetpack_post_was_ever_published', true );
954 - }
955 - }
956 -
957 - /**
958 - * Checks if the current user can publish posts.
959 - *
960 - * @return bool
961 - */
962 - public function first_published_status_meta_auth_callback() {
963 - /**
964 - * Filter the capability to view if a post was ever published in the Subscription Module.
965 - *
966 - * @module subscriptions
967 - *
968 - * @since 13.4
969 - *
970 - * @param string $capability User capability needed to view if a post was ever published. Default to publish_posts.
971 - */
972 - $capability = apply_filters( 'jetpack_subscriptions_post_was_ever_published_capability', 'publish_posts' );
973 - if ( current_user_can( $capability ) ) {
974 - return true;
975 - }
976 - return false;
977 - }
978 -
979 - /**
980 - * Registers the 'post_was_ever_published' post meta for use in the REST API.
981 - */
982 - public function register_post_meta() {
983 - $jetpack_post_was_ever_published = array(
984 - 'type' => 'boolean',
985 - 'description' => __( 'Whether the post was ever published.', 'jetpack' ),
986 - 'single' => true,
987 - 'default' => false,
988 - 'show_in_rest' => array(
989 - 'name' => 'jetpack_post_was_ever_published',
990 - ),
991 - 'auth_callback' => array( $this, 'first_published_status_meta_auth_callback' ),
992 - );
993 -
994 - register_meta( 'post', '_jetpack_post_was_ever_published', $jetpack_post_was_ever_published );
995 - }
996 -
997 - /**
998 - * Create a Subscribers menu displayed on self-hosted sites.
999 - *
1000 - * - It is not displayed on WordPress.com sites.
1001 - * - It directs you to Calypso to the existing Subscribers page.
1002 - *
1003 - * @return void
1004 - */
1005 - public function add_subscribers_menu() {
1006 - /*
1007 - * Do not display any menu on WoA and WordPress.com Simple sites (unless Classic wp-admin is enabled).
1008 - * They already get a menu item under Users via nav-unification.
1009 - */
1010 - if ( ( new Host() )->is_wpcom_platform() && get_option( 'wpcom_admin_interface' ) !== 'wp-admin' ) {
1011 - return;
1012 - }
1013 -
1014 - $status = new Status();
1015 -
1016 - /*
1017 - * Do not display if we're in Offline mode,
1018 - * or if the user is not connected.
1019 - */
1020 - if (
1021 - $status->is_offline_mode()
1022 - || ! ( new Connection_Manager( 'jetpack' ) )->is_user_connected()
1023 - ) {
1024 - return;
1025 - }
1026 -
1027 - $blog_id = Connection_Manager::get_site_id( true );
1028 -
1029 - $link = Redirect::get_url(
1030 - 'jetpack-menu-jetpack-manage-subscribers',
1031 - array( 'site' => $blog_id ? $blog_id : $status->get_site_suffix() )
1032 - );
1033 -
1034 - add_submenu_page(
1035 - 'jetpack',
1036 - esc_attr__( 'Subscribers', 'jetpack' ),
1037 - __( 'Subscribers', 'jetpack' ) . ' <span class="dashicons dashicons-external"></span>',
1038 - 'manage_options',
1039 - esc_url( $link ),
1040 - null
1041 - );
1042 - }
1043 -
1044 - /**
1045 - * Record tracks event if categories is created when user enters
1046 - * the edit category page through the newsletter settings page.
1047 - *
1048 - * @return void
1049 - */
1050 - public function track_newsletter_category_creation() {
1051 -
1052 - // phpcs:disable WordPress.Security.NonceVerification.Missing
1053 - if ( empty( $_POST['_wp_http_referer'] ) ) {
1054 - return;
1055 - }
1056 -
1057 - if ( strpos( sanitize_url( wp_unslash( $_POST['_wp_http_referer'] ) ), 'referer=newsletter-categories' ) > -1 ) {
1058 -
1059 - $parent = filter_var( empty( $_POST['parent'] ) ? 0 : wp_unslash( $_POST['parent'] ), FILTER_SANITIZE_NUMBER_INT );
1060 -
1061 - $is_child_category = $parent > 0;
1062 -
1063 - $tracking = new Automattic\Jetpack\Tracking();
1064 - $tracking->tracks_record_event(
1065 - wp_get_current_user(),
1066 - 'jetpack_newsletter_add_category',
1067 - array(
1068 - 'is_child_category' => $is_child_category,
1069 - )
1070 - );
1071 - }
1072 - }
1073 890 }
1074 891
1075 892 Jetpack_Subscriptions::init();
1076 893
1077 -require __DIR__ . '/subscriptions/views.php';
1078 -require __DIR__ . '/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php';
1079 -require __DIR__ . '/subscriptions/subscribe-overlay/class-jetpack-subscribe-overlay.php';
894 +include dirname( __FILE__ ) . '/subscriptions/views.php';