[wp-trac] [WordPress Trac] #25333: Can't remove theme support for certain custom header arguments

WordPress Trac noreply at wordpress.org
Mon Sep 16 18:10:17 UTC 2013


#25333: Can't remove theme support for certain custom header arguments
--------------------------+-----------------------------
 Reporter:  kovshenin     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:
 Severity:  normal        |   Keywords:  needs-patch
--------------------------+-----------------------------
 While working on a ticket I tried to `remove_theme_support` the `custom-
 header` feature and add it back with a different default image, which did
 not work. Removing theme support *does* remove the feature array from the
 features global, but adding anything back resurrects the old values
 ignoring the new ones for:

 * header-text
 * height and width
 * default-text-color
 * default-image

 This seems to be happening because of the back-compat code that works with
 the older constants. It defines the constants if they were not defined,
 and uses the values next time `add_theme_support` is called, bringing back
 the values from the first call to `add_theme_support`.

 The workaround would be to not use `remove_theme_support` and instead call
 `add_theme_support` with the needed values *before* the call you're trying
 to override, which was sort of intended for child themes, because they run
 earlier, so this issue is far from major, but still lame. Run this during
 theme setup to reproduce:

 {{{
 add_theme_support( 'custom-header', array( 'default-image' =>
 '%s/foo.png', ) );
 var_dump( get_theme_support( 'custom-header', 'default-image' ) ); //
 foo.png

 remove_theme_support( 'custom-header' );
 add_theme_support( 'custom-header', array( 'default-image' =>
 '%s/bar.png', ) );
 var_dump( get_theme_support( 'custom-header', 'default-image' ) ); //
 expected bar.png but got foo.png
 }}}

 Excuse my debugging skills ;)

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25333>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list