wp/wp-admin/theme-install.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
    19 if ( is_multisite() && ! is_network_admin() ) {
    19 if ( is_multisite() && ! is_network_admin() ) {
    20 	wp_redirect( network_admin_url( 'theme-install.php' ) );
    20 	wp_redirect( network_admin_url( 'theme-install.php' ) );
    21 	exit;
    21 	exit;
    22 }
    22 }
    23 
    23 
       
    24 // Used in the HTML title tag.
    24 $title       = __( 'Add Themes' );
    25 $title       = __( 'Add Themes' );
    25 $parent_file = 'themes.php';
    26 $parent_file = 'themes.php';
    26 
    27 
    27 if ( ! is_network_admin() ) {
    28 if ( ! is_network_admin() ) {
    28 	$submenu_file = 'themes.php';
    29 	$submenu_file = 'themes.php';
    32 
    33 
    33 if ( false === $installed_themes ) {
    34 if ( false === $installed_themes ) {
    34 	$installed_themes = array();
    35 	$installed_themes = array();
    35 }
    36 }
    36 
    37 
    37 foreach ( $installed_themes as $k => $v ) {
    38 foreach ( $installed_themes as $theme_slug => $theme_data ) {
    38 	if ( false !== strpos( $k, '/' ) ) {
    39 	// Ignore child themes.
    39 		unset( $installed_themes[ $k ] );
    40 	if ( str_contains( $theme_slug, '/' ) ) {
       
    41 		unset( $installed_themes[ $theme_slug ] );
    40 	}
    42 	}
    41 }
    43 }
    42 
    44 
    43 wp_localize_script(
    45 wp_localize_script(
    44 	'theme',
    46 	'theme',
   121 		'content' => $help_overview,
   123 		'content' => $help_overview,
   122 	)
   124 	)
   123 );
   125 );
   124 
   126 
   125 $help_installing =
   127 $help_installing =
   126 	'<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&#8217;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>' .
   128 	'<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 are 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>' .
   127 	'<p>' . __( 'To install the theme so you can preview it with your site&#8217;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&#8217;s thumbnail image.' ) . '</p>';
   129 	'<p>' . __( 'To install the theme so you can preview it with your site&#8217;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&#8217;s thumbnail image.' ) . '</p>';
   128 
   130 
   129 get_current_screen()->add_help_tab(
   131 get_current_screen()->add_help_tab(
   130 	array(
   132 	array(
   131 		'id'      => 'installing',
   133 		'id'      => 'installing',
   134 	)
   136 	)
   135 );
   137 );
   136 
   138 
   137 get_current_screen()->set_help_sidebar(
   139 get_current_screen()->set_help_sidebar(
   138 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   140 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   139 	'<p>' . __( '<a href="https://wordpress.org/support/article/using-themes/#adding-new-themes">Documentation on Adding New Themes</a>' ) . '</p>' .
   141 	'<p>' . __( '<a href="https://wordpress.org/support/article/appearance-themes-screen/#install-themes">Documentation on Adding New Themes</a>' ) . '</p>' .
   140 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   142 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   141 );
   143 );
   142 
   144 
   143 require_once ABSPATH . 'wp-admin/admin-header.php';
   145 require_once ABSPATH . 'wp-admin/admin-header.php';
   144 
   146 
   218 		<?php
   220 		<?php
   219 		// Use the core list, rather than the .org API, due to inconsistencies
   221 		// Use the core list, rather than the .org API, due to inconsistencies
   220 		// and to ensure tags are translated.
   222 		// and to ensure tags are translated.
   221 		$feature_list = get_theme_feature_list( false );
   223 		$feature_list = get_theme_feature_list( false );
   222 
   224 
   223 		foreach ( $feature_list as $feature_name => $features ) {
   225 		foreach ( $feature_list as $feature_group => $features ) {
   224 			echo '<fieldset class="filter-group">';
   226 			echo '<fieldset class="filter-group">';
   225 			$feature_name = esc_html( $feature_name );
   227 			echo '<legend>' . esc_html( $feature_group ) . '</legend>';
   226 			echo '<legend>' . $feature_name . '</legend>';
       
   227 			echo '<div class="filter-group-feature">';
   228 			echo '<div class="filter-group-feature">';
   228 			foreach ( $features as $feature => $feature_name ) {
   229 			foreach ( $features as $feature => $feature_name ) {
   229 				$feature = esc_attr( $feature );
   230 				$feature = esc_attr( $feature );
   230 				echo '<input type="checkbox" id="filter-id-' . $feature . '" value="' . $feature . '" /> ';
   231 				echo '<input type="checkbox" id="filter-id-' . $feature . '" value="' . $feature . '" /> ';
   231 				echo '<label for="filter-id-' . $feature . '">' . $feature_name . '</label>';
   232 				echo '<label for="filter-id-' . $feature . '">' . esc_html( $feature_name ) . '</label>';
   232 			}
   233 			}
   233 			echo '</div>';
   234 			echo '</div>';
   234 			echo '</fieldset>';
   235 			echo '</fieldset>';
   235 		}
   236 		}
   236 		?>
   237 		?>
   279 </div>
   280 </div>
   280 
   281 
   281 <script id="tmpl-theme" type="text/template">
   282 <script id="tmpl-theme" type="text/template">
   282 	<# if ( data.screenshot_url ) { #>
   283 	<# if ( data.screenshot_url ) { #>
   283 		<div class="theme-screenshot">
   284 		<div class="theme-screenshot">
   284 			<img src="{{ data.screenshot_url }}" alt="" />
   285 			<img src="{{ data.screenshot_url }}?ver={{ data.version }}" alt="" />
   285 		</div>
   286 		</div>
   286 	<# } else { #>
   287 	<# } else { #>
   287 		<div class="theme-screenshot blank"></div>
   288 		<div class="theme-screenshot blank"></div>
   288 	<# } #>
   289 	<# } #>
   289 
   290 
   293 
   294 
   294 	<# if ( ! data.compatible_wp || ! data.compatible_php ) { #>
   295 	<# if ( ! data.compatible_wp || ! data.compatible_php ) { #>
   295 		<div class="notice notice-error notice-alt"><p>
   296 		<div class="notice notice-error notice-alt"><p>
   296 			<# if ( ! data.compatible_wp && ! data.compatible_php ) { #>
   297 			<# if ( ! data.compatible_wp && ! data.compatible_php ) { #>
   297 				<?php
   298 				<?php
   298 				_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
   299 				_e( 'This theme does not work with your versions of WordPress and PHP.' );
   299 				if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   300 				if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   300 					printf(
   301 					printf(
   301 						/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   302 						/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   302 						' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   303 						' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   303 						self_admin_url( 'update-core.php' ),
   304 						self_admin_url( 'update-core.php' ),
   319 					wp_update_php_annotation( '</p><p><em>', '</em>' );
   320 					wp_update_php_annotation( '</p><p><em>', '</em>' );
   320 				}
   321 				}
   321 				?>
   322 				?>
   322 			<# } else if ( ! data.compatible_wp ) { #>
   323 			<# } else if ( ! data.compatible_wp ) { #>
   323 				<?php
   324 				<?php
   324 				_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
   325 				_e( 'This theme does not work with your version of WordPress.' );
   325 				if ( current_user_can( 'update_core' ) ) {
   326 				if ( current_user_can( 'update_core' ) ) {
   326 					printf(
   327 					printf(
   327 						/* translators: %s: URL to WordPress Updates screen. */
   328 						/* translators: %s: URL to WordPress Updates screen. */
   328 						' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   329 						' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   329 						self_admin_url( 'update-core.php' )
   330 						self_admin_url( 'update-core.php' )
   330 					);
   331 					);
   331 				}
   332 				}
   332 				?>
   333 				?>
   333 			<# } else if ( ! data.compatible_php ) { #>
   334 			<# } else if ( ! data.compatible_php ) { #>
   334 				<?php
   335 				<?php
   335 				_e( 'This theme doesn&#8217;t work with your version of PHP.' );
   336 				_e( 'This theme does not work with your version of PHP.' );
   336 				if ( current_user_can( 'update_php' ) ) {
   337 				if ( current_user_can( 'update_php' ) ) {
   337 					printf(
   338 					printf(
   338 						/* translators: %s: URL to Update PHP page. */
   339 						/* translators: %s: URL to Update PHP page. */
   339 						' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   340 						' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   340 						esc_url( wp_get_update_php_url() )
   341 						esc_url( wp_get_update_php_url() )
   371 							<button class="button button-primary disabled"><?php _ex( 'Activated', 'theme' ); ?></button>
   372 							<button class="button button-primary disabled"><?php _ex( 'Activated', 'theme' ); ?></button>
   372 						<# } #>
   373 						<# } #>
   373 					<# } #>
   374 					<# } #>
   374 					<# if ( data.customize_url ) { #>
   375 					<# if ( data.customize_url ) { #>
   375 						<# if ( ! data.active ) { #>
   376 						<# if ( ! data.active ) { #>
   376 							<a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a>
   377 							<# if ( ! data.block_theme ) { #>
       
   378 								<a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Live Preview' ); ?></a>
       
   379 							<# } #>
   377 						<# } else { #>
   380 						<# } else { #>
   378 							<a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Customize' ); ?></a>
   381 							<a class="button load-customize" href="{{ data.customize_url }}"><?php _e( 'Customize' ); ?></a>
   379 						<# } #>
   382 						<# } #>
   380 					<# } else { #>
   383 					<# } else { #>
   381 						<button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
   384 						<button class="button preview install-theme-preview"><?php _e( 'Preview' ); ?></button>
   451 						/* translators: %s: Theme author name. */
   454 						/* translators: %s: Theme author name. */
   452 						printf( __( 'By %s' ), '{{ data.author }}' );
   455 						printf( __( 'By %s' ), '{{ data.author }}' );
   453 						?>
   456 						?>
   454 					</span>
   457 					</span>
   455 
   458 
   456 					<img class="theme-screenshot" src="{{ data.screenshot_url }}" alt="" />
   459 					<div class="theme-screenshot">
       
   460 						<img class="theme-screenshot" src="{{ data.screenshot_url }}?ver={{ data.version }}" alt="" />
       
   461 					</div>
   457 
   462 
   458 					<div class="theme-details">
   463 					<div class="theme-details">
   459 						<# if ( data.rating ) { #>
   464 						<# if ( data.rating ) { #>
   460 							<div class="theme-rating">
   465 							<div class="theme-rating">
   461 								{{{ data.stars }}}
   466 								{{{ data.stars }}}
   479 
   484 
   480 						<# if ( ! data.compatible_wp || ! data.compatible_php ) { #>
   485 						<# if ( ! data.compatible_wp || ! data.compatible_php ) { #>
   481 							<div class="notice notice-error notice-alt notice-large"><p>
   486 							<div class="notice notice-error notice-alt notice-large"><p>
   482 								<# if ( ! data.compatible_wp && ! data.compatible_php ) { #>
   487 								<# if ( ! data.compatible_wp && ! data.compatible_php ) { #>
   483 									<?php
   488 									<?php
   484 									_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
   489 									_e( 'This theme does not work with your versions of WordPress and PHP.' );
   485 									if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   490 									if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   486 										printf(
   491 										printf(
   487 											/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   492 											/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   488 											' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   493 											' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   489 											self_admin_url( 'update-core.php' ),
   494 											self_admin_url( 'update-core.php' ),
   505 										wp_update_php_annotation( '</p><p><em>', '</em>' );
   510 										wp_update_php_annotation( '</p><p><em>', '</em>' );
   506 									}
   511 									}
   507 									?>
   512 									?>
   508 								<# } else if ( ! data.compatible_wp ) { #>
   513 								<# } else if ( ! data.compatible_wp ) { #>
   509 									<?php
   514 									<?php
   510 									_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
   515 									_e( 'This theme does not work with your version of WordPress.' );
   511 									if ( current_user_can( 'update_core' ) ) {
   516 									if ( current_user_can( 'update_core' ) ) {
   512 										printf(
   517 										printf(
   513 											/* translators: %s: URL to WordPress Updates screen. */
   518 											/* translators: %s: URL to WordPress Updates screen. */
   514 											' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   519 											' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   515 											self_admin_url( 'update-core.php' )
   520 											self_admin_url( 'update-core.php' )
   516 										);
   521 										);
   517 									}
   522 									}
   518 									?>
   523 									?>
   519 								<# } else if ( ! data.compatible_php ) { #>
   524 								<# } else if ( ! data.compatible_php ) { #>
   520 									<?php
   525 									<?php
   521 									_e( 'This theme doesn&#8217;t work with your version of PHP.' );
   526 									_e( 'This theme does not work with your version of PHP.' );
   522 									if ( current_user_can( 'update_php' ) ) {
   527 									if ( current_user_can( 'update_php' ) ) {
   523 										printf(
   528 										printf(
   524 											/* translators: %s: URL to Update PHP page. */
   529 											/* translators: %s: URL to Update PHP page. */
   525 											' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   530 											' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   526 											esc_url( wp_get_update_php_url() )
   531 											esc_url( wp_get_update_php_url() )