wp/wp-includes/class-wp-customize-panel.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    22 	 * Incremented with each new class instantiation, then stored in $instance_number.
    22 	 * Incremented with each new class instantiation, then stored in $instance_number.
    23 	 *
    23 	 *
    24 	 * Used when sorting two instances whose priorities are equal.
    24 	 * Used when sorting two instances whose priorities are equal.
    25 	 *
    25 	 *
    26 	 * @since 4.1.0
    26 	 * @since 4.1.0
    27 	 *
       
    28 	 * @static
       
    29 	 * @var int
    27 	 * @var int
    30 	 */
    28 	 */
    31 	protected static $instance_count = 0;
    29 	protected static $instance_count = 0;
    32 
    30 
    33 	/**
    31 	/**
   150 				$this->$key = $args[ $key ];
   148 				$this->$key = $args[ $key ];
   151 			}
   149 			}
   152 		}
   150 		}
   153 
   151 
   154 		$this->manager = $manager;
   152 		$this->manager = $manager;
   155 		$this->id = $id;
   153 		$this->id      = $id;
   156 		if ( empty( $this->active_callback ) ) {
   154 		if ( empty( $this->active_callback ) ) {
   157 			$this->active_callback = array( $this, 'active_callback' );
   155 			$this->active_callback = array( $this, 'active_callback' );
   158 		}
   156 		}
   159 		self::$instance_count += 1;
   157 		self::$instance_count += 1;
   160 		$this->instance_number = self::$instance_count;
   158 		$this->instance_number = self::$instance_count;
   168 	 * @since 4.1.0
   166 	 * @since 4.1.0
   169 	 *
   167 	 *
   170 	 * @return bool Whether the panel is active to the current preview.
   168 	 * @return bool Whether the panel is active to the current preview.
   171 	 */
   169 	 */
   172 	final public function active() {
   170 	final public function active() {
   173 		$panel = $this;
   171 		$panel  = $this;
   174 		$active = call_user_func( $this->active_callback, $this );
   172 		$active = call_user_func( $this->active_callback, $this );
   175 
   173 
   176 		/**
   174 		/**
   177 		 * Filters response of WP_Customize_Panel::active().
   175 		 * Filters response of WP_Customize_Panel::active().
   178 		 *
   176 		 *
   206 	 * @since 4.1.0
   204 	 * @since 4.1.0
   207 	 *
   205 	 *
   208 	 * @return array The array to be exported to the client as JSON.
   206 	 * @return array The array to be exported to the client as JSON.
   209 	 */
   207 	 */
   210 	public function json() {
   208 	public function json() {
   211 		$array = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type' ) );
   209 		$array                          = wp_array_slice_assoc( (array) $this, array( 'id', 'description', 'priority', 'type' ) );
   212 		$array['title'] = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
   210 		$array['title']                 = html_entity_decode( $this->title, ENT_QUOTES, get_bloginfo( 'charset' ) );
   213 		$array['content'] = $this->get_content();
   211 		$array['content']               = $this->get_content();
   214 		$array['active'] = $this->active();
   212 		$array['active']                = $this->active();
   215 		$array['instanceNumber'] = $this->instance_number;
   213 		$array['instanceNumber']        = $this->instance_number;
   216 		$array['autoExpandSoleSection'] = $this->auto_expand_sole_section;
   214 		$array['autoExpandSoleSection'] = $this->auto_expand_sole_section;
   217 		return $array;
   215 		return $array;
   218 	}
   216 	}
   219 
   217 
   220 	/**
   218 	/**
   316 			<?php $this->content_template(); ?>
   314 			<?php $this->content_template(); ?>
   317 		</script>
   315 		</script>
   318 		<script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr( $this->type ); ?>">
   316 		<script type="text/html" id="tmpl-customize-panel-<?php echo esc_attr( $this->type ); ?>">
   319 			<?php $this->render_template(); ?>
   317 			<?php $this->render_template(); ?>
   320 		</script>
   318 		</script>
   321         <?php
   319 		<?php
   322 	}
   320 	}
   323 
   321 
   324 	/**
   322 	/**
   325 	 * An Underscore (JS) template for rendering this panel's container.
   323 	 * An Underscore (JS) template for rendering this panel's container.
   326 	 *
   324 	 *
   356 	protected function content_template() {
   354 	protected function content_template() {
   357 		?>
   355 		?>
   358 		<li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>">
   356 		<li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>">
   359 			<button class="customize-panel-back" tabindex="-1"><span class="screen-reader-text"><?php _e( 'Back' ); ?></span></button>
   357 			<button class="customize-panel-back" tabindex="-1"><span class="screen-reader-text"><?php _e( 'Back' ); ?></span></button>
   360 			<div class="accordion-section-title">
   358 			<div class="accordion-section-title">
   361 				<span class="preview-notice"><?php
   359 				<span class="preview-notice">
       
   360 				<?php
   362 					/* translators: %s: the site/panel title in the Customizer */
   361 					/* translators: %s: the site/panel title in the Customizer */
   363 					echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title">{{ data.title }}</strong>' );
   362 					echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title">{{ data.title }}</strong>' );
   364 				?></span>
   363 				?>
       
   364 				</span>
   365 				<# if ( data.description ) { #>
   365 				<# if ( data.description ) { #>
   366 					<button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
   366 					<button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
   367 				<# } #>
   367 				<# } #>
   368 			</div>
   368 			</div>
   369 			<# if ( data.description ) { #>
   369 			<# if ( data.description ) { #>