如果插件使用custom-background
, 然后您可以轻松切换,更新"theme_mods_{$name}"
选项:
/** Plugin Name: (#64373) Custom background Color */
function wpse64373_set_custom_background( $new_colour )
{
$old_colour = get_theme_mod(
\'background_color\'
,get_theme_support( \'custom-background\', \'default-color\' )
);
// Nothing to do here
if ( $old_colour == $new_colour )
return;
return set_theme_mod( \'background_color\', $new_colour );
}
function wpse64373_update_custom_background()
{
// Not sure if we have to prepend a `#`
wpse64373_set_custom_background( \'009EE0\' );
}
add_action( \'init\', \'wpse64373_update_custom_background\' );