[wp-trac] [WordPress Trac] #24549: Follow the Core Standard, and change The Loop of Core Themes to Use Brackets
WordPress Trac
noreply at wordpress.org
Mon Jun 10 04:32:26 UTC 2013
#24549: Follow the Core Standard, and change The Loop of Core Themes to Use
Brackets
-------------------------+------------------------------------------------
Reporter: chriscct7 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Template | Version: trunk
Severity: normal | Keywords: dev-feedback 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 [https://github.com/easydigitaldownloads
/Easy-Digital-Downloads/pull/1194 Github issue], and even more discussion
in our dev chat, @pippinsplugins published [http://pippinsplugins.com
/please-do-not-use-curly-brackets-in-template-files/ 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 [http://make.wordpress.org/core/handbook/coding-
standards/php/#brace-style 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 [https://drupal.org/node/318 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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24549>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list