[theme-reviewers] Need A Final Call

Otto otto at ottodestruct.com
Mon Jan 21 21:35:36 UTC 2013


After reviewing the code for a bit and looking at the possible
problems, I think that doing it the way the Twenty themes do it is
correct. That is to say, leave it outside a function scope and use
code like this:

if ( ! isset( $content_width ) )
	$content_width = 640;

Alternatively, this method is more clear about what is going on, by
explicitly stating that the value is global (even though a theme's
functions.php already runs in the global context, for now). Note that
theme-check probably doesn't recognize this as valid, yet.

if ( ! isset( $GLOBALS['content_width'] ) )
	$GLOBALS['content_width'] = 640;

Reasons:

- It is possible that a plugin which needs to know this information
will hook to after_setup_theme in order to find it out, because
after_setup_theme runs immediately after the theme's functions.php
file is executed. If the theme puts it in a function hooked to that
same action as well, then the theme's setup function may be called
after the plugin is called upon and looks for it. Relying on usual
hook priorities to get this order correct is uncertain, and best
avoided.

- A child can override a parent just fine if both child and parent
implement this in this way. The child runs first, sets the
content_width, then the parent runs, sees it's already set, and
doesn't change it.

I would treat this as a suggestion or best practice, it shouldn't fail
a theme for doing it differently.

-Otto


On Mon, Jan 21, 2013 at 3:14 PM, Chip Bennett <chip at chipbennett.net> wrote:
> That is absolutely not something that a Theme should be "not-approved" for,
> though.
>
>
> On Mon, Jan 21, 2013 at 4:10 PM, Philip M. Hofer (Frumph)
> <philip at frumph.net> wrote:
>>
>> By that ticket, the $content_width in twentytwelve would fail
>>
>>
>>
>> From: Caroline Moore
>> Sent: Monday, January 21, 2013 5:39 AM
>> To: theme-reviewers at lists.wordpress.org
>> Subject: Re: [theme-reviewers] Need A Final Call
>>
>> The ticket, for reference:
>> http://themes.trac.wordpress.org/ticket/10498
>>
>>
>> On Monday, January 21, 2013 at 8:34 AM, Qamar Ashraf wrote:
>>
>> 1. About $content_width
>>
>> What is the best place for the $content_width
>>
>> A. Wrap $content_width definition in a callback, hooked into
>> after_setup_theme - ( I am reviewing on this point )
>> B. Placing $content_width outside a function
>>
>> 2. About IE Conditional Tags / Scripts like HTML 5 Shiv
>>
>> A. - Additional scripts should not be hard-coded in the header template.
>> The most appropriate way to handle them to place it in a function that hooks
>> into wp_head. ( I am reviewing on this point )
>> B. Can be placed directly in header.php
>>
>>
>>
>> ________________________________
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>>
>> _______________________________________________
>> theme-reviewers mailing list
>> theme-reviewers at lists.wordpress.org
>> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>>
>
>
> _______________________________________________
> theme-reviewers mailing list
> theme-reviewers at lists.wordpress.org
> http://lists.wordpress.org/mailman/listinfo/theme-reviewers
>


More information about the theme-reviewers mailing list