Ticket #27065: 27065.diff
File 27065.diff, 19.2 KB (added by , 11 years ago) |
---|
-
wp-admin/customize.php
1 1 <?php 2 2 /** 3 * Customize Controls3 * Customize Screen. 4 4 * 5 5 * @package WordPress 6 6 * @subpackage Customize … … 9 9 10 10 define( 'IFRAME_REQUEST', true ); 11 11 12 // WordPress Administration Bootstrap 12 13 require_once( dirname( __FILE__ ) . '/admin.php' ); 14 13 15 if ( ! current_user_can( 'edit_theme_options' ) ) 14 16 wp_die( __( 'Cheatin’ uh?' ) ); 15 17 … … 199 201 'customize-login' => 1 200 202 ), wp_login_url() ); 201 203 204 // Prepare customizer settings to pass to Javascript. 202 205 $settings = array( 203 206 'theme' => array( 204 207 'stylesheet' => $wp_customize->get_stylesheet(), … … 227 230 ), 228 231 ); 229 232 233 // Prepare Customize Setting objects to pass to Javascript. 230 234 foreach ( $wp_customize->settings() as $id => $setting ) { 231 235 $settings['settings'][ $id ] = array( 232 236 'value' => $setting->js_value(), … … 234 238 ); 235 239 } 236 240 241 // Prepare Customize Control objects to pass to Javascript. 237 242 foreach ( $wp_customize->controls() as $id => $control ) { 238 243 $control->to_json(); 239 244 $settings['controls'][ $id ] = $control->json; -
wp-content/themes/twentytwelve/style.css
9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 10 Tags: light, gray, white, one-column, two-columns, right-sidebar, fluid-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready 11 11 Text Domain: twentytwelve 12 Template: bp-default 12 13 13 14 This theme, like WordPress, is licensed under the GPL. 14 15 Use it to make something cool, have fun, and share what you've learned with others. -
wp-includes/class-wp-customize-control.php
39 39 * @access public 40 40 * @var int 41 41 */ 42 public $priority 42 public $priority = 10; 43 43 44 44 /** 45 45 * @access public 46 46 * @var string 47 47 */ 48 public $section 48 public $section = ''; 49 49 50 50 /** 51 51 * @access public 52 52 * @var string 53 53 */ 54 public $label 54 public $label = ''; 55 55 56 56 /** 57 57 * @todo: Remove choices … … 59 59 * @access public 60 60 * @var array 61 61 */ 62 public $choices 62 public $choices = array(); 63 63 64 64 /** 65 65 * @access public … … 77 77 /** 78 78 * Constructor. 79 79 * 80 * Supplied $args override class property defaults. 81 * 80 82 * If $args['settings'] is not defined, use the $id as the setting ID. 81 83 * 82 84 * @since 3.4.0 … … 95 97 $this->manager = $manager; 96 98 $this->id = $id; 97 99 98 99 100 // Process settings. 100 101 if ( empty( $this->settings ) ) 101 102 $this->settings = $id; … … 185 186 } 186 187 187 188 /** 188 * Render the control. Renders the control wrapper, then calls $this->render_content().189 * Renders the control wrapper and calls $this->render_content() for the internals. 189 190 * 190 191 * @since 3.4.0 191 192 */ … … 199 200 } 200 201 201 202 /** 202 * Get the data link parameterfor a setting.203 * Get the data link attribute for a setting. 203 204 * 204 205 * @since 3.4.0 205 206 * 206 * @param string $setting_key207 * @param string $setting_key 207 208 * @return string Data link parameter, if $setting_key is a valid setting, empty string otherwise. 208 209 */ 209 210 public function get_link( $setting_key = 'default' ) { … … 214 215 } 215 216 216 217 /** 217 * Render the data link parameter for a setting218 * Render the data link attribute for the control's input element. 218 219 * 219 220 * @since 3.4.0 220 221 * @uses WP_Customize_Control::get_link() … … 228 229 /** 229 230 * Render the control's content. 230 231 * 231 * Allows the content to be overriden without having to rewrite the wrapper .232 * Allows the content to be overriden without having to rewrite the wrapper in $this->render(). 232 233 * 234 * Supports basic input types `text`, `checkbox`, `radio`, `select` and `dropdown-pages`. 235 * 233 236 * @since 3.4.0 234 237 */ 235 238 protected function render_content() { … … 331 334 /** 332 335 * Constructor. 333 336 * 334 * If $args['settings'] is not defined, use the $id as the setting ID.335 *336 337 * @since 3.4.0 337 338 * @uses WP_Customize_Control::__construct() 338 339 * … … 346 347 } 347 348 348 349 /** 349 * Enqueue co ntrolrelated scripts/styles.350 * Enqueue color-picker related scripts/styles. 350 351 * 351 352 * @since 3.4.0 352 353 */ … … 467 468 /** 468 469 * Constructor. 469 470 * 470 * If $args['settings'] is not defined, use the $id as the setting ID.471 *472 471 * @since 3.4.0 473 472 * @uses WP_Customize_Upload_Control::__construct() 474 473 * -
wp-includes/class-wp-customize-manager.php
2 2 /** 3 3 * Customize Manager. 4 4 * 5 * Bootstraps the Customize experience on the server-side. 6 * 7 * Sets up the theme-switching process if a theme other than the active one is 8 * being previewed and customized. 9 * 10 * Serves as a factory for Customize Controls and Settings, and 11 * instantiates default Customize Controls and Settings. 12 * 5 13 * @package WordPress 6 14 * @subpackage Customize 7 15 * @since 3.4.0 8 16 */ 9 17 final class WP_Customize_Manager { 18 /** 19 * An instance of the theme that is being customized. 20 * 21 * @var WP_Theme 22 */ 10 23 protected $theme; 24 25 /** 26 * The directory name of the previously active theme (within the theme_root). 27 * 28 * @var string 29 */ 11 30 protected $original_stylesheet; 12 31 32 /** 33 * Whether filters have been set to change the active theme to the theme being 34 * customized. 35 * 36 * @var boolean 37 */ 13 38 protected $previewing = false; 14 39 15 40 protected $settings = array(); … … 20 45 21 46 protected $customized; 22 47 48 /** 49 * $_POST values for Customize Settings. 50 * 51 * @var array 52 */ 23 53 private $_post_values; 24 54 25 55 /** … … 28 58 * @since 3.4.0 29 59 */ 30 60 public function __construct() { 61 // All classes in session. 31 62 require( ABSPATH . WPINC . '/class-wp-customize-setting.php' ); 32 63 require( ABSPATH . WPINC . '/class-wp-customize-section.php' ); 33 64 require( ABSPATH . WPINC . '/class-wp-customize-control.php' ); … … 127 158 // Once the theme is loaded, we'll validate it. 128 159 add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) ); 129 160 } else { 161 // If the requested theme is not the active theme and the user doesn't have the 162 // switch_themes cap, bail. 130 163 if ( ! current_user_can( 'switch_themes' ) ) 131 164 $this->wp_die( -1 ); 132 165 133 // If the theme isn't active, you can't preview it if it is not allowed or has errors.166 // If the theme has errors while loading, bail. 134 167 if ( $this->theme()->errors() ) 135 168 $this->wp_die( -1 ); 136 169 170 // If the theme isn't allowed per multisite settings, bail. 137 171 if ( ! $this->theme()->is_allowed() ) 138 172 $this->wp_die( -1 ); 139 173 } 140 174 175 // All good, let's do some internal business to preview the theme. 141 176 $this->start_previewing_theme(); 142 177 } 143 178 … … 154 189 } 155 190 156 191 /** 157 * Start previewing the selected theme .192 * Start previewing the selected theme by adding filters to change the current theme. 158 193 * 159 * Adds filters to change the current theme.160 *161 194 * @since 3.4.0 162 195 */ 163 196 public function start_previewing_theme() { … … 300 333 } 301 334 302 335 /** 303 * Decode the $_POST attribute used to override the WP_Customize_Setting values.336 * Decode the $_POST['customized'] values for a specific Customize Setting. 304 337 * 305 338 * @since 3.4.0 306 339 * 307 * @param mixed $settingA WP_Customize_Setting derived object308 * @return string Sanitized attribute340 * @param mixed $setting A WP_Customize_Setting derived object 341 * @return string $post_value Sanitized value 309 342 */ 310 343 public function post_value( $setting ) { 311 344 if ( ! isset( $this->_post_values ) ) { … … 487 520 } 488 521 489 522 /** 490 * Switch the theme and trigger the save action ofeach setting.523 * Switch the theme and trigger the save() method on each setting. 491 524 * 492 525 * @since 3.4.0 493 526 */ … … 522 555 * 523 556 * @since 3.4.0 524 557 * 525 * @param string $id A specific ID of the setting. Can be a526 * theme mod or option name.527 * @param array $args Setting arguments.558 * @param WP_Customize_Setting|string $id Customize Setting object, or ID. 559 * @param array $args Setting arguments; passed to WP_Customize_Setting 560 * constructor. 528 561 */ 529 562 public function add_setting( $id, $args = array() ) { 530 563 if ( is_a( $id, 'WP_Customize_Setting' ) ) … … 540 573 * 541 574 * @since 3.4.0 542 575 * 543 * @param string $id A specific ID of the setting.544 * @return object The settings object.576 * @param string $id Customize Setting ID. 577 * @return WP_Customize_Setting 545 578 */ 546 579 public function get_setting( $id ) { 547 580 if ( isset( $this->settings[ $id ] ) ) … … 553 586 * 554 587 * @since 3.4.0 555 588 * 556 * @param string $id A specific ID of the setting.589 * @param string $id Customize Setting ID. 557 590 */ 558 591 public function remove_setting( $id ) { 559 592 unset( $this->settings[ $id ] ); … … 564 597 * 565 598 * @since 3.4.0 566 599 * 567 * @param string $id A specific ID of the section.568 * @param array $args Section arguments.600 * @param WP_Customize_Section|string $id Customize Section object, or Section ID. 601 * @param array $args Section arguments. 569 602 */ 570 603 public function add_section( $id, $args = array() ) { 571 604 if ( is_a( $id, 'WP_Customize_Section' ) ) … … 581 614 * 582 615 * @since 3.4.0 583 616 * 584 * @param string $id A specific ID of the section.585 * @return object The section object.617 * @param string $id Section ID. 618 * @return WP_Customize_Section 586 619 */ 587 620 public function get_section( $id ) { 588 621 if ( isset( $this->sections[ $id ] ) ) … … 594 627 * 595 628 * @since 3.4.0 596 629 * 597 * @param string $id A specific ID of the section.630 * @param string $id Section ID. 598 631 */ 599 632 public function remove_section( $id ) { 600 633 unset( $this->sections[ $id ] ); … … 605 638 * 606 639 * @since 3.4.0 607 640 * 608 * @param string $id A specific ID of the control. 609 * @param array $args Setting arguments. 641 * @param WP_Customize_Control|string $id Customize Control object, or ID. 642 * @param array $args Control arguments; passed to WP_Customize_Control 643 * constructor. 610 644 */ 611 645 public function add_control( $id, $args = array() ) { 612 646 if ( is_a( $id, 'WP_Customize_Control' ) ) … … 622 656 * 623 657 * @since 3.4.0 624 658 * 625 * @param string $id A specificID of the control.626 * @return object The settingsobject.659 * @param string $id ID of the control. 660 * @return WP_Customize_Control $control The control object. 627 661 */ 628 662 public function get_control( $id ) { 629 663 if ( isset( $this->controls[ $id ] ) ) … … 631 665 } 632 666 633 667 /** 634 * Remove a customize setting.668 * Remove a customize control. 635 669 * 636 670 * @since 3.4.0 637 671 * 638 * @param string $id A specificID of the control.672 * @param string $id ID of the control. 639 673 */ 640 674 public function remove_control( $id ) { 641 675 unset( $this->controls[ $id ] ); … … 662 696 /** 663 697 * Prepare settings and sections. 664 698 * 699 * For each, check if required related components exist, 700 * whether the user has the necessary capabilities, 701 * and sort by priority. 702 * 665 703 * @since 3.4.0 666 704 */ 667 705 public function prepare_controls() { 668 // Prepare controls669 // Reversing makes uasort sort by time added when conflicts occur.670 706 671 707 $this->controls = array_reverse( $this->controls ); 672 708 $controls = array(); … … 995 1031 }; 996 1032 997 1033 /** 998 * Validates a hex color.1034 * Sanitizes a hex color. 999 1035 * 1000 1036 * Returns either '', a 3 or 6 digit hex color (with #), or null. 1001 * For validating values without a #, see sanitize_hex_color_no_hash().1037 * For sanitizing values without a #, see sanitize_hex_color_no_hash(). 1002 1038 * 1003 1039 * @since 3.4.0 1004 1040 * -
wp-includes/class-wp-customize-section.php
2 2 /** 3 3 * Customize Section Class. 4 4 * 5 * A UI container for controls, managed by the WP_Customize_Manager. 6 * 5 7 * @package WordPress 6 8 * @subpackage Customize 7 9 * @since 3.4.0 8 10 */ 9 11 class WP_Customize_Section { 12 /** 13 * @access public 14 * 15 * @var WP_Customize_Manager 16 */ 10 17 public $manager; 18 19 /** 20 * Unique identifier. 21 * 22 * @var string 23 */ 11 24 public $id; 25 26 /** 27 * Priority of the section which informs load order of sections. 28 * 29 * @var integer 30 */ 12 31 public $priority = 10; 32 33 /** 34 * Capability required for the section. 35 * 36 * @var string 37 */ 13 38 public $capability = 'edit_theme_options'; 14 39 public $theme_supports = ''; 40 41 /** 42 * Title of the section to show in UI. 43 * 44 * @var string 45 */ 15 46 public $title = ''; 47 48 /** 49 * Description to show in the UI. 50 * 51 * @var string 52 */ 16 53 public $description = ''; 17 54 public $controls; 18 55 19 56 /** 20 57 * Constructor. 21 58 * 59 * Any supplied $args override class property defaults. 60 * 22 61 * @since 3.4.0 23 62 * 24 63 * @param WP_Customize_Manager $manager 25 * @param string $idAn specific ID of the section.26 * @param array $argsSection arguments.64 * @param string $id An specific ID of the section. 65 * @param array $args Section arguments. 27 66 */ 28 67 function __construct( $manager, $id, $args = array() ) { 29 68 $keys = array_keys( get_class_vars( __CLASS__ ) ); … … 41 80 } 42 81 43 82 /** 44 * Check if the theme supports the section and check user capabilities. 83 * Checks required user capabilities and whether the theme has the 84 * feature support required by the section. 45 85 * 46 86 * @since 3.4.0 47 87 * … … 71 111 * 72 112 * @since 3.4.0 73 113 * 74 * @param WP_Customize_Section $this TheWP_Customize_Section instance.114 * @param WP_Customize_Section $this WP_Customize_Section instance. 75 115 */ 76 116 do_action( 'customize_render_section', $this ); 77 117 /** … … 88 128 } 89 129 90 130 /** 91 * Render the section .131 * Render the section, and the controls that have been added to it. 92 132 * 93 133 * @since 3.4.0 94 134 */ -
wp-includes/class-wp-customize-setting.php
2 2 /** 3 3 * Customize Setting Class. 4 4 * 5 * Handles business logic for a setting: saving and sanitizing data. 6 * 5 7 * @package WordPress 6 8 * @subpackage Customize 7 9 * @since 3.4.0 8 10 */ 9 11 class WP_Customize_Setting { 12 /** 13 * @access public 14 * @var WP_Customize_Manager 15 */ 10 16 public $manager; 17 18 /** 19 * @access public 20 * @var string 21 */ 11 22 public $id; 12 23 13 public $type = 'theme_mod'; 24 /** 25 * @access public 26 * @var string 27 */ 28 public $type = 'theme_mod'; 29 30 /** 31 * Capability required to edit this setting. 32 * 33 * @var string 34 */ 14 35 public $capability = 'edit_theme_options'; 36 37 /** 38 * Feature a theme is required to support to enable this setting. 39 * 40 * @access public 41 * @var string 42 */ 15 43 public $theme_supports = ''; 16 44 public $default = ''; 17 45 public $transport = 'refresh'; 18 46 47 /** 48 * Server-side sanitization callback for the setting's value. 49 * 50 * @var callback 51 */ 19 52 public $sanitize_callback = ''; 20 53 public $sanitize_js_callback = ''; 21 54 22 55 protected $id_data = array(); 23 private $_post_value; // Cached, sanitized $_POST value.24 56 25 57 /** 58 * Cached and sanitized $_POST value for the setting. 59 * 60 * @access private 61 * @var mixed 62 */ 63 private $_post_value; 64 65 /** 26 66 * Constructor. 27 67 * 68 * Any supplied $args override class property defaults. 69 * 28 70 * @since 3.4.0 29 71 * 30 * @param WP_Customize_Manager $manager31 * @param string $idAn specific ID of the setting. Can be a32 * theme mod or option name.33 * @param array $argsSetting arguments.34 * @return WP_Customize_Setting 72 * @param WP_Customize_Manager $manager 73 * @param string $id An specific ID of the setting. Can be a 74 * theme mod or option name. 75 * @param array $args Setting arguments. 76 * @return WP_Customize_Setting $setting 35 77 */ 36 78 function __construct( $manager, $id, $args = array() ) { 37 79 $keys = array_keys( get_class_vars( __CLASS__ ) ); … … 98 140 } 99 141 100 142 /** 101 * Set the value of the parameter for a specific theme. 143 * Check user capabilities and theme supports, and then save 144 * the value of the setting. 102 145 * 103 146 * @since 3.4.0 104 147 * … … 116 159 } 117 160 118 161 /** 119 * Fetch es, validates, and sanitizes the $_POST value.162 * Fetch and sanitize the $_POST value for the setting. 120 163 * 121 164 * @since 3.4.0 122 165 * … … 124 167 * @return mixed The default value on failure, otherwise the sanitized value. 125 168 */ 126 169 public final function post_value( $default = null ) { 170 // Check for a cached value 127 171 if ( isset( $this->_post_value ) ) 128 172 return $this->_post_value; 129 173 174 // Call the manager for the post value 130 175 $result = $this->manager->post_value( $this ); 131 176 132 177 if ( isset( $result ) ) … … 140 185 * 141 186 * @since 3.4.0 142 187 * 143 * @param mixed $value The value to sanitize.188 * @param mixed $value The value to sanitize. 144 189 * @return mixed Null if an input isn't valid, otherwise the sanitized value. 145 190 */ 146 191 public function sanitize( $value ) { … … 149 194 } 150 195 151 196 /** 152 * S et the value of the parameter for a specific theme.197 * Save the value of the setting, using the related API. 153 198 * 154 199 * @since 3.4.0 155 200 * 156 * @param mixed $value The value to update.157 * @return mixed The result of saving the value.201 * @param mixed $value The value to update. 202 * @return mixed The result of saving the value. 158 203 */ 159 204 protected function update( $value ) { 160 205 switch( $this->type ) { … … 190 235 } 191 236 192 237 /** 193 * Update the theme mod from the value of the parameter.238 * Update the option from the value of the setting. 194 239 * 195 240 * @since 3.4.0 196 241 * 197 * @param mixed $value The value to update.242 * @param mixed $value The value to update. 198 243 * @return mixed The result of saving the value. 199 244 */ 200 245 protected function _update_option( $value ) { … … 210 255 } 211 256 212 257 /** 213 * Fetch the value of the parameter for a specific theme.258 * Fetch the value of the setting. 214 259 * 215 260 * @since 3.4.0 216 261 * 217 * @return mixed The requestedvalue.262 * @return mixed The value. 218 263 */ 219 264 public function value() { 265 // Get the callback that corresponds to the setting type. 220 266 switch( $this->type ) { 221 267 case 'theme_mod' : 222 268 $function = 'get_theme_mod'; … … 238 284 } 239 285 240 286 /** 241 * Escape the parameter's value for use in JavaScript.287 * Sanitize and escape the setting's value for use in JavaScript. 242 288 * 243 289 * @since 3.4.0 244 290 * … … 254 300 } 255 301 256 302 /** 257 * Check if the theme supports the setting and check user capabilities.303 * Validate user capabilities whether the theme supports the setting. 258 304 * 259 305 * @since 3.4.0 260 306 *