WordPress.org

Make WordPress Core

Ticket #9152: 9152.patch

File 9152.patch, 1.4 KB (added by Viper007Bond, 6 years ago)
  • 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        $preview_theme_mods = get_option("mods_{$preview_theme_name}"); 
     874        if ( false === $preview_theme_mods ) 
     875                $preview_theme_mods = ''; 
     876        $current_theme = get_current_theme(); 
     877        add_filter( "pre_option_mods_{$current_theme}", create_function('', "return '{$preview_theme_mods}';") ); 
     878 
    866879        ob_start( 'preview_theme_ob_filter' ); 
    867880} 
    868881add_action('setup_theme', 'preview_theme');