Make WordPress Core

Ticket #27177: 27177.diff

File 27177.diff, 2.0 KB (added by obenland, 10 years ago)
  • src/wp-includes/default-filters.php

     
    215215add_action( 'wp_print_footer_scripts', '_wp_footer_scripts'                 );
    216216add_action( 'init',                'check_theme_switched',            99    );
    217217add_action( 'after_switch_theme',  '_wp_sidebars_changed'                   );
     218add_action( 'after_switch_theme',  '_maybe_inherit_theme_mods',       10, 2 );
    218219
    219220if ( isset( $_GET['replytocom'] ) )
    220221    add_action( 'wp_head', 'wp_no_robots' );
  • src/wp-includes/theme.php

     
    18911891}
    18921892
    18931893/**
     1894 * Updates the new theme with the theme mods of the old theme.
     1895 *
     1896 * @param string   $template Old theme name.
     1897 * @param WP_Theme $theme    WP_Theme instance of the old theme.
     1898 */
     1899function _maybe_inherit_theme_mods( $template, $theme = null ) {
     1900        // If the old theme exists, $template is the theme name.
     1901        if ( $template_exists = is_a( $theme, 'WP_Theme' ) ) {
     1902                $template = $theme->get_stylesheet();
     1903        }
     1904
     1905        // If the old theme is the new themes parent...
     1906        if ( wp_get_theme()->get_template() === $template ) {
     1907
     1908                // Check legacy theme mods if the old theme exists.
     1909                if ( false === ( $mods = get_option( "theme_mods_$template" ) ) && $template_exists ) {
     1910                        $theme_name = $theme->get( 'Name' );
     1911                        $mods = get_option( "mods_$theme_name" ); // Deprecated location.
     1912                }
     1913
     1914                // ...and it has theme mods, pass them on.
     1915                if ( false !== $mods ) {
     1916                        foreach ( (array) $mods as $name => $value ) {
     1917                                if ( 'sidebars_widgets' == $name ) {
     1918                                        continue;
     1919                                }
     1920                                set_theme_mod( $name, $value );
     1921                        }
     1922                }
     1923        }
     1924}
     1925
     1926/**
    18941927 * Includes and instantiates the WP_Customize_Manager class.
    18951928 *
    18961929 * Fires when ?wp_customize=on or on wp-admin/customize.php.