Make WordPress Core

Ticket #48153: 48153.3.diff

File 48153.3.diff, 2.8 KB (added by azaozz, 6 years ago)
  • src/wp-login.php

     
    589589                        }
    590590
    591591                        /**
    592                          * Filters the interval for redirecting the user to the admin email confirmation screen.
    593                          * If `0` (zero), or any "falsey" value is returned, the user will not be redirected.
     592                         * Filters the interval for redirecting the user to the admin email verification screen.
     593                         * If `0` or a negative value is returned, the email verification screen will
     594                         * be shown again next time an administrator logs in.
    594595                         *
    595596                         * @since 5.3.0
    596597                         *
     
    598599                         */
    599600                        $admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS );
    600601
    601                         if ( $admin_email_check_interval > 0 ) {
    602                                 update_option( 'admin_email_lifespan', time() + $admin_email_check_interval );
    603                         }
     602                        update_option( 'admin_email_lifespan', time() + $admin_email_check_interval );
    604603
    605604                        wp_safe_redirect( $redirect_to );
    606605                        exit;
     
    12321231                                exit;
    12331232                        }
    12341233
    1235                         /**
    1236                          * Filters the capability required for displaying the admin email check screen.
    1237                          *
    1238                          * @since 5.3.0
    1239                          *
    1240                          * @param string $capability The capability required to display the admin email check screen.
    1241                          */
    1242                         $admin_check_cap = apply_filters( 'admin_email_check_cap', 'manage_options' );
     1234                        // Check if it is time to add a redirect to the admin email verification screen.
     1235                        if ( is_a( $user, 'WP_User' ) && $user->exists() && $user->has_cap( 'manage_options' ) ) {
     1236                                /**
     1237                                 * Filters whether the user should be redirected to the verification screen. Can also be used
     1238                                 * to disable this functionality completely.
     1239                                 *
     1240                                 * @since 5.3.0
     1241                                 *
     1242                                 * @param bool    True to redirect, false otherwise.
     1243                                 * @param WP_User WP_User object.
     1244                                 */
     1245                                $show_verification = (bool) apply_filters( 'show_admin_email_verification', true, $user );
    12431246
    1244                         // Check if it is time to add a redirect to the admin email confirmation screen.
    1245                         if ( is_a( $user, 'WP_User' ) && $user->exists() && $user->has_cap( $admin_check_cap ) ) {
    1246                                 $admin_email_lifespan = (int) get_option( 'admin_email_lifespan' );
     1247                                if ( $show_verification ) {
     1248                                        $admin_email_lifespan = (int) get_option( 'admin_email_lifespan' );
    12471249
    1248                                 /** This filter is documented in wp-login.php */
    1249                                 $admin_email_check_interval = (int) apply_filters( 'admin_email_check_interval', 6 * MONTH_IN_SECONDS );
    1250 
    1251                                 if ( $admin_email_check_interval > 0 && time() > $admin_email_lifespan ) {
    1252                                         $redirect_to = add_query_arg( 'action', 'confirm_admin_email', wp_login_url( $redirect_to ) );
     1250                                        if ( time() > $admin_email_lifespan ) {
     1251                                                $redirect_to = add_query_arg( 'action', 'confirm_admin_email', wp_login_url( $redirect_to ) );
     1252                                        }
    12531253                                }
    12541254                        }
    12551255