Skip to content

Commit

Permalink
Subscriptions: Add a clear message when an email having many pending …
Browse files Browse the repository at this point in the history
…confirmations tries to subscribe a site. (#14275)

Give a clear error message when email addresses are having many pending subscriptions
  • Loading branch information
htdat authored and kraftbj committed Jan 14, 2020
1 parent 1abb311 commit dd76244
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,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
),
'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

0 comments on commit dd76244

Please sign in to comment.