Changeset 20496 for trunk/wp-includes/class-wp-customize.php
- Timestamp:
- 04/17/2012 09:43:47 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/class-wp-customize.php (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-customize.php
r20495 r20496 9 9 10 10 final class WP_Customize { 11 protected $template; 12 protected $stylesheet; 13 protected $original_template; 11 protected $theme; 14 12 protected $original_stylesheet; 15 13 … … 30 28 require( ABSPATH . WPINC . '/class-wp-customize-control.php' ); 31 29 32 add_action( 'setup_theme', array( $this, ' setup_theme' ) );30 add_action( 'setup_theme', array( $this, 'customize_previewing' ) ); 33 31 add_action( 'admin_init', array( $this, 'admin_init' ) ); 34 32 add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); 35 33 36 add_action( 'customize_previewing', array( $this, 'customize_previewing' ) );37 34 add_action( 'customize_register', array( $this, 'register_controls' ) ); 38 35 add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) ); … … 60 57 /** 61 58 * Start preview and customize theme. 62 * Check if customize query variable exist. 63 * 64 * @since 3.4.0 65 */ 66 public function setup_theme() { 59 * 60 * Check if customize query variable exist. Init filters to filter the current theme. 61 * 62 * @since 3.4.0 63 */ 64 public function customize_previewing() { 67 65 if ( ! isset( $_REQUEST['customize'] ) || 'on' != $_REQUEST['customize'] ) 68 66 return; 69 67 70 if ( ! $this->set_ stylesheet() || isset( $_REQUEST['save_customize_controls'] ) )68 if ( ! $this->set_theme() || isset( $_REQUEST['save_customize_controls'] ) ) 71 69 return; 72 70 73 71 $this->previewing = true; 74 do_action( 'customize_previewing' );75 }76 77 /**78 * Init filters to filter theme options.79 *80 * @since 3.4.081 */82 public function customize_previewing() {83 global $wp_theme_directories;84 72 85 73 show_admin_bar( false ); 86 74 87 $this->original_template = get_template();88 75 $this->original_stylesheet = get_stylesheet(); 89 76 … … 97 84 98 85 // Handle custom theme roots. 99 if ( count( $wp_theme_directories ) > 1 ) {100 add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );101 add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); 102 }86 add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); 87 add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); 88 89 do_action( 'customize_previewing' ); 103 90 } 104 91 … … 174 161 175 162 /** 176 * Set the template name of the previewed theme.177 *178 * @since 3.4.0179 *180 * @return bool|string Template name.181 */182 public function set_template() {183 if ( ! empty( $this->template ) )184 return $this->template;185 186 $template = preg_replace('|[^a-z0-9_./-]|i', '', $_REQUEST['template'] );187 if ( validate_file( $template ) )188 return false;189 190 return $this->template = $template;191 }192 193 /**194 163 * Set the stylesheet name of the previewed theme. 195 164 * … … 198 167 * @return bool|string Stylesheet name. 199 168 */ 200 public function set_stylesheet() { 201 if ( ! empty( $this->stylesheet ) ) 202 return $this->stylesheet; 203 204 $this->set_template(); 205 if ( empty( $this->template ) ) 206 return false; 207 208 if ( empty( $_REQUEST['stylesheet'] ) ) { 209 $stylesheet = $this->template; 210 } else { 211 $stylesheet = preg_replace( '|[^a-z0-9_./-]|i', '', $_REQUEST['stylesheet'] ); 212 if ( $stylesheet != $this->template && validate_file( $stylesheet ) ) 213 return false; 214 } 215 return $this->stylesheet = $stylesheet; 216 169 public function set_theme() { 170 if ( isset( $this->theme ) ) 171 return $this->theme; 172 173 $this->theme = wp_get_theme( $_REQUEST['theme'] ); 174 if ( ! $this->theme->exists() ) 175 $this->theme = false; 176 177 return $this->theme; 217 178 } 218 179 … … 225 186 */ 226 187 public function get_template() { 227 return $this->t emplate;188 return $this->theme->get_template(); 228 189 } 229 190 … … 236 197 */ 237 198 public function get_stylesheet() { 238 return $this-> stylesheet;199 return $this->theme->get_stylesheet(); 239 200 } 240 201 … … 247 208 */ 248 209 public function get_template_root() { 249 return get_raw_theme_root( $this-> template, true );210 return get_raw_theme_root( $this->get_template(), true ); 250 211 } 251 212 … … 258 219 */ 259 220 public function get_stylesheet_root() { 260 return get_raw_theme_root( $this-> stylesheet, true );221 return get_raw_theme_root( $this->get_stylesheet(), true ); 261 222 } 262 223 … … 269 230 */ 270 231 public function current_theme( $current_theme ) { 271 return wp_get_theme( $this->stylesheet )->get('Name');232 return $this->theme->display('Name'); 272 233 } 273 234 … … 287 248 return; 288 249 250 if ( empty( $_GET['theme'] ) ) 251 return; 252 289 253 if ( ! $this->is_preview() ) 290 254 return; … … 309 273 check_admin_referer( 'customize_controls' ); 310 274 311 if ( ! $this->set_ stylesheet() )275 if ( ! $this->set_theme() ) 312 276 return; 313 277
Note: See TracChangeset
for help on using the changeset viewer.