David, that boils down to the same approach as I use in my child theme… Only I do not use that neat and clever cms_theme_headers function you did to automate register_default_headers. Do you do that so users can throw in new images which will then be auto-detected? But what after a theme update? Won’t these be overwritten again? Or do you use it for your own convenience? But then, that function will run on each server request so does it not create unnecessary load?
Anyway, what I had so far is
define('MY_CHILD_THEME_URL', get_theme_root_uri() . "/" . basename(dirname(__FILE__)) );
add_filter( 'twentyten_header_image_width', 'my_child_theme_header_image_width' );
add_filter( 'twentyten_header_image_height', 'my_child_theme_header_image_height' );
function my_child_theme_header_image_width () {
return 548;
}
function my_child_theme_header_image_height () {
return 40;
}
add_action( 'after_setup_theme', 'my_child_theme_setup_0', 0 );
function my_child_theme_setup_0 () {
define( 'HEADER_IMAGE', MY_CHILD_THEME_URL . '/images/headers/newimage.jpg' );
}
add_action( 'after_setup_theme', 'ana_lagragna_theme_setup_99', 99 );
function ana_lagragna_theme_setup_99 () {
register_default_headers( array(
'newname' => array(
'url' => MY_CHILD_THEME_URL . '/images/headers/newimage.jpg',
'thumbnail_url' => MY_CHILD_THEME_URL . '/images/headers/newimage-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'New Name', 'twentyten' )
),
'anothername' => array(
'url' => MY_CHILD_THEME_URL . '/images/headers/anotherimage.jpg',
'thumbnail_url' => MY_CHILD_THEME_URL . '/images/headers/anotherimage-thumbnail.jpg',
/* translators: header image description */
'description' => __( 'Another Name', 'twentyten' )
),
) );
unregister_default_headers( array(
'berries',
'cherryblossom',
'concave',
'fern',
'forestfloor',
'inkwell',
'path',
'sunset'
) );
}
but I suppose you are right about the define(‘HEADER_IMAGE’, … ) not having to be inside a after_setup_theme call. It can just be defined nude. And for the deregister to work, you do indeed have to call it AFTER the parent theme has done, so 11 or higher ??
The only concern I had left is that PHP will throw that Notice error the moment the parent theme will try to define HEADER_IMAGE again. I suppose it depends on your server setup whether you get to see that notice (in log file) or not… At any rate, I suppose – since it is not a Warning or Fatal Error – it will not be a show stopper on any setup.
Or will it?