Make WordPress Core


Ignore:
Timestamp:
05/30/2015 12:02:13 AM (11 years ago)
Author:
westonruter
Message:

Add JS templates for Customizer Panels and Sections.

This extends the approach taken for Customizer Controls in #29572.

Props celloexpressions, westonruter, ocean90.
See #30737.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/customize.php

    r32649 r32658  
    176176        <?php
    177177
    178         // Render control templates.
     178        // Render Panel, Section, and Control templates.
     179        $wp_customize->render_panel_templates();
     180        $wp_customize->render_section_templates();
    179181        $wp_customize->render_control_templates();
    180182
    … …  
    260262        // Prepare Customize Setting objects to pass to JavaScript.
    261263        foreach ( $wp_customize->settings() as $id => $setting ) {
    262                 $settings['settings'][ $id ] = array(
    263                         'value'     => $setting->js_value(),
    264                         'transport' => $setting->transport,
    265                         'dirty'     => $setting->dirty,
    266                 );
     264                if ( $setting->check_capabilities() ) {
     265                        $settings['settings'][ $id ] = array(
     266                                'value'     => $setting->js_value(),
     267                                'transport' => $setting->transport,
     268                                'dirty'     => $setting->dirty,
     269                        );
     270                }
    267271        }
    268272
    269273        // Prepare Customize Control objects to pass to JavaScript.
    270274        foreach ( $wp_customize->controls() as $id => $control ) {
    271                 $settings['controls'][ $id ] = $control->json();
     275                if ( $control->check_capabilities() ) {
     276                        $settings['controls'][ $id ] = $control->json();
     277                }
    272278        }
    273279
    274280        // Prepare Customize Section objects to pass to JavaScript.
    275281        foreach ( $wp_customize->sections() as $id => $section ) {
    276                 $settings['sections'][ $id ] = $section->json();
     282                if ( $section->check_capabilities() ) {
     283                        $settings['sections'][ $id ] = $section->json();
     284                }
    277285        }
    278286
    279287        // Prepare Customize Panel objects to pass to JavaScript.
    280         foreach ( $wp_customize->panels() as $id => $panel ) {
    281                 $settings['panels'][ $id ] = $panel->json();
    282                 foreach ( $panel->sections as $section_id => $section ) {
    283                         $settings['sections'][ $section_id ] = $section->json();
     288        foreach ( $wp_customize->panels() as $panel_id => $panel ) {
     289                if ( $panel->check_capabilities() ) {
     290                        $settings['panels'][ $panel_id ] = $panel->json();
     291                        foreach ( $panel->sections as $section_id => $section ) {
     292                                if ( $section->check_capabilities() ) {
     293                                        $settings['sections'][ $section_id ] = $section->json();
     294                                }
     295                        }
    284296                }
    285297        }
Note: See TracChangeset for help on using the changeset viewer.