161 $this->$key = $args[ $key ]; |
159 $this->$key = $args[ $key ]; |
162 } |
160 } |
163 } |
161 } |
164 |
162 |
165 $this->manager = $manager; |
163 $this->manager = $manager; |
166 $this->id = $id; |
164 $this->id = $id; |
167 if ( empty( $this->active_callback ) ) { |
165 if ( empty( $this->active_callback ) ) { |
168 $this->active_callback = array( $this, 'active_callback' ); |
166 $this->active_callback = array( $this, 'active_callback' ); |
169 } |
167 } |
170 self::$instance_count += 1; |
168 self::$instance_count += 1; |
171 $this->instance_number = self::$instance_count; |
169 $this->instance_number = self::$instance_count; |
180 * |
178 * |
181 * @return bool Whether the section is active to the current preview. |
179 * @return bool Whether the section is active to the current preview. |
182 */ |
180 */ |
183 final public function active() { |
181 final public function active() { |
184 $section = $this; |
182 $section = $this; |
185 $active = call_user_func( $this->active_callback, $this ); |
183 $active = call_user_func( $this->active_callback, $this ); |
186 |
184 |
187 /** |
185 /** |
188 * Filters response of WP_Customize_Section::active(). |
186 * Filters response of WP_Customize_Section::active(). |
189 * |
187 * |
190 * @since 4.1.0 |
188 * @since 4.1.0 |
217 * @since 4.1.0 |
215 * @since 4.1.0 |
218 * |
216 * |
219 * @return array The array to be exported to the client as JSON. |
217 * @return array The array to be exported to the client as JSON. |
220 */ |
218 */ |
221 public function json() { |
219 public function json() { |
222 $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'panel', 'type', 'description_hidden' ) ); |
220 $array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'panel', 'type', 'description_hidden' ) ); |
223 $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
221 $array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) ); |
224 $array['content'] = $this->get_content(); |
222 $array['content'] = $this->get_content(); |
225 $array['active'] = $this->active(); |
223 $array['active'] = $this->active(); |
226 $array['instanceNumber'] = $this->instance_number; |
224 $array['instanceNumber'] = $this->instance_number; |
227 |
225 |
228 if ( $this->panel ) { |
226 if ( $this->panel ) { |
229 /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ |
227 /* translators: ▸ is the unicode right-pointing triangle, and %s is the section title in the Customizer */ |
230 $array['customizeAction'] = sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( $this->panel )->title ) ); |
228 $array['customizeAction'] = sprintf( __( 'Customizing ▸ %s' ), esc_html( $this->manager->get_panel( $this->panel )->title ) ); |