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

WordPress Trac noreply at wordpress.org
Fri Feb 21 21:03:38 UTC 2014


#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:  Appearance   |     Version:  3.8
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  administration
-------------------------+------------------------------

Comment (by westonruter):

 Right, so this is due to these specific customizer settings being stored
 in theme mods, as opposed to theme-independent options.

 Replying to [comment:3 nacin]:
 > The customizer simply uses whatever storage the theme declares. If
 they're using an option, then it depends on how the theme keys its options
 (`get_template() . '_options'` versus `my_theme_options` versus
 `get_stylesheet() . '_options', for example). For theme mods, they are
 particular to get_stylesheet(), so a child theme does indeed have its own
 set of options.
 >
 > Perhaps a child theme could say "Yes, please inherit the theme mods from
 the parent" but it's tough to make this uniform, especially at the
 customizer level.

 There could be a API function for child themes to opt-in to use the parent
 theme's theme mods instead of the child themes. This could be implemented
 via filtering, something like this (untested):

 {{{
 #!php
 if ( get_stylesheet() !== get_template() ) {
     add_filter( 'pre_update_option_theme_mods_' . get_stylesheet(),
 function ( $value, $old_value ) {
          update_option( 'theme_mods_' . get_template(), $value );
          return $old_value; // prevent update to child theme mods
     }, 10, 2 );
     add_filter( 'pre_option_theme_mods_' . get_stylesheet(), function (
 $default ) {
         return get_option( 'theme_mods_' . get_template(), $default );
     } );
 }
 }}}

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


More information about the wp-trac mailing list