Users: Introduce `admin_email_remind_interval` filter for dismissing the admin email confirmation screen.

Props desrosj, birgire.
Merges [46838], [46837] to the 5.3 branch.
Fixes #48334.
Built from https://develop.svn.wordpress.org/branches/5.3@46839


git-svn-id: http://core.svn.wordpress.org/branches/5.3@46639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-12-09 13:30:03 +00:00
parent 176a6206a3
commit 97b8443321
2 changed files with 43 additions and 27 deletions

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.3.1-alpha-46836'; $wp_version = '5.3.1-alpha-46839';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -569,14 +569,26 @@ switch ( $action ) {
exit; exit;
} }
/**
* Filters the interval for dismissing the admin email confirmation screen.
*
* If `0` (zero) is returned, the "Remind me later" link will not be displayed.
*
* @since 5.3.1
*
* @param int $interval Interval time (in seconds). Default is 3 days.
*/
$remind_interval = (int) apply_filters( 'admin_email_remind_interval', 3 * DAY_IN_SECONDS );
if ( ! empty( $_GET['remind_me_later'] ) ) { if ( ! empty( $_GET['remind_me_later'] ) ) {
if ( ! wp_verify_nonce( $_GET['remind_me_later'], 'remind_me_later_nonce' ) ) { if ( ! wp_verify_nonce( $_GET['remind_me_later'], 'remind_me_later_nonce' ) ) {
wp_safe_redirect( wp_login_url() ); wp_safe_redirect( wp_login_url() );
exit; exit;
} }
// "Remind me later" is a bit ambiguous. Three days later? if ( $remind_interval > 0 ) {
update_option( 'admin_email_lifespan', time() + 3 * DAY_IN_SECONDS ); update_option( 'admin_email_lifespan', time() + $remind_interval );
}
wp_safe_redirect( $redirect_to ); wp_safe_redirect( $redirect_to );
exit; exit;
@ -590,11 +602,12 @@ switch ( $action ) {
/** /**
* Filters the interval for redirecting the user to the admin email confirmation screen. * Filters the interval for redirecting the user to the admin email confirmation screen.
*
* If `0` (zero) is returned, the user will not be redirected. * If `0` (zero) is returned, the user will not be redirected.
* *
* @since 5.3.0 * @since 5.3.0
* *
* @param int Interval time (in seconds). * @param int $interval Interval time (in seconds). Default is 6 months.
*/ */
$admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS ); $admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS );
@ -609,12 +622,13 @@ switch ( $action ) {
login_header( __( 'Confirm your administration email' ), '', $errors ); login_header( __( 'Confirm your administration email' ), '', $errors );
/** /**
* Fires before the admin email confirm form. * Fires before the admin email confirm form.
* *
* @since 5.3.0 * @since 5.3.0
* *
* @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid credentials. Note that the error object may not contain any errors. * @param WP_Error $errors A `WP_Error` object containing any errors generated by using invalid
*/ * credentials. Note that the error object may not contain any errors.
*/
do_action( 'admin_email_confirm', $errors ); do_action( 'admin_email_confirm', $errors );
?> ?>
@ -622,10 +636,10 @@ switch ( $action ) {
<form class="admin-email-confirm-form" name="admin-email-confirm-form" action="<?php echo esc_url( site_url( 'wp-login.php?action=confirm_admin_email', 'login_post' ) ); ?>" method="post"> <form class="admin-email-confirm-form" name="admin-email-confirm-form" action="<?php echo esc_url( site_url( 'wp-login.php?action=confirm_admin_email', 'login_post' ) ); ?>" method="post">
<?php <?php
/** /**
* Fires inside the admin-email-confirm-form form tags, before the hidden fields. * Fires inside the admin-email-confirm-form form tags, before the hidden fields.
* *
* @since 5.3.0 * @since 5.3.0
*/ */
do_action( 'admin_email_confirm_form' ); do_action( 'admin_email_confirm_form' );
wp_nonce_field( 'confirm_admin_email', 'confirm_admin_email_nonce' ); wp_nonce_field( 'confirm_admin_email', 'confirm_admin_email_nonce' );
@ -681,21 +695,23 @@ switch ( $action ) {
<a class="button button-large" href="<?php echo esc_url( $change_link ); ?>"><?php _e( 'Update' ); ?></a> <a class="button button-large" href="<?php echo esc_url( $change_link ); ?>"><?php _e( 'Update' ); ?></a>
<input type="submit" name="correct-admin-email" id="correct-admin-email" class="button button-primary button-large" value="<?php esc_attr_e( 'The email is correct' ); ?>" /> <input type="submit" name="correct-admin-email" id="correct-admin-email" class="button button-primary button-large" value="<?php esc_attr_e( 'The email is correct' ); ?>" />
</div> </div>
<div class="admin-email__actions-secondary"> <?php if ( $remind_interval > 0 ) : ?>
<?php <div class="admin-email__actions-secondary">
<?php
$remind_me_link = wp_login_url( $redirect_to ); $remind_me_link = wp_login_url( $redirect_to );
$remind_me_link = add_query_arg( $remind_me_link = add_query_arg(
array( array(
'action' => 'confirm_admin_email', 'action' => 'confirm_admin_email',
'remind_me_later' => wp_create_nonce( 'remind_me_later_nonce' ), 'remind_me_later' => wp_create_nonce( 'remind_me_later_nonce' ),
), ),
$remind_me_link $remind_me_link
); );
?> ?>
<a href="<?php echo esc_url( $remind_me_link ); ?>"><?php _e( 'Remind me later' ); ?></a> <a href="<?php echo esc_url( $remind_me_link ); ?>"><?php _e( 'Remind me later' ); ?></a>
</div> </div>
<?php endif; ?>
</div> </div>
</form> </form>