Changeset 27398 for trunk/src/wp-includes/class-wp-customize-manager.php
- Timestamp:
- 03/04/2014 08:20:28 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.