Proposed WordPress 3.4 Guidelines Revisions
As we near the final release of WordPress 3.4, it is time to begin discussion and finalization of the related changes to the Theme Review Guidelines. Below are the proposed changes. Please discuss in the comments. We’ll do our best to keep this proposed list updated based on discussions in the comments.
New WordPress 3.4 Functionality
- Custom Headers/Backgrounds
- New and deprecated functions are already covered by existing Guidelines. Themes may OPTIONALLY provide backward-compatibility with pre-3.4 handling of custom backgrounds and headers
- Child Themes
- Child Themes will formally be allowed to be submitted for inclusion in the Theme repository.
- Child Themes are REQUIRED to use an approved Theme as a Template (i.e. as the Parent Theme)
- Child Themes are REQUIRED to demonstrate sufficient difference from the Parent Theme to warrant inclusion
- Stand-alone Themes are REQUIRED to provide basic Child-Theme support, including:
- Proper use of
get_template_directory()/get_template_directory_uri()vs.get_stylesheet_directory()/get_stylesheet_directory_uri() - Proper enqueueing of stylesheets, and proper cascading of styles, including no inline styles in the Theme template
- Proper use of
- Backward Compatibility
- Backward compatibility is covered by existing Guidelines. Per existing Guidelines (2 major WP versions required/1 major WP version recommended):
- Themes MUST NOT support backward-compatibility for more than two major WordPress versions (i.e. 3.2).
- Themes are RECOMMENDED NOT to support backward-compatibility for more than one major WordPress version (i.e. 3.3).
- Backward compatibility is covered by existing Guidelines. Per existing Guidelines (2 major WP versions required/1 major WP version recommended):
- Theme Settings and Data Security
- Themes are RECOMMENDED to incorporate Theme options into the WordPress core Theme customizer.
New Guidelines (REQUIRED)
- Required Hooks and Navigation
- Add to list of template tags REQUIRED where appropriate:
previous_image_link()/next_image_link()(or equivalent)
- Add to list of template tags REQUIRED where appropriate:
- Theme Features
- If implementing a site logo, Themes are REQUIRED to provide user-configuration of the logo via the core custom header feature. (Exception: if incorporating both a site logo and custom header, the custom header is required to support the core custom header feature, and the custom logo is then required to be implemented via custom Theme option.)
- Function Parameters, Filters, and Action Hooks
- Themes are REQUIRED to use function parameters, filters, and action hooks where appropriate in order to modify content, rather than hard-coding:
wp_title: Themes are REQUIRED to modify output viawp_titlefilter. (Refer to Codex note.)body_class()/post_class():- Themes are RECOMMENDED to modify output via filter
(body_class/post_class) - Themes may OPTIONALLY modify output via function parameter
(body_class( $class )/post_class( $class ))
- Themes are RECOMMENDED to modify output via filter
- Themes are REQUIRED to use function parameters, filters, and action hooks where appropriate in order to modify content, rather than hard-coding:
New Guidelines (RECOMMENDED)
- Code Quality
- Themes are RECOMMENDED to follow the official WordPress coding standards for all PHP code.
- Themes are RECOMMENDED to follow the official WordPress CSS coding standards for all CSS.
- Script Enqueueing
- Themes are RECOMMENDED to enqueue the comment-reply script at the
comment_form_beforehook
function theme_slug_enqueue_comment_reply_script() { if ( comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } add_action( 'comment_form_before', 'theme_slug_enqueue_comment_reply_script' );
- Themes are RECOMMENDED to enqueue the comment-reply script at the
Clarifications
Clarifications to existing guidelines being enforced:
- Presentation vs Functionality
- Themes are REQUIRED to function as stand-alone code. Themes may OPTIONALLY integrate support for third-party Plugins; however, Themes are REQUIRED to degrade gracefully and to function fully and properly without any such Plugins active.
Feedback
What else should be included? What should be revised? Let us know in the comments.
Andy Adams 4:36 pm on May 8, 2012 Permalink |
I’m not all too familiar with the .org theme repository requirements, so forgive me if I’m missing any background information. Thanks for all your work putting this together, Chip.
The piece that I would revise would be the requirement to use the core custom header feature for logos. Many of the themes we develop use logos that don’t span the full width of the page, so it’s technically incorrect to call it a “header”. It comes down to semantics, I suppose. But I don’t like using the word “header” when it doesn’t apply.
Chip Bennett 4:52 pm on May 8, 2012 Permalink |
And thus, the discussion.
The thought behind the requirement is two-fold: one, consistent UI is ideal for the end user, and two, with the advent of flexible headers, the core custom header feature becomes suitable for variable-sized logos.
Personally, I think I’d rather see core implement a “site logo” option, because a site logo is Theme-independent (much like the site favicon, title, description, etc.), and then provide a way for Themes to incorporate/support that core feature.
Greg Priday 4:59 pm on May 8, 2012 Permalink |
3.4 gives you a lot more control over the header size. So it doesn’t need to span the full width of the page. The nice thing about using WordPress’ header functionality is that (I assume) it’ll integrate with 3.4′s theme customizer. Pretty neat.
I agree though, I think using “headers” as logos might confuse a user. Say the user switches from one theme that uses the header as a header, to another theme that uses the header as a logo. That might not go down too well.
Having a site logo in the core would be a great solution but for now, maybe this requirement is a bit strict – given it’s essentially a hack.
Chip Bennett 5:04 pm on May 8, 2012 Permalink |
Which would be easier to migrate in the future, if a “site logo” eventually becomes a core option: a core custom header theme_mod, or a custom Theme option? I don’t know; maybe either one would be equally easy, or equally difficult.
Also, my thinking with using custom headers for the logo is that it might help differentiate the logo as a site option, rather than as a custom Theme option. But the question of end user confusion may very well be valid…
Devin Price 2:22 am on May 12, 2012 Permalink |
I agree. If core had a “logo” option, I would say go ahead and make it a requirement. But header implies something different.
Also, I assume themes that already have a logo option in their theme options would be required to change it, and that could be very confusing for users who update.
Konstantin 4:38 pm on May 8, 2012 Permalink |
Can we drop the requirement for the following, when loading a textdomain?
$locale = get_locale();
$locale_file = get_template_directory() . “/languages/$locale.php”;
if ( is_readable( $locale_file ) )
require_once( $locale_file );
See #20471
In the comment-reply example, the
comments_open()is not necessary (is it?), as it is called just prior to the'comment_form_before'action.Chip Bennett 4:49 pm on May 8, 2012 Permalink |
Are you referencing the right Trac ticket? At first glance, it doesn’t appear relevant to loading a textdomain.
And you’re right:
comments_open()is likely redundant in the example.Konstantin Obenland 4:52 pm on May 8, 2012 Permalink |
No I don’t, it’s supposed to be: http://core.trac.wordpress.org/changeset/20471
Chip Bennett 4:53 pm on May 8, 2012 Permalink |
Ah, there it is.
So, that bit is not actually required in order to load the locale file?
Konstantin Obenland 4:55 pm on May 8, 2012 Permalink
Not AFAIK. I’ve never seen locale files with the filetype being PHP…
Michael Fields 6:31 pm on May 8, 2012 Permalink |
I spoke with Nacin regarding this over Skype and he explained that this code is not really necessary and that core would be moving away from loading .php files for i18n. It was also removed from Twenty Ten r20473, Twenty Twelve r19844. After seeing these changesets we removed it from _s as well.
Chip Bennett 6:52 pm on May 8, 2012 Permalink |
Great! Less code FTW.
Chip Bennett 6:57 pm on May 8, 2012 Permalink |
So, where, exactly, are we actually requiring use of that code?
Michael Fields 7:40 pm on May 8, 2012 Permalink |
I’m not sure, I just checked the docs and did not notice it as a requirement anywhere.
Konstantin Obenland 5:42 am on May 9, 2012 Permalink |
We don’t explicitly. I suspect this falls under the “if you do it, do it right” approach we have towards i18n. But if you look for it in tickets, there are a few: http://themes.trac.wordpress.org/search?q=if+%28+is_readable%28+%24locale_file+%29+%29
Chip Bennett 6:42 pm on May 9, 2012 Permalink |
I would probably chalk that up to a case of following the example of core-bundled Themes…
Andrew Nacin 5:00 am on May 10, 2012 Permalink |
There’s no reason at all for this code in a theme, ever.
Rico Neitzel 6:34 am on June 14, 2012 Permalink |
Hey Guys,
dropping that would be bad for some german implementations. we’re using that file to rewrite permalinks for german sites… we don’t want to use a plugin as this setting is theme related and not system wide.
so removing that might raise an issue for us
Best,
Rico
Chip Bennett 12:34 pm on June 14, 2012 Permalink |
If it works for you, keep using it. What we’ve done, though, is dropped it as a requirement. Generally speaking, a Theme is only required to
load_theme_textdomain().Middlesister 12:52 pm on June 16, 2012 Permalink |
But if theme’s are not required to include a $locale.php, how would languages that need/utilize them be able to localize said theme properly?
For example greek: http://themeshaper.com/forums/topic/thematic-in-greek
What has changed that makes these files unneccessary?
Chip Bennett 2:00 pm on June 16, 2012 Permalink
In most cases,
load_theme_textdomain( $textdomain, get_template_directory() . '/languages' );will suffice. Just drop the language files, named appropriately (e.g. en_US.mo and en_US.po) in the /languages sub-folder inside the Theme, and WordPress will use them.If you still need to use $locale.php, then feel free to do so. We’re just no longer going to require that it be used.
ravi 4:45 pm on May 8, 2012 Permalink |
The section on “backward compatibility” is a bit confusing (to me): 2 major WP versions REQUIRED, 1 major WP version RECOMMENDED. That seems contradictory.
Chip Bennett 4:50 pm on May 8, 2012 Permalink |
Themes are required NOT to provide backward compatibility beyond two major WordPress versions, and they are recommended NOT to provide backward compatibility beyond one major WordPress version. The ideal is no backward compatibility at all, but that ideal simply isn’t practical.