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 -378 14.2.29.2 View file →
@@ -1,36 +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\Admin_UI\Admin_Menu;
19 -use Automattic\Jetpack\Connection\Manager as Connection_Manager;
20 15 use Automattic\Jetpack\Connection\XMLRPC_Async_Call;
21 -use Automattic\Jetpack\Redirect;
22 -use Automattic\Jetpack\Status;
23 -use Automattic\Jetpack\Status\Host;
24 16
25 17 add_action( 'jetpack_modules_loaded', 'jetpack_subscriptions_load' );
26 18
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 19 function jetpack_subscriptions_load() {
34 20 Jetpack::enable_module_configurable( __FILE__ );
35 21 }
36 22
@@ -44,13 +30,13 @@
44 30 function jetpack_subscriptions_cherry_pick_server_data() {
45 31 $data = array();
46 32
47 33 foreach ( $_SERVER as $key => $value ) {
48 - if ( ! is_string( $value ) || str_starts_with( $key, 'HTTP_COOKIE' ) ) {
34 + if ( ! is_string( $value ) || 0 === strpos( $key, 'HTTP_COOKIE' ) ) {
49 35 continue;
50 36 }
51 37
52 - 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 ) ) {
53 39 $data[ $key ] = $value;
54 40 }
55 41 }
56 42
@@ -56,49 +42,32 @@
56 42
57 43 return $data;
58 44 }
59 45
60 -/**
61 - * Main class file for the Subscriptions module.
62 - */
63 46 class Jetpack_Subscriptions {
64 - /**
65 - * Whether Jetpack has been instantiated or not.
66 - *
67 - * @var bool
68 - */
69 47 public $jetpack = false;
70 48
71 - /**
72 - * Hash of the siteurl option.
73 - *
74 - * @var string
75 - */
76 49 public static $hash;
77 50
78 51 /**
79 52 * Singleton
80 - *
81 53 * @static
82 54 */
83 - public static function init() {
55 + static function init() {
84 56 static $instance = false;
85 57
86 - if ( ! $instance ) {
87 - $instance = new Jetpack_Subscriptions();
58 + if ( !$instance ) {
59 + $instance = new Jetpack_Subscriptions;
88 60 }
89 61
90 62 return $instance;
91 63 }
92 64
93 - /**
94 - * Jetpack_Subscriptions constructor.
95 - */
96 - public function __construct() {
65 + function __construct() {
97 66 $this->jetpack = Jetpack::init();
98 67
99 68 // Don't use COOKIEHASH as it could be shared across installs && is non-unique in multisite.
100 - // @see: https://twitter.com/nacin/status/378246957451333632 .
69 + // @see: https://twitter.com/nacin/status/378246957451333632
101 70 self::$hash = md5( get_option( 'siteurl' ) );
102 71
103 72 add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
104 73
@@ -103,23 +72,22 @@
103 72 add_filter( 'jetpack_xmlrpc_methods', array( $this, 'xmlrpc_methods' ) );
104 73
105 74 // @todo remove sync from subscriptions and move elsewhere...
106 75
107 - // Add Configuration Page.
76 + // Add Configuration Page
108 77 add_action( 'admin_init', array( $this, 'configure' ) );
109 78
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.
79 + // Catch subscription widget submits
80 + if ( isset( $_REQUEST['jetpack_subscriptions_widget'] ) )
112 81 add_action( 'template_redirect', array( $this, 'widget_submit' ) );
113 - }
114 82
115 - // Set up the comment subscription checkboxes.
83 + // Set up the comment subscription checkboxes
116 84 add_filter( 'comment_form_submit_field', array( $this, 'comment_subscribe_init' ), 10, 2 );
117 85
118 86 // Catch comment posts and check for subscriptions.
119 87 add_action( 'comment_post', array( $this, 'comment_subscribe_submit' ), 50, 2 );
120 88
121 - // Adds post meta checkbox in the post submit metabox.
89 + // Adds post meta checkbox in the post submit metabox
122 90 add_action( 'post_submitbox_misc_actions', array( $this, 'subscription_post_page_metabox' ) );
123 91
124 92 add_action( 'transition_post_status', array( $this, 'maybe_send_subscription_email' ), 10, 3 );
125 93
@@ -127,27 +95,9 @@
127 95
128 96 add_filter( 'post_updated_messages', array( $this, 'update_published_message' ), 18, 1 );
129 97
130 98 // 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 );
99 + add_action( 'jetpack_activate_module_subscriptions', array( $this, 'set_social_notifications_subscribe' ) );
150 100 }
151 101
152 102 /**
153 103 * Jetpack_Subscriptions::xmlrpc_methods()
@@ -152,12 +102,11 @@
152 102 /**
153 103 * Jetpack_Subscriptions::xmlrpc_methods()
154 104 *
155 105 * Register subscriptions methods with the Jetpack XML-RPC server.
156 - *
157 - * @param array $methods Methods being registered.
106 + * @param array $methods
158 107 */
159 - public function xmlrpc_methods( $methods ) {
108 + function xmlrpc_methods( $methods ) {
160 109 return array_merge(
161 110 $methods,
162 111 array(
163 112 'jetpack.subscriptions.subscribe' => array( $this, 'subscribe' ),
@@ -164,13 +113,13 @@
164 113 )
165 114 );
166 115 }
167 116
168 - /**
117 + /*
169 118 * Disable Subscribe on Single Post
170 119 * Register post meta
171 120 */
172 - public function subscription_post_page_metabox() {
121 + function subscription_post_page_metabox() {
173 122 if (
174 123 /**
175 124 * Filter whether or not to show the per-post subscription option.
176 125 *
@@ -179,9 +128,10 @@
179 128 * @since 3.7.0
180 129 *
181 130 * @param bool true = show checkbox option on all new posts | false = hide the option.
182 131 */
183 - ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) ) {
132 + ! apply_filters( 'jetpack_allow_per_post_subscriptions', false ) )
133 + {
184 134 return;
185 135 }
186 136
187 137 if ( has_filter( 'jetpack_subscriptions_exclude_these_categories' ) || has_filter( 'jetpack_subscriptions_include_only_these_categories' ) ) {
@@ -190,19 +140,18 @@
190 140
191 141 global $post;
192 142 $disable_subscribe_value = get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true );
193 143 // 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.
144 + if ( get_post_status( $post->ID ) !== 'publish' && get_post_type( $post->ID ) == 'post' ) :
145 + // Nonce it
196 146 wp_nonce_field( 'disable_subscribe', 'disable_subscribe_nonce' );
197 147 ?>
198 148 <div class="misc-pub-section">
199 - <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>
200 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 ); ?> />
201 - <?php esc_html_e( 'Don&#8217;t send this to subscribers', 'jetpack' ); ?>
151 + <?php _e( 'Don&#8217;t send this to subscribers', 'jetpack' ); ?>
202 152 </div>
203 - <?php
204 - endif;
153 + <?php endif;
205 154 }
206 155
207 156 /**
208 157 * Checks whether or not the post should be emailed to subscribers
@@ -213,38 +162,32 @@
213 162 * - Existence of the per-post checkbox option
214 163 *
215 164 * Only one of these can be used at any given time.
216 165 *
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.
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
220 169 */
221 - public function maybe_send_subscription_email( $new_status, $old_status, $post ) {
170 + function maybe_send_subscription_email( $new_status, $old_status, $post ) {
222 171
223 172 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
224 173 return;
225 174 }
226 175
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.
176 + // Make sure that the checkbox is preseved
177 + if ( ! empty( $_POST['disable_subscribe_nonce'] ) && wp_verify_nonce( $_POST['disable_subscribe_nonce'], 'disable_subscribe' ) ) {
229 178 $set_checkbox = isset( $_POST['_jetpack_dont_email_post_to_subs'] ) ? 1 : 0;
230 179 update_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', $set_checkbox );
231 180 }
232 181 }
233 182
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 ) {
183 + function update_published_message( $messages ) {
240 184 global $post;
241 185 if ( ! $this->should_email_post_to_subscribers( $post ) ) {
242 186 return $messages;
243 187 }
244 188
245 - $view_post_link_html = sprintf(
246 - ' <a href="%1$s">%2$s</a>',
189 + $view_post_link_html = sprintf( ' <a href="%1$s">%2$s</a>',
247 190 esc_url( get_permalink( $post ) ),
248 191 __( 'View post', 'jetpack' )
249 192 );
250 193
@@ -250,17 +193,12 @@
250 193
251 194 $messages['post'][6] = sprintf(
252 195 /* translators: Message shown after a post is published */
253 196 esc_html__( 'Post published and sending emails to subscribers.', 'jetpack' )
254 - ) . $view_post_link_html;
197 + ) . $view_post_link_html;
255 198 return $messages;
256 199 }
257 200
258 - /**
259 - * Determine if a post should notifiy subscribers via email.
260 - *
261 - * @param object $post The post.
262 - */
263 201 public function should_email_post_to_subscribers( $post ) {
264 202 $should_email = true;
265 203 if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
266 204 return false;
@@ -265,10 +203,10 @@
265 203 if ( get_post_meta( $post->ID, '_jetpack_dont_email_post_to_subs', true ) ) {
266 204 return false;
267 205 }
268 206
269 - // Only posts are currently supported.
270 - if ( 'post' !== $post->post_type ) {
207 + // Only posts are currently supported
208 + if ( $post->post_type !== 'post' ) {
271 209 return false;
272 210 }
273 211
274 212 // Private posts are not sent to subscribers.
@@ -288,9 +226,9 @@
288 226 * @param array $args Array of category slugs or ID's.
289 227 */
290 228 $excluded_categories = apply_filters( 'jetpack_subscriptions_exclude_these_categories', array() );
291 229
292 - // Never email posts from these categories.
230 + // Never email posts from these categories
293 231 if ( ! empty( $excluded_categories ) && in_category( $excluded_categories, $post->ID ) ) {
294 232 $should_email = false;
295 233 }
296 234
@@ -306,9 +244,9 @@
306 244 * @param array $args Array of category slugs or ID's.
307 245 */
308 246 $only_these_categories = apply_filters( 'jetpack_subscriptions_exclude_all_categories_except', array() );
309 247
310 - // Only emails posts from these categories.
248 + // Only emails posts from these categories
311 249 if ( ! empty( $only_these_categories ) && ! in_category( $only_these_categories, $post->ID ) ) {
312 250 $should_email = false;
313 251 }
314 252
@@ -314,15 +252,9 @@
314 252
315 253 return $should_email;
316 254 }
317 255
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 ) {
256 + function set_post_flags( $flags, $post ) {
325 257 $flags['send_subscription'] = $this->should_email_post_to_subscribers( $post );
326 258 return $flags;
327 259 }
328 260
@@ -330,10 +262,10 @@
330 262 * Jetpack_Subscriptions::configure()
331 263 *
332 264 * Jetpack Subscriptions configuration screen.
333 265 */
334 - public function configure() {
335 - // Create the section.
266 + function configure() {
267 + // Create the section
336 268 add_settings_section(
337 269 'jetpack_subscriptions',
338 270 __( 'Jetpack Subscriptions Settings', 'jetpack' ),
339 271 array( $this, 'subscriptions_settings_section' ),
@@ -339,9 +271,9 @@
339 271 array( $this, 'subscriptions_settings_section' ),
340 272 'discussion'
341 273 );
342 274
343 - /** Subscribe to Posts */
275 + /** Subscribe to Posts ***************************************************/
344 276
345 277 add_settings_field(
346 278 'jetpack_subscriptions_post_subscribe',
347 279 __( 'Follow Blog', 'jetpack' ),
@@ -354,9 +286,9 @@
354 286 'discussion',
355 287 'stb_enabled'
356 288 );
357 289
358 - /** Subscribe to Comments */
290 + /** Subscribe to Comments ******************************************************/
359 291
360 292 add_settings_field(
361 293 'jetpack_subscriptions_comment_subscribe',
362 294 __( 'Follow Comments', 'jetpack' ),
@@ -369,14 +301,14 @@
369 301 'discussion',
370 302 'stc_enabled'
371 303 );
372 304
373 - /** Email me whenever: Someone subscribes to my blog */
305 + /** Email me whenever: Someone follows my blog ***************************************************/
374 306 /* @since 8.1 */
375 307
376 308 add_settings_section(
377 309 'notifications_section',
378 - __( 'Someone subscribes to my blog', 'jetpack' ),
310 + __( 'Someone follows my blog', 'jetpack' ),
379 311 array( $this, 'social_notifications_subscribe_section' ),
380 312 'discussion'
381 313 );
382 314
@@ -392,74 +324,90 @@
392 324 'discussion',
393 325 'social_notifications_subscribe',
394 326 array( $this, 'social_notifications_subscribe_validate' )
395 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 + );
396 359 }
397 360
398 361 /**
399 - * Discussions setting section blurb.
362 + * Discussions setting section blurb
363 + *
400 364 */
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>
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>
404 368
405 - <?php
369 + <?php
406 370 }
407 371
408 372 /**
409 - * Post Subscriptions Toggle.
373 + * Post Subscriptions Toggle
374 + *
410 375 */
411 - public function subscription_post_subscribe_setting() {
376 + function subscription_post_subscribe_setting() {
412 377
413 - $stb_enabled = get_option( 'stb_enabled', 1 );
414 - ?>
378 + $stb_enabled = get_option( 'stb_enabled', 1 ); ?>
415 379
416 380 <p class="description">
417 381 <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 - ?>
382 + <?php _e( "Show a <em>'follow blog'</em> option in the comment form", 'jetpack' ); ?>
427 383 </p>
428 - <?php
384 + <?php
429 385 }
430 386
431 387 /**
432 - * Comments Subscriptions Toggle.
388 + * Comments Subscriptions Toggle
389 + *
433 390 */
434 - public function subscription_comment_subscribe_setting() {
391 + function subscription_comment_subscribe_setting() {
435 392
436 - $stc_enabled = get_option( 'stc_enabled', 1 );
437 - ?>
393 + $stc_enabled = get_option( 'stc_enabled', 1 ); ?>
438 394
439 395 <p class="description">
440 396 <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 - ?>
397 + <?php _e( "Show a <em>'follow comments'</em> option in the comment form", 'jetpack' ); ?>
450 398 </p>
451 399
452 - <?php
400 + <?php
453 401 }
454 402
455 403 /**
456 - * Someone subscribes to my blog section
404 + * Someone follows my blog section
457 405 *
458 406 * @since 8.1
459 407 */
460 408 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.
409 + // Atypical usage here. We emit jquery to move subscribe notification checkbox to be with the rest of the email notification settings
462 410 ?>
463 411 <script type="text/javascript">
464 412 jQuery( function( $ ) {
465 413 var table = $( '#social_notifications_subscribe' ).parents( 'table:first' ),
@@ -478,9 +426,9 @@
478 426 <?php
479 427 }
480 428
481 429 /**
482 - * Someone subscribes to my blog Toggle
430 + * Someone follows my blog Toggle
483 431 *
484 432 * @since 8.1
485 433 */
486 434 public function social_notifications_subscribe_field() {
@@ -490,9 +438,9 @@
490 438 <label>
491 439 <input type="checkbox" name="social_notifications_subscribe" id="social_notifications_subscribe" value="1" <?php checked( $checked ); ?> />
492 440 <?php
493 441 /* translators: this is a label for a setting that starts with "Email me whenever" */
494 - esc_html_e( 'Someone subscribes to my blog', 'jetpack' );
442 + esc_html_e( 'Someone follows my blog', 'jetpack' );
495 443 ?>
496 444 </label>
497 445 <?php
498 446 }
@@ -497,9 +445,9 @@
497 445 <?php
498 446 }
499 447
500 448 /**
501 - * Validate "Someone subscribes to my blog" option
449 + * Validate "Someone follows my blog" option
502 450 *
503 451 * @since 8.1
504 452 *
505 453 * @param String $input the input string to be validated.
@@ -514,35 +462,81 @@
514 462 // Otherwise we return 'on'.
515 463 return 'on';
516 464 }
517 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 +
518 513 /**
519 514 * Jetpack_Subscriptions::subscribe()
520 515 *
521 516 * Send a synchronous XML-RPC subscribe to blog posts or subscribe to post comments request.
522 517 *
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.
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
525 520 * @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 521 *
528 522 * @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.
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.
538 532 */
539 - public function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
540 - if ( ! is_email( $email ) ) {
533 + function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
534 + if ( !is_email( $email ) ) {
541 535 return new WP_Error( 'invalid_email' );
542 536 }
543 537
544 - if ( ! $async ) {
538 + if ( !$async ) {
545 539 $xml = new Jetpack_IXR_ClientMulticall();
546 540 }
547 541
548 542 foreach ( (array) $post_ids as $post_id ) {
@@ -548,9 +542,9 @@
548 542 foreach ( (array) $post_ids as $post_id ) {
549 543 $post_id = (int) $post_id;
550 544 if ( $post_id < 0 ) {
551 545 return new WP_Error( 'invalid_post_id' );
552 - } elseif ( $post_id && ! get_post( $post_id ) ) {
546 + } else if ( $post_id && !$post = get_post( $post_id ) ) {
553 547 return new WP_Error( 'unknown_post_id' );
554 548 }
555 549
556 550 if ( $async ) {
@@ -555,9 +549,9 @@
555 549
556 550 if ( $async ) {
557 551 XMLRPC_Async_Call::add_call( 'jetpack.subscribeToSite', 0, $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
558 552 } else {
559 - $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 ) );
560 554 }
561 555 }
562 556
563 557 if ( $async ) {
@@ -563,9 +557,9 @@
563 557 if ( $async ) {
564 558 return;
565 559 }
566 560
567 - // Call.
561 + // Call
568 562 $xml->query();
569 563
570 564 if ( $xml->isError() ) {
571 565 return $xml->get_jetpack_error();
@@ -579,9 +573,9 @@
579 573 $r[] = $xml->get_jetpack_error( $response['faultCode'], $response['faultString'] );
580 574 continue;
581 575 }
582 576
583 - if ( ! is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
577 + if ( !is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
584 578 $r[] = new WP_Error( 'unknown' );
585 579 continue;
586 580 }
587 581
@@ -614,36 +608,35 @@
614 608 * Jetpack_Subscriptions::widget_submit()
615 609 *
616 610 * When a user submits their email via the blog subscription widget, check the details and call the subsribe() method.
617 611 */
618 - public function widget_submit() {
612 + function widget_submit() {
619 613 // 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;
614 + if ( is_user_logged_in() ) {
615 + check_admin_referer( 'blogsub_subscribe_' . get_current_blog_id() );
622 616 }
623 617
624 - if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) ) {
618 + if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) )
625 619 return false;
626 - }
627 620
628 621 $redirect_fragment = false;
629 622 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.
623 + $redirect_fragment = preg_replace( '/[^a-z0-9_-]/i', '', $_REQUEST['redirect_fragment'] );
631 624 }
632 - if ( ! $redirect_fragment || ! is_string( $redirect_fragment ) ) {
625 + if ( !$redirect_fragment || ! is_string( $redirect_fragment ) ) {
633 626 $redirect_fragment = 'subscribe-blog';
634 627 }
635 628
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 - )
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 + )
646 639 );
647 640
648 641 if ( is_wp_error( $subscribe ) ) {
649 642 $error = $subscribe->get_error_code();
@@ -703,17 +696,13 @@
703 696 *
704 697 * Set up and add the comment subscription checkbox to the comment form.
705 698 *
706 699 * @param string $submit_button HTML markup for the submit field.
700 + * @param array $args Arguments passed to `comment_form()`.
707 701 */
708 - public function comment_subscribe_init( $submit_button ) {
702 + function comment_subscribe_init( $submit_button, $args ) {
709 703 global $post;
710 704
711 - // Subscriptions are only available for posts so far.
712 - if ( ! $post || 'post' !== $post->post_type ) {
713 - return $submit_button;
714 - }
715 -
716 705 $comments_checked = '';
717 706 $blog_checked = '';
718 707
719 708 // Check for a comment / blog submission and set a cookie to retain the setting and check the boxes.
@@ -724,20 +713,20 @@
724 713 if ( isset( $_COOKIE[ 'jetpack_blog_subscribe_' . self::$hash ] ) ) {
725 714 $blog_checked = ' checked="checked"';
726 715 }
727 716
728 - // Some themes call this function, don't show the checkbox again.
717 + // Some themes call this function, don't show the checkbox again
729 718 remove_action( 'comment_form', 'subscription_comment_form' );
730 719
731 - // 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
732 721
733 722 $str = '';
734 723
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 . ' /> ';
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 . ' /> ';
738 727 $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(
728 + $str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . esc_html(
740 729 /**
741 730 * Filter the Subscribe to comments text appearing below the comment form.
742 731 *
743 732 * @module subscriptions
@@ -750,13 +739,13 @@
750 739 ) . '</label>';
751 740 $str .= '</p>';
752 741 }
753 742
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 . ' /> ';
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 . ' /> ';
757 746 $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(
747 + $str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . esc_html(
759 748 /**
760 749 * Filter the Subscribe to blog text appearing below the comment form.
761 750 *
762 751 * @module subscriptions
@@ -787,49 +776,40 @@
787 776 /**
788 777 * Jetpack_Subscriptions::comment_subscribe_init()
789 778 *
790 779 * 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 780 */
795 - public function comment_subscribe_submit( $comment_id, $approved ) {
781 + function comment_subscribe_submit( $comment_id, $approved ) {
796 782 if ( 'spam' === $approved ) {
797 783 return;
798 784 }
799 785
800 786 $comment = get_comment( $comment_id );
801 - if ( ! $comment ) {
802 - return;
803 - }
804 787
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
788 + // Set cookies for this post/comment
789 + $this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), $comment->comment_post_ID, isset( $_REQUEST['subscribe_blog'] ) );
807 790
808 - 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'] ) )
809 792 return;
810 - }
811 793
812 794 $post_ids = array();
813 795
814 - if ( isset( $_REQUEST['subscribe_comments'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
796 + if ( isset( $_REQUEST['subscribe_comments'] ) )
815 797 $post_ids[] = $comment->comment_post_ID;
816 - }
817 798
818 - if ( isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
799 + if ( isset( $_REQUEST['subscribe_blog'] ) )
819 800 $post_ids[] = 0;
820 - }
821 801
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 - )
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 + )
832 812 );
833 813
834 814 /**
835 815 * Fires on each comment subscription form submission.
@@ -849,16 +829,16 @@
849 829 *
850 830 * Set a cookie to save state on the comment and post subscription checkboxes.
851 831 *
852 832 * @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.
833 + * @param int $post_id If $subscribe_to_post is true, the post ID they've subscribed to.
854 834 * @param bool $subscribe_to_blog Whether the user chose to subscribe to all new posts on the blog.
855 835 */
856 - 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 ) {
857 837 $post_id = (int) $post_id;
858 838
859 839 /** This filter is already documented in core/wp-includes/comment-functions.php */
860 - $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
840 + $cookie_lifetime = apply_filters( 'comment_cookie_lifetime', 30000000 );
861 841
862 842 /**
863 843 * Filter the Jetpack Comment cookie path.
864 844 *
@@ -867,9 +847,9 @@
867 847 * @since 2.5.0
868 848 *
869 849 * @param string COOKIEPATH Cookie path.
870 850 */
871 - $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
851 + $cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
872 852
873 853 /**
874 854 * Filter the Jetpack Comment cookie domain.
875 855 *
@@ -878,20 +858,20 @@
878 858 * @since 2.5.0
879 859 *
880 860 * @param string COOKIE_DOMAIN Cookie domain.
881 861 */
882 - $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
862 + $cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
883 863
884 864 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 );
865 + setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, 1, time() + $cookie_lifetime, $cookie_path, $cookie_domain );
886 866 } else {
887 - 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 );
888 868 }
889 869
890 870 if ( $subscribe_to_blog ) {
891 - 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 );
892 872 } else {
893 - 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 );
894 874 }
895 875 }
896 876
897 877 /**
@@ -898,153 +878,17 @@
898 878 * Set the social_notifications_subscribe option to `off` when the Subscriptions module is activated in the first time.
899 879 *
900 880 * @since 8.1
901 881 *
902 - * @return void
882 + * @return null
903 883 */
904 - public function set_social_notifications_subscribe() {
884 + function set_social_notifications_subscribe() {
905 885 if ( false === get_option( 'social_notifications_subscribe' ) ) {
906 886 add_option( 'social_notifications_subscribe', 'off' );
907 887 }
908 888 }
909 889
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 890 }
1044 891
1045 892 Jetpack_Subscriptions::init();
1046 893
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';
894 +include dirname( __FILE__ ) . '/subscriptions/views.php';