wp/wp-admin/themes.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
   151 	if ( is_multisite() ) {
   151 	if ( is_multisite() ) {
   152 		$help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
   152 		$help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
   153 	} else {
   153 	} else {
   154 		$help_install = '<p>' . sprintf(
   154 		$help_install = '<p>' . sprintf(
   155 			/* translators: %s: https://wordpress.org/themes/ */
   155 			/* translators: %s: https://wordpress.org/themes/ */
   156 			__( 'If you would like to see more themes to choose from, click on the &#8220;Add New&#8221; button and you will be able to browse or search for additional themes from the <a href="%s">WordPress Theme Directory</a>. Themes in the WordPress Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!' ),
   156 			__( 'If you would like to see more themes to choose from, click on the &#8220;Add New Theme&#8221; button and you will be able to browse or search for additional themes from the <a href="%s">WordPress Theme Directory</a>. Themes in the WordPress Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they&#8217;re free!' ),
   157 			__( 'https://wordpress.org/themes/' )
   157 			__( 'https://wordpress.org/themes/' )
   158 		) . '</p>';
   158 		) . '</p>';
   159 	}
   159 	}
   160 
   160 
   161 	get_current_screen()->add_help_tab(
   161 	get_current_screen()->add_help_tab(
   197 			'title'   => __( 'Auto-updates' ),
   197 			'title'   => __( 'Auto-updates' ),
   198 			'content' => $help_tab_autoupdates,
   198 			'content' => $help_tab_autoupdates,
   199 		)
   199 		)
   200 	);
   200 	);
   201 
   201 
   202 	$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>';
   202 	$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>';
   203 } // End if 'update_themes' && 'wp_is_auto_update_enabled_for_type'.
   203 } // End if 'update_themes' && 'wp_is_auto_update_enabled_for_type'.
   204 
   204 
   205 get_current_screen()->set_help_sidebar(
   205 get_current_screen()->set_help_sidebar(
   206 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   206 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   207 	'<p>' . __( '<a href="https://wordpress.org/support/article/using-themes/">Documentation on Using Themes</a>' ) . '</p>' .
   207 	'<p>' . __( '<a href="https://wordpress.org/documentation/article/work-with-themes/">Documentation on Using Themes</a>' ) . '</p>' .
   208 	'<p>' . __( '<a href="https://wordpress.org/support/article/appearance-themes-screen/">Documentation on Managing Themes</a>' ) . '</p>' .
   208 	'<p>' . __( '<a href="https://wordpress.org/documentation/article/appearance-themes-screen/">Documentation on Managing Themes</a>' ) . '</p>' .
   209 	$help_sidebar_autoupdates .
   209 	$help_sidebar_autoupdates .
   210 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   210 	'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
   211 );
   211 );
   212 
   212 
   213 if ( current_user_can( 'switch_themes' ) ) {
   213 if ( current_user_can( 'switch_themes' ) ) {
   214 	$themes = wp_prepare_themes_for_js();
   214 	$themes = wp_prepare_themes_for_js();
   215 } else {
   215 } else {
   216 	$themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
   216 	$themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
   217 }
   217 }
   218 wp_reset_vars( array( 'theme', 'search' ) );
   218 
       
   219 $theme  = ! empty( $_REQUEST['theme'] ) ? sanitize_text_field( $_REQUEST['theme'] ) : '';
       
   220 $search = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( $_REQUEST['search'] ) : '';
   219 
   221 
   220 wp_localize_script(
   222 wp_localize_script(
   221 	'theme',
   223 	'theme',
   222 	'_wpThemeSettings',
   224 	'_wpThemeSettings',
   223 	array(
   225 	array(
   227 			'installURI'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
   229 			'installURI'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
   228 			'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
   230 			'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
   229 			'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
   231 			'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
   230 		),
   232 		),
   231 		'l10n'     => array(
   233 		'l10n'     => array(
   232 			'addNew'            => __( 'Add New Theme' ),
   234 			'addNew'        => __( 'Add New Theme' ),
   233 			'search'            => __( 'Search Installed Themes' ),
   235 			'search'        => __( 'Search installed themes' ),
   234 			'searchPlaceholder' => __( 'Search installed themes...' ), // Placeholder (no ellipsis).
       
   235 			/* translators: %d: Number of themes. */
   236 			/* translators: %d: Number of themes. */
   236 			'themesFound'       => __( 'Number of Themes found: %d' ),
   237 			'themesFound'   => __( 'Number of Themes found: %d' ),
   237 			'noThemesFound'     => __( 'No themes found. Try a different search.' ),
   238 			'noThemesFound' => __( 'No themes found. Try a different search.' ),
   238 		),
   239 		),
   239 	)
   240 	)
   240 );
   241 );
   241 
   242 
   242 add_thickbox();
   243 add_thickbox();
   248 
   249 
   249 <div class="wrap">
   250 <div class="wrap">
   250 	<h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
   251 	<h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
   251 		<span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
   252 		<span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
   252 	</h1>
   253 	</h1>
   253 
       
   254 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   254 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   255 		<a href="<?php echo esc_url( admin_url( 'theme-install.php' ) ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a>
   255 		<a href="<?php echo esc_url( admin_url( 'theme-install.php' ) ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html__( 'Add New Theme' ); ?></a>
   256 	<?php endif; ?>
   256 	<?php endif; ?>
   257 
       
   258 	<form class="search-form"></form>
       
   259 
       
   260 	<hr class="wp-header-end">
   257 	<hr class="wp-header-end">
       
   258 	<form class="search-form search-themes"><p class="search-box"></p></form>
       
   259 
   261 <?php
   260 <?php
   262 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
   261 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
   263 	?>
   262 	wp_admin_notice(
   264 	<div id="message1" class="updated notice is-dismissible"><p><?php _e( 'The active theme is broken. Reverting to the default theme.' ); ?></p></div>
   263 		__( 'The active theme is broken. Reverting to the default theme.' ),
   265 	<?php
   264 		array(
       
   265 			'id'                 => 'message1',
       
   266 			'additional_classes' => array( 'updated' ),
       
   267 			'dismissible'        => true,
       
   268 		)
       
   269 	);
   266 } elseif ( isset( $_GET['activated'] ) ) {
   270 } elseif ( isset( $_GET['activated'] ) ) {
   267 	if ( isset( $_GET['previewed'] ) ) {
   271 	if ( isset( $_GET['previewed'] ) ) {
   268 		?>
   272 		wp_admin_notice(
   269 		<div id="message2" class="updated notice is-dismissible"><p><?php _e( 'Settings saved and theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
   273 			__( 'Settings saved and theme activated.' ) . ' <a href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Visit site' ) . '</a>',
   270 		<?php
   274 			array(
       
   275 				'id'                 => 'message2',
       
   276 				'additional_classes' => array( 'updated' ),
       
   277 				'dismissible'        => true,
       
   278 			)
       
   279 		);
   271 	} else {
   280 	} else {
   272 		?>
   281 		wp_admin_notice(
   273 		<div id="message2" class="updated notice is-dismissible"><p><?php _e( 'New theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
   282 			__( 'New theme activated.' ) . ' <a href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Visit site' ) . '</a>',
   274 		<?php
   283 			array(
       
   284 				'id'                 => 'message2',
       
   285 				'additional_classes' => array( 'updated' ),
       
   286 				'dismissible'        => true,
       
   287 			)
       
   288 		);
   275 	}
   289 	}
   276 } elseif ( isset( $_GET['deleted'] ) ) {
   290 } elseif ( isset( $_GET['deleted'] ) ) {
   277 	?>
   291 	wp_admin_notice(
   278 	<div id="message3" class="updated notice is-dismissible"><p><?php _e( 'Theme deleted.' ); ?></p></div>
   292 		__( 'Theme deleted.' ),
   279 	<?php
   293 		array(
       
   294 			'id'                 => 'message3',
       
   295 			'additional_classes' => array( 'updated' ),
       
   296 			'dismissible'        => true,
       
   297 		)
       
   298 	);
   280 } elseif ( isset( $_GET['delete-active-child'] ) ) {
   299 } elseif ( isset( $_GET['delete-active-child'] ) ) {
   281 	?>
   300 	wp_admin_notice(
   282 	<div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div>
   301 		__( 'You cannot delete a theme while it has an active child theme.' ),
   283 	<?php
   302 		array(
       
   303 			'id'                 => 'message4',
       
   304 			'additional_classes' => array( 'error' ),
       
   305 		)
       
   306 	);
   284 } elseif ( isset( $_GET['resumed'] ) ) {
   307 } elseif ( isset( $_GET['resumed'] ) ) {
   285 	?>
   308 	wp_admin_notice(
   286 	<div id="message5" class="updated notice is-dismissible"><p><?php _e( 'Theme resumed.' ); ?></p></div>
   309 		__( 'Theme resumed.' ),
   287 	<?php
   310 		array(
       
   311 			'id'                 => 'message5',
       
   312 			'additional_classes' => array( 'updated' ),
       
   313 			'dismissible'        => true,
       
   314 		)
       
   315 	);
   288 } elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
   316 } elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
   289 	?>
   317 	wp_admin_notice(
   290 	<div id="message6" class="error"><p><?php _e( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ); ?></p></div>
   318 		__( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ),
   291 	<?php
   319 		array(
       
   320 			'id'                 => 'message6',
       
   321 			'additional_classes' => array( 'error' ),
       
   322 		)
       
   323 	);
   292 } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
   324 } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
   293 	?>
   325 	wp_admin_notice(
   294 	<div id="message7" class="updated notice is-dismissible"><p><?php _e( 'Theme will be auto-updated.' ); ?></p></div>
   326 		__( 'Theme will be auto-updated.' ),
   295 	<?php
   327 		array(
       
   328 			'id'                 => 'message7',
       
   329 			'additional_classes' => array( 'updated' ),
       
   330 			'dismissible'        => true,
       
   331 		)
       
   332 	);
   296 } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
   333 } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
   297 	?>
   334 	wp_admin_notice(
   298 	<div id="message8" class="updated notice is-dismissible"><p><?php _e( 'Theme will no longer be auto-updated.' ); ?></p></div>
   335 		__( 'Theme will no longer be auto-updated.' ),
   299 	<?php
   336 		array(
       
   337 			'id'                 => 'message8',
       
   338 			'additional_classes' => array( 'updated' ),
       
   339 			'dismissible'        => true,
       
   340 		)
       
   341 	);
   300 }
   342 }
   301 
   343 
   302 $current_theme = wp_get_theme();
   344 $current_theme = wp_get_theme();
   303 
   345 
   304 if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   346 if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   305 	echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message() . '</p></div>';
   347 	wp_admin_notice(
       
   348 		__( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message(),
       
   349 		array(
       
   350 			'additional_classes' => array( 'error' ),
       
   351 		)
       
   352 	);
   306 }
   353 }
   307 
   354 
   308 $current_theme_actions = array();
   355 $current_theme_actions = array();
   309 
   356 
   310 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
   357 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
   393 	<?php } else { ?>
   440 	<?php } else { ?>
   394 		<div class="theme-screenshot blank"></div>
   441 		<div class="theme-screenshot blank"></div>
   395 	<?php } ?>
   442 	<?php } ?>
   396 
   443 
   397 	<?php if ( $theme['hasUpdate'] ) : ?>
   444 	<?php if ( $theme['hasUpdate'] ) : ?>
   398 		<?php if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) : ?>
   445 		<?php
   399 			<div class="update-message notice inline notice-warning notice-alt"><p>
   446 		if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) :
   400 				<?php if ( $theme['hasPackage'] ) : ?>
   447 			if ( $theme['hasPackage'] ) {
   401 					<?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
   448 				$new_version_available = __( 'New version available. <button class="button-link" type="button">Update now</button>' );
   402 				<?php else : ?>
   449 			} else {
   403 					<?php _e( 'New version available.' ); ?>
   450 				$new_version_available = __( 'New version available.' );
   404 				<?php endif; ?>
   451 			}
   405 			</p></div>
   452 			wp_admin_notice(
   406 		<?php else : ?>
   453 				$new_version_available,
   407 			<div class="update-message notice inline notice-error notice-alt"><p>
   454 				array(
   408 				<?php
   455 					'type'               => 'warning',
   409 				if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
   456 					'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
   410 					printf(
   457 				)
   411 						/* translators: %s: Theme name. */
   458 			);
   412 						__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
   459 		else :
   413 						$theme['name']
   460 			$theme_update_error = '';
   414 					);
   461 			if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
   415 					if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   462 				$theme_update_error .= sprintf(
   416 						printf(
   463 					/* translators: %s: Theme name. */
   417 							/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   464 					__( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
   418 							' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   465 					$theme['name']
   419 							self_admin_url( 'update-core.php' ),
   466 				);
   420 							esc_url( wp_get_update_php_url() )
   467 				if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   421 						);
   468 					$theme_update_error .= sprintf(
   422 						wp_update_php_annotation( '</p><p><em>', '</em>' );
   469 						/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   423 					} elseif ( current_user_can( 'update_core' ) ) {
   470 						' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   424 						printf(
   471 						self_admin_url( 'update-core.php' ),
   425 							/* translators: %s: URL to WordPress Updates screen. */
   472 						esc_url( wp_get_update_php_url() )
   426 							' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   473 					);
   427 							self_admin_url( 'update-core.php' )
   474 					wp_update_php_annotation( '</p><p><em>', '</em>', false );
   428 						);
   475 				} elseif ( current_user_can( 'update_core' ) ) {
   429 					} elseif ( current_user_can( 'update_php' ) ) {
   476 					$theme_update_error .= sprintf(
   430 						printf(
   477 						/* translators: %s: URL to WordPress Updates screen. */
   431 							/* translators: %s: URL to Update PHP page. */
   478 						' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   432 							' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   479 						self_admin_url( 'update-core.php' )
   433 							esc_url( wp_get_update_php_url() )
   480 					);
   434 						);
   481 				} elseif ( current_user_can( 'update_php' ) ) {
   435 						wp_update_php_annotation( '</p><p><em>', '</em>' );
   482 					$theme_update_error .= sprintf(
   436 					}
   483 						/* translators: %s: URL to Update PHP page. */
   437 				} elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
   484 						' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   438 					printf(
   485 						esc_url( wp_get_update_php_url() )
   439 						/* translators: %s: Theme name. */
   486 					);
   440 						__( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
   487 					wp_update_php_annotation( '</p><p><em>', '</em>', false );
   441 						$theme['name']
       
   442 					);
       
   443 					if ( current_user_can( 'update_core' ) ) {
       
   444 						printf(
       
   445 							/* translators: %s: URL to WordPress Updates screen. */
       
   446 							' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   447 							self_admin_url( 'update-core.php' )
       
   448 						);
       
   449 					}
       
   450 				} elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
       
   451 					printf(
       
   452 						/* translators: %s: Theme name. */
       
   453 						__( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
       
   454 						$theme['name']
       
   455 					);
       
   456 					if ( current_user_can( 'update_php' ) ) {
       
   457 						printf(
       
   458 							/* translators: %s: URL to Update PHP page. */
       
   459 							' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   460 							esc_url( wp_get_update_php_url() )
       
   461 						);
       
   462 						wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   463 					}
       
   464 				}
   488 				}
   465 				?>
   489 			} elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
   466 			</p></div>
   490 				$theme_update_error .= sprintf(
   467 		<?php endif; ?>
   491 					/* translators: %s: Theme name. */
   468 	<?php endif; ?>
   492 					__( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
   469 
   493 					$theme['name']
   470 	<?php
   494 				);
       
   495 				if ( current_user_can( 'update_core' ) ) {
       
   496 					$theme_update_error .= sprintf(
       
   497 						/* translators: %s: URL to WordPress Updates screen. */
       
   498 						' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   499 						self_admin_url( 'update-core.php' )
       
   500 					);
       
   501 				}
       
   502 			} elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
       
   503 				$theme_update_error .= sprintf(
       
   504 					/* translators: %s: Theme name. */
       
   505 					__( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
       
   506 					$theme['name']
       
   507 				);
       
   508 				if ( current_user_can( 'update_php' ) ) {
       
   509 					$theme_update_error .= sprintf(
       
   510 						/* translators: %s: URL to Update PHP page. */
       
   511 						' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   512 						esc_url( wp_get_update_php_url() )
       
   513 					);
       
   514 					wp_update_php_annotation( '</p><p><em>', '</em>', false );
       
   515 				}
       
   516 			}
       
   517 			wp_admin_notice(
       
   518 				$theme_update_error,
       
   519 				array(
       
   520 					'type'               => 'error',
       
   521 					'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
       
   522 				)
       
   523 			);
       
   524 		endif;
       
   525 	endif;
       
   526 
   471 	if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
   527 	if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
   472 		echo '<div class="notice inline notice-error notice-alt"><p>';
   528 		$message = '';
   473 		if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
   529 		if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
   474 			_e( 'This theme does not work with your versions of WordPress and PHP.' );
   530 			$message = __( 'This theme does not work with your versions of WordPress and PHP.' );
   475 			if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   531 			if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
   476 				printf(
   532 				$message .= sprintf(
   477 					/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   533 					/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   478 					' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   534 					' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   479 					self_admin_url( 'update-core.php' ),
   535 					self_admin_url( 'update-core.php' ),
   480 					esc_url( wp_get_update_php_url() )
   536 					esc_url( wp_get_update_php_url() )
   481 				);
   537 				);
   482 				wp_update_php_annotation( '</p><p><em>', '</em>' );
   538 				$message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
   483 			} elseif ( current_user_can( 'update_core' ) ) {
   539 			} elseif ( current_user_can( 'update_core' ) ) {
   484 				printf(
   540 				$message .= sprintf(
   485 					/* translators: %s: URL to WordPress Updates screen. */
   541 					/* translators: %s: URL to WordPress Updates screen. */
   486 					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   542 					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   487 					self_admin_url( 'update-core.php' )
   543 					self_admin_url( 'update-core.php' )
   488 				);
   544 				);
   489 			} elseif ( current_user_can( 'update_php' ) ) {
   545 			} elseif ( current_user_can( 'update_php' ) ) {
   490 				printf(
   546 				$message .= sprintf(
   491 					/* translators: %s: URL to Update PHP page. */
   547 					/* translators: %s: URL to Update PHP page. */
   492 					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   548 					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   493 					esc_url( wp_get_update_php_url() )
   549 					esc_url( wp_get_update_php_url() )
   494 				);
   550 				);
   495 				wp_update_php_annotation( '</p><p><em>', '</em>' );
   551 				$message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
   496 			}
   552 			}
   497 		} elseif ( ! $theme['compatibleWP'] ) {
   553 		} elseif ( ! $theme['compatibleWP'] ) {
   498 			_e( 'This theme does not work with your version of WordPress.' );
   554 			$message .= __( 'This theme does not work with your version of WordPress.' );
   499 			if ( current_user_can( 'update_core' ) ) {
   555 			if ( current_user_can( 'update_core' ) ) {
   500 				printf(
   556 				$message .= sprintf(
   501 					/* translators: %s: URL to WordPress Updates screen. */
   557 					/* translators: %s: URL to WordPress Updates screen. */
   502 					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   558 					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
   503 					self_admin_url( 'update-core.php' )
   559 					self_admin_url( 'update-core.php' )
   504 				);
   560 				);
   505 			}
   561 			}
   506 		} elseif ( ! $theme['compatiblePHP'] ) {
   562 		} elseif ( ! $theme['compatiblePHP'] ) {
   507 			_e( 'This theme does not work with your version of PHP.' );
   563 			$message .= __( 'This theme does not work with your version of PHP.' );
   508 			if ( current_user_can( 'update_php' ) ) {
   564 			if ( current_user_can( 'update_php' ) ) {
   509 				printf(
   565 				$message .= sprintf(
   510 					/* translators: %s: URL to Update PHP page. */
   566 					/* translators: %s: URL to Update PHP page. */
   511 					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   567 					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
   512 					esc_url( wp_get_update_php_url() )
   568 					esc_url( wp_get_update_php_url() )
   513 				);
   569 				);
   514 				wp_update_php_annotation( '</p><p><em>', '</em>' );
   570 				$message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
   515 			}
   571 			}
   516 		}
   572 		}
   517 		echo '</p></div>';
   573 
       
   574 		wp_admin_notice(
       
   575 			$message,
       
   576 			array(
       
   577 				'type'               => 'error',
       
   578 				'additional_classes' => array( 'inline', 'notice-alt' ),
       
   579 			)
       
   580 		);
   518 	}
   581 	}
   519 	?>
   582 
   520 
       
   521 	<?php
       
   522 	/* translators: %s: Theme name. */
   583 	/* translators: %s: Theme name. */
   523 	$details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
   584 	$details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
   524 	?>
   585 	?>
   525 	<button type="button" aria-label="<?php echo esc_attr( $details_aria_label ); ?>" class="more-details" id="<?php echo esc_attr( $aria_action ); ?>"><?php _e( 'Theme Details' ); ?></button>
   586 	<button type="button" aria-label="<?php echo esc_attr( $details_aria_label ); ?>" class="more-details" id="<?php echo esc_attr( $aria_action ); ?>"><?php _e( 'Theme Details' ); ?></button>
   526 	<div class="theme-author">
   587 	<div class="theme-author">
   553 			/* translators: %s: Theme name. */
   614 			/* translators: %s: Theme name. */
   554 			$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   615 			$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   555 			?>
   616 			?>
   556 			<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   617 			<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   557 			<?php
   618 			<?php
   558 			if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
   619 			// Only classic themes require the "customize" capability.
       
   620 			if ( current_user_can( 'edit_theme_options' ) && ( $theme['blockTheme'] || current_user_can( 'customize' ) ) ) {
   559 				/* translators: %s: Theme name. */
   621 				/* translators: %s: Theme name. */
   560 				$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
   622 				$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
   561 				?>
   623 				?>
   562 				<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
   624 				<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
   563 			<?php } ?>
   625 			<?php } ?>
   609 		<?php } ?>
   671 		<?php } ?>
   610 		<?php if ( $can_install ) { ?>
   672 		<?php if ( $can_install ) { ?>
   611 			<td></td>
   673 			<td></td>
   612 		<?php } ?>
   674 		<?php } ?>
   613 	</tr>
   675 	</tr>
   614 	<?php foreach ( $broken_themes as $broken_theme ) : ?>
   676 	<?php
       
   677 	foreach ( $broken_themes as $broken_theme ) :
       
   678 		?>
   615 		<tr>
   679 		<tr>
   616 			<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
   680 			<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
   617 			<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
   681 			<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
   618 			<?php
   682 			<?php
   619 			if ( $can_resume ) {
   683 			if ( $can_resume ) {
   670 					<?php
   734 					<?php
   671 				}
   735 				}
   672 			}
   736 			}
   673 			?>
   737 			?>
   674 		</tr>
   738 		</tr>
   675 	<?php endforeach; ?>
   739 		<?php
       
   740 	endforeach;
       
   741 	?>
   676 </table>
   742 </table>
   677 </div>
   743 </div>
   678 
   744 
   679 	<?php
   745 	<?php
   680 }
   746 }
   689  * @since 5.5.0
   755  * @since 5.5.0
   690  *
   756  *
   691  * @return string The template for displaying the auto-update setting link.
   757  * @return string The template for displaying the auto-update setting link.
   692  */
   758  */
   693 function wp_theme_auto_update_setting_template() {
   759 function wp_theme_auto_update_setting_template() {
       
   760 	$notice   = wp_get_admin_notice(
       
   761 		'',
       
   762 		array(
       
   763 			'type'               => 'error',
       
   764 			'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
       
   765 		)
       
   766 	);
   694 	$template = '
   767 	$template = '
   695 		<div class="theme-autoupdate">
   768 		<div class="theme-autoupdate">
   696 			<# if ( data.autoupdate.supported ) { #>
   769 			<# if ( data.autoupdate.supported ) { #>
   697 				<# if ( data.autoupdate.forced === false ) { #>
   770 				<# if ( data.autoupdate.forced === false ) { #>
   698 					' . __( 'Auto-updates disabled' ) . '
   771 					' . __( 'Auto-updates disabled' ) . '
   714 				<# } else { #>
   787 				<# } else { #>
   715 					<span class="auto-update-time hidden">
   788 					<span class="auto-update-time hidden">
   716 				<# } #>
   789 				<# } #>
   717 				<br />' . wp_get_auto_update_message() . '</span>
   790 				<br />' . wp_get_auto_update_message() . '</span>
   718 			<# } #>
   791 			<# } #>
   719 			<div class="notice notice-error notice-alt inline hidden"><p></p></div>
   792 			' . $notice . '
   720 		</div>
   793 		</div>
   721 	';
   794 	';
   722 
   795 
   723 	/**
   796 	/**
   724 	 * Filters the JavaScript template used to display the auto-update setting for a theme (in the overlay).
   797 	 * Filters the JavaScript template used to display the auto-update setting for a theme (in the overlay).
   912 					<?php
   985 					<?php
   913 					/* translators: %s: Theme name. */
   986 					/* translators: %s: Theme name. */
   914 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   987 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   915 					?>
   988 					?>
   916 					<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   989 					<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   917 					<# if ( ! data.blockTheme ) { #>
   990 					<?php
   918 						<?php
   991 					/* translators: %s: Theme name. */
   919 						/* translators: %s: Theme name. */
   992 					$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
   920 						$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
   993 					?>
   921 						?>
   994 					<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
   922 						<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
       
   923 					<# } #>
       
   924 				<# } else { #>
   995 				<# } else { #>
   925 					<?php
   996 					<?php
   926 					/* translators: %s: Theme name. */
   997 					/* translators: %s: Theme name. */
   927 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
   998 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
   928 					?>
   999 					?>
   938 
  1009 
   939 <script id="tmpl-theme-single" type="text/template">
  1010 <script id="tmpl-theme-single" type="text/template">
   940 	<div class="theme-backdrop"></div>
  1011 	<div class="theme-backdrop"></div>
   941 	<div class="theme-wrap wp-clearfix" role="document">
  1012 	<div class="theme-wrap wp-clearfix" role="document">
   942 		<div class="theme-header">
  1013 		<div class="theme-header">
   943 			<button class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
  1014 			<button class="left dashicons dashicons-no"><span class="screen-reader-text">
   944 			<button class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
  1015 				<?php
   945 			<button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button>
  1016 				/* translators: Hidden accessibility text. */
       
  1017 				_e( 'Show previous theme' );
       
  1018 				?>
       
  1019 			</span></button>
       
  1020 			<button class="right dashicons dashicons-no"><span class="screen-reader-text">
       
  1021 				<?php
       
  1022 				/* translators: Hidden accessibility text. */
       
  1023 				_e( 'Show next theme' );
       
  1024 				?>
       
  1025 			</span></button>
       
  1026 			<button class="close dashicons dashicons-no"><span class="screen-reader-text">
       
  1027 				<?php
       
  1028 				/* translators: Hidden accessibility text. */
       
  1029 				_e( 'Close details dialog' );
       
  1030 				?>
       
  1031 			</span></button>
   946 		</div>
  1032 		</div>
   947 		<div class="theme-about wp-clearfix">
  1033 		<div class="theme-about wp-clearfix">
   948 			<div class="theme-screenshots">
  1034 			<div class="theme-screenshots">
   949 			<# if ( data.screenshot[0] ) { #>
  1035 			<# if ( data.screenshot[0] ) { #>
   950 				<div class="screenshot"><img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" /></div>
  1036 				<div class="screenshot"><img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" /></div>
  1132 				<# if ( data.compatibleWP && data.compatiblePHP ) { #>
  1218 				<# if ( data.compatibleWP && data.compatiblePHP ) { #>
  1133 					<?php
  1219 					<?php
  1134 					/* translators: %s: Theme name. */
  1220 					/* translators: %s: Theme name. */
  1135 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
  1221 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
  1136 					?>
  1222 					?>
       
  1223 					<# if ( ! data.blockTheme ) { #>
       
  1224 						<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
       
  1225 					<# } #>
  1137 					<# if ( data.actions.activate ) { #>
  1226 					<# if ( data.actions.activate ) { #>
  1138 						<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
  1227 						<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
  1139 					<# } #>
  1228 					<# } #>
  1140 					<# if ( ! data.blockTheme ) { #>
       
  1141 						<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
       
  1142 					<# } #>
       
  1143 				<# } else { #>
  1229 				<# } else { #>
  1144 					<?php
  1230 					<?php
  1145 					/* translators: %s: Theme name. */
  1231 					/* translators: %s: Theme name. */
  1146 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
  1232 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
  1147 					?>
  1233 					?>
       
  1234 					<# if ( ! data.blockTheme ) { #>
       
  1235 						<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
       
  1236 					<# } #>
  1148 					<# if ( data.actions.activate ) { #>
  1237 					<# if ( data.actions.activate ) { #>
  1149 						<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
  1238 						<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
  1150 					<# } #>
       
  1151 					<# if ( ! data.blockTheme ) { #>
       
  1152 						<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
       
  1153 					<# } #>
  1239 					<# } #>
  1154 				<# } #>
  1240 				<# } #>
  1155 			</div>
  1241 			</div>
  1156 
  1242 
  1157 			<# if ( ! data.active && data.actions['delete'] ) { #>
  1243 			<# if ( ! data.active && data.actions['delete'] ) { #>