Changeset 20496
- Timestamp:
- 04/17/2012 09:43:47 PM (13 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
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 -
trunk/wp-includes/customize-controls.php
r20495 r20496 28 28 do_action( 'customize_controls_enqueue_scripts' ); 29 29 30 $theme = wp_get_theme();31 $screenshot = $theme->get_screenshot();32 33 30 // Let's roll. 34 31 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); … … 37 34 _wp_admin_html_begin(); 38 35 39 $admin_title = sprintf( __( '%1$s — WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $th eme['Name']) ) );36 $admin_title = sprintf( __( '%1$s — WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $this->theme->display('Name') ) ) ); 40 37 ?><title><?php echo $admin_title; ?></title><?php 41 38 … … 48 45 <?php wp_nonce_field( 'customize_controls' ); ?> 49 46 <input type="hidden" name="customize" value="on" /> 50 <input type="hidden" id="customize-template" name="template" value="<?php echo esc_attr( $theme['Template'] ); ?>" /> 51 <input type="hidden" id="customize-stylesheet" name="stylesheet" value="<?php echo esc_attr( $theme['Stylesheet'] ); ?>" /> 52 47 <input type="hidden" name="theme" value="<?php echo esc_attr( $this->get_stylesheet() ); ?>" /> 53 48 <div id="customize-header-actions" class="customize-section wp-full-overlay-header"> 54 49 <a class="back" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>"> … … 60 55 <div class="customize-section-title"> 61 56 <span class="preview-notice"><?php _e('You are previewing'); ?></span> 62 <strong class="theme-name"><?php echo $th eme['Name']; ?></strong>57 <strong class="theme-name"><?php echo $this->theme->display('Name'); ?></strong> 63 58 </div> 64 59 <div class="customize-section-content"> 65 <?php if ( $screenshot ) : ?>60 <?php if ( $screenshot = $this->theme->get_screenshot() ) : ?> 66 61 <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" /> 67 62 <?php endif; ?> 68 63 69 <?php if ( $th eme->description): ?>70 <div class="theme-description"><?php echo $th eme->description; ?></div>64 <?php if ( $this->theme->get('Description') ): ?> 65 <div class="theme-description"><?php echo $this->theme->display('Description'); ?></div> 71 66 <?php endif; ?> 72 67 </div> -
trunk/wp-includes/theme.php
r20488 r20496 1602 1602 */ 1603 1603 function wp_customize_url( $stylesheet, $template ) { 1604 return esc_url( admin_url( 'admin.php' ) . '?customize=on&t emplate=' . $template . '&stylesheet=' . $stylesheet );1605 } 1604 return esc_url( admin_url( 'admin.php' ) . '?customize=on&theme=' . $stylesheet ); 1605 }
Note: See TracChangeset
for help on using the changeset viewer.