Make WordPress Core


Ignore:
Timestamp:
11/13/2014 12:18:01 PM (10 years ago)
Author:
ocean90
Message:

Customizer: Improve ability to filter active state for widget area Customizer sections.

  • Mark panels, sections, controls as active if preview explicitly indicates.
  • Introduce WP_Customize_Sidebar_Section PHP class, and SidebarSection JS class.
  • Move logic for determining whether a sidebar section is active from the SidebarControl to SidebarSection.

props westonruter.
fixes #30235.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-section.php

    r30214 r30329  
    311311    }
    312312}
     313
     314/**
     315 * Customizer section representing widget area (sidebar).
     316 *
     317 * @package WordPress
     318 * @subpackage Customize
     319 * @since 4.1.0
     320 */
     321class WP_Customize_Sidebar_Section extends WP_Customize_Section {
     322
     323    /**
     324     * @since 4.1.0
     325     * @access public
     326     * @var string
     327     */
     328    public $type = 'sidebar';
     329
     330    /**
     331     * Unique identifier.
     332     *
     333     * @since 4.1.0
     334     * @access public
     335     * @var string
     336     */
     337    public $sidebar_id;
     338
     339    /**
     340     * Gather the parameters passed to client JavaScript via JSON.
     341     *
     342     * @since 4.1.0
     343     *
     344     * @return array The array to be exported to the client as JSON
     345     */
     346    public function json() {
     347        $json = parent::json();
     348        $json['sidebarId'] = $this->sidebar_id;
     349        return $json;
     350    }
     351
     352    /**
     353     * Whether the current sidebar is rendered on the page.
     354     *
     355     * @since 4.1.0
     356     * @access public
     357     *
     358     * @return bool Whether sidebar is rendered.
     359     */
     360    public function active_callback() {
     361        return $this->manager->widgets->is_sidebar_rendered( $this->sidebar_id );
     362    }
     363}
Note: See TracChangeset for help on using the changeset viewer.