Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/modules/subscrip...
File: views.php
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
[0] Fix | Delete
[1] Fix | Delete
// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
[2] Fix | Delete
[3] Fix | Delete
use Automattic\Jetpack\Assets;
[4] Fix | Delete
[5] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[6] Fix | Delete
exit( 0 );
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Jetpack_Subscriptions_Widget main view class.
[11] Fix | Delete
*/
[12] Fix | Delete
class Jetpack_Subscriptions_Widget extends WP_Widget {
[13] Fix | Delete
[14] Fix | Delete
const ID_BASE = 'blog_subscription';
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Track number of rendered Subscription widgets. The count is used for class names and widget IDs.
[18] Fix | Delete
*
[19] Fix | Delete
* @var int
[20] Fix | Delete
*/
[21] Fix | Delete
public static $instance_count = 0;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* When printing the submit button, what tags are allowed.
[25] Fix | Delete
*
[26] Fix | Delete
* @var array
[27] Fix | Delete
*/
[28] Fix | Delete
public static $allowed_html_tags_for_submit_button = array(
[29] Fix | Delete
'br' => array(),
[30] Fix | Delete
's' => array(),
[31] Fix | Delete
'strong' => array(),
[32] Fix | Delete
'em' => array(),
[33] Fix | Delete
);
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Use this variable when printing the message after submitting an email in subscription widgets
[37] Fix | Delete
*
[38] Fix | Delete
* @var array what tags are allowed
[39] Fix | Delete
*/
[40] Fix | Delete
public static $allowed_html_tags_for_message = array(
[41] Fix | Delete
'a' => array(
[42] Fix | Delete
'href' => array(),
[43] Fix | Delete
'title' => array(),
[44] Fix | Delete
'rel' => array(),
[45] Fix | Delete
'target' => array(),
[46] Fix | Delete
),
[47] Fix | Delete
'br' => array(),
[48] Fix | Delete
);
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Jetpack_Subscriptions_Widget constructor.
[52] Fix | Delete
*/
[53] Fix | Delete
public function __construct() {
[54] Fix | Delete
$widget_ops = array(
[55] Fix | Delete
'classname' => 'widget_blog_subscription jetpack_subscription_widget',
[56] Fix | Delete
'description' => __( 'Add an email signup form to allow people to subscribe to your blog.', 'jetpack' ),
[57] Fix | Delete
'customize_selective_refresh' => true,
[58] Fix | Delete
'show_instance_in_rest' => true,
[59] Fix | Delete
);
[60] Fix | Delete
[61] Fix | Delete
$name = self::is_jetpack() ?
[62] Fix | Delete
/** This filter is documented in modules/widgets/facebook-likebox.php */
[63] Fix | Delete
apply_filters( 'jetpack_widget_name', __( 'Blog Subscriptions', 'jetpack' ) ) :
[64] Fix | Delete
__( 'Follow Blog', 'jetpack' );
[65] Fix | Delete
[66] Fix | Delete
parent::__construct(
[67] Fix | Delete
'blog_subscription',
[68] Fix | Delete
$name,
[69] Fix | Delete
$widget_ops
[70] Fix | Delete
);
[71] Fix | Delete
[72] Fix | Delete
if (
[73] Fix | Delete
self::is_jetpack()
[74] Fix | Delete
&& (
[75] Fix | Delete
is_active_widget( false, false, $this->id_base ) ||
[76] Fix | Delete
is_active_widget( false, false, 'monster' ) ||
[77] Fix | Delete
is_customize_preview()
[78] Fix | Delete
)
[79] Fix | Delete
&& ! wp_is_block_theme()
[80] Fix | Delete
) {
[81] Fix | Delete
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) );
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
add_filter( 'widget_types_to_hide_from_legacy_widget_block', array( $this, 'hide_widget_in_block_editor' ) );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Remove the "Blog Subscription" widget from the Legacy Widget block
[89] Fix | Delete
*
[90] Fix | Delete
* @param array $widget_types List of widgets that are currently removed from the Legacy Widget block.
[91] Fix | Delete
* @return array $widget_types New list of widgets that will be removed.
[92] Fix | Delete
*/
[93] Fix | Delete
public function hide_widget_in_block_editor( $widget_types ) {
[94] Fix | Delete
$widget_types[] = self::ID_BASE;
[95] Fix | Delete
return $widget_types;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Enqueue the form's CSS.
[100] Fix | Delete
*
[101] Fix | Delete
* @since 4.5.0
[102] Fix | Delete
*/
[103] Fix | Delete
public function enqueue_style() {
[104] Fix | Delete
$path = Assets::get_file_url_for_environment(
[105] Fix | Delete
'_inc/build/subscriptions/subscriptions.min.css',
[106] Fix | Delete
'modules/subscriptions/subscriptions.css'
[107] Fix | Delete
);
[108] Fix | Delete
[109] Fix | Delete
wp_enqueue_style(
[110] Fix | Delete
'jetpack-subscriptions',
[111] Fix | Delete
$path,
[112] Fix | Delete
array(),
[113] Fix | Delete
JETPACK__VERSION
[114] Fix | Delete
);
[115] Fix | Delete
wp_style_add_data( 'jetpack-subscriptions', 'path', $path );
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Renders a full widget either within the context of WordPress widget, or in response to a shortcode.
[120] Fix | Delete
*
[121] Fix | Delete
* @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
[122] Fix | Delete
* @param array $instance The settings for the particular instance of the widget.
[123] Fix | Delete
*/
[124] Fix | Delete
public function widget( $args, $instance ) {
[125] Fix | Delete
if ( self::is_wpcom() && ! self::wpcom_has_status_message() && self::is_current_user_subscribed() ) {
[126] Fix | Delete
return null;
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
// Enqueue styles.
[130] Fix | Delete
self::enqueue_style();
[131] Fix | Delete
[132] Fix | Delete
if ( self::is_jetpack() &&
[133] Fix | Delete
/** This filter is documented in \Automattic\Jetpack\Forms\ContactForm\Contact_Form */
[134] Fix | Delete
false === apply_filters( 'jetpack_auto_fill_logged_in_user', false )
[135] Fix | Delete
) {
[136] Fix | Delete
$subscribe_email = '';
[137] Fix | Delete
} else {
[138] Fix | Delete
$current_user = wp_get_current_user();
[139] Fix | Delete
if ( ! empty( $current_user->user_email ) ) {
[140] Fix | Delete
$subscribe_email = esc_attr( $current_user->user_email );
[141] Fix | Delete
} else {
[142] Fix | Delete
$subscribe_email = '';
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
$stats_action = self::is_jetpack() ? 'jetpack_subscriptions' : 'follow_blog';
[147] Fix | Delete
/** This action is documented in modules/widgets/gravatar-profile.php */
[148] Fix | Delete
do_action( 'jetpack_stats_extra', 'widget_view', $stats_action );
[149] Fix | Delete
[150] Fix | Delete
$after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : '';
[151] Fix | Delete
$before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : '';
[152] Fix | Delete
$instance = wp_parse_args( (array) $instance, static::defaults() );
[153] Fix | Delete
[154] Fix | Delete
echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[155] Fix | Delete
[156] Fix | Delete
++self::$instance_count;
[157] Fix | Delete
[158] Fix | Delete
self::render_widget_title( $args, $instance );
[159] Fix | Delete
[160] Fix | Delete
self::render_widget_status_messages( $instance );
[161] Fix | Delete
[162] Fix | Delete
self::render_widget_subscription_form( $args, $instance, $subscribe_email );
[163] Fix | Delete
[164] Fix | Delete
echo "\n" . $after_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
/**
[168] Fix | Delete
* Prints the widget's title. If show_only_email_and_button is true, we will not show a title.
[169] Fix | Delete
*
[170] Fix | Delete
* @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
[171] Fix | Delete
* @param array $instance The settings for the particular instance of the widget.
[172] Fix | Delete
*/
[173] Fix | Delete
public static function render_widget_title( $args, $instance ) {
[174] Fix | Delete
$show_only_email_and_button = $instance['show_only_email_and_button'];
[175] Fix | Delete
$before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
[176] Fix | Delete
$after_title = isset( $args['after_title'] ) ? $args['after_title'] : '';
[177] Fix | Delete
if ( self::is_wpcom() && ! $show_only_email_and_button ) {
[178] Fix | Delete
if ( self::is_current_user_subscribed() ) {
[179] Fix | Delete
if ( ! empty( $instance['title_following'] ) ) {
[180] Fix | Delete
printf(
[181] Fix | Delete
'%1$s<label for="subscribe-field%2$s">%3$s</label>%4$s%5$s',
[182] Fix | Delete
$before_title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[183] Fix | Delete
( self::$instance_count > 1 ? '-' . (int) self::$instance_count : '' ),
[184] Fix | Delete
esc_html( $instance['title_following'] ),
[185] Fix | Delete
$after_title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[186] Fix | Delete
"\n"
[187] Fix | Delete
);
[188] Fix | Delete
}
[189] Fix | Delete
} elseif ( ! empty( $instance['title'] ) ) {
[190] Fix | Delete
printf(
[191] Fix | Delete
'%1$s<label for="subscribe-field%2$s">%3$s</label>%4$s%5$s',
[192] Fix | Delete
$before_title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[193] Fix | Delete
( self::$instance_count > 1 ? '-' . (int) self::$instance_count : '' ),
[194] Fix | Delete
esc_html( $instance['title'] ),
[195] Fix | Delete
$after_title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[196] Fix | Delete
"\n"
[197] Fix | Delete
);
[198] Fix | Delete
}
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
if ( self::is_jetpack() && empty( $instance['show_only_email_and_button'] ) ) {
[202] Fix | Delete
printf(
[203] Fix | Delete
'%1$s%2$s%3$s%4$s',
[204] Fix | Delete
$before_title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[205] Fix | Delete
esc_html( $instance['title'] ),
[206] Fix | Delete
$after_title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[207] Fix | Delete
"\n"
[208] Fix | Delete
);
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Prints the subscription block's status messages after someone has attempted to subscribe.
[214] Fix | Delete
* Either a success message or an error message.
[215] Fix | Delete
*
[216] Fix | Delete
* @param array $instance The settings for the particular instance of the widget.
[217] Fix | Delete
*/
[218] Fix | Delete
public static function render_widget_status_messages( $instance ) {
[219] Fix | Delete
if ( self::is_jetpack() && isset( $_GET['subscribe'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Non-sensitive informational output.
[220] Fix | Delete
$success_message = isset( $instance['success_message'] ) ? stripslashes( $instance['success_message'] ) : '';
[221] Fix | Delete
$subscribers_total = self::fetch_subscriber_count();
[222] Fix | Delete
[223] Fix | Delete
switch ( $_GET['subscribe'] ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended
[224] Fix | Delete
case 'invalid_email':
[225] Fix | Delete
?>
[226] Fix | Delete
<p class="error"><?php esc_html_e( 'Oops! The email you used is invalid. Please try again.', 'jetpack' ); ?></p>
[227] Fix | Delete
<?php
[228] Fix | Delete
break;
[229] Fix | Delete
case 'opted_out':
[230] Fix | Delete
?>
[231] Fix | Delete
<p class="error">
[232] Fix | Delete
<?php
[233] Fix | Delete
printf(
[234] Fix | Delete
wp_kses(
[235] Fix | Delete
/* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link. */
[236] Fix | Delete
__( 'Oops! It seems that the email you used has opted out of subscriptions. You can manage your preferences from the <a href="%1$s" title="%2$s" target="_blank">Subscriptions Manager</a>', 'jetpack' ),
[237] Fix | Delete
self::$allowed_html_tags_for_message
[238] Fix | Delete
),
[239] Fix | Delete
'https://subscribe.wordpress.com/',
[240] Fix | Delete
esc_attr__( 'Subscriptions Manager', 'jetpack' )
[241] Fix | Delete
);
[242] Fix | Delete
?>
[243] Fix | Delete
</p>
[244] Fix | Delete
<?php
[245] Fix | Delete
break;
[246] Fix | Delete
case 'already':
[247] Fix | Delete
?>
[248] Fix | Delete
<p class="error">
[249] Fix | Delete
<?php
[250] Fix | Delete
printf(
[251] Fix | Delete
wp_kses(
[252] Fix | Delete
/* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link. */
[253] Fix | Delete
__( 'You have already subscribed to this site. Please check your email inbox. You can manage your preferences from the <a href="%1$s" title="%2$s" target="_blank">Subscriptions Manager</a>.', 'jetpack' ),
[254] Fix | Delete
self::$allowed_html_tags_for_message
[255] Fix | Delete
),
[256] Fix | Delete
'https://subscribe.wordpress.com/',
[257] Fix | Delete
esc_attr__( 'Subscriptions Manager', 'jetpack' )
[258] Fix | Delete
);
[259] Fix | Delete
?>
[260] Fix | Delete
</p>
[261] Fix | Delete
<?php
[262] Fix | Delete
break;
[263] Fix | Delete
case 'many_pending_subs':
[264] Fix | Delete
?>
[265] Fix | Delete
<p class="error">
[266] Fix | Delete
<?php
[267] Fix | Delete
printf(
[268] Fix | Delete
wp_kses(
[269] Fix | Delete
/* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link */
[270] Fix | Delete
__( 'Oops! It seems you have several subscriptions pending confirmation. You can confirm or unsubscribe some from the <a href="%1$s" title="%2$s" target="_blank" rel="noopener noreferrer">Subscriptions Manager</a> before adding more.', 'jetpack' ),
[271] Fix | Delete
self::$allowed_html_tags_for_message
[272] Fix | Delete
),
[273] Fix | Delete
'https://subscribe.wordpress.com/',
[274] Fix | Delete
esc_attr__( 'Subscriptions Manager', 'jetpack' )
[275] Fix | Delete
);
[276] Fix | Delete
?>
[277] Fix | Delete
</p>
[278] Fix | Delete
<?php
[279] Fix | Delete
break;
[280] Fix | Delete
case 'pending':
[281] Fix | Delete
?>
[282] Fix | Delete
<p class="error">
[283] Fix | Delete
<?php
[284] Fix | Delete
printf(
[285] Fix | Delete
wp_kses(
[286] Fix | Delete
/* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link */
[287] Fix | Delete
__( 'It seems you already tried to subscribe with this email, but have not confirmed from the email link we sent. Please check your email inbox to confirm or you can manage your preferences from the <a href="%1$s" title="%2$s" target="_blank" rel="noopener noreferrer">Subscriptions Manager</a>.', 'jetpack' ),
[288] Fix | Delete
self::$allowed_html_tags_for_message
[289] Fix | Delete
),
[290] Fix | Delete
'https://subscribe.wordpress.com/',
[291] Fix | Delete
esc_attr__( 'Subscriptions Manager', 'jetpack' )
[292] Fix | Delete
);
[293] Fix | Delete
?>
[294] Fix | Delete
</p>
[295] Fix | Delete
<?php
[296] Fix | Delete
break;
[297] Fix | Delete
case 'success':
[298] Fix | Delete
?>
[299] Fix | Delete
<div class="success"><?php echo wp_kses( wpautop( str_replace( '[total-subscribers]', number_format_i18n( $subscribers_total ), $success_message ) ), 'post' ); ?></div>
[300] Fix | Delete
<?php
[301] Fix | Delete
break;
[302] Fix | Delete
default:
[303] Fix | Delete
?>
[304] Fix | Delete
<p class="error"><?php esc_html_e( 'Oops! There was an error when subscribing. Please try again.', 'jetpack' ); ?></p>
[305] Fix | Delete
<?php
[306] Fix | Delete
break;
[307] Fix | Delete
endswitch;
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
if ( self::is_wpcom() && self::wpcom_has_status_message() ) {
[311] Fix | Delete
global $themecolors;
[312] Fix | Delete
$message = '';
[313] Fix | Delete
[314] Fix | Delete
switch ( $_GET['blogsub'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
[315] Fix | Delete
case 'confirming':
[316] Fix | Delete
$message = __( 'Thank you! You can now check your email to confirm your subscription.', 'jetpack' );
[317] Fix | Delete
break;
[318] Fix | Delete
case 'blocked':
[319] Fix | Delete
$message = __( 'Sorry but this email has been blocked for this subscription. <a href="https://en.support.wordpress.com/contact/">Contact us</a> if needed.', 'jetpack' );
[320] Fix | Delete
break;
[321] Fix | Delete
case 'flooded':
[322] Fix | Delete
$message = __( 'Oops! It seems you have several subscriptions pending confirmation. You can confirm or unsubscribe some from the <a href="https://subscribe.wordpress.com/">Subscriptions Manager</a> before adding more.', 'jetpack' );
[323] Fix | Delete
break;
[324] Fix | Delete
case 'spammed':
[325] Fix | Delete
/* translators: %s is a URL */
[326] Fix | Delete
$message = sprintf( __( 'Sorry but this email has been blocked. It has too many subscriptions pending confirmation. Please confirm or unsubscribe some from the <a href="%s">Subscriptions Manager</a>.', 'jetpack' ), 'https://subscribe.wordpress.com/' );
[327] Fix | Delete
break;
[328] Fix | Delete
case 'subscribed':
[329] Fix | Delete
$message = __( 'Hey! You were already subscribed.', 'jetpack' );
[330] Fix | Delete
break;
[331] Fix | Delete
case 'pending':
[332] Fix | Delete
$message = __( 'It seems you already tried to subscribe. We just sent you another email so you can confirm the subscription.', 'jetpack' );
[333] Fix | Delete
break;
[334] Fix | Delete
case 'confirmed':
[335] Fix | Delete
$message = __( 'Cool! You are now subscribed. Now you can check your email for more details and how to manage the subscription.', 'jetpack' );
[336] Fix | Delete
break;
[337] Fix | Delete
}
[338] Fix | Delete
[339] Fix | Delete
$border_color = isset( $themecolors['border'] ) ? " #{$themecolors['border']}" : '';
[340] Fix | Delete
[341] Fix | Delete
$redirect_fragment = self::get_redirect_fragment();
[342] Fix | Delete
printf(
[343] Fix | Delete
'<div id="%1$s" class="jetpack-sub-notification">%3$s</div>',
[344] Fix | Delete
esc_attr( $redirect_fragment ),
[345] Fix | Delete
esc_attr( $border_color ),
[346] Fix | Delete
wp_kses_post( $message )
[347] Fix | Delete
);
[348] Fix | Delete
}
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
/**
[352] Fix | Delete
* Generates the redirect fragment used after form submission.
[353] Fix | Delete
*
[354] Fix | Delete
* @param string $id is the specific id that will appear in the redirect fragment. If none is provided self::$instance_count will be used.
[355] Fix | Delete
*/
[356] Fix | Delete
protected static function get_redirect_fragment( $id = null ) {
[357] Fix | Delete
if ( $id === null ) {
[358] Fix | Delete
return 'subscribe-blog' . ( self::$instance_count > 1 ? '-' . self::$instance_count : '' );
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
return 'subscribe-blog-' . $id;
[362] Fix | Delete
}
[363] Fix | Delete
[364] Fix | Delete
/**
[365] Fix | Delete
* Renders a form allowing folks to subscribe to the blog.
[366] Fix | Delete
*
[367] Fix | Delete
* @param array $args Display arguments including 'before_title', 'after_title', 'before_widget', and 'after_widget'.
[368] Fix | Delete
* @param array $instance The settings for the particular instance of the widget.
[369] Fix | Delete
* @param string $subscribe_email The email to use to prefill the form.
[370] Fix | Delete
*/
[371] Fix | Delete
public static function render_widget_subscription_form( $args, $instance, $subscribe_email ) {
[372] Fix | Delete
$show_only_email_and_button = $instance['show_only_email_and_button'];
[373] Fix | Delete
$show_subscribers_total = (bool) $instance['show_subscribers_total'];
[374] Fix | Delete
$subscribers_total = self::fetch_subscriber_count();
[375] Fix | Delete
$subscribe_text = empty( $instance['show_only_email_and_button'] ) ?
[376] Fix | Delete
wp_kses_post( stripslashes( $instance['subscribe_text'] ) ) :
[377] Fix | Delete
false;
[378] Fix | Delete
$referer = esc_url_raw( ( is_ssl() ? 'https' : 'http' ) . '://' . ( isset( $_SERVER['HTTP_HOST'] ) ? wp_unslash( $_SERVER['HTTP_HOST'] ) : '' ) . ( isset( $_SERVER['REQUEST_URI'] ) ? wp_unslash( $_SERVER['REQUEST_URI'] ) : '' ) );
[379] Fix | Delete
$source = 'widget';
[380] Fix | Delete
$widget_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : self::$instance_count;
[381] Fix | Delete
$subscribe_button = ! empty( $instance['submit_button_text'] ) ? $instance['submit_button_text'] : $instance['subscribe_button'];
[382] Fix | Delete
$subscribe_placeholder = isset( $instance['subscribe_placeholder'] ) ? stripslashes( $instance['subscribe_placeholder'] ) : '';
[383] Fix | Delete
$submit_button_classes = isset( $instance['submit_button_classes'] ) ? 'wp-block-button__link ' . $instance['submit_button_classes'] : 'wp-block-button__link';
[384] Fix | Delete
$submit_button_styles = isset( $instance['submit_button_styles'] ) ? $instance['submit_button_styles'] : '';
[385] Fix | Delete
$submit_button_wrapper_styles = isset( $instance['submit_button_wrapper_styles'] ) ? $instance['submit_button_wrapper_styles'] : '';
[386] Fix | Delete
$email_field_classes = isset( $instance['email_field_classes'] ) ? $instance['email_field_classes'] : '';
[387] Fix | Delete
$email_field_styles = isset( $instance['email_field_styles'] ) ? $instance['email_field_styles'] : '';
[388] Fix | Delete
[389] Fix | Delete
// We need to include those in case Jetpack blocks are disabled
[390] Fix | Delete
require_once JETPACK__PLUGIN_DIR . 'modules/memberships/class-jetpack-memberships.php';
[391] Fix | Delete
require_once JETPACK__PLUGIN_DIR . 'extensions/blocks/premium-content/_inc/subscription-service/include.php';
[392] Fix | Delete
$post_access_level = \Jetpack_Memberships::get_post_access_level();
[393] Fix | Delete
[394] Fix | Delete
if ( self::is_wpcom() && ! self::wpcom_has_status_message() ) {
[395] Fix | Delete
global $current_blog;
[396] Fix | Delete
[397] Fix | Delete
$url = defined( 'SUBSCRIBE_BLOG_URL' ) ? SUBSCRIBE_BLOG_URL : '';
[398] Fix | Delete
$form_id = self::get_redirect_fragment();
[399] Fix | Delete
?>
[400] Fix | Delete
[401] Fix | Delete
<div class="wp-block-jetpack-subscriptions__container">
[402] Fix | Delete
<form
[403] Fix | Delete
action="<?php echo esc_url( $url ); ?>"
[404] Fix | Delete
method="post"
[405] Fix | Delete
accept-charset="utf-8"
[406] Fix | Delete
data-blog="<?php echo esc_attr( get_current_blog_id() ); ?>"
[407] Fix | Delete
data-post_access_level="<?php echo esc_attr( $post_access_level ); ?>"
[408] Fix | Delete
id="<?php echo esc_attr( $form_id ); ?>"
[409] Fix | Delete
>
[410] Fix | Delete
<?php
[411] Fix | Delete
if ( ! $show_only_email_and_button ) {
[412] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
[413] Fix | Delete
echo wpautop( $subscribe_text );
[414] Fix | Delete
}
[415] Fix | Delete
$email_field_id = 'subscribe-field';
[416] Fix | Delete
$email_field_id .= self::$instance_count > 1
[417] Fix | Delete
? '-' . self::$instance_count
[418] Fix | Delete
: '';
[419] Fix | Delete
$label_field_id = $email_field_id . '-label';
[420] Fix | Delete
?>
[421] Fix | Delete
<p id="subscribe-email">
[422] Fix | Delete
<label
[423] Fix | Delete
id="<?php echo esc_attr( $label_field_id ); ?>"
[424] Fix | Delete
for="<?php echo esc_attr( $email_field_id ); ?>"
[425] Fix | Delete
class="screen-reader-text"
[426] Fix | Delete
>
[427] Fix | Delete
<?php echo esc_html__( 'Email Address:', 'jetpack' ); ?>
[428] Fix | Delete
</label>
[429] Fix | Delete
[430] Fix | Delete
<?php
[431] Fix | Delete
printf(
[432] Fix | Delete
'<input
[433] Fix | Delete
type="email"
[434] Fix | Delete
name="email"
[435] Fix | Delete
%1$s
[436] Fix | Delete
style="%2$s"
[437] Fix | Delete
placeholder="%3$s"
[438] Fix | Delete
value=""
[439] Fix | Delete
id="%4$s"
[440] Fix | Delete
required
[441] Fix | Delete
/>',
[442] Fix | Delete
( ! empty( $email_field_classes )
[443] Fix | Delete
? 'class="' . esc_attr( $email_field_classes ) . '"'
[444] Fix | Delete
: ''
[445] Fix | Delete
),
[446] Fix | Delete
( ! empty( $email_field_styles )
[447] Fix | Delete
? esc_attr( $email_field_styles )
[448] Fix | Delete
: 'width: 95%; padding: 1px 10px'
[449] Fix | Delete
),
[450] Fix | Delete
( empty( $subscribe_placeholder ) ? esc_attr__( 'Enter your email address', 'jetpack' ) : esc_attr( $subscribe_placeholder ) ),
[451] Fix | Delete
esc_attr( $email_field_id )
[452] Fix | Delete
);
[453] Fix | Delete
?>
[454] Fix | Delete
</p>
[455] Fix | Delete
[456] Fix | Delete
<p id="subscribe-submit"
[457] Fix | Delete
<?php if ( ! empty( $submit_button_wrapper_styles ) ) { ?>
[458] Fix | Delete
style="<?php echo esc_attr( $submit_button_wrapper_styles ); ?>"
[459] Fix | Delete
<?php } ?>
[460] Fix | Delete
>
[461] Fix | Delete
<input type="hidden" name="action" value="subscribe"/>
[462] Fix | Delete
<input type="hidden" name="blog_id" value="<?php echo (int) $current_blog->blog_id; ?>"/>
[463] Fix | Delete
<input type="hidden" name="source" value="<?php echo esc_url( $referer ); ?>"/>
[464] Fix | Delete
<input type="hidden" name="sub-type" value="<?php echo esc_attr( $source ); ?>"/>
[465] Fix | Delete
<input type="hidden" name="redirect_fragment" value="<?php echo esc_attr( $form_id ); ?>"/>
[466] Fix | Delete
<?php wp_nonce_field( 'blogsub_subscribe_' . $current_blog->blog_id, '_wpnonce', false ); ?>
[467] Fix | Delete
<button type="submit"
[468] Fix | Delete
<?php if ( ! empty( $submit_button_classes ) ) { ?>
[469] Fix | Delete
class="<?php echo esc_attr( $submit_button_classes ); ?>"
[470] Fix | Delete
<?php } ?>
[471] Fix | Delete
<?php if ( ! empty( $submit_button_styles ) ) { ?>
[472] Fix | Delete
style="<?php echo esc_attr( $submit_button_styles ); ?>"
[473] Fix | Delete
<?php } ?>
[474] Fix | Delete
>
[475] Fix | Delete
<?php
[476] Fix | Delete
echo wp_kses(
[477] Fix | Delete
html_entity_decode( $subscribe_button, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ),
[478] Fix | Delete
self::$allowed_html_tags_for_submit_button
[479] Fix | Delete
);
[480] Fix | Delete
?>
[481] Fix | Delete
</button>
[482] Fix | Delete
</p>
[483] Fix | Delete
</form>
[484] Fix | Delete
<?php if ( $show_subscribers_total && $subscribers_total > 0 ) { ?>
[485] Fix | Delete
<div class="wp-block-jetpack-subscriptions__subscount">
[486] Fix | Delete
<?php
[487] Fix | Delete
echo esc_html( Jetpack_Memberships::get_join_others_text( $subscribers_total ) );
[488] Fix | Delete
?>
[489] Fix | Delete
</div>
[490] Fix | Delete
<?php } ?>
[491] Fix | Delete
</div>
[492] Fix | Delete
<?php
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
if ( self::is_jetpack() ) {
[496] Fix | Delete
/**
[497] Fix | Delete
* Filter the subscription form's ID prefix.
[498] Fix | Delete
*
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function