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