Make WordPress Core


Ignore:
Timestamp:
03/21/2012 10:55:43 PM (14 years ago)
Author:
koopersmith
Message:

Theme Customizer: Numerous API refinements and bugfixes. Add a theme_supports check for header_textcolor. see #19910.

  • prepare_controls() now removes any settings and sections that return false for check_capabilities().
  • Added maybe_render() methods to both settings and sections that call the protected render() methods.
  • Stop firing front-end preview functionality when rendering the controls.
  • Merged the WP_Customize_Setting->_render_type() method into WP_Customize_Setting->render().
  • Removed the 'customize_render_control-' hook; use 'customize_render_setting' instead.
  • Added a property to sections and settings so they no longer rely on the global. Hooray for dependency injection.
  • Shifted calls to WP_Customize_Setting->enqueue() to the 'customize_controls_enqueue_scripts' action.
  • Added a theme_supports check for the header_textcolor setting.
File:
1 edited

Legend:

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

    r20232 r20248  
    99
    1010class WP_Customize_Section {
     11        public $manager;
    1112        public $id;
    1213        public $priority       = 10;
     
    2526         * @param array $args Section arguments.
    2627         */
    27         function __construct( $id, $args = array() ) {
    28                 $this->id = $id;
    29 
     28        function __construct( $manager, $id, $args = array() ) {
    3029                $keys = array_keys( get_class_vars( __CLASS__ ) );
    3130                foreach ( $keys as $key ) {
     
    3332                                $this->$key = $args[ $key ];
    3433                }
     34
     35                $this->manager = $manager;
     36                $this->id = $id;
    3537
    3638                $this->settings = array(); // Users cannot customize the $settings array.
     
    4648         * @return bool False if theme doesn't support the section or user doesn't have the capability.
    4749         */
    48         function check_capabilities() {
     50        public final function check_capabilities() {
    4951                if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
    5052                        return false;
     
    5759
    5860        /**
     61         * Check capabiliites and render the section.
     62         *
     63         * @since 3.4.0
     64         */
     65        public final function maybe_render() {
     66                if ( ! $this->check_capabilities() )
     67                        return;
     68
     69                do_action( 'customize_render_section', $this );
     70                do_action( 'customize_render_section_' . $this->id );
     71
     72                $this->render();
     73        }
     74
     75
     76        /**
    5977         * Render the section.
    6078         *
    6179         * @since 3.4.0
    6280         */
    63         function render() {
    64                 if ( ! $this->check_capabilities() )
    65                         return;
     81        protected function render() {
    6682                ?>
    6783                <li id="customize-section-<?php echo esc_attr( $this->id ); ?>" class="control-section customize-section">
     
    7086                                <?php foreach ( $this->settings as $setting ) : ?>
    7187                                <li id="customize-control-<?php echo esc_attr( $setting->id ); ?>" class="customize-control customize-control-<?php echo esc_attr( $setting->control ); ?>">
    72                                         <?php $setting->_render(); ?>
     88                                        <?php $setting->maybe_render(); ?>
    7389                                </li>
    7490                                <?php endforeach; ?>
Note: See TracChangeset for help on using the changeset viewer.