Make WordPress Core


Ignore:
Timestamp:
10/24/2014 04:31:54 PM (11 years ago)
Author:
johnbillion
Message:

Add the ability for a customizer control to render its controls via a JavaScript template. Switches the default color picker control to a JavaScript template. See #29572. Props celloexpressions

File:
1 edited

Legend:

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

    r29903 r30014  
    5555
    5656    /**
     57     * Controls that may be rendered from JS templates.
     58     *
     59     * @since 4.1.0
     60     */
     61    protected $registered_control_types = array();
     62
     63    /**
    5764     * $_POST values for Customize Settings.
    5865     *
     
    823830
    824831    /**
     832     * Register a customize control type.
     833     *
     834     * Registered types are eligible to be rendered
     835     * via JS and created dynamically.
     836     *
     837     * @since 4.1.0
     838     *
     839     * @param string $control Name of a custom control which is a subclass of {@see WP_Customize_Control}.
     840     */
     841    public function register_control_type( $control ) {
     842        $this->registered_control_types[] = $control;
     843    }
     844
     845    /**
     846     * Render JS templates for all registered control types.
     847     *
     848     * @since 4.1.0
     849     */
     850    public function render_control_templates() {
     851        foreach( $this->registered_control_types as $control_type ) {
     852            $control = new $control_type( $this, 'temp', array() );
     853            $control->print_template();
     854        }
     855    }
     856
     857    /**
    825858     * Helper function to compare two objects by priority.
    826859     *
     
    927960     */
    928961    public function register_controls() {
     962
     963        /* Control Types (custom control classes) */
     964        $this->register_control_type( 'WP_Customize_Color_Control' );
    929965
    930966        /* Site Title & Tagline */
Note: See TracChangeset for help on using the changeset viewer.