WordPress / WordPress/WordPress-Coding-Standards
Extra: Sniff to check for overruling of WP included scripts
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
WP ships with a number of scrips by default. If a theme or plugin wants to use one of those scripts they should use the version included with WP and not ship their own version.
Ref: https://developer.wordpress.org/reference/functions/wp_register_script/#core-registered-scripts
While this will never be something for which we can get a 100% detection - as people can rename the script files and use arbitrary handle names -, should we try to detect if a theme/plugin tries to enqueue their own script instead of the WP version ?
I imagine we could sniff the function parameters of the wp_enqueue_scripts function and:
- throw an error if one of the reserved
handles is used in combination with a value for thescrparameter - throw a warning if the filename in the
scrparameter closely resembles the expected filename of one of the scripts WP ships with.
Additionally we could throw a warning if a deps parameter with one of the default values for a reserved handle is found as there is no need to register that dependency (already done by WP core).
Opinions ?
I imagine that the Theme Review theme and the VIP theme might be interested in including such a sniff as well ? /cc @grappler @sboisvert @david-binda
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
Review the WordPress core-registered-scripts reference and the wp_enqueue_scripts parameters described in the issue first. Define the detection scope and expected error or warning behavior for reserved handles, similar filenames, and redundant dependencies; done means the agreed sniff behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100