WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/17/2014 09:24:32 PM (6 years ago)
Author:
ocean90
Message:

Customizer: Extract content markup for panels to its own method, WP_Customize_Panel::render_content().

This allows to override the behavior of a panel, or even to completely replace its contents with something other than controls or sections.

props celloexpressions.
fixes #29324.

File:
1 edited

Legend:

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

    r29610 r29950  
    163163
    164164    /**
    165      * Render the panel, and the sections that have been added to it.
     165     * Render the panel container, and then its contents.
    166166     *
    167167     * @since 4.0.0
     
    176176            </h3>
    177177            <ul class="accordion-sub-container control-panel-content">
    178                 <li class="accordion-section control-section<?php if ( empty( $this->description ) ) echo ' cannot-expand'; ?>">
    179                     <div class="accordion-section-title" tabindex="0">
    180                         <span class="preview-notice"><?php
    181                             /* translators: %s is the site/panel title in the Customizer */
    182                             echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title">' . esc_html( $this->title ) . '</strong>' );
    183                         ?></span>
    184                     </div>
    185                     <?php if ( ! empty( $this->description ) ) : ?>
    186                         <div class="accordion-section-content description">
    187                             <?php echo $this->description; ?>
    188                         </div>
    189                     <?php endif; ?>
    190                 </li>
    191                 <?php
    192                 foreach ( $this->sections as $section ) {
    193                     $section->maybe_render();
    194                 }
    195                 ?>
     178                <?php $this->render_content(); ?>
    196179            </ul>
    197180        </li>
    198181        <?php
    199182    }
     183
     184    /**
     185     * Render the sections that have been added to the panel.
     186     *
     187     * @since 4.1.0
     188     * @access protected
     189     */
     190    protected function render_content() {
     191        ?>
     192        <li class="accordion-section control-section<?php if ( empty( $this->description ) ) echo ' cannot-expand'; ?>">
     193            <div class="accordion-section-title" tabindex="0">
     194                <span class="preview-notice"><?php
     195                    /* translators: %s is the site/panel title in the Customizer */
     196                    echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title">' . esc_html( $this->title ) . '</strong>' );
     197                ?></span>
     198            </div>
     199            <?php if ( ! empty( $this->description ) ) : ?>
     200                <div class="accordion-section-content description">
     201                    <?php echo $this->description; ?>
     202                </div>
     203            <?php endif; ?>
     204        </li>
     205        <?php
     206        foreach ( $this->sections as $section ) {
     207            $section->maybe_render();
     208        }
     209    }
    200210}
Note: See TracChangeset for help on using the changeset viewer.