Changeset 27398
- Timestamp:
- 03/04/2014 08:20:28 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/customize.php
r26085 r27398 1 1 <?php 2 2 /** 3 * Customize Controls3 * Theme Customize Screen. 4 4 * 5 5 * @package WordPress … … 10 10 define( 'IFRAME_REQUEST', true ); 11 11 12 /** Load 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?' ) ); … … 200 202 ), wp_login_url() ); 201 203 204 // Prepare customizer settings to pass to Javascript. 202 205 $settings = array( 203 206 'theme' => array( … … 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( … … 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(); -
trunk/src/wp-includes/class-wp-customize-control.php
r27369 r27398 40 40 * @var int 41 41 */ 42 public $priority 42 public $priority = 10; 43 43 44 44 /** … … 46 46 * @var string 47 47 */ 48 public $section 48 public $section = ''; 49 49 50 50 /** … … 52 52 * @var string 53 53 */ 54 public $label 54 public $label = ''; 55 55 56 56 /** … … 60 60 * @var array 61 61 */ 62 public $choices 62 public $choices = array(); 63 63 64 64 /** … … 77 77 /** 78 78 * Constructor. 79 * 80 * Supplied $args override class property defaults. 79 81 * 80 82 * If $args['settings'] is not defined, use the $id as the setting ID. … … 95 97 $this->manager = $manager; 96 98 $this->id = $id; 97 98 99 99 100 // Process settings. … … 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 … … 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 … … 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 … … 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(). 233 * 234 * Supports basic input types `text`, `checkbox`, `radio`, `select` and `dropdown-pages`. 232 235 * 233 236 * @since 3.4.0 … … 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() … … 347 348 348 349 /** 349 * Enqueue control related scripts/styles.350 * Enqueue scripts/styles for the color picker. 350 351 * 351 352 * @since 3.4.0 … … 467 468 /** 468 469 * Constructor. 469 *470 * If $args['settings'] is not defined, use the $id as the setting ID.471 470 * 472 471 * @since 3.4.0 -
trunk/src/wp-includes/class-wp-customize-manager.php
r24687 r27398 2 2 /** 3 3 * Customize Manager. 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. 4 12 * 5 13 * @package WordPress … … 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 … … 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 … … 128 158 add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) ); 129 159 } else { 160 // If the requested theme is not the active theme and the user doesn't have the 161 // switch_themes cap, bail. 130 162 if ( ! current_user_can( 'switch_themes' ) ) 131 163 $this->wp_die( -1 ); 132 164 133 // If the theme isn't active, you can't preview it if it is not allowed or has errors.165 // If the theme has errors while loading, bail. 134 166 if ( $this->theme()->errors() ) 135 167 $this->wp_die( -1 ); 136 168 169 // If the theme isn't allowed per multisite settings, bail. 137 170 if ( ! $this->theme()->is_allowed() ) 138 171 $this->wp_die( -1 ); 139 172 } 140 173 174 // All good, let's do some internal business to preview the theme. 141 175 $this->start_previewing_theme(); 142 176 } … … 155 189 156 190 /** 157 * Start previewing the selected theme. 158 * 159 * Adds filters to change the current theme. 191 * Start previewing the selected theme by adding filters to change the current theme. 160 192 * 161 193 * @since 3.4.0 … … 301 333 302 334 /** 303 * Decode the $_POST attribute used to override the WP_Customize_Setting values.335 * Decode the $_POST['customized'] values for a specific Customize Setting. 304 336 * 305 337 * @since 3.4.0 306 338 * 307 339 * @param mixed $setting A WP_Customize_Setting derived object 308 * @return string Sanitized attribute340 * @return string $post_value Sanitized value 309 341 */ 310 342 public function post_value( $setting ) { … … 488 520 489 521 /** 490 * Switch the theme and trigger the save action ofeach setting.522 * Switch the theme and trigger the save() method on each setting. 491 523 * 492 524 * @since 3.4.0 … … 523 555 * @since 3.4.0 524 556 * 525 * @param string $id A specific ID of the setting. Can be a526 * theme mod or option name.527 * @param array $args Setting arguments.557 * @param WP_Customize_Setting|string $id Customize Setting object, or ID. 558 * @param array $args Setting arguments; passed to WP_Customize_Setting 559 * constructor. 528 560 */ 529 561 public function add_setting( $id, $args = array() ) { … … 541 573 * @since 3.4.0 542 574 * 543 * @param string $id A specific ID of the setting.544 * @return object The settings object.575 * @param string $id Customize Setting ID. 576 * @return WP_Customize_Setting 545 577 */ 546 578 public function get_setting( $id ) { … … 554 586 * @since 3.4.0 555 587 * 556 * @param string $id A specific ID of the setting.588 * @param string $id Customize Setting ID. 557 589 */ 558 590 public function remove_setting( $id ) { … … 565 597 * @since 3.4.0 566 598 * 567 * @param string $id A specific ID of the section.568 * @param array $args Section arguments.599 * @param WP_Customize_Section|string $id Customize Section object, or Section ID. 600 * @param array $args Section arguments. 569 601 */ 570 602 public function add_section( $id, $args = array() ) { … … 582 614 * @since 3.4.0 583 615 * 584 * @param string $id A specific ID of the section.585 * @return object The section object.616 * @param string $id Section ID. 617 * @return WP_Customize_Section 586 618 */ 587 619 public function get_section( $id ) { … … 595 627 * @since 3.4.0 596 628 * 597 * @param string $id A specific ID of the section.629 * @param string $id Section ID. 598 630 */ 599 631 public function remove_section( $id ) { … … 606 638 * @since 3.4.0 607 639 * 608 * @param string $id A specific ID of the control. 609 * @param array $args Setting arguments. 640 * @param WP_Customize_Control|string $id Customize Control object, or ID. 641 * @param array $args Control arguments; passed to WP_Customize_Control 642 * constructor. 610 643 */ 611 644 public function add_control( $id, $args = array() ) { … … 623 656 * @since 3.4.0 624 657 * 625 * @param string $id A specificID of the control.626 * @return object The settingsobject.658 * @param string $id ID of the control. 659 * @return WP_Customize_Control $control The control object. 627 660 */ 628 661 public function get_control( $id ) { … … 632 665 633 666 /** 634 * Remove a customize setting.635 * 636 * @since 3.4.0 637 * 638 * @param string $id A specificID of the control.667 * Remove a customize control. 668 * 669 * @since 3.4.0 670 * 671 * @param string $id ID of the control. 639 672 */ 640 673 public function remove_control( $id ) { … … 663 696 * Prepare settings and sections. 664 697 * 698 * For each, check if required related components exist, 699 * whether the user has the necessary capabilities, 700 * and sort by priority. 701 * 665 702 * @since 3.4.0 666 703 */ 667 704 public function prepare_controls() { 668 // Prepare controls669 // Reversing makes uasort sort by time added when conflicts occur.670 705 671 706 $this->controls = array_reverse( $this->controls ); … … 681 716 $this->controls = $controls; 682 717 683 // Prepare sections 718 // Prepare sections. 719 // Reversing makes uasort sort by time added when conflicts occur. 684 720 $this->sections = array_reverse( $this->sections ); 685 721 uasort( $this->sections, array( $this, '_cmp_priority' ) ); … … 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 -
trunk/src/wp-includes/class-wp-customize-section.php
r26892 r27398 2 2 /** 3 3 * Customize Section Class. 4 * 5 * A UI container for controls, managed by the WP_Customize_Manager. 4 6 * 5 7 * @package WordPress … … 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; … … 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() ) { … … 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 … … 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 ); … … 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 -
trunk/src/wp-includes/class-wp-customize-setting.php
r27262 r27398 2 2 /** 3 3 * Customize Setting Class. 4 * 5 * Handles saving and sanitizing of settings. 4 6 * 5 7 * @package WordPress … … 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'; 14 public $capability = 'edit_theme_options'; 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 */ 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. 56 57 /** 58 * Cached and sanitized $_POST value for the setting. 59 * 60 * @access private 61 * @var mixed 62 */ 63 private $_post_value; 24 64 25 65 /** 26 66 * Constructor. 27 67 * 68 * Any supplied $args override class property defaults. 69 * 28 70 * @since 3.4.0 29 71 * 30 72 * @param WP_Customize_Manager $manager 31 * @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 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() ) { … … 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 … … 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 … … 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 … … 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 … … 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 … … 211 256 212 257 /** 213 * Fetch the value of the parameter for a specific theme.214 * 215 * @since 3.4.0 216 * 217 * @return mixed The requestedvalue.258 * Fetch the value of the setting. 259 * 260 * @since 3.4.0 261 * 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' : … … 239 285 240 286 /** 241 * Escape the parameter's value for use in JavaScript.287 * Sanitize the setting's value for use in JavaScript. 242 288 * 243 289 * @since 3.4.0 … … 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
Note: See TracChangeset
for help on using the changeset viewer.