Customize: Ease extendability of filter drawer

By moving the `wporg` conditional inside the method body, the filter drawer can be overridden without having to also override the entire section template.

Props celloexpressions.
Closes #42212.



git-svn-id: https://develop.svn.wordpress.org/trunk@41973 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Konstantin Obenland 2017-10-23 18:57:46 +00:00
parent 9dc63e7cab
commit fbf27f0c23
1 changed files with 16 additions and 17 deletions

View File

@ -80,9 +80,7 @@ class WP_Customize_Themes_Section extends WP_Customize_Section {
<div class="customize-preview-header themes-filter-bar">
<?php $this->filter_bar_content_template(); ?>
</div>
<# if ( 'wporg' === data.action ) { #>
<?php $this->filter_drawer_content_template(); ?>
<# } #>
<?php $this->filter_drawer_content_template(); ?>
<div class="error unexpected-error" style="display: none; "><p><?php _e( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ); ?></p></div>
<ul class="themes">
</ul>
@ -150,7 +148,6 @@ class WP_Customize_Themes_Section extends WP_Customize_Section {
/**
* Render the filter drawer portion of a themes section as a JS template.
*
* The template is only rendered by PHP once, so all actions are prepared at once on the server side.
* The filter bar container is rendered by @see `render_template()`.
*
* @since 4.9.0
@ -158,19 +155,21 @@ class WP_Customize_Themes_Section extends WP_Customize_Section {
protected function filter_drawer_content_template() {
$feature_list = get_theme_feature_list( false ); // @todo: Use the .org API instead of the local core feature list. The .org API is currently outdated and will be reconciled when the .org themes directory is next redesigned.
?>
<div class="filter-drawer filter-details">
<?php foreach ( $feature_list as $feature_name => $features ) : ?>
<fieldset class="filter-group">
<legend><?php echo esc_html( $feature_name ); ?></legend>
<div class="filter-group-feature">
<?php foreach ( $features as $feature => $feature_name ) : ?>
<input type="checkbox" id="filter-id-<?php echo esc_attr( $feature ); ?>" value="<?php echo esc_attr( $feature ); ?>" />
<label for="filter-id-<?php echo esc_attr( $feature ); ?>"><?php echo esc_html( $feature_name ); ?></label><br>
<?php endforeach; ?>
</div>
</fieldset>
<?php endforeach; ?>
</div>
<# if ( 'wporg' === data.action ) { #>
<div class="filter-drawer filter-details">
<?php foreach ( $feature_list as $feature_name => $features ) : ?>
<fieldset class="filter-group">
<legend><?php echo esc_html( $feature_name ); ?></legend>
<div class="filter-group-feature">
<?php foreach ( $features as $feature => $feature_name ) : ?>
<input type="checkbox" id="filter-id-<?php echo esc_attr( $feature ); ?>" value="<?php echo esc_attr( $feature ); ?>" />
<label for="filter-id-<?php echo esc_attr( $feature ); ?>"><?php echo esc_html( $feature_name ); ?></label><br>
<?php endforeach; ?>
</div>
</fieldset>
<?php endforeach; ?>
</div>
<# } #>
<?php
}
}