<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[20496] trunk/wp-includes: Move to admin.php?customize=on&theme=$stylesheet, rather than juggling both template and stylesheet values.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/20496">20496</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-04-17 21:43:47 +0000 (Tue, 17 Apr 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move to admin.php?customize=on&theme=$stylesheet, rather than juggling both template and stylesheet values. see <a href="http://core.trac.wordpress.org/ticket/19910">#19910</a>.
Combine the setup_theme() and customize_previewing() methods. Remove the set_template() and set_stylesheet() methods. Add set_theme() method to WP_Customize to store the working WP_Theme object. We will use this for the stylesheet and template.
Use the WP_Theme display() method when preparing headers for display, not get() or the deprecate properties.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesclasswpcustomizephp">trunk/wp-includes/class-wp-customize.php</a></li>
<li><a href="#trunkwpincludescustomizecontrolsphp">trunk/wp-includes/customize-controls.php</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesclasswpcustomizephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-wp-customize.php (20495 => 20496)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize.php        2012-04-17 20:49:39 UTC (rev 20495)
+++ trunk/wp-includes/class-wp-customize.php        2012-04-17 21:43:47 UTC (rev 20496)
</span><span class="lines">@@ -8,9 +8,7 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> final class WP_Customize {
</span><del>-        protected $template;
-        protected $stylesheet;
-        protected $original_template;
</del><ins>+        protected $theme;
</ins><span class="cx">         protected $original_stylesheet;
</span><span class="cx">
</span><span class="cx">         protected $previewing = false;
</span><span class="lines">@@ -29,11 +27,10 @@
</span><span class="cx">                 require( ABSPATH . WPINC . '/class-wp-customize-section.php' );
</span><span class="cx">                 require( ABSPATH . WPINC . '/class-wp-customize-control.php' );
</span><span class="cx">
</span><del>-                add_action( 'setup_theme', array( $this, 'setup_theme' ) );
</del><ins>+                add_action( 'setup_theme', array( $this, 'customize_previewing' ) );
</ins><span class="cx">                 add_action( 'admin_init', array( $this, 'admin_init' ) );
</span><span class="cx">                 add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
</span><span class="cx">
</span><del>-                add_action( 'customize_previewing', array( $this, 'customize_previewing' ) );
</del><span class="cx">                 add_action( 'customize_register', array( $this, 'register_controls' ) );
</span><span class="cx">                 add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) );
</span><span class="cx">                 add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );
</span><span class="lines">@@ -59,32 +56,22 @@
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="cx">          * Start preview and customize theme.
</span><del>-         * Check if customize query variable exist.
</del><span class="cx">          *
</span><ins>+         * Check if customize query variable exist. Init filters to filter the current theme.
+         *
</ins><span class="cx">          * @since 3.4.0
</span><span class="cx">          */
</span><del>-        public function setup_theme() {
</del><ins>+        public function customize_previewing() {
</ins><span class="cx">                 if ( ! isset( $_REQUEST['customize'] ) || 'on' != $_REQUEST['customize'] )
</span><span class="cx">                         return;
</span><span class="cx">
</span><del>-                if ( ! $this->set_stylesheet() || isset( $_REQUEST['save_customize_controls'] ) )
</del><ins>+                if ( ! $this->set_theme() || isset( $_REQUEST['save_customize_controls'] ) )
</ins><span class="cx">                         return;
</span><span class="cx">
</span><span class="cx">                 $this->previewing = true;
</span><del>-                do_action( 'customize_previewing' );
-        }
</del><span class="cx">
</span><del>-        /**
-         * Init filters to filter theme options.
-         *
-         * @since 3.4.0
-         */
-        public function customize_previewing() {
-                global $wp_theme_directories;
-
</del><span class="cx">                 show_admin_bar( false );
</span><span class="cx">
</span><del>-                $this->original_template = get_template();
</del><span class="cx">                 $this->original_stylesheet = get_stylesheet();
</span><span class="cx">
</span><span class="cx">                 add_filter( 'template', array( $this, 'get_template' ) );
</span><span class="lines">@@ -96,10 +83,10 @@
</span><span class="cx">                 add_filter( 'pre_option_template', array( $this, 'get_template' ) );
</span><span class="cx">
</span><span class="cx">                 // Handle custom theme roots.
</span><del>-                if ( count( $wp_theme_directories ) > 1 ) {
-                        add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
-                        add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
-                }
</del><ins>+                add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
+                add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
+
+                do_action( 'customize_previewing' );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -173,47 +160,21 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><del>-         * Set the template name of the previewed theme.
-         *
-         * @since 3.4.0
-         *
-         * @return bool|string Template name.
-         */
-        public function set_template() {
-                if ( ! empty( $this->template ) )
-                        return $this->template;
-
-                $template = preg_replace('|[^a-z0-9_./-]|i', '', $_REQUEST['template'] );
-                if ( validate_file( $template ) )
-                        return false;
-
-                return $this->template = $template;
-        }
-
-        /**
</del><span class="cx">          * Set the stylesheet name of the previewed theme.
</span><span class="cx">          *
</span><span class="cx">          * @since 3.4.0
</span><span class="cx">          *
</span><span class="cx">          * @return bool|string Stylesheet name.
</span><span class="cx">          */
</span><del>-        public function set_stylesheet() {
-                if ( ! empty( $this->stylesheet ) )
-                        return $this->stylesheet;
</del><ins>+        public function set_theme() {
+                if ( isset( $this->theme ) )
+                        return $this->theme;
</ins><span class="cx">
</span><del>-                $this->set_template();
-                if ( empty( $this->template ) )
-                        return false;
</del><ins>+                $this->theme = wp_get_theme( $_REQUEST['theme'] );
+                if ( ! $this->theme->exists() )
+                        $this->theme = false;
</ins><span class="cx">
</span><del>-                if ( empty( $_REQUEST['stylesheet'] ) ) {
-                        $stylesheet = $this->template;
-                } else {
-                        $stylesheet = preg_replace( '|[^a-z0-9_./-]|i', '', $_REQUEST['stylesheet'] );
-                        if ( $stylesheet != $this->template && validate_file( $stylesheet ) )
-                                return false;
-                }
-                return $this->stylesheet = $stylesheet;
-
</del><ins>+                return $this->theme;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -224,7 +185,7 @@
</span><span class="cx">          * @return string Template name.
</span><span class="cx">          */
</span><span class="cx">         public function get_template() {
</span><del>-                return $this->template;
</del><ins>+                return $this->theme->get_template();
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -235,7 +196,7 @@
</span><span class="cx">          * @return string Stylesheet name.
</span><span class="cx">          */
</span><span class="cx">         public function get_stylesheet() {
</span><del>-                return $this->stylesheet;
</del><ins>+                return $this->theme->get_stylesheet();
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -246,7 +207,7 @@
</span><span class="cx">          * @return string Theme root.
</span><span class="cx">          */
</span><span class="cx">         public function get_template_root() {
</span><del>-                return get_raw_theme_root( $this->template, true );
</del><ins>+                return get_raw_theme_root( $this->get_template(), true );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -257,7 +218,7 @@
</span><span class="cx">          * @return string Theme root.
</span><span class="cx">          */
</span><span class="cx">         public function get_stylesheet_root() {
</span><del>-                return get_raw_theme_root( $this->stylesheet, true );
</del><ins>+                return get_raw_theme_root( $this->get_stylesheet(), true );
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -268,7 +229,7 @@
</span><span class="cx">          * @return string Theme name.
</span><span class="cx">          */
</span><span class="cx">         public function current_theme( $current_theme ) {
</span><del>-                return wp_get_theme( $this->stylesheet )->get('Name');
</del><ins>+                return $this->theme->display('Name');
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /**
</span><span class="lines">@@ -286,6 +247,9 @@
</span><span class="cx">                 if ( ! isset( $_GET['customize'] ) || 'on' != $_GET['customize'] )
</span><span class="cx">                         return;
</span><span class="cx">
</span><ins>+                if ( empty( $_GET['theme'] ) )
+                        return;
+
</ins><span class="cx">                 if ( ! $this->is_preview() )
</span><span class="cx">                         return;
</span><span class="cx">
</span><span class="lines">@@ -308,7 +272,7 @@
</span><span class="cx">
</span><span class="cx">                 check_admin_referer( 'customize_controls' );
</span><span class="cx">
</span><del>-                if ( ! $this->set_stylesheet() )
</del><ins>+                if ( ! $this->set_theme() )
</ins><span class="cx">                         return;
</span><span class="cx">
</span><span class="cx">                 $active_template = get_template();
</span></span></pre></div>
<a id="trunkwpincludescustomizecontrolsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/customize-controls.php (20495 => 20496)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/customize-controls.php        2012-04-17 20:49:39 UTC (rev 20495)
+++ trunk/wp-includes/customize-controls.php        2012-04-17 21:43:47 UTC (rev 20496)
</span><span class="lines">@@ -27,16 +27,13 @@
</span><span class="cx">
</span><span class="cx"> do_action( 'customize_controls_enqueue_scripts' );
</span><span class="cx">
</span><del>-$theme = wp_get_theme();
-$screenshot = $theme->get_screenshot();
-
</del><span class="cx"> // Let's roll.
</span><span class="cx"> @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
</span><span class="cx">
</span><span class="cx"> wp_user_settings();
</span><span class="cx"> _wp_admin_html_begin();
</span><span class="cx">
</span><del>-$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $theme['Name'] ) ) );
</del><ins>+$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $this->theme->display('Name') ) ) );
</ins><span class="cx"> ?><title><?php echo $admin_title; ?></title><?php
</span><span class="cx">
</span><span class="cx"> do_action( 'customize_controls_print_styles' );
</span><span class="lines">@@ -47,9 +44,7 @@
</span><span class="cx">         <form id="customize-controls" method="post" class="wrap wp-full-overlay-sidebar" target="_parent" action="<?php echo esc_url( add_query_arg( 'save_customize_controls', '1', admin_url( 'themes.php' ) ) ); ?>">
</span><span class="cx">                 <?php wp_nonce_field( 'customize_controls' ); ?>
</span><span class="cx">                 <input type="hidden" name="customize" value="on" />
</span><del>-                <input type="hidden" id="customize-template" name="template" value="<?php echo esc_attr( $theme['Template'] ); ?>" />
-                <input type="hidden" id="customize-stylesheet" name="stylesheet" value="<?php echo esc_attr( $theme['Stylesheet'] ); ?>" />
-
</del><ins>+                <input type="hidden" name="theme" value="<?php echo esc_attr( $this->get_stylesheet() ); ?>" />
</ins><span class="cx">                 <div id="customize-header-actions" class="customize-section wp-full-overlay-header">
</span><span class="cx">                         <a class="back" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>">
</span><span class="cx">                                 <?php printf( __( '&larr; Return to %s' ), __('Manage Themes') ); ?>
</span><span class="lines">@@ -59,15 +54,15 @@
</span><span class="cx">                 <div id="customize-info" class="customize-section">
</span><span class="cx">                         <div class="customize-section-title">
</span><span class="cx">                                 <span class="preview-notice"><?php _e('You are previewing'); ?></span>
</span><del>-                                <strong class="theme-name"><?php echo $theme['Name']; ?></strong>
</del><ins>+                                <strong class="theme-name"><?php echo $this->theme->display('Name'); ?></strong>
</ins><span class="cx">                         </div>
</span><span class="cx">                         <div class="customize-section-content">
</span><del>-                                <?php if ( $screenshot ) : ?>
</del><ins>+                                <?php if ( $screenshot = $this->theme->get_screenshot() ) : ?>
</ins><span class="cx">                                         <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
</span><span class="cx">                                 <?php endif; ?>
</span><span class="cx">
</span><del>-                                <?php if ( $theme->description ): ?>
-                                        <div class="theme-description"><?php echo $theme->description; ?></div>
</del><ins>+                                <?php if ( $this->theme->get('Description') ): ?>
+                                        <div class="theme-description"><?php echo $this->theme->display('Description'); ?></div>
</ins><span class="cx">                                 <?php endif; ?>
</span><span class="cx">                         </div>
</span><span class="cx">                 </div>
</span></span></pre></div>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (20495 => 20496)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2012-04-17 20:49:39 UTC (rev 20495)
+++ trunk/wp-includes/theme.php        2012-04-17 21:43:47 UTC (rev 20496)
</span><span class="lines">@@ -1601,5 +1601,5 @@
</span><span class="cx"> * @since 3.4.0
</span><span class="cx"> */
</span><span class="cx"> function wp_customize_url( $stylesheet, $template ) {
</span><del>-        return esc_url( admin_url( 'admin.php' ) . '?customize=on&template=' . $template . '&stylesheet=' . $stylesheet );
</del><ins>+        return esc_url( admin_url( 'admin.php' ) . '?customize=on&theme=' . $stylesheet );
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>