Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Move theme preview away from using create_function and to predefined …

…functions. See #10729 for 2.8 branch.

git-svn-id: http://svn.automattic.com/wordpress/branches/2.8@12070 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit 15d5dbd44b9a029cbc1a0f9a613e0e06dd43ee65 1 parent aeaafa3
westi authored

Showing 1 changed file with 20 additions and 2 deletions. Show diff stats Hide diff stats

  1. +20 2 wp-includes/theme.php
22 wp-includes/theme.php
@@ -875,13 +875,13 @@ function preview_theme() {
875 875 if ( validate_file($_GET['template']) )
876 876 return;
877 877
878   - add_filter( 'template', create_function('', "return '{$_GET['template']}';") );
  878 + add_filter( 'template', '_preview_theme_template_filter' );
879 879
880 880 if ( isset($_GET['stylesheet']) ) {
881 881 $_GET['stylesheet'] = preg_replace('|[^a-z0-9_./-]|i', '', $_GET['stylesheet']);
882 882 if ( validate_file($_GET['stylesheet']) )
883 883 return;
884   - add_filter( 'stylesheet', create_function('', "return '{$_GET['stylesheet']}';") );
  884 + add_filter( 'stylesheet', '_preview_theme_stylesheet_filter' );
885 885 }
886 886
887 887 // Prevent theme mods to current theme being used on theme being previewed
@@ -892,6 +892,24 @@ function preview_theme() {
892 892 add_action('setup_theme', 'preview_theme');
893 893
894 894 /**
  895 + * Private function to modify the current template when previewing a theme
  896 + *
  897 + * @return string
  898 + */
  899 +function _preview_theme_template_filter() {
  900 + return isset($_GET['template']) ? $_GET['template'] : '';
  901 +}
  902 +
  903 +/**
  904 + * Private function to modify the current stylesheet when previewing a theme
  905 + *
  906 + * @return string
  907 + */
  908 +function _preview_theme_stylesheet_filter() {
  909 + return isset($_GET['stylesheet']) ? $_GET['stylesheet'] : '';
  910 +}
  911 +
  912 +/**
895 913 * Callback function for ob_start() to capture all links in the theme.
896 914 *
897 915 * @since unknown

0 comments on commit 15d5dbd

Please sign in to comment.
Something went wrong with that request. Please try again.