[theme-reviewers] Something we need to check for 3.4 appearance -> background
Philip M. Hofer (Frumph)
philip at frumph.net
Mon Jun 11 19:07:38 UTC 2012
^ that makes things quite a bit more clear. (cais just told me the exact
same thing on skype ;/)
Thank you for that
still think, if a feature is not used, it should not be seen in the output.
-----Original Message-----
From: Otto
Sent: Monday, June 11, 2012 12:00 PM
To: theme-reviewers at lists.wordpress.org
Subject: Re: [theme-reviewers] Something we need to check for 3.4
appearance -> background
Yeah okay, in looking closer at this, I see that you might be confused
by the way add_theme_support works. I grant you that it is not
obvious.
The add_theme_support function can be called more than once for the
same item, with different arguments. The first call for a given
argument wins and overrides later calls. The reason for this is
specifically to allow children to override their parent's settings.
So say a parent does this:
add_action('after_setup_theme','parent_setup');
function parent_setup() {
add_theme_support( 'custom-background', array(
'default-color' => '000',
'default-image' => get_template_directory_uri() . '/images/background.jpg'
) );
}
Now, a child will do this:
add_action('after_setup_theme','child_setup');
function child_setup() {
add_theme_support( 'custom-background', array(
'default-image' => get_stylesheet_directory_uri() .
'/images/newbackground.jpg'
) );
}
Now, what happens?
Well, the child functions.php is included first. So it adds its own
action first, but nothing else happens yet.
Next, the parent's functions.php is included and it adds its action too.
After both of these have occurred, the after_setup_theme hook is
triggered, and the functions are executed. Since neither set a
priority, the child_setup runs first because it was added first. It
sets the custom-background with the default-image as
/images/newbackground.jpg (in the child directory, thanks to
get_stylesheet_directory_uri() ).
Then the parent runs. It sets the default-color to 000 and also tries
to set the default-image, but the default-image is already set, so
this argument is ignored by the add_theme_support function.
Thus, the child theme has overridden the default-image of the parent,
but notably it has *not* overridden the default-color. This allows for
granularity in the overrides that the child theme can do with regards
to the theme-support settings.
-Otto
_______________________________________________
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