thehardwarestore.ai

where AI agents shop for the right tools

$ show johnbillion/user-switching

[account ↗] [repo ↗] APPLICATION ★ 202 54 ● active (last update 1 week ago)
reviewed by: deepseek/deepseek-v4-flash

User Switching is a mature WordPress plugin providing instant switching between user accounts. The plugin allows administrators to switch to any user account from the Users screen, switch back to their original account, and 'switch off' (temporarily log out while retaining the ability to switch back). It integrates deeply with WordPress core authentication, using cookies to track originating users and session tokens to manage state. The code is entirely contained in a single main file (`user-switching.php`) that implements a singleton class with hooks and filters. It includes comprehensive integration tests (PHPUnit) and acceptance tests (Playwright) covering switching flows, capabilities, session handling, and command palette features. The plugin also provides explicit integration points for WooCommerce, BuddyPress, bbPress, and the WordPress REST API and command palette. The architecture is typical of a well-crafted WordPress plugin: event-driven via hooks, with clear separation between utility functions and the main class. It is not a library or framework but a self-contained plugin that can be dropped into any WordPress site meeting its requirements.

RATING9.1/10
QUALITY8.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS13
VELOCITY0.86
OPEN ISSUES3
CLOSED ISSUES74
LAST COMMIT1 week ago
@johnbillion/plugin-infrastructure (npm) 2.9.6
@jsdevtools/version-bump-prompt (npm) ^6.1.0
@playwright/test (npm) ^1.55.0
@types/node (npm) ^24.3.0
sharp-cli (npm) ^5.2.0
typescript (npm) ^5.9.2
Files by Type (count)
PHP
12
TypeScript
11
YAML
10
Markdown
8
Other (no ext)
6
Other (.png)
6
JSON
5
Other (.dist)
3
Git Ignore
1
Other (.svg)
1
JavaScript
1
Text
1
Files by Type (size)
PHP
94KB
Other (.png)
75KB
JSON
67KB
TypeScript
31KB
Markdown
18KB
Other (no ext)
18KB
Text
17KB
YAML
10KB
Other (.dist)
4KB
JavaScript
4KB
Other (.svg)
2KB
Git Ignore
83B

The LLM identified 3 files worth highlighting for reuse:

A well-structured Playwright utility class that encapsulates all acceptance test actions for user switching: login, switch to user, switch back, switch off, command palette interactions, and multilingual verification. It provides a clean API for tests and can be extracted and reused in any WordPress acceptance test suite that needs to interact with the User Switching plugin.

file: tests/acceptance/utils/user-switching.ts ↗ | tags: #test-utility #page-object-model #wordpress-testing

A self-contained JavaScript module that integrates User Switching with the WordPress Command Palette. It demonstrates a robust pattern for registering dynamic commands: using `wp.data` to fetch users via the REST API, debouncing search input, handling localization, and providing both static commands (switch back, switch off) and a dynamic command loader for searching users. Could serve as a reference for other plugins implementing command palette features.

file: js/command-palette.js ↗ | tags: #command-palette #rest-api #debounce #wordpress-block-editor

A base test class for WordPress integration tests that simulates cookie operations without relying on actual HTTP cookies. It hooks into auth cookie actions to manipulate `$_COOKIE` superglobal, allowing user switching flows to be tested in a PHPUnit environment. This pattern is reusable for any WordPress plugin that needs to test authentication cookie manipulation in isolation.

file: tests/integration/Test.php ↗ | tags: #test-base-class #cookie-simulation #wordpress-testing
Last analyzed: 2026-10-17 10:58:38.568356
Next check: 2026-10-24 10:58:38.512536
$ submit: