<!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>[20852] trunk: Customize API shuffling.</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/20852">20852</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-05-23 17:56:42 +0000 (Wed, 23 May 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>Customize API shuffling.
* Rename WP_Customize to WP_Customize_Manager.
* Move customize-controls.php to wp-admin/customize.php.
* Make customize.php the formal entry point, rather than admin.php?customize=on.
* Rename is_current_theme_active() to is_theme_active().
* Add getters for the theme, settings, controls, and sections properties.
* Allow customize.php (no ?theme=) to load the active theme. Not used yet.
see <a href="http://core.trac.wordpress.org/ticket/20736">#20736</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswppluginslisttablephp">trunk/wp-admin/includes/class-wp-plugins-list-table.php</a></li>
<li><a href="#trunkwpincludesthemephp">trunk/wp-includes/theme.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkwpadmincustomizephp">trunk/wp-admin/customize.php</a></li>
<li><a href="#trunkwpincludesclasswpcustomizemanagerphp">trunk/wp-includes/class-wp-customize-manager.php</a></li>
</ul>
<h3>Removed 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>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincustomizephpfromrev20847trunkwpincludescustomizecontrolsphp"></a>
<div class="copfile"><h4>Copied: trunk/wp-admin/customize.php (from rev 20847, trunk/wp-includes/customize-controls.php) (0 => 20852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/customize.php         (rev 0)
+++ trunk/wp-admin/customize.php        2012-05-23 17:56:42 UTC (rev 20852)
</span><span class="lines">@@ -0,0 +1,149 @@
</span><ins>+<?php
+/**
+ * Customize Controls
+ *
+ * @package WordPress
+ * @subpackage Customize
+ * @since 3.4.0
+ */
+
+require_once( './admin.php' );
+if ( ! current_user_can( 'edit_theme_options' ) )
+        die( 'Cap check failed' );
+
+global $wp_scripts, $wp_customize;
+
+if ( ! $wp_customize->is_preview() )
+        die( 'is_preview() failed' );
+
+wp_reset_vars( array( 'theme' ) );
+
+if ( ! $theme )
+        $theme = get_stylesheet();
+
+$registered = $wp_scripts->registered;
+$wp_scripts = new WP_Scripts;
+$wp_scripts->registered = $registered;
+
+add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
+add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
+add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
+
+do_action( 'customize_controls_init' );
+
+wp_enqueue_script( 'customize-controls' );
+wp_enqueue_style( 'customize-controls' );
+
+do_action( 'customize_controls_enqueue_scripts' );
+
+// Let's roll.
+@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
+
+wp_user_settings();
+_wp_admin_html_begin();
+
+$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
+?><title><?php echo $admin_title; ?></title><?php
+
+do_action( 'customize_controls_print_styles' );
+do_action( 'customize_controls_print_scripts' );
+?>
+</head>
+<body class="wp-full-overlay">
+        <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
+                <?php wp_nonce_field( 'customize_controls' ); ?>
+                <div id="customize-header-actions" class="wp-full-overlay-header">
+                        <a class="back" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>">
+                                <?php printf( __( '&larr; Return to %s' ), __('Manage Themes') ); ?>
+                        </a>
+                </div>
+
+                <div class="wp-full-overlay-sidebar-content">
+                        <div id="customize-info" class="customize-section">
+                                <div class="customize-section-title">
+                                        <span class="preview-notice"><?php _e('You are previewing'); ?></span>
+                                        <strong class="theme-name"><?php echo $wp_customize->theme()->display('Name'); ?></strong>
+                                </div>
+                                <div class="customize-section-content">
+                                        <?php if ( $screenshot = $wp_customize->theme()->get_screenshot() ) : ?>
+                                                <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
+                                        <?php endif; ?>
+
+                                        <?php if ( $wp_customize->theme()->get('Description') ): ?>
+                                                <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
+                                        <?php endif; ?>
+                                </div>
+                        </div>
+
+                        <div id="customize-theme-controls"><ul>
+                                <?php
+                                foreach ( $wp_customize->sections() as $section )
+                                        $section->maybe_render();
+                                ?>
+                        </ul></div>
+                </div>
+
+                <div id="customize-footer-actions" class="wp-full-overlay-footer">
+                        <?php
+                        $save_text = $wp_customize->is_theme_active() ? __('Save') : __('Save and Activate');
+                        submit_button( $save_text, 'primary', 'save', false );
+                        ?>
+                        <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
+
+                        <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
+                                <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
+                                <span class="collapse-sidebar-arrow"></span>
+                        </a>
+                </div>
+        </form>
+        <div id="customize-preview" class="wp-full-overlay-main"></div>
+        <?php
+
+        do_action( 'customize_controls_print_footer_scripts' );
+
+        // If the frontend and the admin are served from the same domain, load the
+        // preview over ssl if the customizer is being loaded over ssl. This avoids
+        // insecure content warnings. This is not attempted if the admin and frontend
+        // are on different domains to avoid the case where the frontend doesn't have
+        // ssl certs. Domain mapping plugins can force ssl in these conditions using
+        // the customize_preview_link filter.
+        $admin_origin = parse_url( admin_url() );
+        $home_origin = parse_url( home_url() );
+        $scheme = null;
+        if ( is_ssl() && ( $admin_origin[ 'host' ] == $home_origin[ 'host' ] ) )
+                $scheme = 'https';
+
+        $preview_url = apply_filters( 'customize_preview_link', home_url( '/', $scheme ) );
+
+        $settings = array(
+                'theme' => array(
+                        'stylesheet' => $wp_customize->get_stylesheet(),
+                        'active' => $wp_customize->is_theme_active(),
+                ),
+                'url' => array(
+                        'preview' => esc_url( $preview_url ),
+                        'parent' => esc_url( admin_url() ),
+                        'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
+                ),
+                'settings' => array(),
+                'controls' => array(),
+        );
+
+        foreach ( $wp_customize->settings() as $id => $setting ) {
+                $settings['settings'][ $id ] = array(
+                        'value' => $setting->js_value(),
+                        'transport' => $setting->transport,
+                );
+        }
+
+        foreach ( $wp_customize->controls() as $id => $control ) {
+                $control->to_json();
+                $settings['controls'][ $id ] = $control->json;
+        }
+
+        ?>
+        <script type="text/javascript">
+                var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
+        </script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkwpadminincludesclasswppluginslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-plugins-list-table.php (20851 => 20852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-plugins-list-table.php        2012-05-23 15:36:27 UTC (rev 20851)
+++ trunk/wp-admin/includes/class-wp-plugins-list-table.php        2012-05-23 17:56:42 UTC (rev 20852)
</span><span class="lines">@@ -69,6 +69,11 @@
</span><span class="cx">                                 $current = get_site_transient( 'update_plugins' );
</span><span class="cx">                                 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
</span><span class="cx">                                         if ( isset( $current->response[ $plugin_file ] ) ) {
</span><ins>+                                                ob_start();
+                                                var_dump( $current->response[ $plugin_file ] );
+                                                error_log( $plugin_file . ': ' . ob_get_clean() );
+                                        }
+                                        if ( ! empty( $current->response[ $plugin_file ] ) ) {
</ins><span class="cx">                                                 $plugins['all'][ $plugin_file ]['update'] = true;
</span><span class="cx">                                                 $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ];
</span><span class="cx">                                         }
</span></span></pre></div>
<a id="trunkwpincludesclasswpcustomizemanagerphpfromrev20847trunkwpincludesclasswpcustomizephp"></a>
<div class="copfile"><h4>Copied: trunk/wp-includes/class-wp-customize-manager.php (from rev 20847, trunk/wp-includes/class-wp-customize.php) (0 => 20852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize-manager.php         (rev 0)
+++ trunk/wp-includes/class-wp-customize-manager.php        2012-05-23 17:56:42 UTC (rev 20852)
</span><span class="lines">@@ -0,0 +1,800 @@
</span><ins>+<?php
+/**
+ * Customize
+ *
+ * @package WordPress
+ * @subpackage Customize
+ * @since 3.4.0
+ */
+
+final class WP_Customize_Manager {
+        protected $theme;
+        protected $original_stylesheet;
+
+        protected $previewing = false;
+
+        protected $settings = array();
+        protected $sections = array();
+        protected $controls = array();
+
+        protected $customized;
+
+        private $_post_values;
+
+        /**
+         * Constructor.
+         *
+         * @since 3.4.0
+         */
+        public function __construct() {
+                require( ABSPATH . WPINC . '/class-wp-customize-setting.php' );
+                require( ABSPATH . WPINC . '/class-wp-customize-section.php' );
+                require( ABSPATH . WPINC . '/class-wp-customize-control.php' );
+
+                add_action( 'setup_theme', array( $this, 'setup_theme' ) );
+                add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
+
+                add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
+
+                add_action( 'customize_register', array( $this, 'register_controls' ) );
+                add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) );
+                add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );
+        }
+
+        /**
+         * Update theme modifications for the current theme.
+         * Note: Candidate core function.
+         * http://core.trac.wordpress.org/ticket/20091
+         *
+         * @since 3.4.0
+         *
+         * @param array $mods Theme modifications.
+         */
+        public function set_theme_mods( $mods ) {
+                $current = get_theme_mods();
+
+                $mods = wp_parse_args( $mods, $current );
+
+                $theme = get_stylesheet();
+                update_option( "theme_mods_$theme", $mods );
+        }
+
+        /**
+         * Start preview and customize theme.
+         *
+         * Check if customize query variable exist. Init filters to filter the current theme.
+         *
+         * @since 3.4.0
+         */
+        public function setup_theme() {
+                if ( ! ( isset( $_REQUEST['customize'] ) && 'on' == $_REQUEST['customize'] ) && ! basename( $_SERVER['PHP_SELF'] ) == 'customize.php' )
+                        return;
+
+                send_origin_headers();
+
+                $this->start_previewing_theme();
+                show_admin_bar( false );
+        }
+
+        /**
+         * Start previewing the selected theme.
+         *
+         * Adds filters to change the current theme.
+         *
+         * @since 3.4.0
+         */
+        public function start_previewing_theme() {
+                if ( $this->is_preview() || false === $this->theme || ( $this->theme && ! $this->theme->exists() ) )
+                        return;
+
+                // Initialize $theme and $original_stylesheet if they do not yet exist.
+                if ( ! isset( $this->theme ) ) {
+                        $this->theme = wp_get_theme( isset( $_REQUEST['theme'] ) ? $_REQUEST['theme'] : null );
+                        if ( ! $this->theme->exists() ) {
+                                $this->theme = false;
+                                return;
+                        }
+                }
+
+                $this->original_stylesheet = get_stylesheet();
+
+                $this->previewing = true;
+
+                add_filter( 'template', array( $this, 'get_template' ) );
+                add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
+                add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );
+
+                // @link: http://core.trac.wordpress.org/ticket/20027
+                add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );
+                add_filter( 'pre_option_template', array( $this, 'get_template' ) );
+
+                // Handle custom theme roots.
+                add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
+                add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
+
+                do_action( 'start_previewing_theme', $this );
+        }
+
+        /**
+         * Stop previewing the selected theme.
+         *
+         * Removes filters to change the current theme.
+         *
+         * @since 3.4.0
+         */
+        public function stop_previewing_theme() {
+                if ( ! $this->is_preview() )
+                        return;
+
+                $this->previewing = false;
+
+                remove_filter( 'template', array( $this, 'get_template' ) );
+                remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
+                remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );
+
+                // @link: http://core.trac.wordpress.org/ticket/20027
+                remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );
+                remove_filter( 'pre_option_template', array( $this, 'get_template' ) );
+
+                // Handle custom theme roots.
+                remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
+                remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
+
+                do_action( 'stop_previewing_theme', $this );
+        }
+
+        /**
+         * Generic getter.
+         *
+         * @since 3.4.0
+         *
+         * @return WP_Theme
+         */
+        public function __call( $callee, $args ) {
+                if ( in_array( $callee, array( 'theme', 'settings', 'controls', 'sections' ) ) )
+                        return $this->$callee;
+        }
+
+        /**
+         * Checks if the current theme is active.
+         *
+         * @since 3.4.0
+         *
+         * @return bool
+         */
+        public function is_theme_active() {
+                return $this->get_stylesheet() == $this->original_stylesheet;
+        }
+
+        /**
+         * Register styles/scripts and initialize the preview of each setting
+         *
+         * @since 3.4.0
+         */
+        public function wp_loaded() {
+                do_action( 'customize_register', $this );
+
+                if ( $this->is_preview() && ! is_admin() )
+                        $this->customize_preview_init();
+        }
+
+        /**
+         * Decode the $_POST attribute used to override the WP_Customize_Setting values.
+         *
+         * @since 3.4.0
+         */
+        public function post_value( $setting ) {
+                if ( ! isset( $this->_post_values ) ) {
+                        if ( isset( $_POST['customized'] ) )
+                                $this->_post_values = json_decode( stripslashes( $_POST['customized'] ), true );
+                        else
+                                $this->_post_values = false;
+                }
+
+                if ( isset( $this->_post_values[ $setting->id ] ) )
+                        return $setting->sanitize( $this->_post_values[ $setting->id ] );
+        }
+
+        /**
+         * Print javascript settings.
+         *
+         * @since 3.4.0
+         */
+        public function customize_preview_init() {
+                $this->prepare_controls();
+
+                wp_enqueue_script( 'customize-preview' );
+                add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 );
+
+                foreach ( $this->settings as $setting ) {
+                        $setting->preview();
+                }
+
+                do_action( 'customize_preview_init', $this );
+        }
+
+
+        /**
+         * Print javascript settings.
+         *
+         * @since 3.4.0
+         */
+        public function customize_preview_settings() {
+                $settings = array(
+                        'values' => array(),
+                );
+
+                foreach ( $this->settings as $id => $setting ) {
+                        $settings['values'][ $id ] = $setting->js_value();
+                }
+
+                ?>
+                <script type="text/javascript">
+                        var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
+                </script>
+                <?php
+        }
+
+        /**
+         * Is it a theme preview?
+         *
+         * @since 3.4.0
+         *
+         * @return bool True if it's a preview, false if not.
+         */
+        public function is_preview() {
+                return (bool) $this->previewing;
+        }
+
+        /**
+         * Retrieve the template name of the previewed theme.
+         *
+         * @since 3.4.0
+         *
+         * @return string Template name.
+         */
+        public function get_template() {
+                return $this->theme->get_template();
+        }
+
+        /**
+         * Retrieve the stylesheet name of the previewed theme.
+         *
+         * @since 3.4.0
+         *
+         * @return string Stylesheet name.
+         */
+        public function get_stylesheet() {
+                return $this->theme->get_stylesheet();
+        }
+
+        /**
+         * Retrieve the template root of the previewed theme.
+         *
+         * @since 3.4.0
+         *
+         * @return string Theme root.
+         */
+        public function get_template_root() {
+                return get_raw_theme_root( $this->get_template(), true );
+        }
+
+        /**
+         * Retrieve the stylesheet root of the previewed theme.
+         *
+         * @since 3.4.0
+         *
+         * @return string Theme root.
+         */
+        public function get_stylesheet_root() {
+                return get_raw_theme_root( $this->get_stylesheet(), true );
+        }
+
+        /**
+         * Filter the current theme and return the name of the previewed theme.
+         *
+         * @since 3.4.0
+         *
+         * @return string Theme name.
+         */
+        public function current_theme( $current_theme ) {
+                return $this->theme->display('Name');
+        }
+
+        /**
+         * Switch the theme and trigger the save action of each setting.
+         *
+         * @since 3.4.0
+         */
+        public function save() {
+                if ( ! $this->is_preview() )
+                        die;
+
+                check_ajax_referer( 'customize_controls', 'nonce' );
+
+                // Do we have to switch themes?
+                if ( $this->get_stylesheet() != $this->original_stylesheet ) {
+                        if ( ! current_user_can( 'switch_themes' ) )
+                                die;
+
+                        // Temporarily stop previewing the theme to allow switch_themes()
+                        // to operate properly.
+                        $this->stop_previewing_theme();
+                        switch_theme( $this->get_template(), $this->get_stylesheet() );
+                        $this->start_previewing_theme();
+                }
+
+                do_action( 'customize_save', $this );
+
+                foreach ( $this->settings as $setting ) {
+                        $setting->save();
+                }
+
+                add_action( 'admin_notices', array( $this, '_save_feedback' ) );
+
+                die;
+        }
+
+        /**
+         * Show an admin notice after settings are saved.
+         *
+         * @since 3.4.0
+         */
+        public function _save_feedback() {
+                ?>
+                <div class="updated"><p><?php printf( __( 'Settings saved and theme activated. <a href="%s">Visit site</a>.' ), home_url( '/' ) ); ?></p></div>
+                <?php
+        }
+
+        /**
+         * Add a customize setting.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the setting. Can be a
+         * theme mod or option name.
+         * @param array $args Setting arguments.
+         */
+        public function add_setting( $id, $args = array() ) {
+                if ( is_a( $id, 'WP_Customize_Setting' ) )
+                        $setting = $id;
+                else
+                        $setting = new WP_Customize_Setting( $this, $id, $args );
+
+                $this->settings[ $setting->id ] = $setting;
+        }
+
+        /**
+         * Retrieve a customize setting.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the setting.
+         * @return object The settings object.
+         */
+        public function get_setting( $id ) {
+                if ( isset( $this->settings[ $id ] ) )
+                        return $this->settings[ $id ];
+        }
+
+        /**
+         * Remove a customize setting.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the setting.
+         */
+        public function remove_setting( $id ) {
+                unset( $this->settings[ $id ] );
+        }
+
+        /**
+         * Add a customize section.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the section.
+         * @param array $args Section arguments.
+         */
+        public function add_section( $id, $args = array() ) {
+                if ( is_a( $id, 'WP_Customize_Section' ) )
+                        $section = $id;
+                else
+                        $section = new WP_Customize_Section( $this, $id, $args );
+
+                $this->sections[ $section->id ] = $section;
+        }
+
+        /**
+         * Retrieve a customize section.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the section.
+         * @return object The section object.
+         */
+        public function get_section( $id ) {
+                if ( isset( $this->sections[ $id ] ) )
+                        return $this->sections[ $id ];
+        }
+
+        /**
+         * Remove a customize section.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the section.
+         */
+        public function remove_section( $id ) {
+                unset( $this->sections[ $id ] );
+        }
+
+        /**
+         * Add a customize control.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the control.
+         * @param array $args Setting arguments.
+         */
+        public function add_control( $id, $args = array() ) {
+                if ( is_a( $id, 'WP_Customize_Control' ) )
+                        $control = $id;
+                else
+                        $control = new WP_Customize_Control( $this, $id, $args );
+
+                $this->controls[ $control->id ] = $control;
+        }
+
+        /**
+         * Retrieve a customize control.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the control.
+         * @return object The settings object.
+         */
+        public function get_control( $id ) {
+                if ( isset( $this->controls[ $id ] ) )
+                        return $this->controls[ $id ];
+        }
+
+        /**
+         * Remove a customize setting.
+         *
+         * @since 3.4.0
+         *
+         * @param string $id A specific ID of the control.
+         */
+        public function remove_control( $id ) {
+                unset( $this->controls[ $id ] );
+        }
+
+        /**
+         * Helper function to compare two objects by priority.
+         *
+         * @since 3.4.0
+         *
+         * @param object $a Object A.
+         * @param object $b Object B.
+         */
+        protected final function _cmp_priority( $a, $b ) {
+                $ap = $a->priority;
+                $bp = $b->priority;
+
+                if ( $ap == $bp )
+                        return 0;
+                return ( $ap > $bp ) ? 1 : -1;
+        }
+
+        /**
+         * Prepare settings and sections.
+         *
+         * @since 3.4.0
+         */
+        public function prepare_controls() {
+                // Prepare controls
+                // Reversing makes uasort sort by time added when conflicts occur.
+
+                $this->controls = array_reverse( $this->controls );
+                $controls = array();
+
+                foreach ( $this->controls as $id => $control ) {
+                        if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() )
+                                continue;
+
+                        $this->sections[ $control->section ]->controls[] = $control;
+                        $controls[ $id ] = $control;
+                }
+                $this->controls = $controls;
+
+                // Prepare sections
+                $this->sections = array_reverse( $this->sections );
+                uasort( $this->sections, array( $this, '_cmp_priority' ) );
+                $sections = array();
+
+                foreach ( $this->sections as $section ) {
+                        if ( ! $section->check_capabilities() || ! $section->controls )
+                                continue;
+
+                        usort( $section->controls, array( $this, '_cmp_priority' ) );
+                        $sections[] = $section;
+                }
+                $this->sections = $sections;
+        }
+
+        /**
+         * Enqueue scripts for customize controls.
+         *
+         * @since 3.4.0
+         */
+        public function enqueue_control_scripts() {
+                foreach ( $this->controls as $control ) {
+                        $control->enqueue();
+                }
+        }
+
+        /**
+         * Register some default controls.
+         *
+         * @since 3.4.0
+         */
+        public function register_controls() {
+
+                /* Custom Header */
+
+                $this->add_section( 'header', array(
+                        'title' => __( 'Header' ),
+                        'theme_supports' => 'custom-header',
+                        'priority' => 20,
+                ) );
+
+                $this->add_setting( 'header_textcolor', array(
+                        'sanitize_callback' => 'sanitize_header_textcolor',
+                        'theme_supports' => array( 'custom-header', 'header-text' ),
+                        'default' => get_theme_support( 'custom-header', 'default-text-color' ),
+                ) );
+
+                $this->add_control( 'display_header_text', array(
+                        'settings' => 'header_textcolor',
+                        'label' => __( 'Display Header Text' ),
+                        'section' => 'header',
+                        'type' => 'checkbox',
+                ) );
+
+                $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array(
+                        'label' => __( 'Text Color' ),
+                        'section' => 'header',
+                ) ) );
+
+                // Input type: checkbox
+                // With custom value
+                $this->add_setting( 'header_image', array(
+                        'default' => get_theme_support( 'custom-header', 'default-image' ),
+                        'theme_supports' => 'custom-header',
+                ) );
+
+                $this->add_control( new WP_Customize_Header_Image_Control( $this ) );
+
+                /* Custom Background */
+
+                $this->add_section( 'background', array(
+                        'title' => __( 'Background' ),
+                        'theme_supports' => 'custom-background',
+                        'priority' => 30,
+                ) );
+
+                // Input type: Color
+                // With sanitize_callback
+                $this->add_setting( 'background_color', array(
+                        'default' => get_theme_support( 'custom-background', 'default-color' ),
+                        'sanitize_callback' => 'sanitize_hexcolor',
+                        'theme_supports' => 'custom-background',
+                        'transport' => 'postMessage',
+                ) );
+
+                $this->add_control( new WP_Customize_Color_Control( $this, 'background_color', array(
+                        'label' => __( 'Background Color' ),
+                        'section' => 'background',
+                ) ) );
+
+                $this->add_setting( 'background_image', array(
+                        'default' => get_theme_support( 'custom-background', 'default-image' ),
+                        'theme_supports' => 'custom-background',
+                ) );
+
+                $this->add_control( new WP_Customize_Image_Control( $this, 'background_image', array(
+                        'label' => __( 'Background Image' ),
+                        'section' => 'background',
+                        'context' => 'custom-background',
+                ) ) );
+
+                $this->add_setting( 'background_repeat', array(
+                        'default' => 'repeat',
+                        'theme_supports' => 'custom-background',
+                ) );
+
+                $this->add_control( 'background_repeat', array(
+                        'label' => __( 'Background Repeat' ),
+                        'section' => 'background',
+                        'type' => 'radio',
+                        'choices' => array(
+                                'no-repeat' => __('No Repeat'),
+                                'repeat' => __('Tile'),
+                                'repeat-x' => __('Tile Horizontally'),
+                                'repeat-y' => __('Tile Vertically'),
+                        ),
+                ) );
+
+                $this->add_setting( 'background_position_x', array(
+                        'default' => 'left',
+                        'theme_supports' => 'custom-background',
+                ) );
+
+                $this->add_control( 'background_position_x', array(
+                        'label' => __( 'Background Position' ),
+                        'section' => 'background',
+                        'type' => 'radio',
+                        'choices' => array(
+                                'left' => __('Left'),
+                                'center' => __('Center'),
+                                'right' => __('Right'),
+                        ),
+                ) );
+
+                $this->add_setting( 'background_attachment', array(
+                        'default' => 'fixed',
+                        'theme_supports' => 'custom-background',
+                ) );
+
+                $this->add_control( 'background_attachment', array(
+                        'label' => __( 'Background Attachment' ),
+                        'section' => 'background',
+                        'type' => 'radio',
+                        'choices' => array(
+                                'fixed' => __('Fixed'),
+                                'scroll' => __('Scroll'),
+                        ),
+                ) );
+
+                /* Nav Menus */
+
+                $locations = get_registered_nav_menus();
+                $menus = wp_get_nav_menus();
+                $menu_locations = get_nav_menu_locations();
+                $num_locations = count( array_keys( $locations ) );
+
+                $this->add_section( 'nav', array(
+                        'title' => __( 'Navigation' ),
+                        'theme_supports' => 'menus',
+                        'priority' => 40,
+                        'description' => sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . "\n\n" . __('You can edit your menu content on the Menus screen in the Appearance section.'),
+                ) );
+
+                if ( $menus ) {
+                        $choices = array( 0 => __( '&mdash; Select &mdash;' ) );
+                        foreach ( $menus as $menu ) {
+                                $truncated_name = wp_html_excerpt( $menu->name, 40 );
+                                $truncated_name = ( $truncated_name == $menu->name ) ? $menu->name : trim( $truncated_name ) . '&hellip;';
+                                $choices[ $menu->term_id ] = $truncated_name;
+                        }
+
+                        foreach ( $locations as $location => $description ) {
+                                $menu_setting_id = "nav_menu_locations[{$location}]";
+
+                                $this->add_setting( $menu_setting_id, array(
+                                        'sanitize_callback' => 'absint',
+                                        'theme_supports' => 'menus',
+                                ) );
+
+                                $this->add_control( $menu_setting_id, array(
+                                        'label' => $description,
+                                        'section' => 'nav',
+                                        'type' => 'select',
+                                        'choices' => $choices,
+                                ) );
+                        }
+                }
+
+                /* Static Front Page */
+                // #WP19627
+
+                $this->add_section( 'static_front_page', array(
+                        'title' => __( 'Static Front Page' ),
+                //        'theme_supports' => 'static-front-page',
+                        'priority' => 50,
+                        'description' => __( 'Your theme supports a static front page.' ),
+                ) );
+
+                $this->add_setting( 'show_on_front', array(
+                        'default' => get_option( 'show_on_front' ),
+                        'capability' => 'manage_options',
+                        'type' => 'option',
+                //        'theme_supports' => 'static-front-page',
+                ) );
+
+                $this->add_control( 'show_on_front', array(
+                        'label' => __( 'Front page displays' ),
+                        'section' => 'static_front_page',
+                        'type' => 'radio',
+                        'choices' => array(
+                                'posts' => __( 'Your latest posts' ),
+                                'page' => __( 'A static page' ),
+                        ),
+                ) );
+
+                $this->add_setting( 'page_on_front', array(
+                        'type' => 'option',
+                        'capability' => 'manage_options',
+                //        'theme_supports' => 'static-front-page',
+                ) );
+
+                $this->add_control( 'page_on_front', array(
+                        'label' => __( 'Front page' ),
+                        'section' => 'static_front_page',
+                        'type' => 'dropdown-pages',
+                ) );
+
+                $this->add_setting( 'page_for_posts', array(
+                        'type' => 'option',
+                        'capability' => 'manage_options',
+                //        'theme_supports' => 'static-front-page',
+                ) );
+
+                $this->add_control( 'page_for_posts', array(
+                        'label' => __( 'Posts page' ),
+                        'section' => 'static_front_page',
+                        'type' => 'dropdown-pages',
+                ) );
+
+                /* Site Title & Tagline */
+
+                $this->add_section( 'strings', array(
+                        'title' => __( 'Site Title & Tagline' ),
+                        'priority' => 5,
+                ) );
+
+                $this->add_setting( 'blogname', array(
+                        'default' => get_option( 'blogname' ),
+                        'type' => 'option',
+                        'capability' => 'manage_options',
+                ) );
+
+                $this->add_control( 'blogname', array(
+                        'label' => __( 'Site Title' ),
+                        'section' => 'strings',
+                ) );
+
+                $this->add_setting( 'blogdescription', array(
+                        'default' => get_option( 'blogdescription' ),
+                        'type' => 'option',
+                        'capability' => 'manage_options',
+                ) );
+
+                $this->add_control( 'blogdescription', array(
+                        'label' => __( 'Tagline' ),
+                        'section' => 'strings',
+                ) );
+        }
+};
+
+// Callback function for sanitizing the header textcolor setting.
+function sanitize_header_textcolor( $color ) {
+        if ( empty( $color ) )
+                return get_theme_support( 'custom-header', 'default-text-color' );
+
+        elseif ( $color == 'blank' )
+                return 'blank';
+
+        return sanitize_hexcolor( $color );
+}
+
+// Callback function for sanitizing a hex color
+function sanitize_hexcolor( $color ) {
+        $color = preg_replace( '/[^0-9a-fA-F]/', '', $color );
+
+        if ( preg_match('|[A-Fa-f0-9]{3,6}|', $color ) )
+                return $color;
+
+        return $color;
+}
</ins></span></pre></div>
<a id="trunkwpincludesclasswpcustomizephp"></a>
<div class="delfile"><h4>Deleted: trunk/wp-includes/class-wp-customize.php (20851 => 20852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-wp-customize.php        2012-05-23 15:36:27 UTC (rev 20851)
+++ trunk/wp-includes/class-wp-customize.php        2012-05-23 17:56:42 UTC (rev 20852)
</span><span class="lines">@@ -1,814 +0,0 @@
</span><del>-<?php
-/**
- * Customize
- *
- * @package WordPress
- * @subpackage Customize
- * @since 3.4.0
- */
-
-final class WP_Customize {
-        protected $theme;
-        protected $original_stylesheet;
-
-        protected $previewing = false;
-
-        protected $settings = array();
-        protected $sections = array();
-        protected $controls = array();
-
-        protected $customized;
-
-        private $_post_values;
-
-        /**
-         * Constructor.
-         *
-         * @since 3.4.0
-         */
-        public function __construct() {
-                require( ABSPATH . WPINC . '/class-wp-customize-setting.php' );
-                require( ABSPATH . WPINC . '/class-wp-customize-section.php' );
-                require( ABSPATH . WPINC . '/class-wp-customize-control.php' );
-
-                add_action( 'setup_theme', array( $this, 'setup_theme' ) );
-                add_action( 'admin_init', array( $this, 'admin_init' ) );
-                add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
-
-                add_action( 'wp_ajax_customize_save', array( $this, 'save' ) );
-
-                add_action( 'customize_register', array( $this, 'register_controls' ) );
-                add_action( 'customize_controls_init', array( $this, 'prepare_controls' ) );
-                add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_control_scripts' ) );
-        }
-
-        /**
-         * Update theme modifications for the current theme.
-         * Note: Candidate core function.
-         * http://core.trac.wordpress.org/ticket/20091
-         *
-         * @since 3.4.0
-         *
-         * @param array $mods Theme modifications.
-         */
-        public function set_theme_mods( $mods ) {
-                $current = get_theme_mods();
-
-                $mods = wp_parse_args( $mods, $current );
-
-                $theme = get_stylesheet();
-                update_option( "theme_mods_$theme", $mods );
-        }
-
-        /**
-         * Start preview and customize theme.
-         *
-         * Check if customize query variable exist. Init filters to filter the current theme.
-         *
-         * @since 3.4.0
-         */
-        public function setup_theme() {
-                if ( ! isset( $_REQUEST['customize'] ) || 'on' != $_REQUEST['customize'] )
-                        return;
-
-                send_origin_headers();
-
-                $this->start_previewing_theme();
-                show_admin_bar( false );
-        }
-
-        /**
-         * Start previewing the selected theme.
-         *
-         * Adds filters to change the current theme.
-         *
-         * @since 3.4.0
-         */
-        public function start_previewing_theme() {
-                if ( $this->is_preview() || false === $this->theme || ( $this->theme && ! $this->theme->exists() ) )
-                        return;
-
-                // Initialize $theme and $original_stylesheet if they do not yet exist.
-                if ( ! isset( $this->theme ) ) {
-                        $this->theme = wp_get_theme( $_REQUEST['theme'] );
-                        if ( ! $this->theme->exists() ) {
-                                $this->theme = false;
-                                return;
-                        }
-                }
-
-                $this->original_stylesheet = get_stylesheet();
-
-                $this->previewing = true;
-
-                add_filter( 'template', array( $this, 'get_template' ) );
-                add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
-                add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );
-
-                // @link: http://core.trac.wordpress.org/ticket/20027
-                add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );
-                add_filter( 'pre_option_template', array( $this, 'get_template' ) );
-
-                // Handle custom theme roots.
-                add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
-                add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
-
-                do_action( 'start_previewing_theme', $this );
-        }
-
-        /**
-         * Stop previewing the selected theme.
-         *
-         * Removes filters to change the current theme.
-         *
-         * @since 3.4.0
-         */
-        public function stop_previewing_theme() {
-                if ( ! $this->is_preview() )
-                        return;
-
-                $this->previewing = false;
-
-                remove_filter( 'template', array( $this, 'get_template' ) );
-                remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) );
-                remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) );
-
-                // @link: http://core.trac.wordpress.org/ticket/20027
-                remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) );
-                remove_filter( 'pre_option_template', array( $this, 'get_template' ) );
-
-                // Handle custom theme roots.
-                remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) );
-                remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) );
-
-                do_action( 'stop_previewing_theme', $this );
-        }
-
-        /**
-         * Checks if the current theme is active.
-         *
-         * @since 3.4.0
-         */
-        public function is_current_theme_active() {
-                return $this->get_stylesheet() == $this->original_stylesheet;
-        }
-
-        /**
-         * Register styles/scripts and initialize the preview of each setting
-         *
-         * @since 3.4.0
-         */
-        public function wp_loaded() {
-                do_action( 'customize_register', $this );
-
-                if ( $this->is_preview() && ! is_admin() )
-                        $this->customize_preview_init();
-        }
-
-        /**
-         * Decode the $_POST attribute used to override the WP_Customize_Setting values.
-         *
-         * @since 3.4.0
-         */
-        public function post_value( $setting ) {
-                if ( ! isset( $this->_post_values ) ) {
-                        if ( isset( $_POST['customized'] ) )
-                                $this->_post_values = json_decode( stripslashes( $_POST['customized'] ), true );
-                        else
-                                $this->_post_values = false;
-                }
-
-                if ( isset( $this->_post_values[ $setting->id ] ) )
-                        return $setting->sanitize( $this->_post_values[ $setting->id ] );
-        }
-
-
-        /**
-         * Print javascript settings.
-         *
-         * @since 3.4.0
-         */
-        public function customize_preview_init() {
-                $this->prepare_controls();
-
-                wp_enqueue_script( 'customize-preview' );
-                add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 );
-
-                foreach ( $this->settings as $setting ) {
-                        $setting->preview();
-                }
-
-                do_action( 'customize_preview_init', $this );
-        }
-
-
-        /**
-         * Print javascript settings.
-         *
-         * @since 3.4.0
-         */
-        public function customize_preview_settings() {
-                $settings = array(
-                        'values' => array(),
-                );
-
-                foreach ( $this->settings as $id => $setting ) {
-                        $settings['values'][ $id ] = $setting->js_value();
-                }
-
-                ?>
-                <script type="text/javascript">
-                        var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
-                </script>
-                <?php
-        }
-
-        /**
-         * Is it a theme preview?
-         *
-         * @since 3.4.0
-         *
-         * @return bool True if it's a preview, false if not.
-         */
-        public function is_preview() {
-                return (bool) $this->previewing;
-        }
-
-        /**
-         * Retrieve the template name of the previewed theme.
-         *
-         * @since 3.4.0
-         *
-         * @return string Template name.
-         */
-        public function get_template() {
-                return $this->theme->get_template();
-        }
-
-        /**
-         * Retrieve the stylesheet name of the previewed theme.
-         *
-         * @since 3.4.0
-         *
-         * @return string Stylesheet name.
-         */
-        public function get_stylesheet() {
-                return $this->theme->get_stylesheet();
-        }
-
-        /**
-         * Retrieve the template root of the previewed theme.
-         *
-         * @since 3.4.0
-         *
-         * @return string Theme root.
-         */
-        public function get_template_root() {
-                return get_raw_theme_root( $this->get_template(), true );
-        }
-
-        /**
-         * Retrieve the stylesheet root of the previewed theme.
-         *
-         * @since 3.4.0
-         *
-         * @return string Theme root.
-         */
-        public function get_stylesheet_root() {
-                return get_raw_theme_root( $this->get_stylesheet(), true );
-        }
-
-        /**
-         * Filter the current theme and return the name of the previewed theme.
-         *
-         * @since 3.4.0
-         *
-         * @return string Theme name.
-         */
-        public function current_theme( $current_theme ) {
-                return $this->theme->display('Name');
-        }
-
-        /**
-         * Trigger save action and load customize controls.
-         *
-         * @since 3.4.0
-         */
-        public function admin_init() {
-                if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) )
-                        return;
-
-                if ( ! isset( $_GET['customize'] ) || 'on' != $_GET['customize'] )
-                        return;
-
-                if ( empty( $_GET['theme'] ) )
-                        return;
-
-                if ( ! $this->is_preview() )
-                        return;
-
-                if ( ! current_user_can( 'edit_theme_options' ) )
-                        return;
-
-                include( ABSPATH . WPINC . '/customize-controls.php' );
-
-                die;
-        }
-
-        /**
-         * Switch the theme and trigger the save action of each setting.
-         *
-         * @since 3.4.0
-         */
-        public function save() {
-                if ( ! $this->is_preview() )
-                        die;
-
-                check_ajax_referer( 'customize_controls', 'nonce' );
-
-                // Do we have to switch themes?
-                if ( $this->get_stylesheet() != $this->original_stylesheet ) {
-                        if ( ! current_user_can( 'switch_themes' ) )
-                                die;
-
-                        // Temporarily stop previewing the theme to allow switch_themes()
-                        // to operate properly.
-                        $this->stop_previewing_theme();
-                        switch_theme( $this->get_template(), $this->get_stylesheet() );
-                        $this->start_previewing_theme();
-                }
-
-                do_action( 'customize_save', $this );
-
-                foreach ( $this->settings as $setting ) {
-                        $setting->save();
-                }
-
-                add_action( 'admin_notices', array( $this, '_save_feedback' ) );
-
-                die;
-        }
-
-        /**
-         * Show an admin notice after settings are saved.
-         *
-         * @since 3.4.0
-         */
-        public function _save_feedback() {
-                ?>
-                <div class="updated"><p><?php printf( __( 'Settings saved and theme activated. <a href="%s">Visit site</a>.' ), home_url( '/' ) ); ?></p></div>
-                <?php
-        }
-
-        /**
-         * Add a customize setting.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the setting. Can be a
-         * theme mod or option name.
-         * @param array $args Setting arguments.
-         */
-        public function add_setting( $id, $args = array() ) {
-                if ( is_a( $id, 'WP_Customize_Setting' ) )
-                        $setting = $id;
-                else
-                        $setting = new WP_Customize_Setting( $this, $id, $args );
-
-                $this->settings[ $setting->id ] = $setting;
-        }
-
-        /**
-         * Retrieve a customize setting.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the setting.
-         * @return object The settings object.
-         */
-        public function get_setting( $id ) {
-                if ( isset( $this->settings[ $id ] ) )
-                        return $this->settings[ $id ];
-        }
-
-        /**
-         * Remove a customize setting.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the setting.
-         */
-        public function remove_setting( $id ) {
-                unset( $this->settings[ $id ] );
-        }
-
-        /**
-         * Add a customize section.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the section.
-         * @param array $args Section arguments.
-         */
-        public function add_section( $id, $args = array() ) {
-                if ( is_a( $id, 'WP_Customize_Section' ) )
-                        $section = $id;
-                else
-                        $section = new WP_Customize_Section( $this, $id, $args );
-
-                $this->sections[ $section->id ] = $section;
-        }
-
-        /**
-         * Retrieve a customize section.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the section.
-         * @return object The section object.
-         */
-        public function get_section( $id ) {
-                if ( isset( $this->sections[ $id ] ) )
-                        return $this->sections[ $id ];
-        }
-
-        /**
-         * Remove a customize section.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the section.
-         */
-        public function remove_section( $id ) {
-                unset( $this->sections[ $id ] );
-        }
-
-        /**
-         * Add a customize control.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the control.
-         * @param array $args Setting arguments.
-         */
-        public function add_control( $id, $args = array() ) {
-                if ( is_a( $id, 'WP_Customize_Control' ) )
-                        $control = $id;
-                else
-                        $control = new WP_Customize_Control( $this, $id, $args );
-
-                $this->controls[ $control->id ] = $control;
-        }
-
-        /**
-         * Retrieve a customize control.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the control.
-         * @return object The settings object.
-         */
-        public function get_control( $id ) {
-                if ( isset( $this->controls[ $id ] ) )
-                        return $this->controls[ $id ];
-        }
-
-        /**
-         * Remove a customize setting.
-         *
-         * @since 3.4.0
-         *
-         * @param string $id A specific ID of the control.
-         */
-        public function remove_control( $id ) {
-                unset( $this->controls[ $id ] );
-        }
-
-        /**
-         * Helper function to compare two objects by priority.
-         *
-         * @since 3.4.0
-         *
-         * @param object $a Object A.
-         * @param object $b Object B.
-         */
-        protected final function _cmp_priority( $a, $b ) {
-                $ap = $a->priority;
-                $bp = $b->priority;
-
-                if ( $ap == $bp )
-                        return 0;
-                return ( $ap > $bp ) ? 1 : -1;
-        }
-
-        /**
-         * Prepare settings and sections.
-         *
-         * @since 3.4.0
-         */
-        public function prepare_controls() {
-                // Prepare controls
-                // Reversing makes uasort sort by time added when conflicts occur.
-
-                $this->controls = array_reverse( $this->controls );
-                $controls = array();
-
-                foreach ( $this->controls as $id => $control ) {
-                        if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() )
-                                continue;
-
-                        $this->sections[ $control->section ]->controls[] = $control;
-                        $controls[ $id ] = $control;
-                }
-                $this->controls = $controls;
-
-                // Prepare sections
-                $this->sections = array_reverse( $this->sections );
-                uasort( $this->sections, array( $this, '_cmp_priority' ) );
-                $sections = array();
-
-                foreach ( $this->sections as $section ) {
-                        if ( ! $section->check_capabilities() || ! $section->controls )
-                                continue;
-
-                        usort( $section->controls, array( $this, '_cmp_priority' ) );
-                        $sections[] = $section;
-                }
-                $this->sections = $sections;
-        }
-
-        /**
-         * Enqueue scripts for customize controls.
-         *
-         * @since 3.4.0
-         */
-        public function enqueue_control_scripts() {
-                foreach ( $this->controls as $control ) {
-                        $control->enqueue();
-                }
-        }
-
-        /**
-         * Register some default controls.
-         *
-         * @since 3.4.0
-         */
-        public function register_controls() {
-
-                /* Custom Header */
-
-                $this->add_section( 'header', array(
-                        'title' => __( 'Header' ),
-                        'theme_supports' => 'custom-header',
-                        'priority' => 20,
-                ) );
-
-                $this->add_setting( 'header_textcolor', array(
-                        'sanitize_callback' => 'sanitize_header_textcolor',
-                        'theme_supports' => array( 'custom-header', 'header-text' ),
-                        'default' => get_theme_support( 'custom-header', 'default-text-color' ),
-                ) );
-
-                $this->add_control( 'display_header_text', array(
-                        'settings' => 'header_textcolor',
-                        'label' => __( 'Display Header Text' ),
-                        'section' => 'header',
-                        'type' => 'checkbox',
-                ) );
-
-                $this->add_control( new WP_Customize_Color_Control( $this, 'header_textcolor', array(
-                        'label' => __( 'Text Color' ),
-                        'section' => 'header',
-                ) ) );
-
-                // Input type: checkbox
-                // With custom value
-                $this->add_setting( 'header_image', array(
-                        'default' => get_theme_support( 'custom-header', 'default-image' ),
-                        'theme_supports' => 'custom-header',
-                ) );
-
-                $this->add_control( new WP_Customize_Header_Image_Control( $this ) );
-
-                /* Custom Background */
-
-                $this->add_section( 'background', array(
-                        'title' => __( 'Background' ),
-                        'theme_supports' => 'custom-background',
-                        'priority' => 30,
-                ) );
-
-                // Input type: Color
-                // With sanitize_callback
-                $this->add_setting( 'background_color', array(
-                        'default' => get_theme_support( 'custom-background', 'default-color' ),
-                        'sanitize_callback' => 'sanitize_hexcolor',
-                        'theme_supports' => 'custom-background',
-                        'transport' => 'postMessage',
-                ) );
-
-                $this->add_control( new WP_Customize_Color_Control( $this, 'background_color', array(
-                        'label' => __( 'Background Color' ),
-                        'section' => 'background',
-                ) ) );
-
-                $this->add_setting( 'background_image', array(
-                        'default' => get_theme_support( 'custom-background', 'default-image' ),
-                        'theme_supports' => 'custom-background',
-                ) );
-
-                $this->add_control( new WP_Customize_Image_Control( $this, 'background_image', array(
-                        'label' => __( 'Background Image' ),
-                        'section' => 'background',
-                        'context' => 'custom-background',
-                ) ) );
-
-                $this->add_setting( 'background_repeat', array(
-                        'default' => 'repeat',
-                        'theme_supports' => 'custom-background',
-                ) );
-
-                $this->add_control( 'background_repeat', array(
-                        'label' => __( 'Background Repeat' ),
-                        'section' => 'background',
-                        'type' => 'radio',
-                        'choices' => array(
-                                'no-repeat' => __('No Repeat'),
-                                'repeat' => __('Tile'),
-                                'repeat-x' => __('Tile Horizontally'),
-                                'repeat-y' => __('Tile Vertically'),
-                        ),
-                ) );
-
-                $this->add_setting( 'background_position_x', array(
-                        'default' => 'left',
-                        'theme_supports' => 'custom-background',
-                ) );
-
-                $this->add_control( 'background_position_x', array(
-                        'label' => __( 'Background Position' ),
-                        'section' => 'background',
-                        'type' => 'radio',
-                        'choices' => array(
-                                'left' => __('Left'),
-                                'center' => __('Center'),
-                                'right' => __('Right'),
-                        ),
-                ) );
-
-                $this->add_setting( 'background_attachment', array(
-                        'default' => 'fixed',
-                        'theme_supports' => 'custom-background',
-                ) );
-
-                $this->add_control( 'background_attachment', array(
-                        'label' => __( 'Background Attachment' ),
-                        'section' => 'background',
-                        'type' => 'radio',
-                        'choices' => array(
-                                'fixed' => __('Fixed'),
-                                'scroll' => __('Scroll'),
-                        ),
-                ) );
-
-                /* Nav Menus */
-
-                $locations = get_registered_nav_menus();
-                $menus = wp_get_nav_menus();
-                $menu_locations = get_nav_menu_locations();
-                $num_locations = count( array_keys( $locations ) );
-
-                $this->add_section( 'nav', array(
-                        'title' => __( 'Navigation' ),
-                        'theme_supports' => 'menus',
-                        'priority' => 40,
-                        'description' => sprintf( _n('Your theme supports %s menu. Select which menu you would like to use.', 'Your theme supports %s menus. Select which menu appears in each location.', $num_locations ), number_format_i18n( $num_locations ) ) . "\n\n" . __('You can edit your menu content on the Menus screen in the Appearance section.'),
-                ) );
-
-                if ( $menus ) {
-                        $choices = array( 0 => __( '&mdash; Select &mdash;' ) );
-                        foreach ( $menus as $menu ) {
-                                $truncated_name = wp_html_excerpt( $menu->name, 40 );
-                                $truncated_name = ( $truncated_name == $menu->name ) ? $menu->name : trim( $truncated_name ) . '&hellip;';
-                                $choices[ $menu->term_id ] = $truncated_name;
-                        }
-
-                        foreach ( $locations as $location => $description ) {
-                                $menu_setting_id = "nav_menu_locations[{$location}]";
-
-                                $this->add_setting( $menu_setting_id, array(
-                                        'sanitize_callback' => 'absint',
-                                        'theme_supports' => 'menus',
-                                ) );
-
-                                $this->add_control( $menu_setting_id, array(
-                                        'label' => $description,
-                                        'section' => 'nav',
-                                        'type' => 'select',
-                                        'choices' => $choices,
-                                ) );
-                        }
-                }
-
-                /* Static Front Page */
-                // #WP19627
-
-                $this->add_section( 'static_front_page', array(
-                        'title' => __( 'Static Front Page' ),
-                //        'theme_supports' => 'static-front-page',
-                        'priority' => 50,
-                        'description' => __( 'Your theme supports a static front page.' ),
-                ) );
-
-                $this->add_setting( 'show_on_front', array(
-                        'default' => get_option( 'show_on_front' ),
-                        'capability' => 'manage_options',
-                        'type' => 'option',
-                //        'theme_supports' => 'static-front-page',
-                ) );
-
-                $this->add_control( 'show_on_front', array(
-                        'label' => __( 'Front page displays' ),
-                        'section' => 'static_front_page',
-                        'type' => 'radio',
-                        'choices' => array(
-                                'posts' => __( 'Your latest posts' ),
-                                'page' => __( 'A static page' ),
-                        ),
-                ) );
-
-                $this->add_setting( 'page_on_front', array(
-                        'type' => 'option',
-                        'capability' => 'manage_options',
-                //        'theme_supports' => 'static-front-page',
-                ) );
-
-                $this->add_control( 'page_on_front', array(
-                        'label' => __( 'Front page' ),
-                        'section' => 'static_front_page',
-                        'type' => 'dropdown-pages',
-                ) );
-
-                $this->add_setting( 'page_for_posts', array(
-                        'type' => 'option',
-                        'capability' => 'manage_options',
-                //        'theme_supports' => 'static-front-page',
-                ) );
-
-                $this->add_control( 'page_for_posts', array(
-                        'label' => __( 'Posts page' ),
-                        'section' => 'static_front_page',
-                        'type' => 'dropdown-pages',
-                ) );
-
-                /* Site Title & Tagline */
-
-                $this->add_section( 'strings', array(
-                        'title' => __( 'Site Title & Tagline' ),
-                        'priority' => 5,
-                ) );
-
-                $this->add_setting( 'blogname', array(
-                        'default' => get_option( 'blogname' ),
-                        'type' => 'option',
-                        'capability' => 'manage_options',
-                ) );
-
-                $this->add_control( 'blogname', array(
-                        'label' => __( 'Site Title' ),
-                        'section' => 'strings',
-                ) );
-
-                $this->add_setting( 'blogdescription', array(
-                        'default' => get_option( 'blogdescription' ),
-                        'type' => 'option',
-                        'capability' => 'manage_options',
-                ) );
-
-                $this->add_control( 'blogdescription', array(
-                        'label' => __( 'Tagline' ),
-                        'section' => 'strings',
-                ) );
-        }
-};
-
-// Callback function for sanitizing the header textcolor setting.
-function sanitize_header_textcolor( $color ) {
-        if ( empty( $color ) )
-                return get_theme_support( 'custom-header', 'default-text-color' );
-
-        elseif ( $color == 'blank' )
-                return 'blank';
-
-        return sanitize_hexcolor( $color );
-}
-
-// Callback function for sanitizing a hex color
-function sanitize_hexcolor( $color ) {
-        $color = preg_replace( '/[^0-9a-fA-F]/', '', $color );
-
-        if ( preg_match('|[A-Fa-f0-9]{3,6}|', $color ) )
-                return $color;
-
-        return $color;
-}
</del><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludescustomizecontrolsphp"></a>
<div class="delfile"><h4>Deleted: trunk/wp-includes/customize-controls.php (20851 => 20852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/customize-controls.php        2012-05-23 15:36:27 UTC (rev 20851)
+++ trunk/wp-includes/customize-controls.php        2012-05-23 17:56:42 UTC (rev 20852)
</span><span class="lines">@@ -1,140 +0,0 @@
</span><del>-<?php
-/**
- * Customize Controls
- *
- * @package WordPress
- * @subpackage Customize
- * @since 3.4.0
- */
-
-if ( ! defined( 'ABSPATH' ) )
-        die;
-
-global $wp_scripts;
-
-$registered = $wp_scripts->registered;
-$wp_scripts = new WP_Scripts;
-$wp_scripts->registered = $registered;
-
-add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
-add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
-add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
-
-do_action( 'customize_controls_init' );
-
-wp_enqueue_script( 'customize-controls' );
-wp_enqueue_style( 'customize-controls' );
-
-do_action( 'customize_controls_enqueue_scripts' );
-
-// Let's roll.
-@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
-
-wp_user_settings();
-_wp_admin_html_begin();
-
-$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $this->theme->display('Name') ) ) );
-?><title><?php echo $admin_title; ?></title><?php
-
-do_action( 'customize_controls_print_styles' );
-do_action( 'customize_controls_print_scripts' );
-?>
-</head>
-<body class="wp-full-overlay">
-        <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
-                <?php wp_nonce_field( 'customize_controls' ); ?>
-                <div id="customize-header-actions" class="wp-full-overlay-header">
-                        <a class="back" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>">
-                                <?php printf( __( '&larr; Return to %s' ), __('Manage Themes') ); ?>
-                        </a>
-                </div>
-
-                <div class="wp-full-overlay-sidebar-content">
-                        <div id="customize-info" class="customize-section">
-                                <div class="customize-section-title">
-                                        <span class="preview-notice"><?php _e('You are previewing'); ?></span>
-                                        <strong class="theme-name"><?php echo $this->theme->display('Name'); ?></strong>
-                                </div>
-                                <div class="customize-section-content">
-                                        <?php if ( $screenshot = $this->theme->get_screenshot() ) : ?>
-                                                <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
-                                        <?php endif; ?>
-
-                                        <?php if ( $this->theme->get('Description') ): ?>
-                                                <div class="theme-description"><?php echo $this->theme->display('Description'); ?></div>
-                                        <?php endif; ?>
-                                </div>
-                        </div>
-
-                        <div id="customize-theme-controls"><ul>
-                                <?php
-                                foreach ( $this->sections as $section )
-                                        $section->maybe_render();
-                                ?>
-                        </ul></div>
-                </div>
-
-                <div id="customize-footer-actions" class="wp-full-overlay-footer">
-                        <?php
-                        $save_text = $this->is_current_theme_active() ? __('Save') : __('Save and Activate');
-                        submit_button( $save_text, 'primary', 'save', false );
-                        ?>
-                        <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" />
-
-                        <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
-                                <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
-                                <span class="collapse-sidebar-arrow"></span>
-                        </a>
-                </div>
-        </form>
-        <div id="customize-preview" class="wp-full-overlay-main"></div>
-        <?php
-
-        do_action( 'customize_controls_print_footer_scripts' );
-
-        // If the frontend and the admin are served from the same domain, load the
-        // preview over ssl if the customizer is being loaded over ssl. This avoids
-        // insecure content warnings. This is not attempted if the admin and frontend
-        // are on different domains to avoid the case where the frontend doesn't have
-        // ssl certs. Domain mapping plugins can force ssl in these conditions using
-        // the customize_preview_link filter.
-        $admin_origin = parse_url( admin_url() );
-        $home_origin = parse_url( home_url() );
-        $scheme = null;
-        if ( is_ssl() && ( $admin_origin[ 'host' ] == $home_origin[ 'host' ] ) )
-                $scheme = 'https';
-
-        $preview_url = apply_filters( 'customize_preview_link', home_url( '/', $scheme ) );
-
-        $settings = array(
-                'theme' => array(
-                        'stylesheet' => $this->get_stylesheet(),
-                        'active' => $this->is_current_theme_active(),
-                ),
-                'url' => array(
-                        'preview' => esc_url( $preview_url ),
-                        'parent' => esc_url( admin_url() ),
-                        'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
-                ),
-                'settings' => array(),
-                'controls' => array(),
-        );
-
-        foreach ( $this->settings as $id => $setting ) {
-                $settings['settings'][ $id ] = array(
-                        'value' => $setting->js_value(),
-                        'transport' => $setting->transport,
-                );
-        }
-
-        foreach ( $this->controls as $id => $control ) {
-                $control->to_json();
-                $settings['controls'][ $id ] = $control->json;
-        }
-
-        ?>
-        <script type="text/javascript">
-                var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
-        </script>
-</body>
-</html>
</del></span></pre></div>
<a id="trunkwpincludesthemephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/theme.php (20851 => 20852)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/theme.php        2012-05-23 15:36:27 UTC (rev 20851)
+++ trunk/wp-includes/theme.php        2012-05-23 17:56:42 UTC (rev 20852)
</span><span class="lines">@@ -1566,7 +1566,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Includes and instantiates the WP_Customize class.
</del><ins>+ * Includes and instantiates the WP_Customize_Manager class.
</ins><span class="cx"> *
</span><span class="cx"> * Fires when ?customize=on.
</span><span class="cx"> *
</span><span class="lines">@@ -1574,12 +1574,12 @@
</span><span class="cx"> */
</span><span class="cx"> function _wp_customize_include() {
</span><span class="cx">         // Load on themes.php or ?customize=on
</span><del>-        if ( ! ( isset( $_REQUEST['customize'] ) && 'on' == $_REQUEST['customize'] ) )
</del><ins>+        if ( ! ( ( isset( $_REQUEST['customize'] ) && 'on' == $_REQUEST['customize'] ) || 'customize.php' == basename( $_SERVER['PHP_SELF'] ) ) )
</ins><span class="cx">                 return;
</span><span class="cx">
</span><del>-        require( ABSPATH . WPINC . '/class-wp-customize.php' );
</del><ins>+        require( ABSPATH . WPINC . '/class-wp-customize-manager.php' );
</ins><span class="cx">         // Init Customize class
</span><del>-        $GLOBALS['wp_customize'] = new WP_Customize;
</del><ins>+        $GLOBALS['wp_customize'] = new WP_Customize_Manager;
</ins><span class="cx"> }
</span><span class="cx"> add_action( 'plugins_loaded', '_wp_customize_include' );
</span><span class="cx">
</span><span class="lines">@@ -1604,5 +1604,5 @@
</span><span class="cx"> * @since 3.4.0
</span><span class="cx"> */
</span><span class="cx"> function wp_customize_url( $stylesheet ) {
</span><del>-        return esc_url( admin_url( 'admin.php' ) . '?customize=on&theme=' . $stylesheet );
</del><ins>+        return esc_url( admin_url( 'customize.php' ) . '?theme=' . $stylesheet );
</ins><span class="cx"> }
</span><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>
</body>
</html>