Make WordPress Core


Ignore:
Timestamp:
10/29/2014 10:50:21 PM (10 years ago)
Author:
ocean90
Message:

Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.

  • Introduce models for panels and sections.
  • Introduce API to expand and focus a control, section or panel.
  • Allow deep-linking to panels, sections, and controls inside of the Customizer.
  • Clean up accordion.js, removing all Customizer-specific logic.
  • Add initial unit tests for wp.customize.Class in customize-base.js.

https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.

props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.

File:
1 edited

Legend:

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

    r30087 r30102  
    7575
    7676    /**
     77     * @deprecated It is better to just call the json() method
    7778     * @access public
    7879     * @var array
     
    219220
    220221        $this->json['type']        = $this->type;
     222        $this->json['priority']    = $this->priority;
     223        $this->json['active']      = $this->active();
     224        $this->json['section']     = $this->section;
     225        $this->json['content']     = $this->get_content();
    221226        $this->json['label']       = $this->label;
    222227        $this->json['description'] = $this->description;
    223         $this->json['active']      = $this->active();
     228    }
     229
     230    /**
     231     * Get the data to export to the client via JSON.
     232     *
     233     * @since 4.1.0
     234     *
     235     * @return array
     236     */
     237    public function json() {
     238        $this->to_json();
     239        return $this->json;
    224240    }
    225241
     
    242258
    243259        return true;
     260    }
     261
     262    /**
     263     * Get the control's content for insertion into the Customizer pane.
     264     *
     265     * @since 4.1.0
     266     *
     267     * @return string
     268     */
     269    public final function get_content() {
     270        ob_start();
     271        $this->maybe_render();
     272        $template = trim( ob_get_contents() );
     273        ob_end_clean();
     274        return $template;
    244275    }
    245276
     
    10741105 * Widget Area Customize Control Class
    10751106 *
     1107 * @since 3.9.0
    10761108 */
    10771109class WP_Widget_Area_Customize_Control extends WP_Customize_Control {
     
    11151147/**
    11161148 * Widget Form Customize Control Class
     1149 *
     1150 * @since 3.9.0
    11171151 */
    11181152class WP_Widget_Form_Customize_Control extends WP_Customize_Control {
Note: See TracChangeset for help on using the changeset viewer.