Comments (11)
I'd just include the most obvious problems in an error, which are probably jquery
(and maybe masonry
). I don't think I've seen a theme attempt to deregister anything else.
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:
wp_deregister_script( 'jquery'
wp_register_script( 'jquery'
Catch those two things and you've caught 99% of the problem.
from wpthemereview.
@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.
from wpthemereview.
See #26
from wpthemereview.
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.
from wpthemereview.
So is the answer to check for deregistering certain scripts?
from wpthemereview.
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.
from wpthemereview.
Should we include ALL scripts from https://developer.wordpress.org/reference/functions/wp_enqueue_script/#defaults or should a list be drawn up?
from wpthemereview.
Updated PR does exactly this ^
from wpthemereview.
From: #26 (comment)
Just a thought: what about keeping this list in line with the scripts WP core protects itself against from being deregistered on the admin side ?
The list can be found in the code of this function: https://developer.wordpress.org/reference/functions/wp_deregister_script/
The current PR #26 checks against jquery
and is about ready for merge consideration.
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
from wpthemereview.
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.
from wpthemereview.
The sniff for this exists: NoDeregisterCoreScript
. If this is correct @jrfnl can you close this issue?
from wpthemereview.
Related Issues (20)
- variables in template files are flagged as global HOT 15
- Exceptions to prefixing hook names HOT 7
- False positive on loading stylesheet in JS file HOT 4
- [New sniff] WC template versions HOT 7
- Dealing with rules that shouldn't apply to templates HOT 1
- Add sniff: WordPress.PHP.IniSet HOT 6
- [New sniff] Check if page templates are using reserved prefix HOT 1
- Detect WPTRT feature project versions HOT 3
- Add sniff documentation HOT 1
- Minimal PHP version HOT 11
- Whitelist wp_body_open function from PrefixAllGlobals sniff HOT 5
- sniff: plugin territory - action hook wp_edit_nav_menu_walker
- File name with reserved slug in subfolder HOT 11
- Optimisation and minor grammar fixes
- [Implement sniff] Warn about short ternary usage in themes HOT 9
- Internal.Exception -- function update_current_version() should be removed.
- [Update existing sniff] Allow register_block_style HOT 1
- Allow `add_menu_page` & `add_submenu_page` HOT 9
- twentyseventeen theme: posts with no date - but date is shown in similar posts HOT 1
- 👍
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wpthemereview.