[wp-trac] [WordPress Trac] #27177: Child themes should inherit parent theme customizer settings on activation / switching

WordPress Trac noreply at wordpress.org
Wed Nov 4 23:42:30 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 yitwail):

 Replying to [comment:14 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 );
 >                       }
 >               }
 >       }
 > }
 > }}}

 Thanks for this code snippet. It seems to work fine, although I think
 'switch_theme' should be changed to 'after_switch_theme'. Also, I'm not
 sure why you want to exclude 'sidebars_widgets'.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27177#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list