Follow the WP Handbook Standard, and change The Loop of Core Themes to Use Brackets
|Reported by:||chriscct7||Owned by:|
|Component:||Bundled Theme||Keywords:||needs-codex has-patch|
This started as a discussion over a pull request to change the if-endif statements to brackets in the template files for Easy Digital Downloads. After lengthy discussion on that Github issue, and even more discussion in our dev chat, @pippinsplugins published a post about his beliefs on the matter.http://techcrunch.com/
The reason for this Trac ticket is to request the core's themes, which (to date) are 2010, 2011, 2012, and in 3.6 trunk, 2013, to use braces instead of if-endifs in The Loop.
At the very beginning, this may seem like a trivial matter. Instead it's far from it. This is actually a pretty deep rooted issue, caused by the ambiguity of the presence of endifs in Core, when combined with the discouragement from using them in the Codex.
The problem lies in that, (as Pippin's belief is) that most new WordPress devs first learn coding by studying their theme's loops files. For most users of WordPress, either their theme is one of the aforementioned core themes, or contains a loop based on one of them.
A plugin author, such as the EDD devs, then make template files for our plugins, which are intended to be edited by said users.
A good place to start, would be advantages to using braces over if-endif.
- Braces are fully supported by most IDEs. Most IDE's can find the corresponding open or close brace based on the highlighting of another one. Importantly, this includes IDE's that said new developers, might be more inclined to use, such as Dreamweaver, or similar. However, if-endifs are not supported in this manner, but in only a handful of IDE's.
- New developers will understand braces better than if-endif. Whether from their background in CSS (where braces contain rules), mathematics, or otherwise, braces are a symbol of a containing element. From Pippin's post, it also seems the vast majority of developers also prefer braces.
- It's shorter. Trivial maybe, but still slightly shorter.
- It's standard. The WordPress Code Handbook states to use braces. If braces are the standard, they should be used throughout core, and particularly not in important, more prominent areas like The Loop of core themes. Several other prominent open source projects follow the same guidelines (ex Drupal etc etc).
- Save users time learning both systems. Currently, if a user looks at The Loop, they learn endif. If they then proceed to other template files of core themes, or to plugin files, they then need to learn brackets. Making one way the Core's preferred method would cut the amount of time down for a new developer to learn the control logic (eliminate the need to learn endif).
The attached patch/diff replaces all if-endif usages with braces in 2010, 2011, 2012, and 2013.
Change History (26)
- Summary changed from Follow the Core Standard, and change The Loop of Core Themes to Use Brackets to Follow the WP Handbook Standard, and change The Loop of Core Themes to Use Brackets
comment:10 follow-ups: ↓ 11 ↓ 15 kovshenin — 9 months ago
comment:23 c3mdigital — 7 months ago
- Keywords dev-feedback removed
- Resolution set to wontfix
- Status changed from new to closed