Making WordPress.org


Ignore:
Timestamp:
02/18/2017 06:12:44 PM (9 years ago)
Author:
ocean90
Message:

Translate: Add redirect parameter for current page to the login URL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/class-plugin.php

    r4924 r4927  
    4747                // Toolbar.
    4848                add_action( 'admin_bar_menu', array( $this, 'add_profile_settings_to_admin_bar' ) );
     49                add_action( 'admin_bar_menu', array( $this, 'replace_login_url_in_admin_bar' ), 20 );
    4950                add_action( 'admin_bar_init', array( $this, 'show_admin_bar' ) );
    5051                add_action( 'add_admin_bar_menus', array( $this, 'remove_admin_bar_menus' ) );
     
    8990         * Adds the link to profile settings to the user actions toolbar menu.
    9091         *
    91          * @param \WP_Admin_Bar $wp_admin_bar
     92         * @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
    9293         */
    9394        public function add_profile_settings_to_admin_bar( $wp_admin_bar ) {
     
    105106                        $wp_admin_bar->add_node( $logout_node ); // Ensures that logout is the last action.
    106107                }
     108        }
     109
     110        /**
     111         * Changes the login URL to include a redirect parameter for the current page.
     112         *
     113         * @param \WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance.
     114         */
     115        public function replace_login_url_in_admin_bar( $wp_admin_bar ) {
     116                if ( ! $wp_admin_bar->get_node( 'log-in' ) ) {
     117                        return;
     118                }
     119
     120                $menu = [
     121                        'id' => 'log-in',
     122                        'href' => wp_login_url( gp_url_current() ),
     123                ];
     124                $wp_admin_bar->add_menu( $menu );
    107125        }
    108126
Note: See TracChangeset for help on using the changeset viewer.