Repository navigation
Conversation
…tions(). See #66561.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
There was a problem hiding this comment.
🟡 Changes recommended
The tests retain Windows compatibility issues: unnormalized registry keys produce incorrect plugin_basename() results, and unlink() fails to remove directory symlinks, leaving them behind.
2 open issues
What changed in this PR
Adds unit tests for plugin path helpers and remove_all_actions() without changing production code.
Changes:
- Covers plugin directory paths, URLs, and basename normalization.
- Tests registered symlink paths, path precedence, and realpath registration.
- Verifies action removal across all priorities, a single priority, and empty hooks.
| File | Description |
|---|---|
tests/phpunit/tests/functions/pluginPaths.php |
Adds path-helper and action-removal tests, including symlink fixtures and cleanup. |
Review effort: Balanced
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Thanks for adding tests for plugin path helpers and remove_all_actions(), @hmbashar!
All 97 CI checks pass cleanly across the matrix. Two cross-platform Windows compatibility details to address:
- Directory symlink cleanup (line ~54): On Windows,
unlink()on a directory symlink can fail. Checking for Windows (DIRECTORY_SEPARATOR === '\\\\') and usingrmdir()ensures clean teardown across all platforms. - Path normalization (line ~171): Normalizing backslashes in registered fixture paths with
wp_normalize_path()before passing towp_register_plugin_realpath()prevents absolute path mismatches on Windows.
Great coverage overall!
AI Review: Gemini 3.8 Flash
…move links like Windows does. See #66561.

Summary
Adds tests for the functions of
wp-includes/plugin.phpthat give the paths of plugins, and forremove_all_actions(). None of them had a test of its own.plugin_dir_path()returns the directory of a file with a trailing slash.plugin_dir_url()returns the URL of the directory of a plugin file (and of a Must-Use plugin file) with a trailing slash.plugin_basename()returns the path relative to the plugins directory, or the Must-Use plugins directory, for a plugin in a folder, a single file, a file in a subfolder, a path with backslashes or extra slashes, a relative path and a path outside of them. It uses the registered path of a plugin that is a symbolic link, and the most specific registered path first.wp_register_plugin_realpath()registers nothing for a file in the plugins or Must-Use plugins directory, or for a plugin that is not a link, and registers the real path of a plugin that is a symbolic link (the test is skipped when links cannot be created).remove_all_actions()removes the actions of all the priorities or of one priority, and returnstruefor a hook without actions.Testing
Mutation check: 14 changes to these functions were each caught by a test, except one that is equivalent on systems that use
/: removingwp_normalize_path()from the directory of the file inwp_register_plugin_realpath().The test with a symbolic link creates a folder in the temporary directory and a link in the plugins directory, and removes both after the test.
Trac ticket: https://core.trac.wordpress.org/ticket/66561
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 5.5
Used for: Written with AI and manually reviewed by me.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.