Permit single-file mu-plugins#337
Merged
Merged
Conversation
Sets up tests to demonstrate the issues in this ruleset that prevent easy use of single-file mu-plugin patterns, which have pragmatic uses in many codebases and should still require namespaces, etc.
Permits files which are direct children of mu-plugins or client-mu-plugins to have sideeffects and to not require a folder-based structure. Proper file organization is still recommended but in many cases a full inc folder is overkill for a small mu-plugin which adjusts third-party plugin functionality, etcetera.
joehoyle
reviewed
Jun 22, 2026
| $path = str_replace( DIRECTORY_SEPARATOR, '/', $path ); | ||
| } | ||
|
|
||
| return (bool) preg_match( '#/(?:client-)?mu-plugins/[^/]+\.php$#', $path ); |
Collaborator
Author
There was a problem hiding this comment.
Not in any projects that I've worked on in the past 3–4 years, my inclination is to leave that one out as it's a confusing pattern
joehoyle
approved these changes
Jun 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I reviewed use of HMCS across a variety of VIP and Altis projects and noticed a recurring configuration in project PHPCS to disable the rules which prevent the use of single-file MU plugins, e.g. to drop a small
hm-thirdpartyplugin-integration.phpwhich simply registers a few hooks to customize third-party code and doesn't benefit practically from the more robust folder-based code structure.I believe this should be permitted by our standards, and this PR "paves the cowpath" by adjusting the ruleset to avoid false-flagging files like this from needing to be organized into
inc/namespaces, and to permit them to have side-effects.