Make WordPress Core

Ticket #39929: 39929.1.diff

File 39929.1.diff, 5.0 KB (added by dcavins, 8 years ago)

Add wp_login_form_nav_links().

  • src/wp-login.php

    diff --git src/wp-login.php src/wp-login.php
    index 03422b3..2cb52e4 100644
    if ( force_ssl_admin() && ! is_ssl() ) { 
    2525/**
    2626 * Output the login page header.
    2727 *
     28 * @since 4.8.0
     29 *
    2830 * @param string   $title    Optional. WordPress login Page title to display in the `<title>` element.
    2931 *                           Default 'Log In'.
    3032 * @param string   $message  Optional. Message to display in header. Default empty.
    function login_header( $title = 'Log In', $message = '', $wp_error = '' ) { 
    216218} // End of login_header()
    217219
    218220/**
     221 * Output the navigation links below the login form.
     222 *
     223 * @param string $action The action that brought the visitor to the login page.
     224 *
     225 * @return string The html code for the navigation links.
     226 */
     227function wp_login_form_nav_links( $action ) {
     228        $nav_links = array();
     229
     230        // Add "Log In" link.
     231        if ( in_array( $action, array( 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register' ) ) ) {
     232                $nav_links[] = sprintf( '<a href="%s">%s</a>', esc_url( wp_login_url() ), __('Log in') );
     233        }
     234
     235        // Add "Register" link.
     236        if ( 'register' != $action ) {
     237                if ( ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) && get_option( 'users_can_register' ) ) {
     238                        $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
     239
     240                        /** This filter is documented in wp-includes/general-template.php */
     241                        $nav_links[] = apply_filters( 'register', $registration_url );
     242                }
     243        }
     244
     245        // Add "Lost Password" link.
     246        if ( ! in_array( $action, array( 'lostpassword', 'retrievepassword', 'resetpass', 'rp' ) ) ) {
     247                if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) {
     248                        $nav_links[] = sprintf( '<a href="%s">%s</a>', esc_url( wp_lostpassword_url() ), __( 'Lost your password?' ) );
     249                }
     250        }
     251
     252        /**
     253         * Filters the login form navigation links.
     254         *
     255         * @since 4.8.0
     256         *
     257         * @param array $nav_links Links to add to the navigation area below the
     258         *                         login form.
     259         * @param string $action   The action that brought the visitor to the
     260         *                         login page.
     261         */
     262        $nav_links = apply_filters( 'wp_login_form_nav_links', $nav_links, $action );
     263
     264        /**
     265         * Filters the characters used to join login form navigation links.
     266         *
     267         * @since 4.8.0
     268         *
     269         * @param string $join_string Default string used to concatenate links.
     270         * @param string $action      The action that brought the visitor to the
     271         *                            login page.
     272         */
     273        $nav_links_join = apply_filters( 'wp_login_form_nav_links_join', ' | ', $action );
     274
     275        echo implode( $nav_links_join, $nav_links );
     276}
     277
     278/**
    219279 * Outputs the footer for the login page.
    220280 *
    221281 * @param string $input_id Which input to auto-focus
    function retrieve_password() { 
    358418
    359419        /**
    360420         * Filters the message body of the password reset mail.
    361          * 
     421         *
    362422         * If the filtered message is empty, the password reset email will not be sent.
    363423         *
    364424         * @since 2.8.0
    case 'retrievepassword' : 
    549609</form>
    550610
    551611<p id="nav">
    552 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e('Log in') ?></a>
    553 <?php
    554 if ( get_option( 'users_can_register' ) ) :
    555         $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
    556 
    557         /** This filter is documented in wp-includes/general-template.php */
    558         echo ' | ' . apply_filters( 'register', $registration_url );
    559 endif;
    560 ?>
     612        <?php wp_login_form_nav_links( $action ); ?>
    561613</p>
    562614
    563615<?php
    case 'rp' : 
    662714</form>
    663715
    664716<p id="nav">
    665 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a>
    666 <?php
    667 if ( get_option( 'users_can_register' ) ) :
    668         $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
    669 
    670         /** This filter is documented in wp-includes/general-template.php */
    671         echo ' | ' . apply_filters( 'register', $registration_url );
    672 endif;
    673 ?>
     717        <?php wp_login_form_nav_links( $action ); ?>
    674718</p>
    675719
    676720<?php
    case 'register' : 
    743787</form>
    744788
    745789<p id="nav">
    746 <a href="<?php echo esc_url( wp_login_url() ); ?>"><?php _e( 'Log in' ); ?></a> |
    747 <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
     790        <?php wp_login_form_nav_links( $action ); ?>
    748791</p>
    749792
    750793<?php
    default: 
    930973
    931974<?php if ( ! $interim_login ) { ?>
    932975<p id="nav">
    933 <?php if ( ! isset( $_GET['checkemail'] ) || ! in_array( $_GET['checkemail'], array( 'confirm', 'newpass' ) ) ) :
    934         if ( get_option( 'users_can_register' ) ) :
    935                 $registration_url = sprintf( '<a href="%s">%s</a>', esc_url( wp_registration_url() ), __( 'Register' ) );
    936 
    937                 /** This filter is documented in wp-includes/general-template.php */
    938                 echo apply_filters( 'register', $registration_url ) . ' | ';
    939         endif;
    940         ?>
    941         <a href="<?php echo esc_url( wp_lostpassword_url() ); ?>"><?php _e( 'Lost your password?' ); ?></a>
    942 <?php endif; ?>
     976        <?php wp_login_form_nav_links( $action ); ?>
    943977</p>
    944978<?php } ?>
    945979