Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/subscrip...
File: views.php
* @module subscriptions
[500] Fix | Delete
*
[501] Fix | Delete
* @since 2.7.0
[502] Fix | Delete
*
[503] Fix | Delete
* @param string subscribe-field Subscription form field prefix.
[504] Fix | Delete
* @param int $widget_id Widget ID.
[505] Fix | Delete
*/
[506] Fix | Delete
$subscribe_field_id = apply_filters( 'subscribe_field_id', 'subscribe-field', $widget_id );
[507] Fix | Delete
[508] Fix | Delete
$form_id = self::get_redirect_fragment( $widget_id );
[509] Fix | Delete
?>
[510] Fix | Delete
<div class="wp-block-jetpack-subscriptions__container">
[511] Fix | Delete
<form action="#" method="post" accept-charset="utf-8" id="<?php echo esc_attr( $form_id ); ?>"
[512] Fix | Delete
data-blog="<?php echo esc_attr( \Jetpack_Options::get_option( 'id' ) ); ?>"
[513] Fix | Delete
data-post_access_level="<?php echo esc_attr( $post_access_level ); ?>" >
[514] Fix | Delete
<?php
[515] Fix | Delete
if ( $subscribe_text && ( ! isset( $_GET['subscribe'] ) || 'success' !== $_GET['subscribe'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Non-sensitive informational output.
[516] Fix | Delete
?>
[517] Fix | Delete
<div id="subscribe-text"><?php echo wp_kses( wpautop( str_replace( '[total-subscribers]', number_format_i18n( $subscribers_total ), $subscribe_text ) ), 'post' ); ?></div>
[518] Fix | Delete
<?php
[519] Fix | Delete
}
[520] Fix | Delete
[521] Fix | Delete
if ( ! isset( $_GET['subscribe'] ) || 'success' !== $_GET['subscribe'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display of unsubmitted form.
[522] Fix | Delete
?>
[523] Fix | Delete
<p id="subscribe-email">
[524] Fix | Delete
<label id="jetpack-subscribe-label"
[525] Fix | Delete
class="screen-reader-text"
[526] Fix | Delete
for="<?php echo esc_attr( $subscribe_field_id . '-' . $widget_id ); ?>">
[527] Fix | Delete
<?php echo ! empty( $subscribe_placeholder ) ? esc_html( $subscribe_placeholder ) : esc_html__( 'Email Address:', 'jetpack' ); ?>
[528] Fix | Delete
</label>
[529] Fix | Delete
<input type="email" name="email" required="required"
[530] Fix | Delete
<?php if ( ! empty( $email_field_classes ) ) { ?>
[531] Fix | Delete
class="<?php echo esc_attr( $email_field_classes ); ?> required"
[532] Fix | Delete
<?php } ?>
[533] Fix | Delete
<?php if ( ! empty( $email_field_styles ) ) { ?>
[534] Fix | Delete
style="<?php echo esc_attr( $email_field_styles ); ?>"
[535] Fix | Delete
<?php } ?>
[536] Fix | Delete
value="<?php echo esc_attr( $subscribe_email ); ?>"
[537] Fix | Delete
id="<?php echo esc_attr( $subscribe_field_id . '-' . $widget_id ); ?>"
[538] Fix | Delete
placeholder="<?php echo esc_attr( $subscribe_placeholder ); ?>"
[539] Fix | Delete
/>
[540] Fix | Delete
</p>
[541] Fix | Delete
[542] Fix | Delete
<p id="subscribe-submit"
[543] Fix | Delete
<?php if ( ! empty( $submit_button_wrapper_styles ) ) { ?>
[544] Fix | Delete
style="<?php echo esc_attr( $submit_button_wrapper_styles ); ?>"
[545] Fix | Delete
<?php } ?>
[546] Fix | Delete
>
[547] Fix | Delete
<input type="hidden" name="action" value="subscribe"/>
[548] Fix | Delete
<input type="hidden" name="source" value="<?php echo esc_url( $referer ); ?>"/>
[549] Fix | Delete
<input type="hidden" name="sub-type" value="<?php echo esc_attr( $source ); ?>"/>
[550] Fix | Delete
<input type="hidden" name="redirect_fragment" value="<?php echo esc_attr( $form_id ); ?>"/>
[551] Fix | Delete
<?php wp_nonce_field( 'blogsub_subscribe_' . \Jetpack_Options::get_option( 'id' ) ); ?>
[552] Fix | Delete
<button type="submit"
[553] Fix | Delete
<?php if ( ! empty( $submit_button_classes ) ) { ?>
[554] Fix | Delete
class="<?php echo esc_attr( $submit_button_classes ); ?>"
[555] Fix | Delete
<?php } ?>
[556] Fix | Delete
<?php if ( ! empty( $submit_button_styles ) ) { ?>
[557] Fix | Delete
style="<?php echo esc_attr( $submit_button_styles ); ?>"
[558] Fix | Delete
<?php } ?>
[559] Fix | Delete
name="jetpack_subscriptions_widget"
[560] Fix | Delete
>
[561] Fix | Delete
<?php
[562] Fix | Delete
echo wp_kses(
[563] Fix | Delete
html_entity_decode( $subscribe_button, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ),
[564] Fix | Delete
self::$allowed_html_tags_for_submit_button
[565] Fix | Delete
);
[566] Fix | Delete
?>
[567] Fix | Delete
</button>
[568] Fix | Delete
</p>
[569] Fix | Delete
<?php } ?>
[570] Fix | Delete
</form>
[571] Fix | Delete
<?php if ( $show_subscribers_total && 0 < $subscribers_total ) { ?>
[572] Fix | Delete
<div class="wp-block-jetpack-subscriptions__subscount">
[573] Fix | Delete
<?php
[574] Fix | Delete
echo esc_html( Jetpack_Memberships::get_join_others_text( $subscribers_total ) );
[575] Fix | Delete
?>
[576] Fix | Delete
</div>
[577] Fix | Delete
<?php } ?>
[578] Fix | Delete
</div>
[579] Fix | Delete
<?php
[580] Fix | Delete
}
[581] Fix | Delete
}
[582] Fix | Delete
[583] Fix | Delete
/**
[584] Fix | Delete
* Determines if the current user is subscribed to the blog.
[585] Fix | Delete
*
[586] Fix | Delete
* @return bool Is the person already subscribed.
[587] Fix | Delete
*/
[588] Fix | Delete
public static function is_current_user_subscribed() {
[589] Fix | Delete
$subscribed = isset( $_GET['subscribe'] ) && 'success' === $_GET['subscribe']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[590] Fix | Delete
[591] Fix | Delete
if ( self::is_wpcom() && class_exists( 'Blog_Subscription' ) && class_exists( 'Blog_Subscriber' ) ) {
[592] Fix | Delete
$subscribed = is_user_logged_in() && Blog_Subscription::is_subscribed( new Blog_Subscriber() );
[593] Fix | Delete
}
[594] Fix | Delete
[595] Fix | Delete
return $subscribed;
[596] Fix | Delete
}
[597] Fix | Delete
[598] Fix | Delete
/**
[599] Fix | Delete
* Is this script running in the wordpress.com environment?
[600] Fix | Delete
*
[601] Fix | Delete
* @return bool
[602] Fix | Delete
*/
[603] Fix | Delete
public static function is_wpcom() {
[604] Fix | Delete
return defined( 'IS_WPCOM' ) && IS_WPCOM;
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
/**
[608] Fix | Delete
* Is this script running in a self-hosted environment?
[609] Fix | Delete
*
[610] Fix | Delete
* @return bool
[611] Fix | Delete
*/
[612] Fix | Delete
public static function is_jetpack() {
[613] Fix | Delete
return ! self::is_wpcom();
[614] Fix | Delete
}
[615] Fix | Delete
[616] Fix | Delete
/**
[617] Fix | Delete
* Used to determine if there is a valid status slug within the wordpress.com environment.
[618] Fix | Delete
*
[619] Fix | Delete
* @return bool
[620] Fix | Delete
*/
[621] Fix | Delete
public static function wpcom_has_status_message() {
[622] Fix | Delete
return isset( $_GET['blogsub'] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[623] Fix | Delete
in_array(
[624] Fix | Delete
$_GET['blogsub'], // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[625] Fix | Delete
array(
[626] Fix | Delete
'confirming',
[627] Fix | Delete
'blocked',
[628] Fix | Delete
'flooded',
[629] Fix | Delete
'spammed',
[630] Fix | Delete
'subscribed',
[631] Fix | Delete
'pending',
[632] Fix | Delete
'confirmed',
[633] Fix | Delete
),
[634] Fix | Delete
true
[635] Fix | Delete
);
[636] Fix | Delete
}
[637] Fix | Delete
[638] Fix | Delete
/**
[639] Fix | Delete
* Determine the amount of folks currently subscribed to the blog.
[640] Fix | Delete
*
[641] Fix | Delete
* @return int
[642] Fix | Delete
*/
[643] Fix | Delete
public static function fetch_subscriber_count() {
[644] Fix | Delete
$subs_count = 0;
[645] Fix | Delete
if ( self::is_jetpack() ) {
[646] Fix | Delete
$cache_key = 'wpcom_subscribers_total';
[647] Fix | Delete
$subs_count = get_transient( $cache_key );
[648] Fix | Delete
if ( false === $subs_count || 'failed' === $subs_count['status'] ) {
[649] Fix | Delete
$xml = new Jetpack_IXR_Client();
[650] Fix | Delete
$xml->query( 'jetpack.fetchSubscriberCount' );
[651] Fix | Delete
[652] Fix | Delete
if ( $xml->isError() ) { // If we get an error from .com, set the status to failed so that we will try again next time the data is requested.
[653] Fix | Delete
[654] Fix | Delete
$subs_count = array(
[655] Fix | Delete
'status' => 'failed',
[656] Fix | Delete
'code' => $xml->getErrorCode(),
[657] Fix | Delete
'message' => $xml->getErrorMessage(),
[658] Fix | Delete
'value' => ( isset( $subs_count['value'] ) ) ? $subs_count['value'] : 0,
[659] Fix | Delete
);
[660] Fix | Delete
} else {
[661] Fix | Delete
$subs_count = array(
[662] Fix | Delete
'status' => 'success',
[663] Fix | Delete
'value' => $xml->getResponse(),
[664] Fix | Delete
);
[665] Fix | Delete
}
[666] Fix | Delete
set_transient( $cache_key, $subs_count, 3600 ); // Try to cache the result for at least 1 hour.
[667] Fix | Delete
}
[668] Fix | Delete
return $subs_count['value'];
[669] Fix | Delete
}
[670] Fix | Delete
[671] Fix | Delete
if ( self::is_wpcom() ) {
[672] Fix | Delete
$subs_count = wpcom_reach_total_for_blog();
[673] Fix | Delete
return $subs_count;
[674] Fix | Delete
}
[675] Fix | Delete
}
[676] Fix | Delete
[677] Fix | Delete
/**
[678] Fix | Delete
* Updates a particular instance of a widget when someone saves it in wp-admin.
[679] Fix | Delete
*
[680] Fix | Delete
* @param array $new_instance New widget instance settings.
[681] Fix | Delete
* @param array $old_instance Old widget instance settings.
[682] Fix | Delete
*
[683] Fix | Delete
* @return array
[684] Fix | Delete
*/
[685] Fix | Delete
public function update( $new_instance, $old_instance ) {
[686] Fix | Delete
// Merge new values over old, then fill in any missing keys with defaults
[687] Fix | Delete
$instance = wp_parse_args( (array) $new_instance, wp_parse_args( (array) $old_instance, static::defaults() ) );
[688] Fix | Delete
[689] Fix | Delete
if ( self::is_jetpack() ) {
[690] Fix | Delete
$instance['title'] = wp_kses( stripslashes( $instance['title'] ), array() );
[691] Fix | Delete
$instance['subscribe_placeholder'] = wp_kses( stripslashes( $instance['subscribe_placeholder'] ), array() );
[692] Fix | Delete
$instance['subscribe_button'] = wp_kses( stripslashes( $instance['subscribe_button'] ), array() );
[693] Fix | Delete
$instance['success_message'] = wp_kses( stripslashes( $instance['success_message'] ), array() );
[694] Fix | Delete
}
[695] Fix | Delete
[696] Fix | Delete
if ( self::is_wpcom() ) {
[697] Fix | Delete
$instance['title'] = wp_strip_all_tags( stripslashes( $instance['title'] ) );
[698] Fix | Delete
$instance['title_following'] = isset( $instance['title_following'] ) ? wp_strip_all_tags( stripslashes( $instance['title_following'] ) ) : '';
[699] Fix | Delete
$instance['subscribe_logged_in'] = isset( $instance['subscribe_logged_in'] ) ? wp_filter_post_kses( stripslashes( $instance['subscribe_logged_in'] ) ) : '';
[700] Fix | Delete
$instance['subscribe_button'] = wp_strip_all_tags( stripslashes( $instance['subscribe_button'] ) );
[701] Fix | Delete
}
[702] Fix | Delete
[703] Fix | Delete
$instance['show_subscribers_total'] = isset( $new_instance['show_subscribers_total'] ) && $new_instance['show_subscribers_total'];
[704] Fix | Delete
$instance['show_only_email_and_button'] = isset( $new_instance['show_only_email_and_button'] ) && $new_instance['show_only_email_and_button'];
[705] Fix | Delete
$instance['subscribe_text'] = wp_filter_post_kses( stripslashes( $instance['subscribe_text'] ) );
[706] Fix | Delete
[707] Fix | Delete
return $instance;
[708] Fix | Delete
}
[709] Fix | Delete
[710] Fix | Delete
/**
[711] Fix | Delete
* The default args for rendering a subscription form.
[712] Fix | Delete
*
[713] Fix | Delete
* @return array
[714] Fix | Delete
*/
[715] Fix | Delete
public static function defaults() {
[716] Fix | Delete
$defaults = array(
[717] Fix | Delete
'show_subscribers_total' => true,
[718] Fix | Delete
'show_only_email_and_button' => false,
[719] Fix | Delete
'include_social_followers' => true,
[720] Fix | Delete
);
[721] Fix | Delete
[722] Fix | Delete
$defaults['title'] = esc_html__( 'Subscribe to Blog via Email', 'jetpack' );
[723] Fix | Delete
$defaults['subscribe_text'] = esc_html__( 'Enter your email address to subscribe to this blog and receive notifications of new posts by email.', 'jetpack' );
[724] Fix | Delete
$defaults['subscribe_placeholder'] = esc_html__( 'Email Address', 'jetpack' );
[725] Fix | Delete
$defaults['subscribe_button'] = esc_html__( 'Subscribe', 'jetpack' );
[726] Fix | Delete
$defaults['success_message'] = esc_html__( "Success! An email was just sent to confirm your subscription. Please find the email now and click 'Confirm' to start subscribing.", 'jetpack' );
[727] Fix | Delete
[728] Fix | Delete
return $defaults;
[729] Fix | Delete
}
[730] Fix | Delete
[731] Fix | Delete
/**
[732] Fix | Delete
* Renders the widget's options form in wp-admin.
[733] Fix | Delete
*
[734] Fix | Delete
* @param array $instance Widget instance.
[735] Fix | Delete
* @return string|void
[736] Fix | Delete
*/
[737] Fix | Delete
public function form( $instance ) {
[738] Fix | Delete
$instance = wp_parse_args( (array) $instance, static::defaults() );
[739] Fix | Delete
$show_subscribers_total = checked( $instance['show_subscribers_total'], true, false );
[740] Fix | Delete
[741] Fix | Delete
if ( self::is_wpcom() ) {
[742] Fix | Delete
$title = ! empty( $instance['title'] ) ? esc_attr( stripslashes( $instance['title'] ) ) : '';
[743] Fix | Delete
$title_following = ! empty( $instance['title_following'] ) ? esc_attr( stripslashes( $instance['title_following'] ) ) : '';
[744] Fix | Delete
$subscribe_text = ! empty( $instance['subscribe_text'] ) ? esc_attr( stripslashes( $instance['subscribe_text'] ) ) : '';
[745] Fix | Delete
$subscribe_logged_in = ! empty( $instance['subscribe_logged_in'] ) ? esc_attr( stripslashes( $instance['subscribe_logged_in'] ) ) : '';
[746] Fix | Delete
$subscribe_button = ! empty( $instance['subscribe_button'] ) ? esc_attr( stripslashes( $instance['subscribe_button'] ) ) : '';
[747] Fix | Delete
$subscribers_total = self::fetch_subscriber_count();
[748] Fix | Delete
}
[749] Fix | Delete
[750] Fix | Delete
if ( self::is_jetpack() ) {
[751] Fix | Delete
$title = ! empty( $instance['title'] ) ? stripslashes( $instance['title'] ) : '';
[752] Fix | Delete
$subscribe_text = ! empty( $instance['subscribe_text'] ) ? stripslashes( $instance['subscribe_text'] ) : '';
[753] Fix | Delete
$subscribe_placeholder = ! empty( $instance['subscribe_placeholder'] ) ? stripslashes( $instance['subscribe_placeholder'] ) : '';
[754] Fix | Delete
$subscribe_button = ! empty( $instance['subscribe_button'] ) ? stripslashes( $instance['subscribe_button'] ) : '';
[755] Fix | Delete
$success_message = ! empty( $instance['success_message'] ) ? stripslashes( $instance['success_message'] ) : '';
[756] Fix | Delete
$subscribers_total = self::fetch_subscriber_count();
[757] Fix | Delete
}
[758] Fix | Delete
[759] Fix | Delete
if ( self::is_wpcom() ) :
[760] Fix | Delete
?>
[761] Fix | Delete
<p>
[762] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
[763] Fix | Delete
<?php esc_html_e( 'Widget title for non-followers:', 'jetpack' ); ?>
[764] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
[765] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
[766] Fix | Delete
value="<?php echo esc_attr( $title ); ?>"/>
[767] Fix | Delete
</label>
[768] Fix | Delete
</p>
[769] Fix | Delete
<p>
[770] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'title_following' ) ); ?>">
[771] Fix | Delete
<?php esc_html_e( 'Widget title for followers:', 'jetpack' ); ?>
[772] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title_following' ) ); ?>"
[773] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'title_following' ) ); ?>" type="text"
[774] Fix | Delete
value="<?php echo esc_attr( $title_following ); ?>"/>
[775] Fix | Delete
</label>
[776] Fix | Delete
</p>
[777] Fix | Delete
<p>
[778] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_logged_in' ) ); ?>">
[779] Fix | Delete
<?php esc_html_e( 'Optional text to display to logged in WordPress.com users:', 'jetpack' ); ?>
[780] Fix | Delete
<textarea style="width: 95%" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_logged_in' ) ); ?>"
[781] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'subscribe_logged_in' ) ); ?>"
[782] Fix | Delete
type="text"><?php echo esc_html( $subscribe_logged_in ); ?></textarea>
[783] Fix | Delete
</label>
[784] Fix | Delete
</p>
[785] Fix | Delete
<p>
[786] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>">
[787] Fix | Delete
<?php esc_html_e( 'Optional text to display to non-WordPress.com users:', 'jetpack' ); ?>
[788] Fix | Delete
<textarea style="width: 95%" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>"
[789] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'subscribe_text' ) ); ?>"
[790] Fix | Delete
type="text"><?php echo esc_html( $subscribe_text ); ?></textarea>
[791] Fix | Delete
</label>
[792] Fix | Delete
</p>
[793] Fix | Delete
<p>
[794] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>">
[795] Fix | Delete
<?php esc_html_e( 'Follow Button Text:', 'jetpack' ); ?>
[796] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>"
[797] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'subscribe_button' ) ); ?>" type="text"
[798] Fix | Delete
value="<?php echo esc_attr( $subscribe_button ); ?>"/>
[799] Fix | Delete
</label>
[800] Fix | Delete
</p>
[801] Fix | Delete
<p>
[802] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>">
[803] Fix | Delete
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>"
[804] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'show_subscribers_total' ) ); ?>"
[805] Fix | Delete
value="1"<?php echo esc_attr( $show_subscribers_total ); ?> />
[806] Fix | Delete
<?php
[807] Fix | Delete
/* translators: %s: Number of followers. */
[808] Fix | Delete
echo esc_html( sprintf( _n( 'Show total number of followers? (%s follower)', 'Show total number of followers? (%s followers)', $subscribers_total, 'jetpack' ), number_format_i18n( $subscribers_total ) ) );
[809] Fix | Delete
?>
[810] Fix | Delete
</label>
[811] Fix | Delete
</p>
[812] Fix | Delete
<?php
[813] Fix | Delete
endif;
[814] Fix | Delete
[815] Fix | Delete
if ( self::is_jetpack() ) :
[816] Fix | Delete
?>
[817] Fix | Delete
<p>
[818] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
[819] Fix | Delete
<?php esc_html_e( 'Widget title:', 'jetpack' ); ?>
[820] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"
[821] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text"
[822] Fix | Delete
value="<?php echo esc_attr( $title ); ?>"/>
[823] Fix | Delete
</label>
[824] Fix | Delete
</p>
[825] Fix | Delete
<p>
[826] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>">
[827] Fix | Delete
<?php esc_html_e( 'Optional text to display to your readers:', 'jetpack' ); ?>
[828] Fix | Delete
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_text' ) ); ?>"
[829] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'subscribe_text' ) ); ?>"
[830] Fix | Delete
rows="3"><?php echo esc_html( $subscribe_text ); ?></textarea>
[831] Fix | Delete
</label>
[832] Fix | Delete
</p>
[833] Fix | Delete
<p>
[834] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_placeholder' ) ); ?>">
[835] Fix | Delete
<?php esc_html_e( 'Subscribe Placeholder:', 'jetpack' ); ?>
[836] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_placeholder' ) ); ?>"
[837] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'subscribe_placeholder' ) ); ?>" type="text"
[838] Fix | Delete
value="<?php echo esc_attr( $subscribe_placeholder ); ?>"/>
[839] Fix | Delete
</label>
[840] Fix | Delete
</p>
[841] Fix | Delete
<p>
[842] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>">
[843] Fix | Delete
<?php esc_html_e( 'Subscribe Button:', 'jetpack' ); ?>
[844] Fix | Delete
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'subscribe_button' ) ); ?>"
[845] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'subscribe_button' ) ); ?>" type="text"
[846] Fix | Delete
value="<?php echo esc_attr( $subscribe_button ); ?>"/>
[847] Fix | Delete
</label>
[848] Fix | Delete
</p>
[849] Fix | Delete
<p>
[850] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'success_message' ) ); ?>">
[851] Fix | Delete
<?php esc_html_e( 'Success Message Text:', 'jetpack' ); ?>
[852] Fix | Delete
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'success_message' ) ); ?>"
[853] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'success_message' ) ); ?>"
[854] Fix | Delete
rows="5"><?php echo esc_html( $success_message ); ?></textarea>
[855] Fix | Delete
</label>
[856] Fix | Delete
</p>
[857] Fix | Delete
<p>
[858] Fix | Delete
<label for="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>">
[859] Fix | Delete
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_subscribers_total' ) ); ?>"
[860] Fix | Delete
name="<?php echo esc_attr( $this->get_field_name( 'show_subscribers_total' ) ); ?>"
[861] Fix | Delete
value="1"<?php echo esc_attr( $show_subscribers_total ); ?> />
[862] Fix | Delete
<?php
[863] Fix | Delete
/* translators: %s: Number of subscribers. */
[864] Fix | Delete
echo esc_html( sprintf( _n( 'Show total number of subscribers? (%s subscriber)', 'Show total number of subscribers? (%s subscribers)', $subscribers_total, 'jetpack' ), $subscribers_total ) );
[865] Fix | Delete
?>
[866] Fix | Delete
</label>
[867] Fix | Delete
</p>
[868] Fix | Delete
<?php
[869] Fix | Delete
endif;
[870] Fix | Delete
}
[871] Fix | Delete
}
[872] Fix | Delete
[873] Fix | Delete
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
[874] Fix | Delete
class_alias( 'Jetpack_Subscriptions_Widget', 'Blog_Subscription_Widget' );
[875] Fix | Delete
}
[876] Fix | Delete
[877] Fix | Delete
/**
[878] Fix | Delete
* Classname / shortcode tag to use for the Subscriptions widget.
[879] Fix | Delete
*
[880] Fix | Delete
* @return string
[881] Fix | Delete
*/
[882] Fix | Delete
function get_jetpack_blog_subscriptions_widget_classname() {
[883] Fix | Delete
return ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ?
[884] Fix | Delete
'Blog_Subscription_Widget' :
[885] Fix | Delete
'Jetpack_Subscriptions_Widget';
[886] Fix | Delete
}
[887] Fix | Delete
[888] Fix | Delete
/**
[889] Fix | Delete
* Subscriptions widget form HTML output.
[890] Fix | Delete
*
[891] Fix | Delete
* @param array $instance Widget instance data.
[892] Fix | Delete
*/
[893] Fix | Delete
function jetpack_do_subscription_form( $instance ) {
[894] Fix | Delete
if ( empty( $instance ) || ! is_array( $instance ) ) {
[895] Fix | Delete
$instance = array();
[896] Fix | Delete
}
[897] Fix | Delete
[898] Fix | Delete
if ( empty( $instance['show_subscribers_total'] ) || 'false' === $instance['show_subscribers_total'] ) {
[899] Fix | Delete
$instance['show_subscribers_total'] = false;
[900] Fix | Delete
} else {
[901] Fix | Delete
$instance['show_subscribers_total'] = true;
[902] Fix | Delete
}
[903] Fix | Delete
[904] Fix | Delete
// the default behavior is to include the social followers
[905] Fix | Delete
if ( empty( $instance['include_social_followers'] ) || 'true' === $instance['include_social_followers'] ) {
[906] Fix | Delete
$instance['include_social_followers'] = true;
[907] Fix | Delete
} else {
[908] Fix | Delete
$instance['include_social_followers'] = false;
[909] Fix | Delete
}
[910] Fix | Delete
[911] Fix | Delete
$show_only_email_and_button = isset( $instance['show_only_email_and_button'] ) ? $instance['show_only_email_and_button'] : false;
[912] Fix | Delete
$submit_button_text = isset( $instance['submit_button_text'] ) ? $instance['submit_button_text'] : '';
[913] Fix | Delete
[914] Fix | Delete
// Build up a string with the submit button's classes and styles and set it on the instance.
[915] Fix | Delete
$submit_button_classes = isset( $instance['submit_button_classes'] ) ? $instance['submit_button_classes'] : '';
[916] Fix | Delete
$email_field_classes = isset( $instance['email_field_classes'] ) ? $instance['email_field_classes'] : '';
[917] Fix | Delete
$style = '';
[918] Fix | Delete
$submit_button_styles = '';
[919] Fix | Delete
$submit_button_wrapper_styles = '';
[920] Fix | Delete
$email_field_styles = '';
[921] Fix | Delete
$success_message = '';
[922] Fix | Delete
[923] Fix | Delete
if ( isset( $instance['custom_background_button_color'] ) && 'undefined' !== $instance['custom_background_button_color'] ) {
[924] Fix | Delete
$submit_button_styles .= 'background: ' . $instance['custom_background_button_color'] . '; ';
[925] Fix | Delete
}
[926] Fix | Delete
if ( isset( $instance['custom_text_button_color'] ) && 'undefined' !== $instance['custom_text_button_color'] ) {
[927] Fix | Delete
$submit_button_styles .= 'color: ' . $instance['custom_text_button_color'] . '; ';
[928] Fix | Delete
}
[929] Fix | Delete
if ( isset( $instance['custom_button_width'] ) && 'undefined' !== $instance['custom_button_width'] ) {
[930] Fix | Delete
$submit_button_wrapper_styles .= 'width: ' . $instance['custom_button_width'] . '; ';
[931] Fix | Delete
$submit_button_wrapper_styles .= 'max-width: 100%; ';
[932] Fix | Delete
[933] Fix | Delete
// Account for custom margins on inline forms.
[934] Fix | Delete
if (
[935] Fix | Delete
! empty( $instance['custom_spacing'] ) &&
[936] Fix | Delete
! ( isset( $instance['button_on_newline'] ) && 'true' === $instance['button_on_newline'] )
[937] Fix | Delete
) {
[938] Fix | Delete
$submit_button_styles .= 'width: calc(100% - ' . $instance['custom_spacing'] . 'px); ';
[939] Fix | Delete
} else {
[940] Fix | Delete
$submit_button_styles .= 'width: 100%; ';
[941] Fix | Delete
}
[942] Fix | Delete
}
[943] Fix | Delete
[944] Fix | Delete
if ( isset( $instance['custom_font_size'] ) && 'undefined' !== $instance['custom_font_size'] ) {
[945] Fix | Delete
$style = 'font-size: ' . $instance['custom_font_size'];
[946] Fix | Delete
$style .= is_numeric( $instance['custom_font_size'] ) ? 'px; ' : '; '; // Handle deprecated numeric font size values.
[947] Fix | Delete
[948] Fix | Delete
$submit_button_styles .= $style;
[949] Fix | Delete
$email_field_styles .= $style;
[950] Fix | Delete
}
[951] Fix | Delete
if ( isset( $instance['custom_padding'] ) && 'undefined' !== $instance['custom_padding'] ) {
[952] Fix | Delete
$style = 'padding: ' .
[953] Fix | Delete
$instance['custom_padding'] . 'px ' .
[954] Fix | Delete
round( floatval( $instance['custom_padding'] ) * 1.5 ) . 'px ' .
[955] Fix | Delete
$instance['custom_padding'] . 'px ' .
[956] Fix | Delete
round( floatval( $instance['custom_padding'] ) * 1.5 ) . 'px; ';
[957] Fix | Delete
[958] Fix | Delete
$submit_button_styles .= $style;
[959] Fix | Delete
$email_field_styles .= $style;
[960] Fix | Delete
}
[961] Fix | Delete
[962] Fix | Delete
$button_spacing = 0;
[963] Fix | Delete
if ( ! empty( $instance['custom_spacing'] ) ) {
[964] Fix | Delete
$button_spacing = $instance['custom_spacing'];
[965] Fix | Delete
}
[966] Fix | Delete
if ( isset( $instance['button_on_newline'] ) && 'true' === $instance['button_on_newline'] ) {
[967] Fix | Delete
$submit_button_styles .= 'margin-top: ' . $button_spacing . 'px; ';
[968] Fix | Delete
} else {
[969] Fix | Delete
$submit_button_styles .= 'margin: 0; '; // Reset Safari's 2px default margin for buttons affecting input and button union
[970] Fix | Delete
$submit_button_styles .= 'margin-left: ' . $button_spacing . 'px; ';
[971] Fix | Delete
}
[972] Fix | Delete
[973] Fix | Delete
if ( isset( $instance['custom_border_radius'] ) && 'undefined' !== $instance['custom_border_radius'] ) {
[974] Fix | Delete
$style = 'border-radius: ' . $instance['custom_border_radius'] . 'px; ';
[975] Fix | Delete
$submit_button_styles .= $style;
[976] Fix | Delete
$email_field_styles .= $style;
[977] Fix | Delete
}
[978] Fix | Delete
if ( isset( $instance['custom_border_weight'] ) && 'undefined' !== $instance['custom_border_weight'] ) {
[979] Fix | Delete
$style = 'border-width: ' . $instance['custom_border_weight'] . 'px; ';
[980] Fix | Delete
$submit_button_styles .= $style;
[981] Fix | Delete
$email_field_styles .= $style;
[982] Fix | Delete
}
[983] Fix | Delete
if ( isset( $instance['custom_border_color'] ) && 'undefined' !== $instance['custom_border_color'] ) {
[984] Fix | Delete
$style =
[985] Fix | Delete
'border-color: ' . $instance['custom_border_color'] . '; ' .
[986] Fix | Delete
'border-style: solid;';
[987] Fix | Delete
[988] Fix | Delete
$submit_button_styles .= $style;
[989] Fix | Delete
$email_field_styles .= $style;
[990] Fix | Delete
}
[991] Fix | Delete
if ( isset( $instance['success_message'] ) && 'undefined' !== $instance['success_message'] ) {
[992] Fix | Delete
$success_message = wp_kses( stripslashes( $instance['success_message'] ), array() );
[993] Fix | Delete
}
[994] Fix | Delete
[995] Fix | Delete
$instance = shortcode_atts(
[996] Fix | Delete
Jetpack_Subscriptions_Widget::defaults(),
[997] Fix | Delete
$instance,
[998] Fix | Delete
'jetpack_subscription_form'
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function