2015-10-24 14:21:25 -04:00
< ? php
/**
* Customize API : WP_Customize_Themes_Section class
*
* @ package WordPress
* @ subpackage Customize
* @ since 4.4 . 0
*/
/**
* Customize Themes Section class .
*
2016-10-18 23:20:29 -04:00
* A UI container for theme controls , which are displayed in tabbed sections .
2015-10-24 14:21:25 -04:00
*
* @ since 4.2 . 0
*
* @ see WP_Customize_Section
*/
class WP_Customize_Themes_Section extends WP_Customize_Section {
/**
* Customize section type .
*
* @ since 4.2 . 0
* @ access public
* @ var string
*/
public $type = 'themes' ;
/**
2016-10-18 23:20:29 -04:00
* Theme section action .
2015-10-24 14:21:25 -04:00
*
2016-10-18 23:20:29 -04:00
* Defines the type of themes to load ( installed , featured , latest , etc . ) .
*
* @ since 4.7 . 0
* @ access public
* @ var string
*/
public $action = '' ;
/**
* Text before theme section heading .
*
* @ since 4.7 . 0
* @ access public
* @ var string
*/
public $text_before = '' ;
/**
* Get section parameters for JS .
*
* @ since 4.7 . 0
* @ access public
* @ return array Exported parameters .
*/
public function json () {
$exported = parent :: json ();
$exported [ 'action' ] = $this -> action ;
$exported [ 'text_before' ] = $this -> text_before ;
return $exported ;
}
/**
* Render 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 .
*
* @ since 4.7 . 0
2015-10-24 14:21:25 -04:00
* @ access protected
*/
2016-10-18 23:20:29 -04:00
protected function render_template () {
2015-10-24 14:21:25 -04:00
?>
2016-10-18 23:20:29 -04:00
< li id = " accordion-section- { { data.id }} " class = " theme-section " >
< # if ( '' !== data.text_before ) { #>
< p class = " customize-themes-text-before " > {{ data . text_before }} </ p >
< # } #>
< # if ( 'search' === data.action ) { #>
< div class = " search-form customize-themes-section-title themes-section-search_themes " >
< label class = " screen-reader-text " for = " wp-filter-search-input " > {{ data . title }} </ label >
< input placeholder = " { { data.title }} " type = " text " aria - describedby = " live-search-desc " id = " wp-filter-search-input " class = " wp-filter-search " >
< span id = " live-search-desc " class = " screen-reader-text " >< ? php _e ( 'The search results will be updated as you type.' ); ?> </span>
</ div >
< # } else { #>
< # if ( 'favorites' === data.action || 'feature_filter' === data.action ) {
var attr = ' aria-expanded="false"' ;
2015-10-24 14:21:25 -04:00
} else {
2016-10-18 23:20:29 -04:00
var attr = '' ;
} #>
< button type = " button " class = " customize-themes-section-title themes-section- { { data.id }} " {{{ attr }}} > {{ data . title }} </ button >
< # } #>
< ? php if ( ! current_user_can ( 'install_themes' ) || is_multisite () ) : ?>
< # if ( 'installed' === data.action ) { #>
< p class = " themes-filter-container " >
< label for = " themes-filter " >
< span class = " screen-reader-text " >< ? php _e ( 'Search installed themes…' ); ?> </span>
< input type = " text " id = " themes-filter " placeholder = " <?php esc_attr_e( 'Search installed themes…' ); ?> " />
</ label >
</ p >
< # } #>
< ? php endif ; ?>
< # if ( 'favorites' === data.action ) { #>
< div class = " favorites-form filter-details " >
< p class = " install-help " >< ? php _e ( 'If you have marked themes as favorites on WordPress.org, you can browse them here.' ); ?> </p>
< p >
< label for = " wporg-username-input " >< ? php _e ( 'Your WordPress.org username:' ); ?> </label>
< input type = " search " id = " wporg-username-input " value = " " >
< button type = " button " class = " button button-secondary favorites-form-submit " >< ? php _e ( 'Get Favorites' ); ?> </button>
</ p >
</ div >
< # } else if ( 'feature_filter' === data.action ) { #>
< div class = " filter-drawer filter-details " >
2015-10-24 14:21:25 -04:00
< ? php
2016-10-18 23:20:29 -04:00
$feature_list = get_theme_feature_list ();
foreach ( $feature_list as $feature_name => $features ) {
echo '<fieldset class="filter-group">' ;
$feature_name = esc_html ( $feature_name );
echo '<legend><button type="button" class="button-link" aria-expanded="false">' . $feature_name . '</button></legend>' ;
echo '<div class="filter-group-feature">' ;
foreach ( $features as $feature => $feature_name ) {
$feature = esc_attr ( $feature );
echo '<input type="checkbox" id="filter-id-' . $feature . '" value="' . $feature . '" /> ' ;
echo '<label for="filter-id-' . $feature . '">' . $feature_name . '</label><br>' ;
}
echo '</div>' ;
echo '</fieldset>' ;
2015-10-24 14:21:25 -04:00
}
?>
2016-10-18 23:20:29 -04:00
</ div >
< # } #>
< div class = " customize-themes-section themes-section- { { data.id }} control-section-content themes-php " >
2015-10-24 14:21:25 -04:00
< div class = " theme-overlay " tabindex = " 0 " role = " dialog " aria - label = " <?php esc_attr_e( 'Theme Details' ); ?> " ></ div >
< div class = " theme-browser rendered " >
2016-10-18 23:20:29 -04:00
< 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’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 " >
2015-10-24 14:21:25 -04:00
</ ul >
2016-10-18 23:20:29 -04:00
< p class = " no-themes " >< ? php _e ( 'No themes found. Try a different search.' ); ?> </p>
< p class = " spinner " ></ p >
2015-10-24 14:21:25 -04:00
</ div >
</ div >
</ li >
< ? php }
}