[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Install theme administration panel. 4 * 5 * @package WordPress 6 * @subpackage Administration 7 */ 8 9 /** WordPress Administration Bootstrap */ 10 require_once( dirname( __FILE__ ) . '/admin.php' ); 11 require( ABSPATH . 'wp-admin/includes/theme-install.php' ); 12 13 wp_reset_vars( array( 'tab' ) ); 14 15 if ( ! current_user_can( 'install_themes' ) ) { 16 wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) ); 17 } 18 19 if ( is_multisite() && ! is_network_admin() ) { 20 wp_redirect( network_admin_url( 'theme-install.php' ) ); 21 exit(); 22 } 23 24 $title = __( 'Add Themes' ); 25 $parent_file = 'themes.php'; 26 27 if ( ! is_network_admin() ) { 28 $submenu_file = 'themes.php'; 29 } 30 31 $installed_themes = search_theme_directories(); 32 33 if ( false === $installed_themes ) { 34 $installed_themes = array(); 35 } 36 37 foreach ( $installed_themes as $k => $v ) { 38 if ( false !== strpos( $k, '/' ) ) { 39 unset( $installed_themes[ $k ] ); 40 } 41 } 42 43 wp_localize_script( 44 'theme', 45 '_wpThemeSettings', 46 array( 47 'themes' => false, 48 'settings' => array( 49 'isInstall' => true, 50 'canInstall' => current_user_can( 'install_themes' ), 51 'installURI' => current_user_can( 'install_themes' ) ? self_admin_url( 'theme-install.php' ) : null, 52 'adminUrl' => parse_url( self_admin_url(), PHP_URL_PATH ), 53 ), 54 'l10n' => array( 55 'addNew' => __( 'Add New Theme' ), 56 'search' => __( 'Search Themes' ), 57 'searchPlaceholder' => __( 'Search themes...' ), // placeholder (no ellipsis) 58 'upload' => __( 'Upload Theme' ), 59 'back' => __( 'Back' ), 60 'error' => sprintf( 61 /* translators: %s: Support forums URL. */ 62 __( '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>.' ), 63 __( 'https://wordpress.org/support/forums/' ) 64 ), 65 'tryAgain' => __( 'Try Again' ), 66 /* translators: %d: Number of themes. */ 67 'themesFound' => __( 'Number of Themes found: %d' ), 68 'noThemesFound' => __( 'No themes found. Try a different search.' ), 69 'collapseSidebar' => __( 'Collapse Sidebar' ), 70 'expandSidebar' => __( 'Expand Sidebar' ), 71 /* translators: Accessibility text. */ 72 'selectFeatureFilter' => __( 'Select one or more Theme features to filter by' ), 73 ), 74 'installedThemes' => array_keys( $installed_themes ), 75 ) 76 ); 77 78 wp_enqueue_script( 'theme' ); 79 wp_enqueue_script( 'updates' ); 80 81 if ( $tab ) { 82 /** 83 * Fires before each of the tabs are rendered on the Install Themes page. 84 * 85 * The dynamic portion of the hook name, `$tab`, refers to the current 86 * theme installation tab. Possible values are 'dashboard', 'search', 'upload', 87 * 'featured', 'new', or 'updated'. 88 * 89 * @since 2.8.0 90 */ 91 do_action( "install_themes_pre_{$tab}" ); 92 } 93 94 $help_overview = 95 '<p>' . sprintf( 96 /* translators: %s: Theme Directory URL. */ 97 __( 'You can find additional themes for your site by using the Theme Browser/Installer on this screen, which will display themes from the <a href="%s">WordPress Theme Directory</a>. These themes are designed and developed by third parties, are available free of charge, and are compatible with the license WordPress uses.' ), 98 __( 'https://wordpress.org/themes/' ) 99 ) . '</p>' . 100 '<p>' . __( 'You can Search for themes by keyword, author, or tag, or can get more specific and search by criteria listed in the feature filter.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>' . 101 '<p>' . __( 'Alternately, you can browse the themes that are Featured, Popular, or Latest. When you find a theme you like, you can preview it or install it.' ) . '</p>' . 102 '<p>' . sprintf( 103 /* translators: %s: /wp-content/themes */ 104 __( 'You can Upload a theme manually if you have already downloaded its ZIP archive onto your computer (make sure it is from a trusted and original source). You can also do it the old-fashioned way and copy a downloaded theme’s folder via FTP into your %s directory.' ), 105 '<code>/wp-content/themes</code>' 106 ) . '</p>'; 107 108 get_current_screen()->add_help_tab( 109 array( 110 'id' => 'overview', 111 'title' => __( 'Overview' ), 112 'content' => $help_overview, 113 ) 114 ); 115 116 $help_installing = 117 '<p>' . __( 'Once you have generated a list of themes, you can preview and install any of them. Click on the thumbnail of the theme you’re interested in previewing. It will open up in a full-screen Preview page to give you a better idea of how that theme will look.' ) . '</p>' . 118 '<p>' . __( 'To install the theme so you can preview it with your site’s content and customize its theme options, click the "Install" button at the top of the left-hand pane. The theme files will be downloaded to your website automatically. When this is complete, the theme is now available for activation, which you can do by clicking the "Activate" link, or by navigating to your Manage Themes screen and clicking the "Live Preview" link under any installed theme’s thumbnail image.' ) . '</p>'; 119 120 get_current_screen()->add_help_tab( 121 array( 122 'id' => 'installing', 123 'title' => __( 'Previewing and Installing' ), 124 'content' => $help_installing, 125 ) 126 ); 127 128 get_current_screen()->set_help_sidebar( 129 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 130 '<p>' . __( '<a href="https://wordpress.org/support/article/using-themes/#adding-new-themes">Documentation on Adding New Themes</a>' ) . '</p>' . 131 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' 132 ); 133 134 include( ABSPATH . 'wp-admin/admin-header.php' ); 135 136 ?> 137 <div class="wrap"> 138 <h1 class="wp-heading-inline"><?php echo esc_html( $title ); ?></h1> 139 140 <?php 141 142 /** 143 * Filters the tabs shown on the Add Themes screen. 144 * 145 * This filter is for backward compatibility only, for the suppression of the upload tab. 146 * 147 * @since 2.8.0 148 * 149 * @param string[] $tabs Associative array of the tabs shown on the Add Themes screen. Default is 'upload'. 150 */ 151 $tabs = apply_filters( 'install_themes_tabs', array( 'upload' => __( 'Upload Theme' ) ) ); 152 if ( ! empty( $tabs['upload'] ) && current_user_can( 'upload_themes' ) ) { 153 echo ' <button type="button" class="upload-view-toggle page-title-action hide-if-no-js" aria-expanded="false">' . __( 'Upload Theme' ) . '</button>'; 154 } 155 ?> 156 157 <hr class="wp-header-end"> 158 159 <div class="error hide-if-js"> 160 <p><?php _e( 'The Theme Installer screen requires JavaScript.' ); ?></p> 161 </div> 162 163 <div class="upload-theme"> 164 <?php install_themes_upload(); ?> 165 </div> 166 167 <h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Filter themes list' ); ?></h2> 168 169 <div class="wp-filter hide-if-no-js"> 170 <div class="filter-count"> 171 <span class="count theme-count"></span> 172 </div> 173 174 <ul class="filter-links"> 175 <li><a href="#" data-sort="featured"><?php _ex( 'Featured', 'themes' ); ?></a></li> 176 <li><a href="#" data-sort="popular"><?php _ex( 'Popular', 'themes' ); ?></a></li> 177 <li><a href="#" data-sort="new"><?php _ex( 'Latest', 'themes' ); ?></a></li> 178 <li><a href="#" data-sort="favorites"><?php _ex( 'Favorites', 'themes' ); ?></a></li> 179 </ul> 180 181 <button type="button" class="button drawer-toggle" aria-expanded="false"><?php _e( 'Feature Filter' ); ?></button> 182 183 <form class="search-form"></form> 184 185 <div class="favorites-form"> 186 <?php 187 $action = 'save_wporg_username_' . get_current_user_id(); 188 if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), $action ) ) { 189 $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); 190 update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); 191 } else { 192 $user = get_user_option( 'wporg_favorites' ); 193 } 194 ?> 195 <p class="install-help"><?php _e( 'If you have marked themes as favorites on WordPress.org, you can browse them here.' ); ?></p> 196 197 <p> 198 <label for="wporg-username-input"><?php _e( 'Your WordPress.org username:' ); ?></label> 199 <input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( $action ) ); ?>" /> 200 <input type="search" id="wporg-username-input" value="<?php echo esc_attr( $user ); ?>" /> 201 <input type="button" class="button favorites-form-submit" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> 202 </p> 203 </div> 204 205 <div class="filter-drawer"> 206 <div class="buttons"> 207 <button type="button" class="apply-filters button"><?php _e( 'Apply Filters' ); ?><span></span></button> 208 <button type="button" class="clear-filters button" aria-label="<?php esc_attr_e( 'Clear current filters' ); ?>"><?php _e( 'Clear' ); ?></button> 209 </div> 210 <?php 211 $feature_list = get_theme_feature_list( false ); // Use the core list, rather than the .org API, due to inconsistencies and to ensure tags are translated. 212 foreach ( $feature_list as $feature_name => $features ) { 213 echo '<fieldset class="filter-group">'; 214 $feature_name = esc_html( $feature_name ); 215 echo '<legend>' . $feature_name . '</legend>'; 216 echo '<div class="filter-group-feature">'; 217 foreach ( $features as $feature => $feature_name ) { 218 $feature = esc_attr( $feature ); 219 echo '<input type="checkbox" id="filter-id-' . $feature . '" value="' . $feature . '" /> '; 220 echo '<label for="filter-id-' . $feature . '">' . $feature_name . '</label>'; 221 } 222 echo '</div>'; 223 echo '</fieldset>'; 224 } 225 ?> 226 <div class="buttons"> 227 <button type="button" class="apply-filters button"><?php _e( 'Apply Filters' ); ?><span></span></button> 228 <button type="button" class="clear-filters button" aria-label="<?php esc_attr_e( 'Clear current filters' ); ?>"><?php _e( 'Clear' ); ?></button> 229 </div> 230 <div class="filtered-by"> 231 <span><?php _e( 'Filtering by:' ); ?></span> 232 <div class="tags"></div> 233 <button type="button" class="button-link edit-filters"><?php _e( 'Edit Filters' ); ?></button> 234 </div> 235 </div> 236 </div> 237 <h2 class="screen-reader-text hide-if-no-js"><?php _e( 'Themes list' ); ?></h2> 238 <div class="theme-browser content-filterable"></div> 239 <div class="theme-install-overlay wp-full-overlay expanded"></div> 240 241 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p> 242 <span class="spinner"></span> 243 244 <?php 245 if ( $tab ) { 246 /** 247 * Fires at the top of each of the tabs on the Install Themes page. 248 * 249 * The dynamic portion of the hook name, `$tab`, refers to the current 250 * theme installation tab. Possible values are 'dashboard', 'search', 'upload', 251 * 'featured', 'new', or 'updated'. 252 * 253 * @since 2.8.0 254 * 255 * @param int $paged Number of the current page of results being viewed. 256 */ 257 do_action( "install_themes_{$tab}", $paged ); 258 } 259 ?> 260 </div> 261 262 <script id="tmpl-theme" type="text/template"> 263 <# if ( data.screenshot_url ) { #> 264 <div class="theme-screenshot"> 265 <img src="{{ data.screenshot_url }}" alt="" /> 266 </div> 267 <# } else { #> 268 <div class="theme-screenshot blank"></div> 269 <# } #> 270 <span class="more-details"><?php _ex( 'Details & Preview', 'theme' ); ?></span> 271 <div class="theme-author"> 272 <?php 273 /* translators: %s: Theme author name. */ 274 printf( __( 'By %s' ), '{{ data.author }}' ); 275 ?> 276 </div> 277 278 <div class="theme-id-container"> 279 <h3 class="theme-name">{{ data.name }}</h3> 280 281 <div class="theme-actions"> 282 <# if ( data.installed ) { #> 283 <?php 284 /* translators: %s: Theme name. */ 285 $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' ); 286 ?> 287 <# if ( data.activate_url ) { #> 288 <a class="button button-primary activate" href="{{ data.activate_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a> 289 <# } #> 290 <# if ( data.customize_url ) { #> 291 <a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a> 292 <# } else { #> 293 <button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button> 294 <# } #> 295 <# } else { #> 296 <?php 297 /* translators: %s: Theme name. */ 298 $aria_label = sprintf( __( 'Install %s' ), '{{ data.name }}' ); 299 ?> 300 <a class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}" href="{{ data.install_url }}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Install' ); ?></a> 301 <button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button> 302 <# } #> 303 </div> 304 </div> 305 306 <# if ( data.installed ) { #> 307 <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div> 308 <# } #> 309 </script> 310 311 <script id="tmpl-theme-preview" type="text/template"> 312 <div class="wp-full-overlay-sidebar"> 313 <div class="wp-full-overlay-header"> 314 <button class="close-full-overlay"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> 315 <button class="previous-theme"><span class="screen-reader-text"><?php _e( 'Previous theme' ); ?></span></button> 316 <button class="next-theme"><span class="screen-reader-text"><?php _e( 'Next theme' ); ?></span></button> 317 <# if ( data.installed ) { #> 318 <a class="button button-primary activate" href="{{ data.activate_url }}"><?php _e( 'Activate' ); ?></a> 319 <# } else { #> 320 <a href="{{ data.install_url }}" class="button button-primary theme-install" data-name="{{ data.name }}" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></a> 321 <# } #> 322 </div> 323 <div class="wp-full-overlay-sidebar-content"> 324 <div class="install-theme-info"> 325 <h3 class="theme-name">{{ data.name }}</h3> 326 <span class="theme-by"> 327 <?php 328 /* translators: %s: Theme author name. */ 329 printf( __( 'By %s' ), '{{ data.author }}' ); 330 ?> 331 </span> 332 333 <img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" /> 334 335 <div class="theme-details"> 336 <# if ( data.rating ) { #> 337 <div class="theme-rating"> 338 {{{ data.stars }}} 339 <a class="num-ratings" href="{{ data.reviews_url }}"> 340 <?php 341 /* translators: %s: Number of ratings. */ 342 echo sprintf( __( '(%s ratings)' ), '{{ data.num_ratings }}' ); 343 ?> 344 </a> 345 </div> 346 <# } else { #> 347 <span class="no-rating"><?php _e( 'This theme has not been rated yet.' ); ?></span> 348 <# } #> 349 <div class="theme-version"> 350 <?php 351 /* translators: %s: Theme version. */ 352 printf( __( 'Version: %s' ), '{{ data.version }}' ); 353 ?> 354 </div> 355 <div class="theme-description">{{{ data.description }}}</div> 356 </div> 357 </div> 358 </div> 359 <div class="wp-full-overlay-footer"> 360 <button type="button" class="collapse-sidebar button" aria-expanded="true" aria-label="<?php esc_attr_e( 'Collapse Sidebar' ); ?>"> 361 <span class="collapse-sidebar-arrow"></span> 362 <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span> 363 </button> 364 </div> 365 </div> 366 <div class="wp-full-overlay-main"> 367 <iframe src="{{ data.preview_url }}" title="<?php esc_attr_e( 'Preview' ); ?>"></iframe> 368 </div> 369 </script> 370 371 <?php 372 wp_print_request_filesystem_credentials_modal(); 373 wp_print_admin_notice_templates(); 374 375 include( ABSPATH . 'wp-admin/admin-footer.php' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Dec 8 01:00:03 2019 | Cross-referenced by PHPXref 0.7.1 |