Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,29 @@ jobs:
# See the following for PHP compatibility of WordPress versions:
# https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/
matrix:
wp:
# Three most recent versions of WordPress
- '6.9'
- '6.8'
- '6.7'
php:
# Most recent version of PHP supported by all of the above, plus 7.4
- '8.4'
- '7.4'
include:
# Latest WordPress on latest PHP
# - wp: '6.9'
# php: '8.5'
# Oldest supported WordPress on its newest supported PHP, plus 7.4:
- wp: '6.1'
# Latest:
- wp: '7.0'
php: '8.5'
- wp: '7.0'
php: '7.4'
# Latest -1:
- wp: '6.9'
php: '8.5'
- wp: '6.9'
php: '7.4'
# Latest -2:
- wp: '6.8'
php: '8.4'
- wp: '6.8'
php: '7.4'
# Oldest supported:
- wp: '6.2'
php: '8.2'
- wp: '6.1'
- wp: '6.2'
php: '7.4'
fail-fast: false
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
with:
wp: ${{ matrix.wp }}
php: ${{ matrix.php }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
name: ${{ matrix.label }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-coding-standards.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-coding-standards.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
strategy:
matrix:
label:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: WordPress.org
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-assets.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-assets.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
with:
plugin: user-switching
readme: readme.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
deploy:
name: Deploy Tag
if: github.event_name == 'workflow_dispatch' || github.event.release.prerelease == false
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-tag.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-deploy-tag.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
permissions:
contents: write # Required to push the new branch
issues: write # Required for write access to milestones.
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,30 @@ jobs:
name: WP ${{ matrix.wp }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
strategy:
# See the following for PHP compatibility of WordPress versions:
# https://make.wordpress.org/core/handbook/references/php-compatibility-and-wordpress-versions/
matrix:
wp:
# Three most recent versions of WordPress
# Three most recent versions of WordPress:
- '7.0'
- '6.9'
- '6.8'
- '6.7'
php:
# Most recent version of PHP supported by all of the above, plus 7.4
# Most recent version of PHP supported by all of the above:
- '8.4'
# Oldest support PHP:
- '7.4'
include:
# Latest WordPress on latest PHP
- wp: '6.9'
# Latest WordPress on latest PHP:
- wp: '7.0'
php: '8.5'
# Oldest supported WordPress on its newest supported PHP, plus 7.4:
- wp: '6.1'
# Oldest supported WordPress on its newest supported PHP:
- wp: '6.2'
php: '8.2'
- wp: '6.1'
# Oldest supported WordPress on oldest support PHP:
- wp: '6.2'
php: '7.4'
fail-fast: false
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint-workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
security-events: write # Required for upload-sarif to upload SARIF files.
contents: read # Needed to clone the repo.
actions: read # Needed for upload-sarif to read workflow run info.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-workflow-lint.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-workflow-lint.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
4 changes: 2 additions & 2 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- '8.3'
- '7.4'
fail-fast: false
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-acceptance-tests.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
with:
wp: 'nightly'
php: ${{ matrix.php }}
Expand All @@ -52,7 +52,7 @@ jobs:
name: Nightly ${{ matrix.label }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-integration-tests.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
strategy:
matrix:
label:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
name: ${{ matrix.label }}
permissions:
contents: read # Needed to clone the repo.
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-static-analysis.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-static-analysis.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
strategy:
matrix:
label:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
permissions:
contents: write # Needed to push commits
pull-requests: write # Needed to create a PR
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-verify-distribution.yml@cc47e37177c694e00b901a5dc89fda5644bc550f # 2.9.1
uses: johnbillion/plugin-infrastructure/.github/workflows/reusable-verify-distribution.yml@667f50aeb549afa5a5cf0137a21a08de1bc983f5 # 2.9.3
with:
plugin: user-switching
owner: johnbillion
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"composer/installers": "^1.0 || ^2.0"
},
"require-dev": {
"johnbillion/plugin-infrastructure": "2.9.1",
"johnbillion/wp-compat": "1.3.0",
"php-stubs/wordpress-stubs": "6.9.0",
"johnbillion/plugin-infrastructure": "2.9.3",
"johnbillion/wp-compat": "1.5.0",
"php-stubs/wordpress-stubs": "7.0.0 as 6.9.4",
"phpcompatibility/phpcompatibility-wp": "2.1.8",
"phpstan/phpstan": "2.1.33",
"phpstan/phpstan-phpunit": "2.0.11",
Expand Down Expand Up @@ -79,7 +79,7 @@
"phpcs -ps --colors --report-code --report-summary --report-width=80 --basepath='./' ."
],
"test:phpstan": [
"phpstan analyze -v --memory-limit=1024M"
"phpstan analyze -v --memory-limit=2G"
],
"test:start": [
"tests-start"
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"engines": {
"node": ">=24"
},
"type": "module",
"devDependencies": {
"@johnbillion/plugin-infrastructure": "2.9.1",
"@johnbillion/plugin-infrastructure": "2.9.3",
"@jsdevtools/version-bump-prompt": "^6.1.0",
"@playwright/test": "^1.55.0",
"@types/node": "^24.3.0",
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<ruleset name="User Switching">
<arg name="cache" value="tests/cache/phpcs.json"/>

<config name="minimum_wp_version" value="6.1"/>
<config name="minimum_wp_version" value="6.2"/>
<config name="testVersion" value="7.4-"/>

<exclude-pattern>/.wordpress-org/*</exclude-pattern>
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# User Switching

Stable tag: 1.11.2
Tested up to: 6.9
Tested up to: 7.0
License: GPL v2 or later
Tags: users, user switching, fast user switching, multisite, woocommerce
Contributors: johnbillion
Expand Down
11 changes: 5 additions & 6 deletions user-switching.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Text Domain: user-switching
* Domain Path: /languages/
* Network: true
* Requires at least: 6.1
* Requires at least: 6.2
* Requires PHP: 7.4
* License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
Expand Down Expand Up @@ -487,9 +487,8 @@ public function action_admin_notices(): void {
$old_user = self::get_old_user();

if ( $old_user instanceof WP_User ) {
$locale = get_user_locale( $old_user );
$switched_locale = switch_to_locale( $locale );
$lang_attr = str_replace( '_', '-', $locale );
$switched_locale = switch_to_user_locale( $old_user->ID );
$lang_attr = str_replace( '_', '-', get_user_locale( $old_user ) );

?>
<div id="user_switching" class="updated notice notice-success is-dismissible">
Expand Down Expand Up @@ -678,7 +677,7 @@ public function action_admin_bar_menu( WP_Admin_Bar $wp_admin_bar ): void {
* Adds a 'Switch back to {user}' link to access denied messages within the admin area.
*/
public function action_shutdown_for_wp_die(): void {
if ( ! did_action( 'admin_page_access_denied' ) && ! ( function_exists( 'did_filter' ) && did_filter( 'wp_die_handler' ) ) ) {
if ( ! did_action( 'admin_page_access_denied' ) && ! did_filter( 'wp_die_handler' ) ) {
return;
}

Expand Down Expand Up @@ -1062,7 +1061,7 @@ public static function switched_to_message( WP_User $user ): string {
* @return string The message.
*/
public static function switch_back_message( WP_User $user ): string {
$switched_locale = switch_to_locale( get_user_locale( $user ) );
$switched_locale = switch_to_user_locale( $user->ID );

$message = sprintf(
/* Translators: 1: user display name; 2: username; */
Expand Down