-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New sniff] Verify that wp_deregister_script() isn't called #21
Comments
See #26 |
@WPTRT/core Can you think of any reason why a them should be able able to deregister a script? I can' think of any. If we can't think of any we could change the sniff from a WARNING to an ERROR. |
There's definitely at least one reason. For example, a theme might want to run a custom media player on the front end. It could deregister or dequeue the core scripts and roll its own. I do this with styles and don't think it's a stretch to think that a theme could do it with the media player scripts. That's all I got at the moment. |
So is the answer to check for deregistering certain scripts? |
Definitely. We can stop themes from deregistering core WP scripts (can always dequeue in my example above). Themes must have the ability to deregister parent theme and/or plugin scripts. |
Should we include ALL scripts from https://developer.wordpress.org/reference/functions/wp_enqueue_script/#defaults or should a list be drawn up? |
I'd just include the most obvious problems in an error, which are probably The entire reason behind this came about because we had themes trying to deregister the core jQuery and register their own. So, the core of the problem is this:
Catch those two things and you've caught 99% of the problem. |
Updated PR does exactly this ^ |
From: #26 (comment)
The current PR #26 checks against Is there a decision that that's enough or are what we have currently opinions and does this still have to go to the Theme Review Board for definite approval ? /cc @grappler |
I think we're probably OK with this. If we need to add more, the code already looks like it's set up for just plugging in new script handles. |
The sniff for this exists: |
Rule:
WARNING : Themes must not deregister core scripts.
Ref: https://make.wordpress.org/themes/handbook/review/required/#stylesheets-and-scripts
This is basically meant to only check that core scripts aren't being deregistered, however maintaining a list of core scripts for that purpose would be a maintenance nightmare, so returning a warning when any such call is encountered is the current solution.
Theme check file covering this rule:
https://github.com/Otto42/theme-check/blob/master/checks/deregister.php
To do:
The text was updated successfully, but these errors were encountered: