Changeset 28861 for trunk/src/wp-includes/class-wp-customize-manager.php
- Timestamp:
- 06/26/2014 08:16:21 PM (11 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src
- Property svn:ignore
-
old new 1 1 .wp-tests-version 2 2 .htaccess 3 web-store-experiences
-
- Property svn:ignore
-
trunk/src/wp-includes/class-wp-customize-manager.php
r28546 r28861 46 46 47 47 protected $settings = array(); 48 protected $panels = array(); 48 49 protected $sections = array(); 49 50 protected $controls = array(); … … 313 314 public function sections() { 314 315 return $this->sections; 316 } 317 318 /** 319 * Get the registered panels. 320 * 321 * @since 4.0.0 322 * 323 * @return array 324 */ 325 public function panels() { 326 return $this->panels; 315 327 } 316 328 … … 649 661 650 662 /** 663 * Add a customize panel. 664 * 665 * @since 4.0.0 666 * 667 * @param WP_Customize_Panel|string $id Customize Panel object, or Panel ID. 668 * @param array $args Panel arguments. 669 */ 670 public function add_panel( $id, $args = array() ) { 671 if ( is_a( $id, 'WP_Customize_Panel' ) ) { 672 $panel = $id; 673 } 674 else { 675 $panel = new WP_Customize_Panel( $this, $id, $args ); 676 } 677 678 $this->panels[ $panel->id ] = $panel; 679 } 680 681 /** 682 * Retrieve a customize panel. 683 * 684 * @since 4.0.0 685 * 686 * @param string $id Panel ID. 687 * @return WP_Customize_Panel 688 */ 689 public function get_panel( $id ) { 690 if ( isset( $this->panels[ $id ] ) ) { 691 return $this->panels[ $id ]; 692 } 693 } 694 695 /** 696 * Remove a customize panel. 697 * 698 * @since 4.0.0 699 * 700 * @param string $id Panel ID. 701 */ 702 public function remove_panel( $id ) { 703 unset( $this->panels[ $id ] ); 704 } 705 706 /** 651 707 * Add a customize section. 652 708 * … … 750 806 751 807 /** 752 * Prepare settings and sections.808 * Prepare panels, sections, and controls. 753 809 * 754 810 * For each, check if required related components exist, … … 764 820 765 821 foreach ( $this->controls as $id => $control ) { 766 if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() ) 822 if ( ! isset( $this->sections[ $control->section ] ) || ! $control->check_capabilities() ) { 767 823 continue; 824 } 768 825 769 826 $this->sections[ $control->section ]->controls[] = $control; … … 779 836 780 837 foreach ( $this->sections as $section ) { 781 if ( ! $section->check_capabilities() || ! $section->controls ) 838 if ( ! $section->check_capabilities() || ! $section->controls ) { 782 839 continue; 840 } 783 841 784 842 usort( $section->controls, array( $this, '_cmp_priority' ) ); 785 $sections[] = $section; 843 844 if ( ! $section->panel ) { 845 // Top-level section. 846 $sections[] = $section; 847 } else { 848 // This section belongs to a panel. 849 if ( isset( $this->panels [ $section->panel ] ) ) { 850 $this->panels[ $section->panel ]->sections[] = $section; 851 } 852 } 786 853 } 787 854 $this->sections = $sections; 855 856 // Prepare panels. 857 // Reversing makes uasort sort by time added when conflicts occur. 858 $this->panels = array_reverse( $this->panels ); 859 uasort( $this->panels, array( $this, '_cmp_priority' ) ); 860 $panels = array(); 861 862 foreach ( $this->panels as $panel ) { 863 if ( ! $panel->check_capabilities() || ! $panel->sections ) { 864 continue; 865 } 866 867 usort( $panel->sections, array( $this, '_cmp_priority' ) ); 868 $panels[] = $panel; 869 } 870 $this->panels = $panels; 788 871 } 789 872
Note: See TracChangeset
for help on using the changeset viewer.