Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions: Add a clear message when an email having many pending confirmations tries to subscribe a site. #14275

Merged
merged 4 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,9 @@ function widget_submit() {
case 'pending':
$result = 'already';
break;
case 'flooded_email':
$result = 'many_pending_subs';
break;
default:
$result = 'error';
break;
Expand Down
30 changes: 30 additions & 0 deletions modules/subscriptions/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ class Jetpack_Subscriptions_Widget extends WP_Widget {
* @var array When printing the submit button, what tags are allowed
*/
static $allowed_html_tags_for_submit_button = array( 'br' => array() );
/**
* Use this variable when printing the message after submitting an email in subscription widgets
*
* @var array what tags are allowed
*/
public static $allowed_html_tags_for_message = array(
'a' => array(
'href' => array(),
'title' => array(),
'rel' => array(),
'target' => array(),
),
'br' => array(),
);

function __construct() {
$widget_ops = array(
Expand Down Expand Up @@ -150,6 +164,22 @@ static function render_widget_status_messages( $instance ) {
__( 'Manage your email preferences.', 'jetpack' )
); ?></p>
<?php break;
case 'many_pending_subs':
?>
<p class="error">
<?php
printf(
wp_kses(
/* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link */
__( 'You already have several pending email subscriptions. <br /> Approve or delete a few subscriptions at <a href="%1$s" title="%2$s" target="_blank" rel="noopener noreferrer">subscribe.wordpress.com</a> before continuing.', 'jetpack' ),
self::$allowed_html_tags_for_message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nice way to keep things tidy and makes it easily reusable in the future. Cool.

),
'https://subscribe.wordpress.com/',
esc_attr__( 'Manage your email preferences.', 'jetpack' )
);
?>
</p>
<?php break;
case 'success' : ?>
<div class="success"><?php echo wpautop( str_replace( '[total-subscribers]', number_format_i18n( $subscribers_total['value'] ), $success_message ) ); ?></div>
<?php break;
Expand Down