Version Description
Download this release
Release Info
Developer | johnbillion |
Plugin | User Switching |
Version | 1.5.0 |
Comparing to | |
See all releases |
Code changes from version 1.4.2 to 1.5.0
- composer.json +26 -3
- readme.txt +6 -2
- user-switching.php +23 -1
composer.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{
|
2 |
"name" : "johnbillion/user-switching",
|
3 |
-
"description": "
|
4 |
"homepage" : "https://github.com/johnbillion/user-switching",
|
5 |
"type" : "wordpress-plugin",
|
6 |
"license" : "GPL-2.0-or-later",
|
@@ -18,6 +18,9 @@
|
|
18 |
"config": {
|
19 |
"sort-packages": true
|
20 |
},
|
|
|
|
|
|
|
21 |
"require": {
|
22 |
"composer/installers": "^1"
|
23 |
},
|
@@ -30,7 +33,27 @@
|
|
30 |
"paulgibbs/behat-wordpress-extension": "^3.1",
|
31 |
"phpcompatibility/php-compatibility": "^9",
|
32 |
"phpunit/phpunit": "^5",
|
|
|
|
|
33 |
"wp-cli/wp-cli-bundle": "^2.1",
|
34 |
-
"wp-coding-standards/wpcs": "^2"
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
1 |
{
|
2 |
"name" : "johnbillion/user-switching",
|
3 |
+
"description": "Instant switching between user accounts in WordPress.",
|
4 |
"homepage" : "https://github.com/johnbillion/user-switching",
|
5 |
"type" : "wordpress-plugin",
|
6 |
"license" : "GPL-2.0-or-later",
|
18 |
"config": {
|
19 |
"sort-packages": true
|
20 |
},
|
21 |
+
"extra": {
|
22 |
+
"wordpress-install-dir": "tests/wordpress"
|
23 |
+
},
|
24 |
"require": {
|
25 |
"composer/installers": "^1"
|
26 |
},
|
33 |
"paulgibbs/behat-wordpress-extension": "^3.1",
|
34 |
"phpcompatibility/php-compatibility": "^9",
|
35 |
"phpunit/phpunit": "^5",
|
36 |
+
"roots/wordpress": "*",
|
37 |
+
"vlucas/phpdotenv": "^3",
|
38 |
"wp-cli/wp-cli-bundle": "^2.1",
|
39 |
+
"wp-coding-standards/wpcs": "^2",
|
40 |
+
"wp-phpunit/wp-phpunit": "*"
|
41 |
+
},
|
42 |
+
"scripts": {
|
43 |
+
"test:cs": [
|
44 |
+
"vendor/bin/phpcs -nps --colors --report-code --report-summary --report-width=80 ."
|
45 |
+
],
|
46 |
+
"test:ut": [
|
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 |
+
],
|
50 |
+
"test:ft": [
|
51 |
+
"bin/test.sh"
|
52 |
+
],
|
53 |
+
"test": [
|
54 |
+
"@test:cs",
|
55 |
+
"@test:ut",
|
56 |
+
"@test:ft"
|
57 |
+
]
|
58 |
+
}
|
59 |
}
|
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.1
|
7 |
-
Stable tag: 1.
|
8 |
Requires PHP: 5.3
|
9 |
License: GPL v2 or later
|
10 |
|
@@ -20,7 +20,7 @@ This plugin allows you to quickly swap between user accounts in WordPress at the
|
|
20 |
* Switch back: Instantly switch back to your originating account.
|
21 |
* Switch off: Log out of your account but retain the ability to instantly switch back in again.
|
22 |
* It's completely secure (see the *Security* section below).
|
23 |
-
* Compatible with WordPress, WordPress Multisite, BuddyPress, and bbPress.
|
24 |
|
25 |
= Security =
|
26 |
|
@@ -74,6 +74,10 @@ Yes, and you'll also be able to switch users from member profile screens and the
|
|
74 |
|
75 |
Yes, and you'll also be able to switch users from member profile screens.
|
76 |
|
|
|
|
|
|
|
|
|
77 |
= Does this plugin work if my site is using a two-factor authentication plugin? =
|
78 |
|
79 |
Yes, mostly.
|
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.1
|
7 |
+
Stable tag: 1.5.0
|
8 |
Requires PHP: 5.3
|
9 |
License: GPL v2 or later
|
10 |
|
20 |
* Switch back: Instantly switch back to your originating account.
|
21 |
* Switch off: Log out of your account but retain the ability to instantly switch back in again.
|
22 |
* It's completely secure (see the *Security* section below).
|
23 |
+
* Compatible with WordPress, WordPress Multisite, WooCommerce, BuddyPress, and bbPress.
|
24 |
|
25 |
= Security =
|
26 |
|
74 |
|
75 |
Yes, and you'll also be able to switch users from member profile screens.
|
76 |
|
77 |
+
= Does this plugin work with WooCommerce? =
|
78 |
+
|
79 |
+
Yes, but for maximum compatibility you should use WooCommerce version 3.6 or later.
|
80 |
+
|
81 |
= Does this plugin work if my site is using a two-factor authentication plugin? =
|
82 |
|
83 |
Yes, mostly.
|
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.
|
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
|
@@ -774,6 +774,23 @@ class user_switching {
|
|
774 |
return ( is_ssl() && ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) ) );
|
775 |
}
|
776 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
777 |
/**
|
778 |
* Filters a user's capabilities so they can be altered at runtime.
|
779 |
*
|
@@ -1109,6 +1126,11 @@ if ( ! function_exists( 'switch_to_user' ) ) {
|
|
1109 |
$manager->destroy( $old_token );
|
1110 |
}
|
1111 |
|
|
|
|
|
|
|
|
|
|
|
1112 |
return $user;
|
1113 |
}
|
1114 |
}
|
10 |
*
|
11 |
* Plugin Name: User Switching
|
12 |
* Description: Instant switching between user accounts in WordPress
|
13 |
+
* Version: 1.5.0
|
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
|
774 |
return ( is_ssl() && ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) ) );
|
775 |
}
|
776 |
|
777 |
+
/**
|
778 |
+
* Instructs WooCommerce to forget the session for the current user, without deleting it.
|
779 |
+
*
|
780 |
+
* @param WooCommerce $wc The WooCommerce instance.
|
781 |
+
*/
|
782 |
+
public static function forget_woocommerce_session( WooCommerce $wc ) {
|
783 |
+
if ( ! property_exists( $wc, 'session' ) ) {
|
784 |
+
return false;
|
785 |
+
}
|
786 |
+
|
787 |
+
if ( ! method_exists( $wc->session, 'forget_session' ) ) {
|
788 |
+
return false;
|
789 |
+
}
|
790 |
+
|
791 |
+
$wc->session->forget_session();
|
792 |
+
}
|
793 |
+
|
794 |
/**
|
795 |
* Filters a user's capabilities so they can be altered at runtime.
|
796 |
*
|
1126 |
$manager->destroy( $old_token );
|
1127 |
}
|
1128 |
|
1129 |
+
// When switching, instruct WooCommerce to forget about the current user's session
|
1130 |
+
if ( function_exists( 'WC' ) ) {
|
1131 |
+
user_switching::forget_woocommerce_session( WC() );
|
1132 |
+
}
|
1133 |
+
|
1134 |
return $user;
|
1135 |
}
|
1136 |
}
|