Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules
File: subscriptions.php
$checked = (int) ( 'on' === get_option( 'social_notifications_subscribe', 'on' ) );
[500] Fix | Delete
?>
[501] Fix | Delete
[502] Fix | Delete
<label>
[503] Fix | Delete
<input type="checkbox" name="social_notifications_subscribe" id="social_notifications_subscribe" value="1" <?php checked( $checked ); ?> />
[504] Fix | Delete
<?php
[505] Fix | Delete
/* translators: this is a label for a setting that starts with "Email me whenever" */
[506] Fix | Delete
esc_html_e( 'Someone subscribes to my blog', 'jetpack' );
[507] Fix | Delete
?>
[508] Fix | Delete
</label>
[509] Fix | Delete
<?php
[510] Fix | Delete
}
[511] Fix | Delete
[512] Fix | Delete
/**
[513] Fix | Delete
* Validate "Someone subscribes to my blog" option
[514] Fix | Delete
*
[515] Fix | Delete
* @since 8.1
[516] Fix | Delete
*
[517] Fix | Delete
* @param String $input the input string to be validated.
[518] Fix | Delete
* @return string on|off
[519] Fix | Delete
*/
[520] Fix | Delete
public function social_notifications_subscribe_validate( $input ) {
[521] Fix | Delete
// If it's not set (was unchecked during form submission) or was set to off (during option update), return 'off'.
[522] Fix | Delete
if ( ! $input || 'off' === $input ) {
[523] Fix | Delete
return 'off';
[524] Fix | Delete
}
[525] Fix | Delete
[526] Fix | Delete
// Otherwise we return 'on'.
[527] Fix | Delete
return 'on';
[528] Fix | Delete
}
[529] Fix | Delete
[530] Fix | Delete
/**
[531] Fix | Delete
* Jetpack_Subscriptions::subscribe()
[532] Fix | Delete
*
[533] Fix | Delete
* Send a synchronous XML-RPC subscribe to blog posts or subscribe to post comments request.
[534] Fix | Delete
*
[535] Fix | Delete
* @param string $email being subscribed.
[536] Fix | Delete
* @param array $post_ids (optional) defaults to 0 for blog posts only: array of post IDs to subscribe to blog's posts.
[537] Fix | Delete
* @param bool $async (optional) Should the subscription be performed asynchronously? Defaults to true.
[538] Fix | Delete
* @param array $extra_data Additional data passed to the `jetpack.subscribeToSite` call.
[539] Fix | Delete
*
[540] Fix | Delete
* @return true|WP_Error true on success
[541] Fix | Delete
* invalid_email : not a valid email address
[542] Fix | Delete
* invalid_post_id : not a valid post ID
[543] Fix | Delete
* unknown_post_id : unknown post
[544] Fix | Delete
* not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email.
[545] Fix | Delete
* disabled : Site owner has disabled subscriptions.
[546] Fix | Delete
* active : Already subscribed.
[547] Fix | Delete
* pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent.
[548] Fix | Delete
* unknown : strange error. Jetpack servers at WordPress.com returned something malformed.
[549] Fix | Delete
* unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
[550] Fix | Delete
*/
[551] Fix | Delete
public function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array() ) {
[552] Fix | Delete
if ( ! is_email( $email ) ) {
[553] Fix | Delete
return new WP_Error( 'invalid_email' );
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
if ( ! $async ) {
[557] Fix | Delete
$xml = new Jetpack_IXR_ClientMulticall();
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
foreach ( (array) $post_ids as $post_id ) {
[561] Fix | Delete
$post_id = (int) $post_id;
[562] Fix | Delete
if ( $post_id < 0 ) {
[563] Fix | Delete
return new WP_Error( 'invalid_post_id' );
[564] Fix | Delete
} elseif ( $post_id && ! get_post( $post_id ) ) {
[565] Fix | Delete
return new WP_Error( 'unknown_post_id' );
[566] Fix | Delete
}
[567] Fix | Delete
[568] Fix | Delete
if ( $async ) {
[569] Fix | Delete
XMLRPC_Async_Call::add_call( 'jetpack.subscribeToSite', 0, $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
[570] Fix | Delete
} else {
[571] Fix | Delete
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false
[572] Fix | Delete
$xml->addCall( 'jetpack.subscribeToSite', $email, $post_id, serialize( $extra_data ) ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
[573] Fix | Delete
}
[574] Fix | Delete
}
[575] Fix | Delete
[576] Fix | Delete
if ( $async ) {
[577] Fix | Delete
return;
[578] Fix | Delete
}
[579] Fix | Delete
[580] Fix | Delete
// Call.
[581] Fix | Delete
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false, otherwise we return early
[582] Fix | Delete
$xml->query();
[583] Fix | Delete
[584] Fix | Delete
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false, otherwise we return early
[585] Fix | Delete
if ( $xml->isError() ) {
[586] Fix | Delete
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false, otherwise we return early
[587] Fix | Delete
return $xml->get_jetpack_error();
[588] Fix | Delete
}
[589] Fix | Delete
[590] Fix | Delete
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false
[591] Fix | Delete
$responses = $xml->getResponse();
[592] Fix | Delete
[593] Fix | Delete
$r = array();
[594] Fix | Delete
foreach ( (array) $responses as $response ) {
[595] Fix | Delete
if ( isset( $response['faultCode'] ) || isset( $response['faultString'] ) ) {
[596] Fix | Delete
// @phan-suppress-next-line PhanPossiblyUndeclaredVariable -- $xml is set when $async is false
[597] Fix | Delete
$r[] = $xml->get_jetpack_error( $response['faultCode'], $response['faultString'] );
[598] Fix | Delete
continue;
[599] Fix | Delete
}
[600] Fix | Delete
[601] Fix | Delete
if ( ! is_array( $response[0] ) || empty( $response[0]['status'] ) ) {
[602] Fix | Delete
$r[] = new WP_Error( 'unknown' );
[603] Fix | Delete
continue;
[604] Fix | Delete
}
[605] Fix | Delete
[606] Fix | Delete
switch ( $response[0]['status'] ) {
[607] Fix | Delete
case 'error':
[608] Fix | Delete
$r[] = new WP_Error( 'not_subscribed' );
[609] Fix | Delete
continue 2;
[610] Fix | Delete
case 'disabled':
[611] Fix | Delete
$r[] = new WP_Error( 'disabled' );
[612] Fix | Delete
continue 2;
[613] Fix | Delete
case 'active':
[614] Fix | Delete
$r[] = new WP_Error( 'active' );
[615] Fix | Delete
continue 2;
[616] Fix | Delete
case 'confirming':
[617] Fix | Delete
$r[] = true;
[618] Fix | Delete
continue 2;
[619] Fix | Delete
case 'pending':
[620] Fix | Delete
$r[] = new WP_Error( 'pending' );
[621] Fix | Delete
continue 2;
[622] Fix | Delete
default:
[623] Fix | Delete
$r[] = new WP_Error( 'unknown_status', (string) $response[0]['status'] );
[624] Fix | Delete
continue 2;
[625] Fix | Delete
}
[626] Fix | Delete
}
[627] Fix | Delete
[628] Fix | Delete
return $r;
[629] Fix | Delete
}
[630] Fix | Delete
[631] Fix | Delete
/**
[632] Fix | Delete
* Jetpack_Subscriptions::widget_submit()
[633] Fix | Delete
*
[634] Fix | Delete
* When a user submits their email via the blog subscription widget, check the details and call the subsribe() method.
[635] Fix | Delete
*/
[636] Fix | Delete
public function widget_submit() {
[637] Fix | Delete
// Check the nonce.
[638] Fix | Delete
if ( ! wp_verify_nonce( isset( $_REQUEST['_wpnonce'] ) ? sanitize_key( $_REQUEST['_wpnonce'] ) : '', 'blogsub_subscribe_' . \Jetpack_Options::get_option( 'id' ) ) ) {
[639] Fix | Delete
return false;
[640] Fix | Delete
}
[641] Fix | Delete
[642] Fix | Delete
if ( empty( $_REQUEST['email'] ) || ! is_string( $_REQUEST['email'] ) ) {
[643] Fix | Delete
return false;
[644] Fix | Delete
}
[645] Fix | Delete
[646] Fix | Delete
$redirect_fragment = false;
[647] Fix | Delete
if ( isset( $_REQUEST['redirect_fragment'] ) ) {
[648] Fix | Delete
$redirect_fragment = preg_replace( '/[^a-z0-9_-]/i', '', $_REQUEST['redirect_fragment'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput -- This is manually unslashing and sanitizing.
[649] Fix | Delete
}
[650] Fix | Delete
if ( ! $redirect_fragment || ! is_string( $redirect_fragment ) ) {
[651] Fix | Delete
$redirect_fragment = 'subscribe-blog';
[652] Fix | Delete
}
[653] Fix | Delete
[654] Fix | Delete
$subscribe = self::subscribe(
[655] Fix | Delete
isset( $_REQUEST['email'] ) ? wp_unslash( $_REQUEST['email'] ) : null, // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Validated inside self::subscribe().
[656] Fix | Delete
0,
[657] Fix | Delete
false,
[658] Fix | Delete
array(
[659] Fix | Delete
'source' => 'widget',
[660] Fix | Delete
'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
[661] Fix | Delete
'comment_status' => '',
[662] Fix | Delete
'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
[663] Fix | Delete
)
[664] Fix | Delete
);
[665] Fix | Delete
[666] Fix | Delete
if ( is_wp_error( $subscribe ) ) {
[667] Fix | Delete
$error = $subscribe->get_error_code();
[668] Fix | Delete
} else {
[669] Fix | Delete
$error = false;
[670] Fix | Delete
foreach ( $subscribe as $response ) {
[671] Fix | Delete
if ( is_wp_error( $response ) ) {
[672] Fix | Delete
$error = $response->get_error_code();
[673] Fix | Delete
break;
[674] Fix | Delete
}
[675] Fix | Delete
}
[676] Fix | Delete
}
[677] Fix | Delete
[678] Fix | Delete
switch ( $error ) {
[679] Fix | Delete
case false:
[680] Fix | Delete
$result = 'success';
[681] Fix | Delete
break;
[682] Fix | Delete
case 'invalid_email':
[683] Fix | Delete
$result = $error;
[684] Fix | Delete
break;
[685] Fix | Delete
case 'blocked_email':
[686] Fix | Delete
$result = 'opted_out';
[687] Fix | Delete
break;
[688] Fix | Delete
case 'active':
[689] Fix | Delete
$result = 'already';
[690] Fix | Delete
break;
[691] Fix | Delete
case 'flooded_email':
[692] Fix | Delete
$result = 'many_pending_subs';
[693] Fix | Delete
break;
[694] Fix | Delete
case 'pending':
[695] Fix | Delete
$result = 'pending';
[696] Fix | Delete
break;
[697] Fix | Delete
default:
[698] Fix | Delete
$result = 'error';
[699] Fix | Delete
break;
[700] Fix | Delete
}
[701] Fix | Delete
[702] Fix | Delete
$redirect = add_query_arg( 'subscribe', $result );
[703] Fix | Delete
[704] Fix | Delete
/**
[705] Fix | Delete
* Fires on each subscription form submission.
[706] Fix | Delete
*
[707] Fix | Delete
* @module subscriptions
[708] Fix | Delete
*
[709] Fix | Delete
* @since 3.7.0
[710] Fix | Delete
*
[711] Fix | Delete
* @param string $result Result of form submission: success, invalid_email, already, error.
[712] Fix | Delete
*/
[713] Fix | Delete
do_action( 'jetpack_subscriptions_form_submission', $result );
[714] Fix | Delete
[715] Fix | Delete
wp_safe_redirect( "$redirect#$redirect_fragment" );
[716] Fix | Delete
exit( 0 );
[717] Fix | Delete
}
[718] Fix | Delete
[719] Fix | Delete
/**
[720] Fix | Delete
* Jetpack_Subscriptions::comment_subscribe_init()
[721] Fix | Delete
*
[722] Fix | Delete
* Set up and add the comment subscription checkbox to the comment form.
[723] Fix | Delete
*
[724] Fix | Delete
* @param string $submit_button HTML markup for the submit field.
[725] Fix | Delete
*/
[726] Fix | Delete
public function comment_subscribe_init( $submit_button ) {
[727] Fix | Delete
global $post;
[728] Fix | Delete
[729] Fix | Delete
// Subscriptions are only available for posts so far.
[730] Fix | Delete
if ( ! $post || 'post' !== $post->post_type ) {
[731] Fix | Delete
return $submit_button;
[732] Fix | Delete
}
[733] Fix | Delete
[734] Fix | Delete
$comments_checked = '';
[735] Fix | Delete
$blog_checked = '';
[736] Fix | Delete
[737] Fix | Delete
// Check for a comment / blog submission and set a cookie to retain the setting and check the boxes.
[738] Fix | Delete
if ( isset( $_COOKIE[ 'jetpack_comments_subscribe_' . self::$hash . '_' . $post->ID ] ) ) {
[739] Fix | Delete
$comments_checked = ' checked="checked"';
[740] Fix | Delete
}
[741] Fix | Delete
[742] Fix | Delete
if ( isset( $_COOKIE[ 'jetpack_blog_subscribe_' . self::$hash ] ) ) {
[743] Fix | Delete
$blog_checked = ' checked="checked"';
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
// Some themes call this function, don't show the checkbox again.
[747] Fix | Delete
remove_action( 'comment_form', 'subscription_comment_form' );
[748] Fix | Delete
[749] Fix | Delete
// Check if Mark Jaquith's Subscribe to Comments plugin is active - if so, suppress Jetpack checkbox.
[750] Fix | Delete
[751] Fix | Delete
$str = '';
[752] Fix | Delete
[753] Fix | Delete
if ( false === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 === (int) get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) && 'post' === get_post_type() ) {
[754] Fix | Delete
// Subscribe to comments checkbox.
[755] Fix | Delete
$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 . ' /> ';
[756] Fix | Delete
$comment_sub_text = __( 'Notify me of follow-up comments by email.', 'jetpack' );
[757] Fix | Delete
$str .= '<label class="subscribe-label" id="subscribe-label" for="subscribe_comments">' . esc_html(
[758] Fix | Delete
/**
[759] Fix | Delete
* Filter the Subscribe to comments text appearing below the comment form.
[760] Fix | Delete
*
[761] Fix | Delete
* @module subscriptions
[762] Fix | Delete
*
[763] Fix | Delete
* @since 3.4.0
[764] Fix | Delete
*
[765] Fix | Delete
* @param string $comment_sub_text Subscribe to comments text.
[766] Fix | Delete
*/
[767] Fix | Delete
apply_filters( 'jetpack_subscribe_comment_label', $comment_sub_text )
[768] Fix | Delete
) . '</label>';
[769] Fix | Delete
$str .= '</p>';
[770] Fix | Delete
}
[771] Fix | Delete
[772] Fix | Delete
if ( 1 === (int) get_option( 'stb_enabled', 1 ) ) {
[773] Fix | Delete
// Subscribe to blog checkbox.
[774] Fix | Delete
$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 . ' /> ';
[775] Fix | Delete
$blog_sub_text = __( 'Notify me of new posts by email.', 'jetpack' );
[776] Fix | Delete
$str .= '<label class="subscribe-label" id="subscribe-blog-label" for="subscribe_blog">' . esc_html(
[777] Fix | Delete
/**
[778] Fix | Delete
* Filter the Subscribe to blog text appearing below the comment form.
[779] Fix | Delete
*
[780] Fix | Delete
* @module subscriptions
[781] Fix | Delete
*
[782] Fix | Delete
* @since 3.4.0
[783] Fix | Delete
*
[784] Fix | Delete
* @param string $comment_sub_text Subscribe to blog text.
[785] Fix | Delete
*/
[786] Fix | Delete
apply_filters( 'jetpack_subscribe_blog_label', $blog_sub_text )
[787] Fix | Delete
) . '</label>';
[788] Fix | Delete
$str .= '</p>';
[789] Fix | Delete
}
[790] Fix | Delete
[791] Fix | Delete
/**
[792] Fix | Delete
* Filter the output of the subscription options appearing below the comment form.
[793] Fix | Delete
*
[794] Fix | Delete
* @module subscriptions
[795] Fix | Delete
*
[796] Fix | Delete
* @since 1.2.0
[797] Fix | Delete
*
[798] Fix | Delete
* @param string $str Comment Subscription form HTML output.
[799] Fix | Delete
*/
[800] Fix | Delete
$str = apply_filters( 'jetpack_comment_subscription_form', $str );
[801] Fix | Delete
[802] Fix | Delete
return $str . $submit_button;
[803] Fix | Delete
}
[804] Fix | Delete
[805] Fix | Delete
/**
[806] Fix | Delete
* Jetpack_Subscriptions::comment_subscribe_init()
[807] Fix | Delete
*
[808] Fix | Delete
* When a user checks the comment subscribe box and submits a comment, subscribe them to the comment thread.
[809] Fix | Delete
*
[810] Fix | Delete
* @param int|string $comment_id Comment thread being subscribed to.
[811] Fix | Delete
* @param string $approved Comment status.
[812] Fix | Delete
*/
[813] Fix | Delete
public function comment_subscribe_submit( $comment_id, $approved ) {
[814] Fix | Delete
/**
[815] Fix | Delete
* Filters whether to skip comment subscription processing.
[816] Fix | Delete
*
[817] Fix | Delete
* @since 15.5
[818] Fix | Delete
*
[819] Fix | Delete
* @param bool $skip Whether to skip comment subscription. Default false.
[820] Fix | Delete
*/
[821] Fix | Delete
if ( apply_filters( 'jetpack_subscription_comment_subscribe_skip', false ) ) {
[822] Fix | Delete
return;
[823] Fix | Delete
}
[824] Fix | Delete
[825] Fix | Delete
if ( 'spam' === $approved ) {
[826] Fix | Delete
return;
[827] Fix | Delete
}
[828] Fix | Delete
[829] Fix | Delete
$comment = get_comment( $comment_id );
[830] Fix | Delete
if ( ! $comment ) {
[831] Fix | Delete
return;
[832] Fix | Delete
}
[833] Fix | Delete
[834] Fix | Delete
// Set cookies for this post/comment.
[835] Fix | Delete
$this->set_cookies( isset( $_REQUEST['subscribe_comments'] ), $comment->comment_post_ID, isset( $_REQUEST['subscribe_blog'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[836] Fix | Delete
[837] Fix | Delete
if ( ! isset( $_REQUEST['subscribe_comments'] ) && ! isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[838] Fix | Delete
return;
[839] Fix | Delete
}
[840] Fix | Delete
[841] Fix | Delete
$post_ids = array();
[842] Fix | Delete
[843] Fix | Delete
if ( isset( $_REQUEST['subscribe_comments'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[844] Fix | Delete
$post_ids[] = $comment->comment_post_ID;
[845] Fix | Delete
}
[846] Fix | Delete
[847] Fix | Delete
if ( isset( $_REQUEST['subscribe_blog'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[848] Fix | Delete
$post_ids[] = 0;
[849] Fix | Delete
}
[850] Fix | Delete
[851] Fix | Delete
$result = self::subscribe(
[852] Fix | Delete
$comment->comment_author_email,
[853] Fix | Delete
$post_ids,
[854] Fix | Delete
true,
[855] Fix | Delete
array(
[856] Fix | Delete
'source' => 'comment-form',
[857] Fix | Delete
'widget-in-use' => is_active_widget( false, false, 'blog_subscription', true ) ? 'yes' : 'no',
[858] Fix | Delete
'comment_status' => $approved,
[859] Fix | Delete
'server_data' => jetpack_subscriptions_cherry_pick_server_data(),
[860] Fix | Delete
)
[861] Fix | Delete
);
[862] Fix | Delete
[863] Fix | Delete
/**
[864] Fix | Delete
* Fires on each comment subscription form submission.
[865] Fix | Delete
*
[866] Fix | Delete
* @module subscriptions
[867] Fix | Delete
*
[868] Fix | Delete
* @since 5.5.0
[869] Fix | Delete
*
[870] Fix | Delete
* @param NULL|WP_Error $result Result of form submission: NULL on success, WP_Error otherwise.
[871] Fix | Delete
* @param array $post_ids An array of post IDs that the user subscribed to, 0 means blog subscription.
[872] Fix | Delete
*/
[873] Fix | Delete
do_action( 'jetpack_subscriptions_comment_form_submission', $result, $post_ids );
[874] Fix | Delete
}
[875] Fix | Delete
[876] Fix | Delete
/**
[877] Fix | Delete
* Jetpack_Subscriptions::set_cookies()
[878] Fix | Delete
*
[879] Fix | Delete
* Set a cookie to save state on the comment and post subscription checkboxes.
[880] Fix | Delete
*
[881] Fix | Delete
* @param bool $subscribe_to_post Whether the user chose to subscribe to subsequent comments on this post.
[882] Fix | Delete
* @param int $post_id If $subscribe_to_post is true, the post ID they've subscribed to.
[883] Fix | Delete
* @param bool $subscribe_to_blog Whether the user chose to subscribe to all new posts on the blog.
[884] Fix | Delete
*/
[885] Fix | Delete
public function set_cookies( $subscribe_to_post = false, $post_id = null, $subscribe_to_blog = false ) {
[886] Fix | Delete
$post_id = (int) $post_id;
[887] Fix | Delete
[888] Fix | Delete
/** This filter is already documented in core/wp-includes/comment-functions.php */
[889] Fix | Delete
$cookie_lifetime = apply_filters( 'comment_cookie_lifetime', YEAR_IN_SECONDS );
[890] Fix | Delete
[891] Fix | Delete
/**
[892] Fix | Delete
* Filter the Jetpack Comment cookie path.
[893] Fix | Delete
*
[894] Fix | Delete
* @module subscriptions
[895] Fix | Delete
*
[896] Fix | Delete
* @since 2.5.0
[897] Fix | Delete
*
[898] Fix | Delete
* @param string COOKIEPATH Cookie path.
[899] Fix | Delete
*/
[900] Fix | Delete
$cookie_path = apply_filters( 'jetpack_comment_cookie_path', COOKIEPATH );
[901] Fix | Delete
[902] Fix | Delete
/**
[903] Fix | Delete
* Filter the Jetpack Comment cookie domain.
[904] Fix | Delete
*
[905] Fix | Delete
* @module subscriptions
[906] Fix | Delete
*
[907] Fix | Delete
* @since 2.5.0
[908] Fix | Delete
*
[909] Fix | Delete
* @param string COOKIE_DOMAIN Cookie domain.
[910] Fix | Delete
*/
[911] Fix | Delete
$cookie_domain = apply_filters( 'jetpack_comment_cookie_domain', COOKIE_DOMAIN );
[912] Fix | Delete
[913] Fix | Delete
if ( $subscribe_to_post && $post_id >= 0 ) {
[914] Fix | Delete
setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '1', time() + $cookie_lifetime, $cookie_path, $cookie_domain, is_ssl(), true );
[915] Fix | Delete
} else {
[916] Fix | Delete
setcookie( 'jetpack_comments_subscribe_' . self::$hash . '_' . $post_id, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
[917] Fix | Delete
}
[918] Fix | Delete
[919] Fix | Delete
if ( $subscribe_to_blog ) {
[920] Fix | Delete
setcookie( 'jetpack_blog_subscribe_' . self::$hash, '1', time() + $cookie_lifetime, $cookie_path, $cookie_domain, is_ssl(), true );
[921] Fix | Delete
} else {
[922] Fix | Delete
setcookie( 'jetpack_blog_subscribe_' . self::$hash, '', time() - 3600, $cookie_path, $cookie_domain, is_ssl(), true );
[923] Fix | Delete
}
[924] Fix | Delete
}
[925] Fix | Delete
[926] Fix | Delete
/**
[927] Fix | Delete
* Set the social_notifications_subscribe option to `off` when the Subscriptions module is activated in the first time.
[928] Fix | Delete
*
[929] Fix | Delete
* @since 8.1
[930] Fix | Delete
*
[931] Fix | Delete
* @return void
[932] Fix | Delete
*/
[933] Fix | Delete
public function set_social_notifications_subscribe() {
[934] Fix | Delete
if ( false === get_option( 'social_notifications_subscribe' ) ) {
[935] Fix | Delete
add_option( 'social_notifications_subscribe', 'off' );
[936] Fix | Delete
}
[937] Fix | Delete
}
[938] Fix | Delete
[939] Fix | Delete
/**
[940] Fix | Delete
* Set the featured image in email option to `1` when the Subscriptions module is activated in the first time.
[941] Fix | Delete
*
[942] Fix | Delete
* @return void
[943] Fix | Delete
*/
[944] Fix | Delete
public function set_featured_image_in_email_default() {
[945] Fix | Delete
add_option( 'wpcom_featured_image_in_email', 1 );
[946] Fix | Delete
}
[947] Fix | Delete
[948] Fix | Delete
/**
[949] Fix | Delete
* Save a flag when a post was ever published.
[950] Fix | Delete
*
[951] Fix | Delete
* It saves the post meta when the post was published and becomes a draft.
[952] Fix | Delete
* Then this meta is used to hide subscription messaging in Publish panel.
[953] Fix | Delete
*
[954] Fix | Delete
* @param string $new_status Tthe "new" post status of the transition when saved.
[955] Fix | Delete
* @param string $old_status The "old" post status of the transition when saved.
[956] Fix | Delete
* @param object $post obj The post object.
[957] Fix | Delete
*/
[958] Fix | Delete
public function maybe_set_first_published_status( $new_status, $old_status, $post ) {
[959] Fix | Delete
$was_post_ever_published = get_post_meta( $post->ID, '_jetpack_post_was_ever_published', true );
[960] Fix | Delete
if ( ! $was_post_ever_published && 'publish' === $old_status && 'draft' === $new_status ) {
[961] Fix | Delete
update_post_meta( $post->ID, '_jetpack_post_was_ever_published', true );
[962] Fix | Delete
}
[963] Fix | Delete
}
[964] Fix | Delete
[965] Fix | Delete
/**
[966] Fix | Delete
* Checks if the current user can publish posts.
[967] Fix | Delete
*
[968] Fix | Delete
* @return bool
[969] Fix | Delete
*/
[970] Fix | Delete
public function first_published_status_meta_auth_callback() {
[971] Fix | Delete
/**
[972] Fix | Delete
* Filter the capability to view if a post was ever published in the Subscription Module.
[973] Fix | Delete
*
[974] Fix | Delete
* @module subscriptions
[975] Fix | Delete
*
[976] Fix | Delete
* @since 13.4
[977] Fix | Delete
*
[978] Fix | Delete
* @param string $capability User capability needed to view if a post was ever published. Default to publish_posts.
[979] Fix | Delete
*/
[980] Fix | Delete
$capability = apply_filters( 'jetpack_subscriptions_post_was_ever_published_capability', 'publish_posts' );
[981] Fix | Delete
if ( current_user_can( $capability ) ) {
[982] Fix | Delete
return true;
[983] Fix | Delete
}
[984] Fix | Delete
return false;
[985] Fix | Delete
}
[986] Fix | Delete
[987] Fix | Delete
/**
[988] Fix | Delete
* Registers the 'post_was_ever_published' post meta for use in the REST API.
[989] Fix | Delete
*/
[990] Fix | Delete
public function register_post_meta() {
[991] Fix | Delete
$jetpack_post_was_ever_published = array(
[992] Fix | Delete
'type' => 'boolean',
[993] Fix | Delete
'description' => __( 'Whether the post was ever published.', 'jetpack' ),
[994] Fix | Delete
'single' => true,
[995] Fix | Delete
'default' => false,
[996] Fix | Delete
'show_in_rest' => array(
[997] Fix | Delete
'name' => 'jetpack_post_was_ever_published',
[998] Fix | Delete
),
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function