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