Ticket #29758: 29758.php.diff
File 29758.php.diff, 4.6 KB (added by , 10 years ago) |
---|
-
src/wp-includes/class-wp-customize-panel.php
83 83 public $sections; 84 84 85 85 /** 86 * Callback. 87 * 88 * @since 4.1.0 89 * @access public 90 * 91 * @see WP_Customize_Panel::active() 92 * 93 * @var callable Callback is called with one argument, the instance of 94 * WP_Customize_Panel, and returns bool to indicate whether 95 * the panel is active (such as it relates to the URL 96 * currently being previewed). 97 */ 98 public $active_callback = ''; 99 100 /** 86 101 * Constructor. 87 102 * 88 103 * Any supplied $args override class property defaults. … … 103 118 104 119 $this->manager = $manager; 105 120 $this->id = $id; 121 if ( empty( $this->active_callback ) ) { 122 $this->active_callback = array( $this, 'active_callback' ); 123 } 106 124 107 125 $this->sections = array(); // Users cannot customize the $sections array. 108 126 … … 110 128 } 111 129 112 130 /** 131 * Check whether panel is active to current customizer preview. 132 * 133 * @since 4.1.0 134 * @access public 135 * 136 * @return bool Whether the panel is active to the current preview. 137 */ 138 public final function active() { 139 $panel = $this; 140 $active = call_user_func( $this->active_callback, $this ); 141 142 /** 143 * Filter response of WP_Customize_Panel::active(). 144 * 145 * @since 4.1.0 146 * 147 * @param bool $active Whether the Customizer panel is active. 148 * @param WP_Customize_Panel $panel WP_Customize_Panel instance. 149 */ 150 $active = apply_filters( 'customize_panel_active', $active, $panel ); 151 152 return $active; 153 } 154 155 /** 156 * Default callback used when invoking WP_Customize_Panel::active(). 157 * 158 * Subclasses can override this with their specific logic, or they may 159 * provide an 'active_callback' argument to the constructor. 160 * 161 * @since 4.1.0 162 * @access public 163 * 164 * @return bool Always true. 165 */ 166 public function active_callback() { 167 return true; 168 } 169 170 // @todo once JS API is in place: $this->json['active'] = $this->active(); 171 172 /** 113 173 * Checks required user capabilities and whether the theme has the 114 174 * feature support required by the panel. 115 175 * -
src/wp-includes/class-wp-customize-section.php
92 92 public $controls; 93 93 94 94 /** 95 * Callback. 96 * 97 * @since 4.1.0 98 * @access public 99 * 100 * @see WP_Customize_Section::active() 101 * 102 * @var callable Callback is called with one argument, the instance of 103 * WP_Customize_Section, and returns bool to indicate whether 104 * the secyion is active (such as it relates to the URL 105 * currently being previewed). 106 */ 107 public $active_callback = ''; 108 109 /** 95 110 * Constructor. 96 111 * 97 112 * Any supplied $args override class property defaults. … … 112 127 $this->manager = $manager; 113 128 $this->id = $id; 114 129 130 if ( empty( $this->active_callback ) ) { 131 $this->active_callback = array( $this, 'active_callback' ); 132 } 133 115 134 $this->controls = array(); // Users cannot customize the $controls array. 116 135 117 136 return $this; … … 118 137 } 119 138 120 139 /** 140 * Check whether section is active to current customizer preview. 141 * 142 * @since 4.1.0 143 * @access public 144 * 145 * @return bool Whether the section is active to the current preview. 146 */ 147 public final function active() { 148 $section = $this; 149 $active = call_user_func( $this->active_callback, $this ); 150 151 /** 152 * Filter response of WP_Customize_Section::active(). 153 * 154 * @since 4.1.0 155 * 156 * @param bool $active Whether the Customizer section is active. 157 * @param WP_Customize_Section $section WP_Customize_Section instance. 158 */ 159 $active = apply_filters( 'customize_section_active', $active, $section ); 160 161 return $active; 162 } 163 164 /** 165 * Default callback used when invoking WP_Customize_Section::active(). 166 * 167 * Subclasses can override this with their specific logic, or they may 168 * provide an 'active_callback' argument to the constructor. 169 * 170 * @since 4.1.0 171 * @access public 172 * 173 * @return bool Always true. 174 */ 175 public function active_callback() { 176 return true; 177 } 178 179 // @todo once JS API is in place: $this->json['active'] = $this->active(); 180 181 /** 121 182 * Checks required user capabilities and whether the theme has the 122 183 * feature support required by the section. 123 184 *