WordPress.org

Make WordPress Core

Ticket #9152: 9152.2.patch

File 9152.2.patch, 1.4 KB (added by Viper007Bond, 6 years ago)

Previous patch wasn't properly returning mod options for theme being previewed, now it does

  • wp-includes/theme.php

     
    854854        if ( validate_file($_GET['template']) ) 
    855855                return; 
    856856 
    857         add_filter('template', create_function('', "return '{$_GET['template']}';") ); 
     857        add_filter( 'template', create_function('', "return '{$_GET['template']}';") ); 
    858858 
     859        $preview_theme_path = $_GET['template']; 
     860 
    859861        if ( isset($_GET['stylesheet']) ) { 
    860862                $_GET['stylesheet'] = preg_replace('|[^a-z0-9_.-/]|i', '', $_GET['stylesheet']); 
    861863                if ( validate_file($_GET['stylesheet']) ) 
    862864                        return; 
    863                 add_filter('stylesheet', create_function('', "return '{$_GET['stylesheet']}';") ); 
     865                add_filter( 'stylesheet', create_function('', "return '{$_GET['stylesheet']}';") ); 
     866 
     867                $preview_theme_path = $_GET['stylesheet']; 
    864868        } 
    865869 
     870        // Prevent theme mods to current theme being used on theme being previewed 
     871        $preview_theme = get_theme_data( WP_CONTENT_DIR . "/themes/$preview_theme_path/style.css" ); 
     872        $preview_theme_name = $preview_theme['Name']; 
     873        $current_theme = get_current_theme(); 
     874        if ( $current_theme !== $preview_theme_name ) 
     875                add_filter( "pre_option_mods_{$current_theme}", create_function('', "return get_option(\"mods_{$preview_theme_name}\");") ); 
     876 
    866877        ob_start( 'preview_theme_ob_filter' ); 
    867878} 
    868879add_action('setup_theme', 'preview_theme');