Make WordPress Core

Ticket #39537: 39537.diff

File 39537.diff, 1.3 KB (added by igmoweb, 8 years ago)

Patch

  • src/wp-includes/theme.php

     
    737737                                set_theme_mod( 'nav_menu_locations', $nav_menu_locations );
    738738                        }
    739739                }
     740
     741                $autoload_options = wp_cache_get( 'alloptions', 'options' );
     742                if ( ! is_array( $autoload_options ) ) {
     743                        $autoload_options = array();
     744                }
     745
     746                if ( ! in_array( "theme_mods_$stylesheet", $autoload_options ) ) {
     747                        // If the switched theme options are not autoload, update to autoload=yes
     748                        $theme_mods = get_option( "theme_mods_$stylesheet" );
     749                        delete_option( "theme_mods_$stylesheet" );
     750                        add_option( "theme_mods_$stylesheet", $theme_mods );
     751                }
    740752        }
    741753
    742754        update_option( 'theme_switched', $old_theme->get_stylesheet() );
    743755
     756        // Set autoload=no for the previous theme (delete and add the option again is needed for this purpose)
     757        $old_theme_stylesheet = $old_theme->get_stylesheet();
     758        $old_theme_mods = get_option( "theme_mods_$old_theme_stylesheet" );
     759        delete_option( "theme_mods_$old_theme_stylesheet" );
     760        add_option( "theme_mods_$old_theme_stylesheet", $old_theme_mods, null, 'no' );
     761
     762        // Reload autoload options
     763        wp_load_alloptions();
     764
    744765        /**
    745766         * Fires after the theme is switched.
    746767         *