Created
April 25, 2015 10:21
-
-
Save karpstrucking/ec8e7de6b6f570f38ab8 to your computer and use it in GitHub Desktop.
Copy parent theme's mods to child theme on activation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'after_switch_theme', 'gowp_copy_theme_mods' ); | |
function gowp_copy_theme_mods() { | |
$mods = get_theme_mods(); | |
if ( is_null( $mods ) || ( ( 1 == count( $mods ) ) && ! $mods[0] ) ) { | |
$parent = wp_get_theme()->get('Template'); | |
$child = basename( dirname( __FILE__ ) ); | |
update_option( "theme_mods_$child", get_option( "theme_mods_$parent" ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment