Can't remove theme support for certain custom header arguments
|Reported by:||kovshenin||Owned by:|
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:
- height and width
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 ;)