WordPress.org

Plugin Directory

Changeset 613948


Ignore:
Timestamp:
10/18/12 05:54:52 (18 months ago)
Author:
johnbillion
Message:

Always show a 'Switch back' link in the footer when the admin toolbar isn't showing.
More intuitive redirecting after switching.

Location:
user-switching/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • user-switching/trunk/readme.txt

    r604774 r613948  
    33Donate link: http://lud.icro.us/donations/ 
    44Tags: user, users, profiles, switching, wpmu, multisite, buddypress, become, user control, user management, user access, developer 
    5 Requires at least: 2.7 
    6 Tested up to: 3.4.2 
     5Requires at least: 3.1 
     6Tested up to: 3.5 
    77Stable tag: trunk 
    88 
     
    3535 * Slovak by Max Samael 
    3636 * Polish by Bartosz Arendt 
    37  * Lithuanian by Tommixoft 
    3837 
    3938== Installation == 
     
    9796== Upgrade Notice == 
    9897 
    99 = 0.6.3 = 
    100 * Lithuanian, Polish and Slovak translations. 
    101  
    102 = 0.6 = 
    103 * More intuitive redirecting after switching, a BuddyPress bugfix and some hooks added. 
     98= 0.7 = 
     99* More intuitive redirecting after switching. Always show a 'Switch back' link in the footer when the admin toolbar isn't showing. 
    104100 
    105101== Changelog == 
     102 
     103= 0.7 = 
     104* Always show a 'Switch back' link in the footer when the admin toolbar isn't showing. 
     105* More intuitive redirecting after switching. 
    106106 
    107107= 0.6.3 = 
  • user-switching/trunk/user-switching.php

    r604774 r613948  
    33Plugin Name:  User Switching 
    44Description:  Instant switching between user accounts in WordPress 
    5 Version:      0.6.3 
     5Version:      0.7 
    66Plugin URI:   http://lud.icro.us/wordpress-plugin-user-switching/ 
    77Author:       John Blackbourn 
     
    115115 
    116116        if ( isset( $_REQUEST['redirect_to'] ) and !empty( $_REQUEST['redirect_to'] ) ) 
    117             $redirect_to = remove_query_arg( array( 'user_switched', 'switched_off', 'switched_back' ), $_REQUEST['redirect_to'] ); 
     117            $redirect_to = remove_query_arg( array( 'user_switched', 'switched_off', 'switched_back', 'message', 'updated', 'settings-updated' ), $_REQUEST['redirect_to'] ); 
    118118        else 
    119119            $redirect_to = false; 
     
    201201                    if ( isset( $_GET['user_switched'] ) ) 
    202202                        printf( __( 'Switched to %1$s (%2$s).', 'user_switching' ), $user_identity, $user_login ); 
    203                     printf( ' <a href="%s">%s</a>.', $this->switch_back_url(), sprintf( __( 'Switch back to %1$s (%2$s)', 'user_switching' ), $old_user->display_name, $old_user->user_login ) ); 
     203                    $url = add_query_arg( array( 
     204                        'redirect_to' => urlencode( $this->current_url() ) 
     205                    ), $this->switch_back_url() ); 
     206                    printf( ' <a href="%s">%s</a>.', $url, sprintf( __( 'Switch back to %1$s (%2$s)', 'user_switching' ), $old_user->display_name, $old_user->user_login ) ); 
    204207                ?></p> 
    205208            </div> 
     
    260263                'id'     => 'wp-admin-bar-switch-back', 
    261264                'title'  => sprintf( __( 'Switch back to %1$s (%2$s)', 'user_switching' ), $old_user->display_name, $old_user->user_login ), 
    262                 'href'   => $this->switch_back_url() 
     265                'href'   => add_query_arg( array( 
     266                    'redirect_to' => urlencode( $this->current_url() ) 
     267                ), $this->switch_back_url() ) 
    263268            ) ); 
    264269 
     
    270275            if ( !is_admin() ) { 
    271276                $url = add_query_arg( array( 
    272                     'redirect_to' => $_SERVER['REQUEST_URI'] 
     277                    'redirect_to' => urlencode( $this->current_url() ) 
    273278                ), $url ); 
    274279            } 
     
    286291 
    287292    /** 
    288      * Adds a 'Switch back to {user}' link to the WordPress footer if a user is switched off. 
     293     * Adds a 'Switch back to {user}' link to the WordPress footer if the admin toolbar isn't showing. 
    289294     * 
    290295     * @return null 
     
    292297    function switch_on() { 
    293298 
    294         if ( !is_user_logged_in() and $old_user = $this->get_old_user() ) { 
     299        if ( !is_admin_bar_showing() and $old_user = $this->get_old_user() ) { 
    295300            $link = sprintf( __( 'Switch back to %1$s (%2$s)', 'user_switching' ), $old_user->display_name, $old_user->user_login ); 
    296301            $url = add_query_arg( array( 
    297                 'redirect_to' => $_SERVER['REQUEST_URI'] 
     302                'redirect_to' => urlencode( $this->current_url() ) 
    298303            ), $this->switch_back_url() ); 
    299304            echo '<p id="user_switching_switch_on"><a href="' . $url . '">' . $link . '</a></p>'; 
     
    303308 
    304309    /** 
    305      * Adds a 'Switch back to {user}' link to the WordPress login screen if a user is switched off. 
     310     * Adds a 'Switch back to {user}' link to the WordPress login screen. 
    306311     * 
    307312     * @return null 
     
    309314    function login_message( $message ) { 
    310315 
    311         if ( !is_user_logged_in() and $old_user = $this->get_old_user() ) { 
     316        if ( $old_user = $this->get_old_user() ) { 
    312317            $link = sprintf( __( 'Switch back to %1$s (%2$s)', 'user_switching' ), $old_user->display_name, $old_user->user_login ); 
    313318            $url = $this->switch_back_url(); 
     
    418423            'action' => 'switch_off' 
    419424        ), site_url( 'wp-login.php', 'login' ) ), 'switch_off' ); 
     425    } 
     426 
     427    /** 
     428     * Returns the current URL. 
     429     * 
     430     * @return string The current URL 
     431     */ 
     432    function current_url() { 
     433        return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; 
    420434    } 
    421435 
Note: See TracChangeset for help on using the changeset viewer.