WordPress / WordPress/WordPress-Coding-Standards
Update needed to the WP global variables list
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
As discussed in https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/904#pullrequestreview-30382018, the list with WP global variables needs to be updated.
The list is currently used by two sniffs:
Variables.GlobalVariablesto check for overwriting WordPress native global variables.NamingConventions.PrefixAllGlobals- to verifies whether a prefix is needed for variables.
For the NamingConventions.PrefixAllGlobals sniff the list needs to be complete.
For the Variables.GlobalVariables we'll need to allow for a number of variables which plugins/themes are allowed to override.
we should probably have a small $overrule_allowed list in the Global Var Override sniff and do an array_diff() to prime the list for usage in that sniff.
@JDGrimes has created an initial diff between WP core and the list currently in WPCS which is a good starting point:
I've just checked over trunk and come up with a new list of WordPress globals, and there are some changes from the old list: https://www.diffchecker.com/jOhQZYHl
But take note of:
While searching for global and $GLOBALS gives us a good starting point, any variable created in the global namespace and not unset should be on the list.
Some more references about WP global vars (which may well be out of date):
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Variables.GlobalVariables and NamingConventions.PrefixAllGlobals sniffs, then compare their current WordPress global-variable list with the core globals and the initial diff linked in the issue. Done means the PrefixAllGlobals list is complete and GlobalVariables permits the documented override exceptions without false positives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100