Version Description
Download this release
Release Info
Developer | johnbillion |
Plugin | User Switching |
Version | 1.5.2 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.5.2
- composer.json +6 -3
- readme.txt +2 -2
- user-switching.php +30 -14
composer.json
CHANGED
@@ -32,18 +32,21 @@
|
|
32 |
"paulgibbs/behat-wordpress-extension": "dev-master",
|
33 |
"phpcompatibility/php-compatibility": "^9",
|
34 |
"phpunit/phpunit": "^7",
|
35 |
-
"roots/wordpress": "*",
|
36 |
"vlucas/phpdotenv": "^3",
|
37 |
"wp-cli/wp-cli-bundle": "^2.1",
|
38 |
"wp-coding-standards/wpcs": "^2",
|
39 |
-
"wp-phpunit/wp-phpunit": "*"
|
40 |
},
|
41 |
"scripts": {
|
|
|
|
|
|
|
42 |
"test:cs": [
|
43 |
"vendor/bin/phpcs -nps --colors --report-code --report-summary --report-width=80 ."
|
44 |
],
|
45 |
"test:ut": [
|
46 |
-
"vendor/bin/wp db reset --yes --path
|
47 |
"export WP_MULTISITE=0 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-required",
|
48 |
"export WP_MULTISITE=1 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-excluded"
|
49 |
],
|
32 |
"paulgibbs/behat-wordpress-extension": "dev-master",
|
33 |
"phpcompatibility/php-compatibility": "^9",
|
34 |
"phpunit/phpunit": "^7",
|
35 |
+
"roots/wordpress": "* || *",
|
36 |
"vlucas/phpdotenv": "^3",
|
37 |
"wp-cli/wp-cli-bundle": "^2.1",
|
38 |
"wp-coding-standards/wpcs": "^2",
|
39 |
+
"wp-phpunit/wp-phpunit": "* || *"
|
40 |
},
|
41 |
"scripts": {
|
42 |
+
"post-update-cmd": [
|
43 |
+
"@php -r \"! file_exists( 'tests/.env' ) && copy( 'tests/.env.dist', 'tests/.env' );\""
|
44 |
+
],
|
45 |
"test:cs": [
|
46 |
"vendor/bin/phpcs -nps --colors --report-code --report-summary --report-width=80 ."
|
47 |
],
|
48 |
"test:ut": [
|
49 |
+
"vendor/bin/wp db reset --yes --path=$(npm run --silent jq '.extra .\"wordpress-install-dir\"' composer.json -- -r) #",
|
50 |
"export WP_MULTISITE=0 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-required",
|
51 |
"export WP_MULTISITE=1 && vendor/bin/phpunit --verbose --colors=always --exclude-group=ms-excluded"
|
52 |
],
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: johnbillion
|
|
4 |
Tags: users, profiles, user switching, fast user switching, multisite, buddypress, bbpress, become, user management, developer
|
5 |
Requires at least: 3.7
|
6 |
Tested up to: 5.2
|
7 |
-
Stable tag: 1.5.
|
8 |
Requires PHP: 5.3
|
9 |
License: GPL v2 or later
|
10 |
|
@@ -60,7 +60,7 @@ User Switching does not send data to any third party, nor does it include any th
|
|
60 |
|
61 |
Switching off logs you out of your account but retains your user ID in an authentication cookie so you can switch straight back without having to log in again manually. It's akin to switching to no user, and being able to switch back.
|
62 |
|
63 |
-
The *Switch Off* link can be found in your profile menu in the WordPress toolbar. Once you've switched off you'll see a *Switch back* link in the footer of your site.
|
64 |
|
65 |
= Does this plugin work with WordPress Multisite? =
|
66 |
|
4 |
Tags: users, profiles, user switching, fast user switching, multisite, buddypress, bbpress, become, user management, developer
|
5 |
Requires at least: 3.7
|
6 |
Tested up to: 5.2
|
7 |
+
Stable tag: 1.5.2
|
8 |
Requires PHP: 5.3
|
9 |
License: GPL v2 or later
|
10 |
|
60 |
|
61 |
Switching off logs you out of your account but retains your user ID in an authentication cookie so you can switch straight back without having to log in again manually. It's akin to switching to no user, and being able to switch back.
|
62 |
|
63 |
+
The *Switch Off* link can be found in your profile menu in the WordPress toolbar. Once you've switched off you'll see a *Switch back* link on the Log In screen and in the footer of your site.
|
64 |
|
65 |
= Does this plugin work with WordPress Multisite? =
|
66 |
|
user-switching.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
*
|
11 |
* Plugin Name: User Switching
|
12 |
* Description: Instant switching between user accounts in WordPress
|
13 |
-
* Version: 1.5.
|
14 |
* Plugin URI: https://johnblackbourn.com/wordpress-plugin-user-switching/
|
15 |
* Author: John Blackbourn & contributors
|
16 |
* Author URI: https://github.com/johnbillion/user-switching/graphs/contributors
|
@@ -67,6 +67,8 @@ class user_switching {
|
|
67 |
add_action( 'bp_member_header_actions', array( $this, 'action_bp_button' ), 11 );
|
68 |
add_action( 'bp_directory_members_actions', array( $this, 'action_bp_button' ), 11 );
|
69 |
add_action( 'bbp_template_after_user_details', array( $this, 'action_bbpress_button' ) );
|
|
|
|
|
70 |
}
|
71 |
|
72 |
/**
|
@@ -104,7 +106,7 @@ class user_switching {
|
|
104 |
?>
|
105 |
<tr>
|
106 |
<th scope="row"><?php echo esc_html_x( 'User Switching', 'User Switching title on user profile screen', 'user-switching' ); ?></th>
|
107 |
-
<td><a href="<?php echo esc_url( $link ); ?>"><?php esc_html_e( 'Switch To', 'user-switching' ); ?></a></td>
|
108 |
</tr>
|
109 |
<?php
|
110 |
}
|
@@ -290,12 +292,27 @@ class user_switching {
|
|
290 |
|
291 |
if ( $old_user ) {
|
292 |
$switched_locale = false;
|
|
|
|
|
293 |
if ( function_exists( 'get_user_locale' ) ) {
|
294 |
-
$
|
|
|
|
|
295 |
}
|
|
|
296 |
?>
|
297 |
<div id="user_switching" class="updated notice is-dismissible">
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
<?php
|
300 |
$message = '';
|
301 |
$just_switched = isset( $_GET['user_switched'] );
|
@@ -805,16 +822,20 @@ class user_switching {
|
|
805 |
|
806 |
/**
|
807 |
* Instructs WooCommerce to forget the session for the current user, without deleting it.
|
808 |
-
*
|
809 |
-
* @param WooCommerce $wc The WooCommerce instance.
|
810 |
*/
|
811 |
-
public
|
|
|
|
|
|
|
|
|
|
|
|
|
812 |
if ( ! property_exists( $wc, 'session' ) ) {
|
813 |
-
return
|
814 |
}
|
815 |
|
816 |
if ( ! method_exists( $wc->session, 'forget_session' ) ) {
|
817 |
-
return
|
818 |
}
|
819 |
|
820 |
$wc->session->forget_session();
|
@@ -1161,11 +1182,6 @@ if ( ! function_exists( 'switch_to_user' ) ) {
|
|
1161 |
$manager->destroy( $old_token );
|
1162 |
}
|
1163 |
|
1164 |
-
// When switching, instruct WooCommerce to forget about the current user's session
|
1165 |
-
if ( function_exists( 'WC' ) ) {
|
1166 |
-
user_switching::forget_woocommerce_session( WC() );
|
1167 |
-
}
|
1168 |
-
|
1169 |
return $user;
|
1170 |
}
|
1171 |
}
|
10 |
*
|
11 |
* Plugin Name: User Switching
|
12 |
* Description: Instant switching between user accounts in WordPress
|
13 |
+
* Version: 1.5.2
|
14 |
* Plugin URI: https://johnblackbourn.com/wordpress-plugin-user-switching/
|
15 |
* Author: John Blackbourn & contributors
|
16 |
* Author URI: https://github.com/johnbillion/user-switching/graphs/contributors
|
67 |
add_action( 'bp_member_header_actions', array( $this, 'action_bp_button' ), 11 );
|
68 |
add_action( 'bp_directory_members_actions', array( $this, 'action_bp_button' ), 11 );
|
69 |
add_action( 'bbp_template_after_user_details', array( $this, 'action_bbpress_button' ) );
|
70 |
+
add_action( 'switch_to_user', array( $this, 'forget_woocommerce_session' ) );
|
71 |
+
add_action( 'switch_back_user', array( $this, 'forget_woocommerce_session' ) );
|
72 |
}
|
73 |
|
74 |
/**
|
106 |
?>
|
107 |
<tr>
|
108 |
<th scope="row"><?php echo esc_html_x( 'User Switching', 'User Switching title on user profile screen', 'user-switching' ); ?></th>
|
109 |
+
<td><a id="user_switching_switcher" href="<?php echo esc_url( $link ); ?>"><?php esc_html_e( 'Switch To', 'user-switching' ); ?></a></td>
|
110 |
</tr>
|
111 |
<?php
|
112 |
}
|
292 |
|
293 |
if ( $old_user ) {
|
294 |
$switched_locale = false;
|
295 |
+
$lang_attr = '';
|
296 |
+
|
297 |
if ( function_exists( 'get_user_locale' ) ) {
|
298 |
+
$locale = get_user_locale( $old_user );
|
299 |
+
$switched_locale = switch_to_locale( $locale );
|
300 |
+
$lang_attr = str_replace( '_', '-', $locale );
|
301 |
}
|
302 |
+
|
303 |
?>
|
304 |
<div id="user_switching" class="updated notice is-dismissible">
|
305 |
+
<?php
|
306 |
+
if ( $lang_attr ) {
|
307 |
+
printf(
|
308 |
+
'<p lang="%s">',
|
309 |
+
esc_attr( $lang_attr )
|
310 |
+
);
|
311 |
+
} else {
|
312 |
+
echo '<p>';
|
313 |
+
}
|
314 |
+
?>
|
315 |
+
<span class="dashicons dashicons-admin-users" style="color:#56c234" aria-hidden="true"></span>
|
316 |
<?php
|
317 |
$message = '';
|
318 |
$just_switched = isset( $_GET['user_switched'] );
|
822 |
|
823 |
/**
|
824 |
* Instructs WooCommerce to forget the session for the current user, without deleting it.
|
|
|
|
|
825 |
*/
|
826 |
+
public function forget_woocommerce_session() {
|
827 |
+
if ( ! function_exists( 'WC' ) ) {
|
828 |
+
return;
|
829 |
+
}
|
830 |
+
|
831 |
+
$wc = WC();
|
832 |
+
|
833 |
if ( ! property_exists( $wc, 'session' ) ) {
|
834 |
+
return;
|
835 |
}
|
836 |
|
837 |
if ( ! method_exists( $wc->session, 'forget_session' ) ) {
|
838 |
+
return;
|
839 |
}
|
840 |
|
841 |
$wc->session->forget_session();
|
1182 |
$manager->destroy( $old_token );
|
1183 |
}
|
1184 |
|
|
|
|
|
|
|
|
|
|
|
1185 |
return $user;
|
1186 |
}
|
1187 |
}
|