]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/class-wp-customize-section.php
WordPress 4.2.5
[autoinstalls/wordpress.git] / wp-includes / class-wp-customize-section.php
index b033203e7fa9394ebeefbb8d86e8d4fe51970161..b852dfbacdf148a281e70006a6e88da8418f0cfb 100644 (file)
@@ -1,13 +1,21 @@
 <?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 {
 
        /**
@@ -163,8 +171,6 @@ class WP_Customize_Section {
                $this->instance_number = self::$instance_count;
 
                $this->controls = array(); // Users cannot customize the $controls array.
-
-               return $this;
        }
 
        /**
@@ -175,7 +181,7 @@ class WP_Customize_Section {
         *
         * @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 );
 
@@ -230,7 +236,7 @@ class WP_Customize_Section {
         *
         * @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;
                }
@@ -249,7 +255,7 @@ class WP_Customize_Section {
         *
         * @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() );
@@ -262,7 +268,7 @@ class WP_Customize_Section {
         *
         * @since 3.4.0
         */
-       public final function maybe_render() {
+       final public function maybe_render() {
                if ( ! $this->check_capabilities() ) {
                        return;
                }
@@ -314,10 +320,87 @@ class WP_Customize_Section {
 }
 
 /**
- * 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
  *