Comments (11)
Looks like the subdirectory in TwentyTwenty is called parts
, i.e. not one of the whitelisted subdirectories.
Adding something along the lines of the below to the custom ruleset should solve this:
<rule ref="WPThemeReview.CoreFunctionality.PrefixAllGlobals">
<properties>
<property name="allowed_folders" type="array" extend="true">
<element value="parts"/>
</property>
</properties>
</rule>
from wpthemereview.
This is odd, as there is a list of allowed folders in the ruleset
So this should work out of the box if I'm not mistaken 🤔
Unless this needs to be re-set in the custom ruleset 🤷♂
Any info on this @jrfnl ?
from wpthemereview.
Oh, I did not know we had such exclusion. template-parts/page-header.php
was just an example. Actually this was reported in TwentyTwenty theme.
from wpthemereview.
from wpthemereview.
So this should work out of the box if I'm not mistaken
Unless this needs to be re-set in the custom ruleset
It should work out of the box.
Based on the remark by @joyously in WordPress/twentytwenty#111 (comment), I wonder if all templates files in subdirectories should be excluded ?
Note: this may not be feasible to do as PHPCS does not natively know what the root directory of a project is (and the sniff(s) may not be run from the root).
from wpthemereview.
I'll mention this to the twenty twenty team. Maybe they can just follow the standard practices and use template-parts
instead.
from wpthemereview.
I just noticed that it's not PrefixAllGlobals
that is triggered, but ReservedTemplatePrefix
sniff.
1 | ERROR | [ ] Template files should not be slug specific. The
| | file name used for this template will be
| | interpreted by WP as page-header and only applied
| | when a page with the slug "header" is loaded.
Should we add the same property to this sniff as well?
from wpthemereview.
@dingo-d Sounds like a good idea, but beware of what I said in #233 (comment)
from wpthemereview.
I guess this can be closed.
from wpthemereview.
Oh, I'd leave this open, because this is an issue with the sniff, we just need to be smart around how to attack this problem (given the comment that Juliette mentioned).
from wpthemereview.
@jrfnl Could we use <exclude-pattern>
with this sniff, so that if the file path is in one of the proposed patterns the sniff would be ignored (so that we don't care where the root of the project is)? Or should we just use some helper inside the sniff to check if the path of contains template-parts
, templates
, partials
or page-templates
?
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
- 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.