[wp-trac] [WordPress Trac] #27177: Child themes should inherit parent theme customizer settings on activation / switching
WordPress Trac
noreply at wordpress.org
Wed Jun 17 20:55:15 UTC 2015
#27177: Child themes should inherit parent theme customizer settings on activation
/ switching
-------------------------+------------------------------
Reporter: krogsgard | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: 3.8
Severity: normal | Resolution:
Keywords: | Focuses: administration
-------------------------+------------------------------
Comment (by greenshady):
As I really dislike the idea of the initial proposal making it into core
(it'll break several of my child themes and probably others that have been
using theme mods for years), I've been thinking of a possible solution for
theme authors who want to opt-into this functionality.
Here's a quick bit of code that I was thinking about for theme authors.
It may need some tweaking (untested).
{{{
add_action( 'switch_theme', 'jt_switch_theme_update_mods' );
function jt_switch_theme_update_mods() {
if ( is_child_theme() && false === get_theme_mods() ) {
$mods = get_option( 'theme_mods_' . get_option( 'template'
) );
if ( false !== $mods ) {
foreach ( (array) $mods as $mod => $value ) {
if ( 'sidebars_widgets' !== $mod )
set_theme_mod( $mod, $value );
}
}
}
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27177#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list