PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 9.9.3
Jetpack – WP Security, Backup, Speed, & Growth v9.9.3
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 14.4.2 All 500 releases
← All changes | modules/subscriptions.php +222 -405 13.4.59.9.3 View file →
@@ -1,7 +1,7 @@
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
@@ -9,27 +9,15 @@
9 9 * Requires User Connection: Yes
10 10 * Auto Activate: No
11 11 * Module Tags: Social
12 12 * Feature: Engagement
13 - * Additional Search Queries: subscriptions, subscription, email, follow, followers, subscribers, signup, newsletter, creator
13 + * Additional Search Queries: subscriptions, subscription, email, follow, followers, subscribers, signup
14 14 */
15 15
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 16 use Automattic\Jetpack\Connection\XMLRPC_Async_Call;
20 -use Automattic\Jetpack\Redirect;
21 -use Automattic\Jetpack\Status;
22 -use Automattic\Jetpack\Status\Host;
23 17
24 18 add_action( 'jetpack_modules_loaded', 'jetpack_subscriptions_load' );
25 19
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 20 function jetpack_subscriptions_load() {
33 21 Jetpack::enable_module_configurable( __FILE__ );
34 22 }
35 23
@@ -43,13 +31,13 @@
43 31 function jetpack_subscriptions_cherry_pick_server_data() {
44 32 $data = array();
45 33
46 34 foreach ( $_SERVER as $key => $value ) {
47 - if ( ! is_string( $value ) || str_starts_with( $key, 'HTTP_COOKIE' ) ) {
35 + if ( ! is_string( $value ) || 0 === strpos( $key, 'HTTP_COOKIE' ) ) {
48 36 continue;
49 37 }
50 38
51 - if ( str_starts_with( $key, 'HTTP_' ) || in_array( $key, array( 'REMOTE_ADDR', 'REQUEST_URI', 'DOCUMENT_URI' ), true ) ) {
39 + if ( 0 === strpos( $key, 'HTTP_' ) || in_array( $key, array( 'REMOTE_ADDR', 'REQUEST_URI', 'DOCUMENT_URI' ), true ) ) {
52 40 $data[ $key ] = $value;
53 41 }
54 42 }
55 43
@@ -55,49 +43,32 @@
55 43
56 44 return $data;
57 45 }
58 46
59 -/**
60 - * Main class file for the Subscriptions module.
61 - */
62 47 class Jetpack_Subscriptions {
63 - /**
64 - * Whether Jetpack has been instantiated or not.
65 - *
66 - * @var bool
67 - */
68 48 public $jetpack = false;
69 49
70 - /**
71 - * Hash of the siteurl option.
72 - *
73 - * @var string
74 - */
75 50 public static $hash;
76 51
77 52 /**
78 53 * Singleton
79 - *
80 54 * @static
81 55 */
82 - public static function init() {
56 + static function init() {
83 57 static $instance = false;
84 58
85 - if ( ! $instance ) {
86 - $instance = new Jetpack_Subscriptions();
59 + if ( !$instance ) {
60 + $instance = new Jetpack_Subscriptions;
87 61 }
88 62
89 63 return $instance;
90 64 }
91 65
92 - /**
93 - * Jetpack_Subscriptions constructor.
94 - */
95 - public function __construct() {
66 + function __construct() {
96 67 $this->jetpack = Jetpack::init();
97 68
98 69 // Don't use COOKIEHASH as it could be shared across installs && is non-unique in multisite.
99 - // @see: https://twitter.com/nacin/status/378246957451333632 .
70 + // @see: https://twitter.com/nacin/status/378246957451333632
100 71 self::$hash = md5( get_option( 'siteurl' ) );
101 72
102 73 add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
103 74
@@ -102,23 +73,22 @@
102 73 add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
103 74
104 75 // @todo remove sync from subscriptions and move elsewhere...
105 76
106 - // Add Configuration Page.
77 + // Add Configuration Page
107 78 add_action( 'admin_init', array( $this, 'configure' ) );
108 79
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.
80 + // Catch subscription widget submits
81 + if ( isset( $_REQUEST['jetpack_subscriptions_widget'] ) )
111 82 add_action( 'template_redirect', array( $this, 'widget_submit' ) );
112 - }
113 83
114 - // Set up the comment subscription checkboxes.
84 + // Set up the comment subscription checkboxes
115 85 add_filter( 'comment_form_submit_field', array( $this, 'comment_subscribe_init' ), 10, 2 );
116 86
117 87 // Catch comment posts and check for subscriptions.
118 88 add_action( 'comment_post', array( $this, 'comment_subscribe_submit' ), 50, 2 );
119 89
120 - // Adds post meta checkbox in the post submit metabox.
90 + // Adds post meta checkbox in the post submit metabox
121 91 add_action( 'post_submitbox_misc_actions', array( $this, 'subscription_post_page_metabox' ) );
122 92
123 93 add_action( 'transition_post_status', array( $this, 'maybe_send_subscription_email' ), 10, 3 );
124 94
@@ -126,27 +96,9 @@
126 96
127 97 add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 18, 1 );
128 98
129 99 // 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 );
100 + add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_social_notifications_subscribe' ) );
149 101 }
150 102
151 103 /**
152 104 * Jetpack_Subscriptions::xmlrpc_methods()
@@ -151,12 +103,11 @@
151 103 /**
152 104 * Jetpack_Subscriptions::xmlrpc_methods()
153 105 *
154 106 * Register subscriptions methods with the Jetpack XML-RPC server.
155 - *
156 - * @param array $methods Methods being registered.
107 + * @param array $methods
157 108 */
158 - public function xmlrpc_methods( $methods ) {
109 + function xmlrpc_methods( $methods ) {
159 110 return array_merge(
160 111 $methods,
161 112 array(
162 113 'jetpack.subscriptions.subscribe' => array( $this, 'subscribe' ),
@@ -163,13 +114,13 @@
163 114 )
164 115 );
165 116 }
166 117
167 - /**
118 + /*
168 119 * Disable Subscribe on Single Post
169 120 * Register post meta
170 121 */
171 - public function subscription_post_page_metabox() {
122 + function subscription_post_page_metabox() {
172 123 if (
173 124 /**
174 125 * Filter whether or not to show the per-post subscription option.
175 126 *
@@ -178,9 +129,10 @@
178 129 * @since 3.7.0
179 130 *
180 131 * @param bool true = show checkbox option on all new posts | false = hide the option.
181 132 */
182 - ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) ) {
133 + ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) )
134 + {
183 135 return;
184 136 }
185 137
186 138 if ( has_filter( 'jetpack_subscriptions_exclude_these_categories' ) || has_filter( 'jetpack_subscriptions_include_only_these_categories' ) ) {
@@ -189,19 +141,18 @@
189 141
190 142 global $post;
191 143 $disable_subscribe_value = get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true );
192 144 // 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.
145 + if ( get_post_status( $post->ID ) !== 'publish' && get_post_type( $post->ID ) == 'post' ) :
146 + // Nonce it
195 147 wp_nonce_field( 'disable_subscribe', 'disable_subscribe_nonce' );
196 148 ?>
197 149 <div class="misc-pub-section">
198 - <label for="_jetpack_dont_email_post_to_subs"><?php esc_html_e( 'Jetpack Subscriptions:', 'jetpack' ); ?></label><br>
150 + <label for="_jetpack_dont_email_post_to_subs"><?php _e( 'Jetpack Subscriptions:', 'jetpack' ); ?></label><br>
199 151 <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' ); ?>
152 + <?php _e( 'Don&#8217;t send this to subscribers', 'jetpack' ); ?>
201 153 </div>
202 - <?php
203 - endif;
154 + <?php endif;
204 155 }
205 156
206 157 /**
207 158 * Checks whether or not the post should be emailed to subscribers
@@ -212,38 +163,32 @@
212 163 * - Existence of the per-post checkbox option
213 164 *
214 165 * Only one of these can be used at any given time.
215 166 *
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.
167 + * @param $new_status string - the "new" post status of the transition when saved
168 + * @param $old_status string - the "old" post status of the transition when saved
169 + * @param $post obj - The post object
219 170 */
220 - public function maybe_send_subscription_email( $new_status, $old_status, $post ) {
171 + function maybe_send_subscription_email( $new_status, $old_status, $post ) {
221 172
222 173 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
223 174 return;
224 175 }
225 176
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.
177 + // Make sure that the checkbox is preseved
178 + if ( ! empty( $_POST['disable_subscribe_nonce'] ) && wp_verify_nonce( $_POST['disable_subscribe_nonce'], 'disable_subscribe' ) ) {
228 179 $set_checkbox = isset( $_POST['_jetpack_dont_email_post_to_subs'] ) ? 1 : 0;
229 180 update_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', $set_checkbox );
230 181 }
231 182 }
232 183
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 ) {
184 + function update_published_message( $messages ) {
239 185 global $post;
240 186 if ( ! $this->should_email_post_to_subscribers( $post ) ) {
241 187 return $messages;
242 188 }
243 189
244 - $view_post_link_html = sprintf(
245 - ' <a href="%1$s">%2$s</a>',
190 + $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
246 191 esc_url( get_permalink( $post ) ),
247 192 __( 'View post', 'jetpack' )
248 193 );
249 194
@@ -249,17 +194,12 @@
249 194
250 195 $messages['post'][6] = sprintf(
251 196 /* translators: Message shown after a post is published */
252 197 esc_html__( 'Post published and sending emails to subscribers.', 'jetpack' )
253 - ) . $view_post_link_html;
198 + ) . $view_post_link_html;
254 199 return $messages;
255 200 }
256 201
257 - /**
258 - * Determine if a post should notifiy subscribers via email.
259 - *
260 - * @param object $post The post.
261 - */
262 202 public function should_email_post_to_subscribers( $post ) {
263 203 $should_email = true;
264 204 if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
265 205 return false;
@@ -264,10 +204,10 @@
264 204 if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
265 205 return false;
266 206 }
267 207
268 - // Only posts are currently supported.
269 - if ( 'post' !== $post->post_type ) {
208 + // Only posts are currently supported
209 + if ( $post->post_type !== 'post' ) {
270 210 return false;
271 211 }
272 212
273 213 // Private posts are not sent to subscribers.
@@ -287,9 +227,9 @@
287 227 * @param array $args Array of category slugs or ID's.
288 228 */
289 229 $excluded_categories = apply_filters( 'jetpack_subscriptions_exclude_these_categories', array() );
290 230
291 - // Never email posts from these categories.
231 + // Never email posts from these categories
292 232 if ( ! empty( $excluded_categories ) && in_category( $excluded_categories, $post->ID ) ) {
293 233 $should_email = false;
294 234 }
295 235
@@ -305,9 +245,9 @@
305 245 * @param array $args Array of category slugs or ID's.
306 246 */
307 247 $only_these_categories = apply_filters( 'jetpack_subscriptions_exclude_all_categories_except', array() );
308 248
309 - // Only emails posts from these categories.
249 + // Only emails posts from these categories
310 250 if ( ! empty( $only_these_categories ) && ! in_category( $only_these_categories, $post->ID ) ) {
311 251 $should_email = false;
312 252 }
313 253
@@ -313,15 +253,9 @@
313 253
314 254 return $should_email;
315 255 }
316 256
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 ) {
257 + function set_post_flags( $flags, $post ) {
324 258 $flags['send_subscription'] = $this->should_email_post_to_subscribers( $post );
325 259 return $flags;
326 260 }
327 261
@@ -329,10 +263,10 @@
329 263 * Jetpack_Subscriptions::configure()
330 264 *
331 265 * Jetpack Subscriptions configuration screen.
332 266 */
333 - public function configure() {
334 - // Create the section.
267 + function configure() {
268 + // Create the section
335 269 add_settings_section(
336 270 'jetpack_subscriptions',
337 271 __( 'Jetpack Subscriptions Settings', 'jetpack' ),
338 272 array( $this, 'subscriptions_settings_section' ),
@@ -338,9 +272,9 @@
338 272 array( $this, 'subscriptions_settings_section' ),
339 273 'discussion'
340 274 );
341 275
342 - /** Subscribe to Posts */
276 + /** Subscribe to Posts ***************************************************/
343 277
344 278 add_settings_field(
345 279 'jetpack_subscriptions_post_subscribe',
346 280 __( 'Follow Blog', 'jetpack' ),
@@ -353,9 +287,9 @@
353 287 'discussion',
354 288 'stb_enabled'
355 289 );
356 290
357 - /** Subscribe to Comments */
291 + /** Subscribe to Comments ******************************************************/
358 292
359 293 add_settings_field(
360 294 'jetpack_subscriptions_comment_subscribe',
361 295 __( 'Follow Comments', 'jetpack' ),
@@ -368,29 +302,14 @@
368 302 'discussion',
369 303 'stc_enabled'
370 304 );
371 305
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 */
306 + /** Email me whenever: Someone follows my blog ***************************************************/
388 307 /* @since 8.1 */
389 308
390 309 add_settings_section(
391 310 'notifications_section',
392 - __( 'Someone subscribes to my blog', 'jetpack' ),
311 + __( 'Someone follows my blog', 'jetpack' ),
393 312 array( $this, 'social_notifications_subscribe_section' ),
394 313 'discussion'
395 314 );
396 315
@@ -406,90 +325,90 @@
406 325 'discussion',
407 326 'social_notifications_subscribe',
408 327 array( $this, 'social_notifications_subscribe_validate' )
409 328 );
329 +
330 + /** Subscription Messaging Options ******************************************************/
331 +
332 + register_setting(
333 + 'reading',
334 + 'subscription_options',
335 + array( $this, 'validate_settings' )
336 + );
337 +
338 + add_settings_section(
339 + 'email_settings',
340 + __( 'Follower Settings', 'jetpack' ),
341 + array( $this, 'reading_section' ),
342 + 'reading'
343 + );
344 +
345 + add_settings_field(
346 + 'invitation',
347 + __( 'Blog follow email text', 'jetpack' ),
348 + array( $this, 'setting_invitation' ),
349 + 'reading',
350 + 'email_settings'
351 + );
352 +
353 + add_settings_field(
354 + 'comment-follow',
355 + __( 'Comment follow email text', 'jetpack' ),
356 + array( $this, 'setting_comment_follow' ),
357 + 'reading',
358 + 'email_settings'
359 + );
410 360 }
411 361
412 362 /**
413 - * Discussions setting section blurb.
363 + * Discussions setting section blurb
364 + *
414 365 */
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>
366 + function subscriptions_settings_section() {
367 + ?>
368 + <p id="jetpack-subscriptions-settings"><?php _e( 'Change whether your visitors can subscribe to your posts or comments or both.', 'jetpack' ); ?></p>
418 369
419 - <?php
370 + <?php
420 371 }
421 372
422 373 /**
423 - * Post Subscriptions Toggle.
374 + * Post Subscriptions Toggle
375 + *
424 376 */
425 - public function subscription_post_subscribe_setting() {
377 + function subscription_post_subscribe_setting() {
426 378
427 - $stb_enabled = get_option( 'stb_enabled', 1 );
428 - ?>
379 + $stb_enabled = get_option( 'stb_enabled', 1 ); ?>
429 380
430 381 <p class="description">
431 382 <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 - ?>
383 + <?php _e( "Show a <em>'follow blog'</em> option in the comment form", 'jetpack' ); ?>
441 384 </p>
442 - <?php
385 + <?php
443 386 }
444 387
445 388 /**
446 - * Comments Subscriptions Toggle.
389 + * Comments Subscriptions Toggle
390 + *
447 391 */
448 - public function subscription_comment_subscribe_setting() {
392 + function subscription_comment_subscribe_setting() {
449 393
450 - $stc_enabled = get_option( 'stc_enabled', 1 );
451 - ?>
394 + $stc_enabled = get_option( 'stc_enabled', 1 ); ?>
452 395
453 396 <p class="description">
454 397 <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 - ?>
398 + <?php _e( "Show a <em>'follow comments'</em> option in the comment form", 'jetpack' ); ?>
464 399 </p>
465 400
466 - <?php
401 + <?php
467 402 }
468 403
469 404 /**
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
405 + * Someone follows my blog section
487 406 *
488 407 * @since 8.1
489 408 */
490 409 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.
410 + // Atypical usage here. We emit jquery to move subscribe notification checkbox to be with the rest of the email notification settings
492 411 ?>
493 412 <script type="text/javascript">
494 413 jQuery( function( $ ) {
495 414 var table = $( '#social_notifications_subscribe' ).parents( 'table:first' ),
@@ -508,9 +427,9 @@
508 427 <?php
509 428 }
510 429
511 430 /**
512 - * Someone subscribes to my blog Toggle
431 + * Someone follows my blog Toggle
513 432 *
514 433 * @since 8.1
515 434 */
516 435 public function social_notifications_subscribe_field() {
@@ -520,9 +439,9 @@
520 439 <label>
521 440 <input type="checkbox" name="social_notifications_subscribe" id="social_notifications_subscribe" value="1" <?php checked( $checked ); ?> />
522 441 <?php
523 442 /* translators: this is a label for a setting that starts with "Email me whenever" */
524 - esc_html_e( 'Someone subscribes to my blog', 'jetpack' );
443 + esc_html_e( 'Someone follows my blog', 'jetpack' );
525 444 ?>
526 445 </label>
527 446 <?php
528 447 }
@@ -527,9 +446,9 @@
527 446 <?php
528 447 }
529 448
530 449 /**
531 - * Validate "Someone subscribes to my blog" option
450 + * Validate "Someone follows my blog" option
532 451 *
533 452 * @since 8.1
534 453 *
535 454 * @param String $input the input string to be validated.
@@ -544,35 +463,81 @@
544 463 // Otherwise we return 'on'.
545 464 return 'on';
546 465 }
547 466
467 + function validate_settings( $settings ) {
468 + global $allowedposttags;
469 +
470 + $default = $this->get_default_settings();
471 +
472 + // Blog Follow
473 + $settings['invitation'] = trim( wp_kses( $settings['invitation'], $allowedposttags ) );
474 + if ( empty( $settings['invitation'] ) )
475 + $settings['invitation'] = $default['invitation'];
476 +
477 + // Comments Follow (single post)
478 + $settings['comment_follow'] = trim( wp_kses( $settings['comment_follow'], $allowedposttags ) );
479 + if ( empty( $settings['comment_follow'] ) )
480 + $settings['comment_follow'] = $default['comment_follow'];
481 +
482 + return $settings;
483 + }
484 +
485 + public function reading_section() {
486 + echo '<p id="follower-settings">';
487 + _e( 'These settings change emails sent from your blog to followers.', 'jetpack' );
488 + echo '</p>';
489 + }
490 +
491 + public function setting_invitation() {
492 + $settings = $this->get_settings();
493 + echo '<textarea name="subscription_options[invitation]" class="large-text" cols="50" rows="5">' . esc_textarea( $settings['invitation'] ) . '</textarea>';
494 + 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>';
495 + }
496 +
497 + public function setting_comment_follow() {
498 + $settings = $this->get_settings();
499 + echo '<textarea name="subscription_options[comment_follow]" class="large-text" cols="50" rows="5">' . esc_textarea( $settings['comment_follow'] ) . '</textarea>';
500 + 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>';
501 + }
502 +
503 + function get_default_settings() {
504 + return array(
505 + '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' ),
506 + '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' )
507 + );
508 + }
509 +
510 + function get_settings() {
511 + return wp_parse_args( (array) get_option( 'subscription_options', array() ), $this->get_default_settings() );
512 + }
513 +
548 514 /**
549 515 * Jetpack_Subscriptions::subscribe()
550 516 *
551 517 * Send a synchronous XML-RPC subscribe to blog posts or subscribe to post comments request.
552 518 *
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.
519 + * @param string $email
520 + * @param array $post_ids (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts
555 521 * @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 522 *
558 523 * @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.
524 + * invalid_email : not a valid email address
525 + * invalid_post_id : not a valid post ID
526 + * unknown_post_id : unknown post
527 + * not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email.
528 + * disabled : Site owner has disabled subscriptions.
529 + * active : Already subscribed.
530 + * pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent.
531 + * unknown : strange error. Jetpack servers at WordPress.com returned something malformed.
532 + * unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
568 533 */
569 - public function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
570 - if ( ! is_email( $email ) ) {
534 + function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
535 + if ( !is_email( $email ) ) {
571 536 return new WP_Error( 'invalid_email' );
572 537 }
573 538
574 - if ( ! $async ) {
539 + if ( !$async ) {
575 540 $xml = new Jetpack_IXR_ClientMulticall();
576 541 }
577 542
578 543 foreach ( (array) $post_ids as $post_id ) {
@@ -578,9 +543,9 @@
578 543 foreach ( (array) $post_ids as $post_id ) {
579 544 $post_id = (int) $post_id;
580 545 if ( $post_id < 0 ) {
581 546 return new WP_Error( 'invalid_post_id' );
582 - } elseif ( $post_id && ! get_post( $post_id ) ) {
547 + } else if ( $post_id && !$post = get_post( $post_id ) ) {
583 548 return new WP_Error( 'unknown_post_id' );
584 549 }
585 550
586 551 if ( $async ) {
@@ -585,9 +550,9 @@
585 550
586 551 if ( $async ) {
587 552 XMLRPC_Async_Call::add_call( 'jetpack.subscribeToSite', 0, $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
588 553 } else {
589 - $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
554 + $xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) );
590 555 }
591 556 }
592 557
593 558 if ( $async ) {
@@ -593,9 +558,9 @@
593 558 if ( $async ) {
594 559 return;
595 560 }
596 561
597 - // Call.
562 + // Call
598 563 $xml->query();
599 564
600 565 if ( $xml->isError() ) {
601 566 return $xml->get_jetpack_error();
@@ -609,9 +574,9 @@
609 574 $r[] = $xml->get_jetpack_error( $response['faultCode'], $response['faultString'] );
610 575 continue;
611 576 }
612 577
613 - if ( ! is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
578 + if ( !is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
614 579 $r[] = new WP_Error( 'unknown' );
615 580 continue;
616 581 }
617 582
@@ -644,36 +609,35 @@
644 609 * Jetpack_Subscriptions::widget_submit()
645 610 *
646 611 * When a user submits their email via the blog subscription widget, check the details and call the subsribe() method.
647 612 */
648 - public function widget_submit() {
613 + function widget_submit() {
649 614 // 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;
615 + if ( is_user_logged_in() ) {
616 + check_admin_referer( 'blogsub_subscribe_' . get_current_blog_id() );
652 617 }
653 618
654 - if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) ) {
619 + if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) )
655 620 return false;
656 - }
657 621
658 622 $redirect_fragment = false;
659 623 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.
624 + $redirect_fragment = preg_replace( '/[^a-z0-9_-]/i', '', $_REQUEST['redirect_fragment'] );
661 625 }
662 - if ( ! $redirect_fragment || ! is_string( $redirect_fragment ) ) {
626 + if ( !$redirect_fragment || ! is_string( $redirect_fragment ) ) {
663 627 $redirect_fragment = 'subscribe-blog';
664 628 }
665 629
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 - )
630 + $subscribe = Jetpack_Subscriptions::subscribe(
631 + $_REQUEST['email'],
632 + 0,
633 + false,
634 + array(
635 + 'source' => 'widget',
636 + 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
637 + 'comment_status' => '',
638 + 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
639 + )
676 640 );
677 641
678 642 if ( is_wp_error( $subscribe ) ) {
679 643 $error = $subscribe->get_error_code();
@@ -733,17 +697,13 @@
733 697 *
734 698 * Set up and add the comment subscription checkbox to the comment form.
735 699 *
736 700 * @param string $submit_button HTML markup for the submit field.
701 + * @param array $args Arguments passed to `comment_form()`.
737 702 */
738 - public function comment_subscribe_init( $submit_button ) {
703 + function comment_subscribe_init( $submit_button, $args ) {
739 704 global $post;
740 705
741 - // Subscriptions are only available for posts so far.
742 - if ( ! $post || 'post' !== $post->post_type ) {
743 - return $submit_button;
744 - }
745 -
746 706 $comments_checked = '';
747 707 $blog_checked = '';
748 708
749 709 // Check for a comment / blog submission and set a cookie to retain the setting and check the boxes.
@@ -754,20 +714,20 @@
754 714 if ( isset( $_COOKIE[ 'jetpack_blog_subscribe_' . self::$hash ] ) ) {
755 715 $blog_checked = ' checked="checked"';
756 716 }
757 717
758 - // Some themes call this function, don't show the checkbox again.
718 + // Some themes call this function, don't show the checkbox again
759 719 remove_action( 'comment_form', 'subscription_comment_form' );
760 720
761 - // Check if Mark Jaquith's Subscribe to Comments plugin is active - if so, suppress Jetpack checkbox.
721 + // Check if Mark Jaquith's Subscribe to Comments plugin is active - if so, suppress Jetpack checkbox
762 722
763 723 $str = '';
764 724
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 . ' /> ';
725 + if ( FALSE === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 == get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) && 'post' == get_post_type() ) {
726 + // Subscribe to comments checkbox
727 + $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 728 $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(
729 + $str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . esc_html(
770 730 /**
771 731 * Filter the Subscribe to comments text appearing below the comment form.
772 732 *
773 733 * @module subscriptions
@@ -780,13 +740,13 @@
780 740 ) . '</label>';
781 741 $str .= '</p>';
782 742 }
783 743
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 . ' /> ';
744 + if ( 1 == get_option( 'stb_enabled', 1 ) ) {
745 + // Subscribe to blog checkbox
746 + $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 747 $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(
748 + $str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . esc_html(
789 749 /**
790 750 * Filter the Subscribe to blog text appearing below the comment form.
791 751 *
792 752 * @module subscriptions
@@ -817,49 +777,40 @@
817 777 /**
818 778 * Jetpack_Subscriptions::comment_subscribe_init()
819 779 *
820 780 * 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 781 */
825 - public function comment_subscribe_submit( $comment_id, $approved ) {
782 + function comment_subscribe_submit( $comment_id, $approved ) {
826 783 if ( 'spam' === $approved ) {
827 784 return;
828 785 }
829 786
830 787 $comment = get_comment( $comment_id );
831 - if ( ! $comment ) {
832 - return;
833 - }
834 788
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
789 + // Set cookies for this post/comment
790 + $this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), $comment->comment_post_ID, isset( $_REQUEST['subscribe_blog'] ) );
837 791
838 - if ( ! isset( $_REQUEST['subscribe_comments'] ) && ! isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
792 + if ( !isset( $_REQUEST['subscribe_comments'] ) && !isset( $_REQUEST['subscribe_blog'] ) )
839 793 return;
840 - }
841 794
842 795 $post_ids = array();
843 796
844 - if ( isset( $_REQUEST['subscribe_comments'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
797 + if ( isset( $_REQUEST['subscribe_comments'] ) )
845 798 $post_ids[] = $comment->comment_post_ID;
846 - }
847 799
848 - if ( isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
800 + if ( isset( $_REQUEST['subscribe_blog'] ) )
849 801 $post_ids[] = 0;
850 - }
851 802
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 - )
803 + $result = Jetpack_Subscriptions::subscribe(
804 + $comment->comment_author_email,
805 + $post_ids,
806 + true,
807 + array(
808 + 'source' => 'comment-form',
809 + 'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
810 + 'comment_status' => $approved,
811 + 'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
812 + )
862 813 );
863 814
864 815 /**
865 816 * Fires on each comment subscription form submission.
@@ -879,16 +830,16 @@
879 830 *
880 831 * Set a cookie to save state on the comment and post subscription checkboxes.
881 832 *
882 833 * @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.
834 + * @param int $post_id If $subscribe_to_post is true, the post ID they've subscribed to.
884 835 * @param bool $subscribe_to_blog Whether the user chose to subscribe to all new posts on the blog.
885 836 */
886 - public function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) {
837 + function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) {
887 838 $post_id = (int) $post_id;
888 839
889 840 /** This filter is already documented in core/wp-includes/comment-functions.php */
890 - $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
841 + $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
891 842
892 843 /**
893 844 * Filter the Jetpack Comment cookie path.
894 845 *
@@ -897,9 +848,9 @@
897 848 * @since 2.5.0
898 849 *
899 850 * @param string COOKIEPATH Cookie path.
900 851 */
901 - $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
852 + $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
902 853
903 854 /**
904 855 * Filter the Jetpack Comment cookie domain.
905 856 *
@@ -908,20 +859,20 @@
908 859 * @since 2.5.0
909 860 *
910 861 * @param string COOKIE_DOMAIN Cookie domain.
911 862 */
912 - $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
863 + $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
913 864
914 865 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 );
866 + setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain );
916 867 } else {
917 - setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
868 + setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '', time() - 3600, $cookie_path, $cookie_domain );
918 869 }
919 870
920 871 if ( $subscribe_to_blog ) {
921 - setcookie( 'jetpack_blog_subscribe_' . self::$hash, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain, is_ssl(), true );
872 + setcookie( 'jetpack_blog_subscribe_' . self::$hash, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain );
922 873 } else {
923 - setcookie( 'jetpack_blog_subscribe_' . self::$hash, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
874 + setcookie( 'jetpack_blog_subscribe_' . self::$hash, '', time() - 3600, $cookie_path, $cookie_domain );
924 875 }
925 876 }
926 877
927 878 /**
@@ -928,151 +879,17 @@
928 879 * Set the social_notifications_subscribe option to `off` when the Subscriptions module is activated in the first time.
929 880 *
930 881 * @since 8.1
931 882 *
932 - * @return void
883 + * @return null
933 884 */
934 - public function set_social_notifications_subscribe() {
885 + function set_social_notifications_subscribe() {
935 886 if ( false === get_option( 'social_notifications_subscribe' ) ) {
936 887 add_option( 'social_notifications_subscribe', 'off' );
937 888 }
938 889 }
939 890
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 891 }
1074 892
1075 893 Jetpack_Subscriptions::init();
1076 894
1077 -require __DIR__ . '/subscriptions/views.php';
1078 -require __DIR__ . '/subscriptions/subscribe-modal/class-jetpack-subscribe-modal.php';
895 +include dirname( __FILE__ ) . '/subscriptions/views.php';