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: inform a clear error for pending confirmations #14326

Merged
merged 5 commits into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 8 additions & 2 deletions modules/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ function get_settings() {
* not_subscribed : strange error. Jetpack servers at WordPress.com could subscribe the email.
* disabled : Site owner has disabled subscriptions.
* active : Already subscribed.
* pending : Tried to subscribe before but the confirmation link is never clicked. No confirmation email is sent.
* unknown : strange error. Jetpack servers at WordPress.com returned something malformed.
* unknown_status : strange error. Jetpack servers at WordPress.com returned something I didn't understand.
*/
Expand Down Expand Up @@ -587,9 +588,12 @@ function subscribe( $email, $post_ids = 0, $async = true, $extra_data = array()
case 'active' :
$r[] = new Jetpack_Error( 'active' );
continue 2;
case 'pending' :
case 'confirming' :
$r[] = true;
continue 2;
case 'pending' :
$r[] = new Jetpack_Error( 'pending' );
continue 2;
default :
$r[] = new Jetpack_Error( 'unknown_status', (string) $response[0]['status'] );
continue 2;
Expand Down Expand Up @@ -656,12 +660,14 @@ function widget_submit() {
$result = 'opted_out';
break;
case 'active':
case 'pending':
$result = 'already';
break;
case 'flooded_email':
$result = 'many_pending_subs';
break;
case 'pending':
$result = 'pending';
break;
default:
$result = 'error';
break;
Expand Down
17 changes: 17 additions & 0 deletions modules/subscriptions/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,23 @@ static function render_widget_status_messages( $instance ) {
?>
</p>
<?php break;
case 'pending':
?>
<p class="error">
<?php
printf(
wp_kses(
/* translators: 1: Link to Subscription Management page https://subscribe.wordpress.com/, 2: Description of this link */
__( 'You subscribed this site before but you have not clicked the confirmation link yet. Please check your mailbox. <br /> Otherwise, you can manage your preferences at <a href="%1$s" title="%2$s" target="_blank">subscribe.wordpress.com</a>.', 'jetpack' ),
htdat marked this conversation as resolved.
Show resolved Hide resolved
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