[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Customize API: WP_Customize_Themes_Section class 4 * 5 * @package WordPress 6 * @subpackage Customize 7 * @since 4.4.0 8 */ 9 10 /** 11 * Customize Themes Section class. 12 * 13 * A UI container for theme controls, which are displayed within sections. 14 * 15 * @since 4.2.0 16 * 17 * @see WP_Customize_Section 18 */ 19 class WP_Customize_Themes_Section extends WP_Customize_Section { 20 21 /** 22 * Section type. 23 * 24 * @since 4.2.0 25 * @var string 26 */ 27 public $type = 'themes'; 28 29 /** 30 * Theme section action. 31 * 32 * Defines the type of themes to load (installed, wporg, etc.). 33 * 34 * @since 4.9.0 35 * @var string 36 */ 37 public $action = ''; 38 39 /** 40 * Theme section filter type. 41 * 42 * Determines whether filters are applied to loaded (local) themes or by initiating a new remote query (remote). 43 * When filtering is local, the initial themes query is not paginated by default. 44 * 45 * @since 4.9.0 46 * @var string 47 */ 48 public $filter_type = 'local'; 49 50 /** 51 * Gets section parameters for JS. 52 * 53 * @since 4.9.0 54 * @return array Exported parameters. 55 */ 56 public function json() { 57 $exported = parent::json(); 58 $exported['action'] = $this->action; 59 $exported['filter_type'] = $this->filter_type; 60 61 return $exported; 62 } 63 64 /** 65 * Renders a themes section as a JS template. 66 * 67 * The template is only rendered by PHP once, so all actions are prepared at once on the server side. 68 * 69 * @since 4.9.0 70 */ 71 protected function render_template() { 72 ?> 73 <li id="accordion-section-{{ data.id }}" class="theme-section"> 74 <button type="button" class="customize-themes-section-title themes-section-{{ data.id }}">{{ data.title }}</button> 75 <?php if ( current_user_can( 'install_themes' ) || is_multisite() ) : // @todo Upload support. ?> 76 <?php endif; ?> 77 <div class="customize-themes-section themes-section-{{ data.id }} control-section-content themes-php"> 78 <div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div> 79 <div class="theme-browser rendered"> 80 <div class="customize-preview-header themes-filter-bar"> 81 <?php $this->filter_bar_content_template(); ?> 82 </div> 83 <?php $this->filter_drawer_content_template(); ?> 84 <div class="error unexpected-error" style="display: none; "> 85 <p> 86 <?php 87 printf( 88 /* translators: %s: Support forums URL. */ 89 __( '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="%s">support forums</a>.' ), 90 __( 'https://wordpress.org/support/forums/' ) 91 ); 92 ?> 93 </p> 94 </div> 95 <ul class="themes"> 96 </ul> 97 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p> 98 <p class="no-themes-local"> 99 <?php 100 printf( 101 /* translators: %s: "Search WordPress.org themes" button text. */ 102 __( 'No themes found. Try a different search, or %s.' ), 103 sprintf( '<button type="button" class="button-link search-dotorg-themes">%s</button>', __( 'Search WordPress.org themes' ) ) 104 ); 105 ?> 106 </p> 107 <p class="spinner"></p> 108 </div> 109 </div> 110 </li> 111 <?php 112 } 113 114 /** 115 * Renders the filter bar portion of a themes section as a JS template. 116 * 117 * The template is only rendered by PHP once, so all actions are prepared at once on the server side. 118 * The filter bar container is rendered by {@see render_template()}. 119 * 120 * @since 4.9.0 121 */ 122 protected function filter_bar_content_template() { 123 ?> 124 <button type="button" class="button button-primary customize-section-back customize-themes-mobile-back"><?php _e( 'Go to theme sources' ); ?></button> 125 <# if ( 'wporg' === data.action ) { #> 126 <div class="search-form"> 127 <label for="wp-filter-search-input-{{ data.id }}" class="screen-reader-text"> 128 <?php 129 /* translators: Hidden accessibility text. */ 130 _e( 'Search themes…' ); 131 ?> 132 </label> 133 <input type="search" id="wp-filter-search-input-{{ data.id }}" placeholder="<?php esc_attr_e( 'Search themes…' ); ?>" aria-describedby="{{ data.id }}-live-search-desc" class="wp-filter-search"> 134 <div class="search-icon" aria-hidden="true"></div> 135 <span id="{{ data.id }}-live-search-desc" class="screen-reader-text"> 136 <?php 137 /* translators: Hidden accessibility text. */ 138 _e( 'The search results will be updated as you type.' ); 139 ?> 140 </span> 141 </div> 142 <button type="button" class="button feature-filter-toggle"> 143 <span class="filter-count-0"><?php _e( 'Filter themes' ); ?></span><span class="filter-count-filters"> 144 <?php 145 /* translators: %s: Number of filters selected. */ 146 printf( __( 'Filter themes (%s)' ), '<span class="theme-filter-count">0</span>' ); 147 ?> 148 </span> 149 </button> 150 <# } else { #> 151 <div class="themes-filter-container"> 152 <label for="{{ data.id }}-themes-filter" class="screen-reader-text"> 153 <?php 154 /* translators: Hidden accessibility text. */ 155 _e( 'Search themes…' ); 156 ?> 157 </label> 158 <input type="search" id="{{ data.id }}-themes-filter" placeholder="<?php esc_attr_e( 'Search themes…' ); ?>" aria-describedby="{{ data.id }}-live-search-desc" class="wp-filter-search wp-filter-search-themes" /> 159 <div class="search-icon" aria-hidden="true"></div> 160 <span id="{{ data.id }}-live-search-desc" class="screen-reader-text"> 161 <?php 162 /* translators: Hidden accessibility text. */ 163 _e( 'The search results will be updated as you type.' ); 164 ?> 165 </span> 166 </div> 167 <# } #> 168 <div class="filter-themes-count"> 169 <span class="themes-displayed"> 170 <?php 171 /* translators: %s: Number of themes displayed. */ 172 printf( __( '%s themes' ), '<span class="theme-count">0</span>' ); 173 ?> 174 </span> 175 </div> 176 <?php 177 } 178 179 /** 180 * Renders the filter drawer portion of a themes section as a JS template. 181 * 182 * The filter bar container is rendered by {@see render_template()}. 183 * 184 * @since 4.9.0 185 */ 186 protected function filter_drawer_content_template() { 187 /* 188 * @todo Use the .org API instead of the local core feature list. 189 * The .org API is currently outdated and will be reconciled when the .org themes directory is next redesigned. 190 */ 191 $feature_list = get_theme_feature_list( false ); 192 ?> 193 <# if ( 'wporg' === data.action ) { #> 194 <div class="filter-drawer filter-details"> 195 <?php foreach ( $feature_list as $feature_name => $features ) : ?> 196 <fieldset class="filter-group"> 197 <legend><?php echo esc_html( $feature_name ); ?></legend> 198 <div class="filter-group-feature"> 199 <?php foreach ( $features as $feature => $feature_name ) : ?> 200 <input type="checkbox" id="filter-id-<?php echo esc_attr( $feature ); ?>" value="<?php echo esc_attr( $feature ); ?>" /> 201 <label for="filter-id-<?php echo esc_attr( $feature ); ?>"><?php echo esc_html( $feature_name ); ?></label> 202 <?php endforeach; ?> 203 </div> 204 </fieldset> 205 <?php endforeach; ?> 206 </div> 207 <# } #> 208 <?php 209 } 210 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu May 9 08:20:02 2024 | Cross-referenced by PHPXref |