<?php
/**
- * Customize Section Class.
- *
- * A UI container for controls, managed by the WP_Customize_Manager.
+ * WordPress Customize Section classes
*
* @package WordPress
* @subpackage Customize
* @since 3.4.0
*/
+
+/**
+ * Customize Section class.
+ *
+ * A UI container for controls, managed by the WP_Customize_Manager class.
+ *
+ * @since 3.4.0
+ *
+ * @see WP_Customize_Manager
+ */
class WP_Customize_Section {
/**
$this->instance_number = self::$instance_count;
$this->controls = array(); // Users cannot customize the $controls array.
-
- return $this;
}
/**
*
* @return bool Whether the section is active to the current preview.
*/
- public final function active() {
+ final public function active() {
$section = $this;
$active = call_user_func( $this->active_callback, $this );
*
* @return bool False if theme doesn't support the section or user doesn't have the capability.
*/
- public final function check_capabilities() {
+ final public function check_capabilities() {
if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) ) {
return false;
}
*
* @return string Contents of the section.
*/
- public final function get_content() {
+ final public function get_content() {
ob_start();
$this->maybe_render();
$template = trim( ob_get_contents() );
*
* @since 3.4.0
*/
- public final function maybe_render() {
+ final public function maybe_render() {
if ( ! $this->check_capabilities() ) {
return;
}
}
/**
- * Customizer section representing widget area (sidebar).
+ * Customize Themes Section class.
*
- * @package WordPress
- * @subpackage Customize
+ * A UI container for theme controls, which behaves like a backwards Panel.
+ *
+ * @since 4.2.0
+ *
+ * @see WP_Customize_Section
+ */
+class WP_Customize_Themes_Section extends WP_Customize_Section {
+
+ /**
+ * Customize section type.
+ *
+ * @since 4.2.0
+ * @access public
+ * @var string
+ */
+ public $type = 'themes';
+
+ /**
+ * Render the themes section, which behaves like a panel.
+ *
+ * @since 4.2.0
+ * @access protected
+ */
+ protected function render() {
+ $classes = 'accordion-section control-section control-section-' . $this->type;
+ ?>
+ <li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
+ <h3 class="accordion-section-title">
+ <?php
+ if ( $this->manager->is_theme_active() ) {
+ /* translators: %s: theme name */
+ printf( __( '<span>Active theme</span> %s' ), $this->title );
+ } else {
+ /* translators: %s: theme name */
+ printf( __( '<span>Previewing theme</span> %s' ), $this->title );
+ }
+ ?>
+
+ <button type="button" class="button change-theme"><?php _ex( 'Change', 'theme' ); ?></button>
+ </h3>
+ <div class="customize-themes-panel control-panel-content themes-php">
+ <h2>
+ <?php _e( 'Themes' ); ?>
+ <span class="title-count theme-count"><?php echo count( $this->controls ) + 1 /* Active theme */; ?></span>
+ </h2>
+
+ <h3 class="accordion-section-title customize-section-title">
+ <?php
+ if ( $this->manager->is_theme_active() ) {
+ /* translators: %s: theme name */
+ printf( __( '<span>Active theme</span> %s' ), $this->title );
+ } else {
+ /* translators: %s: theme name */
+ printf( __( '<span>Previewing theme</span> %s' ), $this->title );
+ }
+ ?>
+ <button type="button" class="button customize-theme"><?php _e( 'Customize' ); ?></button>
+ </h3>
+
+ <div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div>
+
+ <div id="customize-container"></div>
+ <?php if ( count( $this->controls ) > 4 ) : ?>
+ <p><label for="themes-filter">
+ <span class="screen-reader-text"><?php _e( 'Search installed themes...' ); ?></span>
+ <input type="text" id="themes-filter" placeholder="<?php esc_attr_e( 'Search installed themes...' ); ?>" />
+ </label></p>
+ <?php endif; ?>
+ <div class="theme-browser rendered">
+ <ul class="themes accordion-section-content">
+ </ul>
+ </div>
+ </div>
+ </li>
+<?php }
+}
+
+/**
+ * Customizer section representing widget area (sidebar).
*
* @since 4.1.0
*