Plugin Directory

Changeset 1157185


Ignore:
Timestamp:
05/10/2015 08:20:23 AM (11 years ago)
Author:
irenem
Message:

Update version compatability

Location:
userswitcher
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • userswitcher/tags/1.1.2/readme.txt

    r1098959 r1157185  
    11=== userSwitcher ===
     2
    23Contributors: irenem
     4
    35Tags: guest, user, users, roles, capabilities, switcher
     6
    47Requires at least: 3.4
    5 Tested up to: 4.1
     8
     9Tested up to: 4.2
     10
    611Stable tag: 1.1.2
     12
    713License: GPLv2 or later
     14
     15
    816
    917Switch between user accounts to xperience what you're users can and cannot do without logging in and out.
    1018
     19
     20
    1121== Description ==
     22
    1223userSwitcher allows you to switch between user accounts without the hassle of logging in/out. It allows you to do, experience and know what you're users can and cannot do.
    1324
     25
     26
    1427= Features =
     28
    1529* Switch between user role or account.
     30
    1631* Switch to "Guest" account without logging out.
     32
    1733* Inherit all capabilities to the selected account.
    1834
    1935
     36
     37
     38
    2039== Installation ==
     40
    21411. Upload `userSwitcher` to the `/wp-content/plugins/` directory
     42
    22431. Activate the plugin through the 'Plugins' menu in WordPress
     44
    23451. Click `userSwitcher` menu at the top to select user role or account. You will automatically switched to your selected role or account.
     46
     47
    2448
    2549== Frequently Asked Questions ==
    2650
    2751
     52
     53
     54
    2855= How to use userSwitcher? =
     56
    2957Click the `userSwitcher` menu at the top then select the type of role and account you wish to switch to. You will automatically switched to that account.
     58
    3059Select `Administrator` to change back to your account.
    3160
     61
     62
    3263= Why am I redirected to the front page when selecting guest user? =
     64
    3365Dah. Obviously `GUEST` user do not have access to admin's panel. But no worries, you can still able to go back to admin's panel by selecting a different role or account then navigate back.
    3466
     67
     68
    3569= Am I logged out when switching to GUEST user? =
     70
    3671No. Regardless of what type of role or user you switch yourself into, you are still logged in as you.
    3772
     73
     74
    3875= Can I add post while switching? =
     76
    3977That depends on the type of user you switch yourself into. If you switch to say editor then you still able to add post. Take note though that if you choose an account and not a role, you will not be the author of the post but the selected user.
    4078
     79
     80
    4181= I switch to guest user, why can I still read private posts? =
     82
    4283Private or password protected posts authored by you are still readable if you switch to `GUEST` or any other user `role`.
    4384
     85
     86
    4487== Screenshots ==
     88
    45891. Switcher menu
    4690
     91
     92
    4793== Changelog ==
     94
    4895= 1.0 =
     96
    4997* First release.
    5098
     99
     100
    51101= 1.1 =
     102
    52103* Fix switcher UI at admin bar.
     104
    53105* Added switcher UI if admin bar is disabled.
    54106
     107
     108
    55109= 1.1.2 =
     110
    56111* Rename directory url not showing on Linux.
     112
    57113* Added "My Account" option for easy switching back to current account.
  • userswitcher/tags/1.1.2/style.css

    r1098954 r1157185  
    11.switch-bg {
     2
    23    background: rgb(111,207,202);
     4
    35    background: -moz-linear-gradient(top, rgba(111,207,202,1) 0%, rgba(55,168,163,1) 100%);
     6
    47    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(111,207,202,1)), color-stop(100%,rgba(55,168,163,1)));
     8
    59    background: -webkit-linear-gradient(top, rgba(111,207,202,1) 0%,rgba(55,168,163,1) 100%);
     10
    611    background: -o-linear-gradient(top, rgba(111,207,202,1) 0%,rgba(55,168,163,1) 100%);
     12
    713    background: -ms-linear-gradient(top, rgba(111,207,202,1) 0%,rgba(55,168,163,1) 100%);
     14
    815    background: linear-gradient(to bottom, rgba(111,207,202,1) 0%,rgba(55,168,163,1) 100%);
     16
    917}
     18
    1019#switcher-form {
     20
    1121    position: absolute;
     22
    1223    border: 1px #ddd solid;
     24
    1325    margin: 0;
     26
    1427    z-index: 999;
     28
    1529    left:0;
     30
    1631    padding: 1px 0;
     32
    1733    cursor: pointer;
     34
    1835    height: 30px;
     36
    1937    width: 120px;
     38
    2039    text-indent: 0;
     40
    2141}
     42
    2243#switcher-form select,
     44
    2345#wpadminbar #switcher-form select {
     46
    2447    position: relative;
     48
    2549    font-size: 14px;
     50
    2651    padding: 0;
     52
    2753    -moz-border-radius: 0;
     54
    2855    border-radius: 0;
     56
    2957    display: table;
     58
    3059    vertical-align: middle;
     60
    3161    width: 0;
     62
    3263    overflow: hidden;
     64
    3365    -webkit-transition: width 0.4s ease;
     66
    3467    -moz-transition: width 0.4s ease;
     68
    3569    transition: width 0.4s ease;
     70
    3671    -webkit-transform: translate3d(0,0,0);
     72
    3773    -moz-transform: translate3d(0,0,0);
     74
    3875    transform: translate3d(0,0,0);
     76
    3977    margin: 0 0 0 110px;
     78
    4079    cursor: pointer;
     80
    4181    border:0;
     82
    4283    outline: none;
     84
    4385}
     86
    4487#switcher-form option {
     88
    4589    padding: 3px 15px;
     90
    4691    border-bottom: 1px #ddd solid;
     92
    4793}
     94
    4895#switcher-form .switch-icon {
     96
    4997    position: absolute;
     98
    5099    left:0;
     100
    51101    height: 100%;
     102
    52103    padding-left: 30px;
     104
    53105    padding-right:5px;
     106
    54107    color: #333;
     108
    55109    line-height: 28px;
     110
    56111    background: url(arrow_switch_right.png) no-repeat left center;
     112
    57113}
     114
    58115#switcher-form.switch-fixed {
     116
    59117    position: fixed;
     118
    60119    left:0;
     120
    61121    bottom:0;
     122
    62123}
     124
    63125#switcher-form.switch-fixed select {
     126
    64127    margin-left: 115px;
     128
    65129}
     130
    66131#switcher-form.switch-admin {
     132
    67133    border: 0;
     134
    68135}
  • userswitcher/tags/1.1.2/userSwitcher.php

    r1098955 r1157185  
    11<?php
     2
    23/**
     4
    35 * Plugin Name: userSwitcher
     6
    47 * Plugin URI: http://irenemitchell.com/userswitcher
     8
    59 * Description: Experience what you're user experienced and know what they can do to your site without logging in/out.
     10
    611 * Version: 1.1.2
     12
    713 * Author: Irene A. Mitchell
     14
    815 * Author URI: http://irenemitchell.com
     16
    917 * License: GPLv2 or later
     18
    1019 **/
    1120
     21
     22
    1223if( ! class_exists( 'userSwitcher' ) ):
     24
    1325        class userSwitcher {
     26
    1427                var $current_switcher;
     28
    1529                var $user_switcher;
     30
    1631                var $is_switching = false;
     32
    1733                var $user_data;
    18                
     34
     35               
     36
    1937                public function __construct(){
     38
    2039                        add_action( 'init', array($this, 'validate_current_user'), 1);
     40
    2141                        add_action( 'admin_init', array($this, 'admin_init'), 1);
     42
    2243                        add_action( 'admin_bar_menu', array( $this, 'switcher_html' ), 1000 );                       
     44
    2345                        add_action( ( is_admin() ? 'admin_footer' : 'wp_footer'), array( $this, 'footer'), 1 );
    24                 }
    25                
     46
     47                }
     48
     49               
     50
    2651                public function admin_init(){
     52
    2753                        register_setting( 'user_switcher', 'user_switcher', array( $this, 'redirect_switcher' ) );
    28                 }
    29                
     54
     55                }
     56
     57               
     58
    3059                public function redirect_switcher($req){                       
     60
    3161                        if( preg_match( '%wp-admin%', $_REQUEST['_wp_http_referer']) ){                               
     62
    3263                                $_REQUEST['_wp_http_referer'] = in_array( 'guest', (array) $_REQUEST['user_switcher']) ? site_url() : admin_url();
    33                         }
     64
     65                        }
     66
    3467                        return $req;
    35                 }
    36                
     68
     69                }
     70
     71               
     72
    3773                public function validate_current_user(){
     74
    3875                        global $pagenow, $current_user;
     76
    3977                        $this->current_switcher = get_current_user_id();
     78
    4079                        $switchers = (array) get_option( 'user_switcher' );
    41                         $this->user_switcher = $switchers[$this->current_switcher];
     80
     81                        $this->user_switcher = isset( $switchers[$this->current_switcher] ) ? $switchers[$this->current_switcher] : '';
     82
    4283                        $this->is_switching = is_super_admin();
    4384
     85
     86
    4487                        if( !empty($this->user_switcher)  && $this->current_switcher != $this->user_switcher ){
     88
    4589                                add_filter( 'user_has_cap', array( $this, 'set_option_cap' ), 15, 3 );
    46                                
     90
     91                               
     92
    4793                                // Get the switcher's original userdata first
     94
    4895                                $this->user_data = get_userdata( (int) $this->current_switcher );
    49                                
     96
     97                               
     98
    5099                                if( intval( $this->user_switcher ) > 0 ){                                       
     100
    51101                                        $user = get_userdata( (int) $this->user_switcher );
     102
    52103                                        $current_user = $user;                                       
    53                                 }
     104
     105                                }
     106
    54107                                else {
     108
    55109                                        $caps = get_role( (string) $this->user_switcher )->capabilities;                                     
     110
    56111                                        $current_user->allcaps = $caps;
     112
    57113                                        $current_user->allcaps[ (string) $this->user_switcher ] = 1;                                       
     114
    58115                                        $current_user->roles = $current_user->caps = array( $this->user_switcher );
    59                                 }
    60                                
     116
     117                                }
     118
     119                               
     120
    61121                                if( $pagenow == 'options.php' && isset($_REQUEST['user_switcher']) ) {
     122
    62123                                        $current_user = $this->user_data;
    63                                 }
    64                         }
    65                 }
    66                
     124
     125                                }
     126
     127                        }
     128
     129                }
     130
     131               
     132
    67133                public function set_option_cap($caps, $cap, $a){
     134
    68135                        global $pagenow, $current_user;
     136
    69137                       
     138
    70139                        if( $pagenow == 'options.php' && $this->is_switching ){
     140
    71141                                $caps['manage_options']= 1;
    72                         }
    73                                
     142
     143                        }
     144
     145                               
     146
    74147                        if( !is_admin() ){
     148
    75149                                switch( $this->user_switcher ){
     150
    76151                                        case 'subscriber':
     152
    77153                                                $caps = array('read' => 1);
     154
    78155                                                break;
    79                                 }
    80                         }
     156
     157                                }
     158
     159                        }
     160
    81161                        return $caps;
    82                 }
    83                
     162
     163                }
     164
     165               
     166
    84167                public function switcher_html(){
     168
    85169                        $current = get_userdata( (int) $this->current_switcher );
     170
    86171                        if( in_array( 'administrator', $current->roles ) ) {
     172
    87173                       
     174
    88175                                global $wp_admin_bar;
    89                                
     176
     177                               
     178
    90179                                $wp_admin_bar->add_menu( array(
     180
    91181                                        'id' => 'user-switcher',
     182
    92183                                        'title' => '<span class="switcher-icon">Switch To: </span>'
     184
    93185                                ));
    94                         }
    95                 }
    96                
     186
     187                        }
     188
     189                }
     190
     191               
     192
    97193                public function footer(){                       
     194
    98195                        global $wp_admin_bar, $current_user, $wp_roles;
     196
    99197                       
     198
    100199                        if( $this->is_switching ){       
     200
    101201                                $switcher_url = WP_PLUGIN_URL . "/userswitcher";
     202
    102203                                wp_enqueue_style( 'switch-css', $switcher_url . '/style.css' );
     204
    103205                                wp_enqueue_script( 'switch-js', $switcher_url . '/switch.js' );
     206
    104207                                $old_userdata = $current_user;
     208
    105209                                $current_user = $this->user_data;
     210
    106211                ?>
     212
    107213                        <script type="text/template" id="switcher-template">
     214
    108215                        <form method="post" action="<?php _e(admin_url()); ?>options.php" class="switch-bg" id="switcher-form">
     216
    109217                                <input type="hidden" name="option_page" value="<?php _e( esc_attr( 'user_switcher' ) ); ?>" />
     218
    110219                                <input type="hidden" name="action" value="update" />
     220
    111221                                <?php wp_nonce_field("user_switcher-options");?>
     222
    112223                                        <span class="switch-icon">userSwitcher</span>
     224
    113225                                        <select tabindex="1" name="user_switcher[<?php _e($this->current_switcher); ?>]">
     226
    114227                                                <option value="<?php _e($this->current_switcher); ?>">My Account</option>
     228
    115229                                                <option value="guest" <?php selected('guest', $this->user_switcher); ?>>Guest</option>
     230
    116231                                                <?php
     232
    117233                                                global $wp_roles;
     234
    118235                                                $roles = array_map(create_function('$a', ' return $a["name"]; ' ), $wp_roles->roles );
     236
    119237                                               
     238
    120239                                                foreach( $roles as $role => $label ): ?>
     240
    121241                                                        <option value="<?php _e($role); ?>" <?php selected($this->user_switcher, $role); ?>><?php _e($label); ?></option>
     242
    122243                                                        <?php
     244
    123245                                                        $users = get_users( array( 'role' => $role, 'exclude' => $this->current_switcher ) );
     246
    124247                                                       
     248
    125249                                                        if( !is_wp_error( $users ) && count( $users ) > 0 ):
     250
    126251                                                                foreach( $users as $user ): ?>
     252
    127253                                                                <option value="<?php _e($user->ID); ?>" <?php selected($this->user_switcher, $user->ID); ?>>&rarr; <?php _e($user->display_name); ?></option>
     254
    128255                                                                <?php endforeach; ?>
     256
    129257                                                        <?php endif; ?>
     258
    130259                                                <?php endforeach; ?>
     260
    131261                                        </select>
     262
    132263                        </form>
     264
    133265                        </script>
     266
    134267                <?php
     268
    135269                                $current_user = $old_userdata;
    136                         }
    137                 }
     270
     271                        }
     272
     273                }
     274
    138275        }
     276
    139277        new userSwitcher;
     278
    140279endif;
  • userswitcher/trunk/readme.txt

    r1098959 r1157185  
    33Tags: guest, user, users, roles, capabilities, switcher
    44Requires at least: 3.4
    5 Tested up to: 4.1
     5Tested up to: 4.2
    66Stable tag: 1.1.2
    77License: GPLv2 or later
Note: See TracChangeset for help on using the changeset viewer.