wp/wp-admin/themes.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage Administration
     6  * @subpackage Administration
     7  */
     7  */
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once __DIR__ . '/admin.php';
    11 
    11 
    12 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
    12 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
    13 	wp_die(
    13 	wp_die(
    14 		'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
    14 		'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
    15 		'<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>',
    15 		'<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>',
    16 		403
    16 		403
    17 	);
    17 	);
    18 }
    18 }
    19 
    19 
    20 if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) {
    20 if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) {
    21 	if ( 'activate' == $_GET['action'] ) {
    21 	if ( 'activate' === $_GET['action'] ) {
    22 		check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] );
    22 		check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] );
    23 		$theme = wp_get_theme( $_GET['stylesheet'] );
    23 		$theme = wp_get_theme( $_GET['stylesheet'] );
    24 
    24 
    25 		if ( ! $theme->exists() || ! $theme->is_allowed() ) {
    25 		if ( ! $theme->exists() || ! $theme->is_allowed() ) {
    26 			wp_die(
    26 			wp_die(
    51 			wp_die( $result );
    51 			wp_die( $result );
    52 		}
    52 		}
    53 
    53 
    54 		wp_redirect( admin_url( 'themes.php?resumed=true' ) );
    54 		wp_redirect( admin_url( 'themes.php?resumed=true' ) );
    55 		exit;
    55 		exit;
    56 	} elseif ( 'delete' == $_GET['action'] ) {
    56 	} elseif ( 'delete' === $_GET['action'] ) {
    57 		check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] );
    57 		check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] );
    58 		$theme = wp_get_theme( $_GET['stylesheet'] );
    58 		$theme = wp_get_theme( $_GET['stylesheet'] );
    59 
    59 
    60 		if ( ! current_user_can( 'delete_themes' ) ) {
    60 		if ( ! current_user_can( 'delete_themes' ) ) {
    61 			wp_die(
    61 			wp_die(
    79 		} else {
    79 		} else {
    80 			delete_theme( $_GET['stylesheet'] );
    80 			delete_theme( $_GET['stylesheet'] );
    81 			wp_redirect( admin_url( 'themes.php?deleted=true' ) );
    81 			wp_redirect( admin_url( 'themes.php?deleted=true' ) );
    82 		}
    82 		}
    83 		exit;
    83 		exit;
       
    84 	} elseif ( 'enable-auto-update' === $_GET['action'] ) {
       
    85 		if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) {
       
    86 			wp_die( __( 'Sorry, you are not allowed to enable themes automatic updates.' ) );
       
    87 		}
       
    88 
       
    89 		check_admin_referer( 'updates' );
       
    90 
       
    91 		$all_items    = wp_get_themes();
       
    92 		$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
       
    93 
       
    94 		$auto_updates[] = $_GET['stylesheet'];
       
    95 		$auto_updates   = array_unique( $auto_updates );
       
    96 		// Remove themes that have been deleted since the site option was last updated.
       
    97 		$auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
       
    98 
       
    99 		update_site_option( 'auto_update_themes', $auto_updates );
       
   100 
       
   101 		wp_redirect( admin_url( 'themes.php?enabled-auto-update=true' ) );
       
   102 
       
   103 		exit;
       
   104 	} elseif ( 'disable-auto-update' === $_GET['action'] ) {
       
   105 		if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) {
       
   106 			wp_die( __( 'Sorry, you are not allowed to disable themes automatic updates.' ) );
       
   107 		}
       
   108 
       
   109 		check_admin_referer( 'updates' );
       
   110 
       
   111 		$all_items    = wp_get_themes();
       
   112 		$auto_updates = (array) get_site_option( 'auto_update_themes', array() );
       
   113 
       
   114 		$auto_updates = array_diff( $auto_updates, array( $_GET['stylesheet'] ) );
       
   115 		// Remove themes that have been deleted since the site option was last updated.
       
   116 		$auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
       
   117 
       
   118 		update_site_option( 'auto_update_themes', $auto_updates );
       
   119 
       
   120 		wp_redirect( admin_url( 'themes.php?disabled-auto-update=true' ) );
       
   121 
       
   122 		exit;
    84 	}
   123 	}
    85 }
   124 }
    86 
   125 
    87 $title       = __( 'Manage Themes' );
   126 $title       = __( 'Manage Themes' );
    88 $parent_file = 'themes.php';
   127 $parent_file = 'themes.php';
    89 
   128 
    90 // Help tab: Overview
   129 // Help tab: Overview.
    91 if ( current_user_can( 'switch_themes' ) ) {
   130 if ( current_user_can( 'switch_themes' ) ) {
    92 	$help_overview = '<p>' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) included with your WordPress installation, themes are designed and developed by third parties.' ) . '</p>' .
   131 	$help_overview = '<p>' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) included with your WordPress installation, themes are designed and developed by third parties.' ) . '</p>' .
    93 		'<p>' . __( 'From this screen you can:' ) . '</p>' .
   132 		'<p>' . __( 'From this screen you can:' ) . '</p>' .
    94 		'<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' .
   133 		'<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' .
    95 		'<li>' . __( 'Click on the theme to see the theme name, version, author, description, tags, and the Delete link' ) . '</li>' .
   134 		'<li>' . __( 'Click on the theme to see the theme name, version, author, description, tags, and the Delete link' ) . '</li>' .
   102 			'id'      => 'overview',
   141 			'id'      => 'overview',
   103 			'title'   => __( 'Overview' ),
   142 			'title'   => __( 'Overview' ),
   104 			'content' => $help_overview,
   143 			'content' => $help_overview,
   105 		)
   144 		)
   106 	);
   145 	);
   107 } // switch_themes
   146 } // End if 'switch_themes'.
   108 
   147 
   109 // Help tab: Adding Themes
   148 // Help tab: Adding Themes.
   110 if ( current_user_can( 'install_themes' ) ) {
   149 if ( current_user_can( 'install_themes' ) ) {
   111 	if ( is_multisite() ) {
   150 	if ( is_multisite() ) {
   112 		$help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
   151 		$help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
   113 	} else {
   152 	} else {
   114 		$help_install = '<p>' . sprintf( __( '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!' ), __( 'https://wordpress.org/themes/' ) ) . '</p>';
   153 		$help_install = '<p>' . sprintf(
       
   154 			/* translators: %s: https://wordpress.org/themes/ */
       
   155 			__( '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 			__( 'https://wordpress.org/themes/' )
       
   157 		) . '</p>';
   115 	}
   158 	}
   116 
   159 
   117 	get_current_screen()->add_help_tab(
   160 	get_current_screen()->add_help_tab(
   118 		array(
   161 		array(
   119 			'id'      => 'adding-themes',
   162 			'id'      => 'adding-themes',
   120 			'title'   => __( 'Adding Themes' ),
   163 			'title'   => __( 'Adding Themes' ),
   121 			'content' => $help_install,
   164 			'content' => $help_install,
   122 		)
   165 		)
   123 	);
   166 	);
   124 } // install_themes
   167 } // End if 'install_themes'.
   125 
   168 
   126 // Help tab: Previewing and Customizing
   169 // Help tab: Previewing and Customizing.
   127 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
   170 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
   128 	$help_customize =
   171 	$help_customize =
   129 		'<p>' . __( 'Tap or hover on any theme then click the Live Preview button to see a live preview of that theme and change theme options in a separate, full-screen view. You can also find a Live Preview button at the bottom of the theme details screen. Any installed theme can be previewed and customized in this way.' ) . '</p>' .
   172 		'<p>' . __( 'Tap or hover on any theme then click the Live Preview button to see a live preview of that theme and change theme options in a separate, full-screen view. You can also find a Live Preview button at the bottom of the theme details screen. Any installed theme can be previewed and customized in this way.' ) . '</p>' .
   130 		'<p>' . __( 'The theme being previewed is fully interactive &mdash; navigate to different pages to see how the theme handles posts, archives, and other page templates. The settings may differ depending on what theme features the theme being previewed supports. To accept the new settings and activate the theme all in one step, click the Publish &amp; Activate button above the menu.' ) . '</p>' .
   173 		'<p>' . __( 'The theme being previewed is fully interactive &mdash; navigate to different pages to see how the theme handles posts, archives, and other page templates. The settings may differ depending on what theme features the theme being previewed supports. To accept the new settings and activate the theme all in one step, click the Publish &amp; Activate button above the menu.' ) . '</p>' .
   131 		'<p>' . __( 'When previewing on smaller monitors, you can use the collapse icon at the bottom of the left-hand pane. This will hide the pane, giving you more room to preview your site in the new theme. To bring the pane back, click on the collapse icon again.' ) . '</p>';
   174 		'<p>' . __( 'When previewing on smaller monitors, you can use the collapse icon at the bottom of the left-hand pane. This will hide the pane, giving you more room to preview your site in the new theme. To bring the pane back, click on the collapse icon again.' ) . '</p>';
   135 			'id'      => 'customize-preview-themes',
   178 			'id'      => 'customize-preview-themes',
   136 			'title'   => __( 'Previewing and Customizing' ),
   179 			'title'   => __( 'Previewing and Customizing' ),
   137 			'content' => $help_customize,
   180 			'content' => $help_customize,
   138 		)
   181 		)
   139 	);
   182 	);
   140 } // edit_theme_options && customize
   183 } // End if 'edit_theme_options' && 'customize'.
       
   184 
       
   185 $help_sidebar_autoupdates = '';
       
   186 
       
   187 // Help tab: Auto-updates.
       
   188 if ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) {
       
   189 	$help_tab_autoupdates =
       
   190 		'<p>' . __( 'Auto-updates can be enabled or disabled for each individual theme. Themes with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>' .
       
   191 		'<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>';
       
   192 
       
   193 	get_current_screen()->add_help_tab(
       
   194 		array(
       
   195 			'id'      => 'plugins-themes-auto-updates',
       
   196 			'title'   => __( 'Auto-updates' ),
       
   197 			'content' => $help_tab_autoupdates,
       
   198 		)
       
   199 	);
       
   200 
       
   201 	$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>';
       
   202 } // End if 'update_themes' && 'wp_is_auto_update_enabled_for_type'.
   141 
   203 
   142 get_current_screen()->set_help_sidebar(
   204 get_current_screen()->set_help_sidebar(
   143 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   205 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   144 	'<p>' . __( '<a href="https://codex.wordpress.org/Using_Themes">Documentation on Using Themes</a>' ) . '</p>' .
   206 	'<p>' . __( '<a href="https://wordpress.org/support/article/using-themes/">Documentation on Using Themes</a>' ) . '</p>' .
       
   207 	$help_sidebar_autoupdates .
   145 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   208 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
   146 );
   209 );
   147 
   210 
   148 if ( current_user_can( 'switch_themes' ) ) {
   211 if ( current_user_can( 'switch_themes' ) ) {
   149 	$themes = wp_prepare_themes_for_js();
   212 	$themes = wp_prepare_themes_for_js();
   164 			'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
   227 			'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
   165 		),
   228 		),
   166 		'l10n'     => array(
   229 		'l10n'     => array(
   167 			'addNew'            => __( 'Add New Theme' ),
   230 			'addNew'            => __( 'Add New Theme' ),
   168 			'search'            => __( 'Search Installed Themes' ),
   231 			'search'            => __( 'Search Installed Themes' ),
   169 			'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis)
   232 			'searchPlaceholder' => __( 'Search installed themes...' ), // Placeholder (no ellipsis).
       
   233 			/* translators: %d: Number of themes. */
   170 			'themesFound'       => __( 'Number of Themes found: %d' ),
   234 			'themesFound'       => __( 'Number of Themes found: %d' ),
   171 			'noThemesFound'     => __( 'No themes found. Try a different search.' ),
   235 			'noThemesFound'     => __( 'No themes found. Try a different search.' ),
   172 		),
   236 		),
   173 	)
   237 	)
   174 );
   238 );
   175 
   239 
   176 add_thickbox();
   240 add_thickbox();
   177 wp_enqueue_script( 'theme' );
   241 wp_enqueue_script( 'theme' );
   178 wp_enqueue_script( 'updates' );
   242 wp_enqueue_script( 'updates' );
   179 
   243 
   180 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   244 require_once ABSPATH . 'wp-admin/admin-header.php';
   181 ?>
   245 ?>
   182 
   246 
   183 <div class="wrap">
   247 <div class="wrap">
   184 	<h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
   248 	<h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
   185 		<span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
   249 		<span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
   186 	</h1>
   250 	</h1>
   187 
   251 
   188 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   252 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   189 		<a href="<?php echo admin_url( 'theme-install.php' ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html_x( 'Add New', 'Add new theme' ); ?></a>
   253 		<a href="<?php echo admin_url( 'theme-install.php' ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a>
   190 	<?php endif; ?>
   254 	<?php endif; ?>
   191 
   255 
   192 	<form class="search-form"></form>
   256 	<form class="search-form"></form>
   193 
   257 
   194 	<hr class="wp-header-end">
   258 	<hr class="wp-header-end">
   221 	<?php
   285 	<?php
   222 } elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
   286 } elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
   223 	?>
   287 	?>
   224 	<div id="message6" class="error"><p><?php _e( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ); ?></p></div>
   288 	<div id="message6" class="error"><p><?php _e( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ); ?></p></div>
   225 	<?php
   289 	<?php
       
   290 } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
       
   291 	?>
       
   292 	<div id="message7" class="updated notice is-dismissible"><p><?php _e( 'Theme will be auto-updated.' ); ?></p></div>
       
   293 	<?php
       
   294 } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
       
   295 	?>
       
   296 	<div id="message8" class="updated notice is-dismissible"><p><?php _e( 'Theme will no longer be auto-updated.' ); ?></p></div>
       
   297 	<?php
   226 }
   298 }
   227 
   299 
   228 $ct = wp_get_theme();
   300 $ct = wp_get_theme();
   229 
   301 
   230 if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   302 if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   231 	echo '<div class="error"><p>' . __( 'ERROR:' ) . ' ' . $ct->errors()->get_error_message() . '</p></div>';
   303 	echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $ct->errors()->get_error_message() . '</p></div>';
   232 }
   304 }
   233 
   305 
   234 /*
   306 /*
   235 // Certain error codes are less fatal than others. We can still display theme information in most cases.
   307 // Certain error codes are less fatal than others. We can still display theme information in most cases.
   236 if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
   308 if ( ! $ct->errors() || ( 1 === count( $ct->errors()->get_error_codes() )
   237 	&& in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
   309 	&& in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
   238 */
   310 */
   239 
   311 
   240 	// Pretend you didn't see this.
   312 	// Pretend you didn't see this.
   241 	$current_theme_actions = array();
   313 	$current_theme_actions = array();
   242 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
   314 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
   243 	foreach ( (array) $submenu['themes.php'] as $item ) {
   315 	foreach ( (array) $submenu['themes.php'] as $item ) {
   244 		$class = '';
   316 		$class = '';
   245 		if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) {
   317 		if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) {
   246 			continue;
   318 			continue;
   247 		}
   319 		}
   248 		// 0 = name, 1 = capability, 2 = file
   320 		// 0 = name, 1 = capability, 2 = file.
   249 		if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) {
   321 		if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) {
   250 			$class = ' current';
   322 			$class = ' current';
   251 		}
   323 		}
   252 		if ( ! empty( $submenu[ $item[2] ] ) ) {
   324 		if ( ! empty( $submenu[ $item[2] ] ) ) {
   253 			$submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index.
   325 			$submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index.
   266 				} elseif ( 'custom-background' === $menu_file ) {
   338 				} elseif ( 'custom-background' === $menu_file ) {
   267 					$current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
   339 					$current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
   268 				}
   340 				}
   269 			}
   341 			}
   270 
   342 
   271 			if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) {
   343 			$pos = strpos( $menu_file, '?' );
       
   344 			if ( false !== $pos ) {
   272 				$menu_file = substr( $menu_file, 0, $pos );
   345 				$menu_file = substr( $menu_file, 0, $pos );
   273 			}
   346 			}
   274 
   347 
   275 			if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
   348 			if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
   276 				$current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>";
   349 				$current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>";
   314 	<?php } else { ?>
   387 	<?php } else { ?>
   315 		<div class="theme-screenshot blank"></div>
   388 		<div class="theme-screenshot blank"></div>
   316 	<?php } ?>
   389 	<?php } ?>
   317 
   390 
   318 	<?php if ( $theme['hasUpdate'] ) : ?>
   391 	<?php if ( $theme['hasUpdate'] ) : ?>
   319 		<div class="update-message notice inline notice-warning notice-alt">
   392 		<?php if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) : ?>
   320 		<?php if ( $theme['hasPackage'] ) : ?>
   393 			<div class="update-message notice inline notice-warning notice-alt"><p>
   321 			<p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p>
   394 				<?php if ( $theme['hasPackage'] ) : ?>
       
   395 					<?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
       
   396 				<?php else : ?>
       
   397 					<?php _e( 'New version available.' ); ?>
       
   398 				<?php endif; ?>
       
   399 			</p></div>
   322 		<?php else : ?>
   400 		<?php else : ?>
   323 			<p><?php _e( 'New version available.' ); ?></p>
   401 			<div class="update-message notice inline notice-error notice-alt"><p>
       
   402 				<?php
       
   403 				if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
       
   404 					printf(
       
   405 						/* translators: %s: Theme name. */
       
   406 						__( 'There is a new version of %s available, but it doesn&#8217;t work with your versions of WordPress and PHP.' ),
       
   407 						$theme['name']
       
   408 					);
       
   409 					if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
       
   410 						printf(
       
   411 							/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
       
   412 							' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
       
   413 							self_admin_url( 'update-core.php' ),
       
   414 							esc_url( wp_get_update_php_url() )
       
   415 						);
       
   416 						wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   417 					} elseif ( current_user_can( 'update_core' ) ) {
       
   418 						printf(
       
   419 							/* translators: %s: URL to WordPress Updates screen. */
       
   420 							' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   421 							self_admin_url( 'update-core.php' )
       
   422 						);
       
   423 					} elseif ( current_user_can( 'update_php' ) ) {
       
   424 						printf(
       
   425 							/* translators: %s: URL to Update PHP page. */
       
   426 							' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   427 							esc_url( wp_get_update_php_url() )
       
   428 						);
       
   429 						wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   430 					}
       
   431 				} elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
       
   432 					printf(
       
   433 						/* translators: %s: Theme name. */
       
   434 						__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of WordPress.' ),
       
   435 						$theme['name']
       
   436 					);
       
   437 					if ( current_user_can( 'update_core' ) ) {
       
   438 						printf(
       
   439 							/* translators: %s: URL to WordPress Updates screen. */
       
   440 							' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   441 							self_admin_url( 'update-core.php' )
       
   442 						);
       
   443 					}
       
   444 				} elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
       
   445 					printf(
       
   446 						/* translators: %s: Theme name. */
       
   447 						__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of PHP.' ),
       
   448 						$theme['name']
       
   449 					);
       
   450 					if ( current_user_can( 'update_php' ) ) {
       
   451 						printf(
       
   452 							/* translators: %s: URL to Update PHP page. */
       
   453 							' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   454 							esc_url( wp_get_update_php_url() )
       
   455 						);
       
   456 						wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   457 					}
       
   458 				}
       
   459 				?>
       
   460 			</p></div>
   324 		<?php endif; ?>
   461 		<?php endif; ?>
   325 		</div>
       
   326 	<?php endif; ?>
   462 	<?php endif; ?>
   327 
   463 
       
   464 	<?php
       
   465 	if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
       
   466 		echo '<div class="notice inline notice-error notice-alt"><p>';
       
   467 		if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
       
   468 			_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
       
   469 			if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
       
   470 				printf(
       
   471 					/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
       
   472 					' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
       
   473 					self_admin_url( 'update-core.php' ),
       
   474 					esc_url( wp_get_update_php_url() )
       
   475 				);
       
   476 				wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   477 			} elseif ( current_user_can( 'update_core' ) ) {
       
   478 				printf(
       
   479 					/* translators: %s: URL to WordPress Updates screen. */
       
   480 					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   481 					self_admin_url( 'update-core.php' )
       
   482 				);
       
   483 			} elseif ( current_user_can( 'update_php' ) ) {
       
   484 				printf(
       
   485 					/* translators: %s: URL to Update PHP page. */
       
   486 					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   487 					esc_url( wp_get_update_php_url() )
       
   488 				);
       
   489 				wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   490 			}
       
   491 		} elseif ( ! $theme['compatibleWP'] ) {
       
   492 			_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
       
   493 			if ( current_user_can( 'update_core' ) ) {
       
   494 				printf(
       
   495 					/* translators: %s: URL to WordPress Updates screen. */
       
   496 					' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   497 					self_admin_url( 'update-core.php' )
       
   498 				);
       
   499 			}
       
   500 		} elseif ( ! $theme['compatiblePHP'] ) {
       
   501 			_e( 'This theme doesn&#8217;t work with your version of PHP.' );
       
   502 			if ( current_user_can( 'update_php' ) ) {
       
   503 				printf(
       
   504 					/* translators: %s: URL to Update PHP page. */
       
   505 					' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   506 					esc_url( wp_get_update_php_url() )
       
   507 				);
       
   508 				wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   509 			}
       
   510 		}
       
   511 		echo '</p></div>';
       
   512 	}
       
   513 	?>
       
   514 
   328 	<span class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></span>
   515 	<span class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></span>
   329 	<div class="theme-author"><?php printf( __( 'By %s' ), $theme['author'] ); ?></div>
   516 	<div class="theme-author">
       
   517 		<?php
       
   518 		/* translators: %s: Theme author name. */
       
   519 		printf( __( 'By %s' ), $theme['author'] );
       
   520 		?>
       
   521 	</div>
   330 
   522 
   331 	<div class="theme-id-container">
   523 	<div class="theme-id-container">
   332 		<?php if ( $theme['active'] ) { ?>
   524 		<?php if ( $theme['active'] ) { ?>
   333 			<h2 class="theme-name" id="<?php echo $aria_name; ?>">
   525 			<h2 class="theme-name" id="<?php echo $aria_name; ?>">
   334 				<?php
   526 				<span><?php _ex( 'Active:', 'theme' ); ?></span> <?php echo $theme['name']; ?>
   335 				/* translators: %s: theme name */
       
   336 				printf( __( '<span>Active:</span> %s' ), $theme['name'] );
       
   337 				?>
       
   338 			</h2>
   527 			</h2>
   339 		<?php } else { ?>
   528 		<?php } else { ?>
   340 			<h2 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h2>
   529 			<h2 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h2>
   341 		<?php } ?>
   530 		<?php } ?>
   342 
   531 
   343 		<div class="theme-actions">
   532 		<div class="theme-actions">
   344 		<?php if ( $theme['active'] ) { ?>
   533 		<?php if ( $theme['active'] ) { ?>
   345 			<?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
   534 			<?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
   346 				<a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
   535 				<a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
   347 			<?php } ?>
   536 			<?php } ?>
   348 		<?php } else { ?>
   537 		<?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
   349 			<?php
   538 			<?php
   350 			/* translators: %s: Theme name */
   539 			/* translators: %s: Theme name. */
   351 			$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   540 			$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   352 			?>
   541 			?>
   353 			<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   542 			<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   354 			<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
   543 			<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
   355 				<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
   544 				<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
       
   545 			<?php } ?>
       
   546 		<?php } else { ?>
       
   547 			<?php
       
   548 			/* translators: %s: Theme name. */
       
   549 			$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
       
   550 			?>
       
   551 			<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
       
   552 			<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
       
   553 				<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
   356 			<?php } ?>
   554 			<?php } ?>
   357 		<?php } ?>
   555 		<?php } ?>
   358 
   556 
   359 		</div>
   557 		</div>
   360 	</div>
   558 	</div>
   366 
   564 
   367 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
   565 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
   368 
   566 
   369 <?php
   567 <?php
   370 // List broken themes, if any.
   568 // List broken themes, if any.
   371 if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
   569 $broken_themes = wp_get_themes( array( 'errors' => true ) );
       
   570 if ( ! is_multisite() && $broken_themes ) {
   372 	?>
   571 	?>
   373 
   572 
   374 <div class="broken-themes">
   573 <div class="broken-themes">
   375 <h3><?php _e( 'Broken Themes' ); ?></h3>
   574 <h3><?php _e( 'Broken Themes' ); ?></h3>
   376 <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
   575 <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
   394 			<td></td>
   593 			<td></td>
   395 		<?php } ?>
   594 		<?php } ?>
   396 	</tr>
   595 	</tr>
   397 	<?php foreach ( $broken_themes as $broken_theme ) : ?>
   596 	<?php foreach ( $broken_themes as $broken_theme ) : ?>
   398 		<tr>
   597 		<tr>
   399 			<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
   598 			<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
   400 			<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
   599 			<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
   401 			<?php
   600 			<?php
   402 			if ( $can_resume ) {
   601 			if ( $can_resume ) {
   403 				if ( 'theme_paused' === $broken_theme->errors()->get_error_code() ) {
   602 				if ( 'theme_paused' === $broken_theme->errors()->get_error_code() ) {
   404 					$stylesheet = $broken_theme->get_stylesheet();
   603 					$stylesheet = $broken_theme->get_stylesheet();
   463 }
   662 }
   464 ?>
   663 ?>
   465 </div><!-- .wrap -->
   664 </div><!-- .wrap -->
   466 
   665 
   467 <?php
   666 <?php
       
   667 
       
   668 /**
       
   669  * Returns the JavaScript template used to display the auto-update setting for a theme.
       
   670  *
       
   671  * @since 5.5.0
       
   672  *
       
   673  * @return string The template for displaying the auto-update setting link.
       
   674  */
       
   675 function wp_theme_auto_update_setting_template() {
       
   676 	$template = '
       
   677 		<div class="theme-autoupdate">
       
   678 			<# if ( data.autoupdate.supported ) { #>
       
   679 				<# if ( data.autoupdate.forced === false ) { #>
       
   680 					' . __( 'Auto-updates disabled' ) . '
       
   681 				<# } else if ( data.autoupdate.forced ) { #>
       
   682 					' . __( 'Auto-updates enabled' ) . '
       
   683 				<# } else if ( data.autoupdate.enabled ) { #>
       
   684 					<button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable">
       
   685 						<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span>
       
   686 					</button>
       
   687 				<# } else { #>
       
   688 					<button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable">
       
   689 						<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span>
       
   690 					</button>
       
   691 				<# } #>
       
   692 			<# } #>
       
   693 			<# if ( data.hasUpdate ) { #>
       
   694 				<# if ( data.autoupdate.supported && data.autoupdate.enabled ) { #>
       
   695 					<span class="auto-update-time">
       
   696 				<# } else { #>
       
   697 					<span class="auto-update-time hidden">
       
   698 				<# } #>
       
   699 				<br />' . wp_get_auto_update_message() . '</span>
       
   700 			<# } #>
       
   701 			<div class="notice notice-error notice-alt inline hidden"><p></p></div>
       
   702 		</div>
       
   703 	';
       
   704 
       
   705 	/**
       
   706 	 * Filters the JavaScript template used to display the auto-update setting for a theme (in the overlay).
       
   707 	 *
       
   708 	 * See {@see wp_prepare_themes_for_js()} for the properties of the `data` object.
       
   709 	 *
       
   710 	 * @since 5.5.0
       
   711 	 *
       
   712 	 * @param string $template The template for displaying the auto-update setting link.
       
   713 	 */
       
   714 	return apply_filters( 'theme_auto_update_setting_template', $template );
       
   715 }
       
   716 
   468 /*
   717 /*
   469  * The tmpl-theme template is synchronized with PHP above!
   718  * The tmpl-theme template is synchronized with PHP above!
   470  */
   719  */
   471 ?>
   720 ?>
   472 <script id="tmpl-theme" type="text/template">
   721 <script id="tmpl-theme" type="text/template">
   477 	<# } else { #>
   726 	<# } else { #>
   478 		<div class="theme-screenshot blank"></div>
   727 		<div class="theme-screenshot blank"></div>
   479 	<# } #>
   728 	<# } #>
   480 
   729 
   481 	<# if ( data.hasUpdate ) { #>
   730 	<# if ( data.hasUpdate ) { #>
   482 		<# if ( data.hasPackage ) { #>
   731 		<# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
   483 			<div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div>
   732 			<div class="update-message notice inline notice-warning notice-alt"><p>
       
   733 				<# if ( data.hasPackage ) { #>
       
   734 					<?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
       
   735 				<# } else { #>
       
   736 					<?php _e( 'New version available.' ); ?>
       
   737 				<# } #>
       
   738 			</p></div>
   484 		<# } else { #>
   739 		<# } else { #>
   485 			<div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div>
   740 			<div class="update-message notice inline notice-error notice-alt"><p>
       
   741 				<# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
       
   742 					<?php
       
   743 					printf(
       
   744 						/* translators: %s: Theme name. */
       
   745 						__( 'There is a new version of %s available, but it doesn&#8217;t work with your versions of WordPress and PHP.' ),
       
   746 						'{{{ data.name }}}'
       
   747 					);
       
   748 					if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
       
   749 						printf(
       
   750 							/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
       
   751 							' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
       
   752 							self_admin_url( 'update-core.php' ),
       
   753 							esc_url( wp_get_update_php_url() )
       
   754 						);
       
   755 						wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   756 					} elseif ( current_user_can( 'update_core' ) ) {
       
   757 						printf(
       
   758 							/* translators: %s: URL to WordPress Updates screen. */
       
   759 							' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   760 							self_admin_url( 'update-core.php' )
       
   761 						);
       
   762 					} elseif ( current_user_can( 'update_php' ) ) {
       
   763 						printf(
       
   764 							/* translators: %s: URL to Update PHP page. */
       
   765 							' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   766 							esc_url( wp_get_update_php_url() )
       
   767 						);
       
   768 						wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   769 					}
       
   770 					?>
       
   771 				<# } else if ( ! data.updateResponse.compatibleWP ) { #>
       
   772 					<?php
       
   773 					printf(
       
   774 						/* translators: %s: Theme name. */
       
   775 						__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of WordPress.' ),
       
   776 						'{{{ data.name }}}'
       
   777 					);
       
   778 					if ( current_user_can( 'update_core' ) ) {
       
   779 						printf(
       
   780 							/* translators: %s: URL to WordPress Updates screen. */
       
   781 							' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   782 							self_admin_url( 'update-core.php' )
       
   783 						);
       
   784 					}
       
   785 					?>
       
   786 				<# } else if ( ! data.updateResponse.compatiblePHP ) { #>
       
   787 					<?php
       
   788 					printf(
       
   789 						/* translators: %s: Theme name. */
       
   790 						__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of PHP.' ),
       
   791 						'{{{ data.name }}}'
       
   792 					);
       
   793 					if ( current_user_can( 'update_php' ) ) {
       
   794 						printf(
       
   795 							/* translators: %s: URL to Update PHP page. */
       
   796 							' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   797 							esc_url( wp_get_update_php_url() )
       
   798 						);
       
   799 						wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   800 					}
       
   801 					?>
       
   802 				<# } #>
       
   803 			</p></div>
   486 		<# } #>
   804 		<# } #>
       
   805 	<# } #>
       
   806 
       
   807 	<# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
       
   808 		<div class="notice notice-error notice-alt"><p>
       
   809 			<# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
       
   810 				<?php
       
   811 				_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
       
   812 				if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
       
   813 					printf(
       
   814 						/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
       
   815 						' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
       
   816 						self_admin_url( 'update-core.php' ),
       
   817 						esc_url( wp_get_update_php_url() )
       
   818 					);
       
   819 					wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   820 				} elseif ( current_user_can( 'update_core' ) ) {
       
   821 					printf(
       
   822 						/* translators: %s: URL to WordPress Updates screen. */
       
   823 						' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   824 						self_admin_url( 'update-core.php' )
       
   825 					);
       
   826 				} elseif ( current_user_can( 'update_php' ) ) {
       
   827 					printf(
       
   828 						/* translators: %s: URL to Update PHP page. */
       
   829 						' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   830 						esc_url( wp_get_update_php_url() )
       
   831 					);
       
   832 					wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   833 				}
       
   834 				?>
       
   835 			<# } else if ( ! data.compatibleWP ) { #>
       
   836 				<?php
       
   837 				_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
       
   838 				if ( current_user_can( 'update_core' ) ) {
       
   839 					printf(
       
   840 						/* translators: %s: URL to WordPress Updates screen. */
       
   841 						' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   842 						self_admin_url( 'update-core.php' )
       
   843 					);
       
   844 				}
       
   845 				?>
       
   846 			<# } else if ( ! data.compatiblePHP ) { #>
       
   847 				<?php
       
   848 				_e( 'This theme doesn&#8217;t work with your version of PHP.' );
       
   849 				if ( current_user_can( 'update_php' ) ) {
       
   850 					printf(
       
   851 						/* translators: %s: URL to Update PHP page. */
       
   852 						' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   853 						esc_url( wp_get_update_php_url() )
       
   854 					);
       
   855 					wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   856 				}
       
   857 				?>
       
   858 			<# } #>
       
   859 		</p></div>
   487 	<# } #>
   860 	<# } #>
   488 
   861 
   489 	<span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span>
   862 	<span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span>
   490 	<div class="theme-author">
   863 	<div class="theme-author">
   491 		<?php
   864 		<?php
   492 		/* translators: %s: Theme author name */
   865 		/* translators: %s: Theme author name. */
   493 		printf( __( 'By %s' ), '{{{ data.author }}}' );
   866 		printf( __( 'By %s' ), '{{{ data.author }}}' );
   494 		?>
   867 		?>
   495 	</div>
   868 	</div>
   496 
   869 
   497 	<div class="theme-id-container">
   870 	<div class="theme-id-container">
   498 		<# if ( data.active ) { #>
   871 		<# if ( data.active ) { #>
   499 			<h2 class="theme-name" id="{{ data.id }}-name">
   872 			<h2 class="theme-name" id="{{ data.id }}-name">
   500 				<?php
   873 				<span><?php _ex( 'Active:', 'theme' ); ?></span> {{{ data.name }}}
   501 				/* translators: %s: Theme name */
       
   502 				printf( __( '<span>Active:</span> %s' ), '{{{ data.name }}}' );
       
   503 				?>
       
   504 			</h2>
   874 			</h2>
   505 		<# } else { #>
   875 		<# } else { #>
   506 			<h2 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h2>
   876 			<h2 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h2>
   507 		<# } #>
   877 		<# } #>
   508 
   878 
   510 			<# if ( data.active ) { #>
   880 			<# if ( data.active ) { #>
   511 				<# if ( data.actions.customize ) { #>
   881 				<# if ( data.actions.customize ) { #>
   512 					<a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
   882 					<a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
   513 				<# } #>
   883 				<# } #>
   514 			<# } else { #>
   884 			<# } else { #>
   515 				<?php
   885 				<# if ( data.compatibleWP && data.compatiblePHP ) { #>
   516 				/* translators: %s: Theme name */
   886 					<?php
   517 				$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   887 					/* translators: %s: Theme name. */
   518 				?>
   888 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   519 				<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
   889 					?>
   520 				<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
   890 					<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
       
   891 					<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
       
   892 				<# } else { #>
       
   893 					<?php
       
   894 					/* translators: %s: Theme name. */
       
   895 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
       
   896 					?>
       
   897 					<a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
       
   898 					<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
       
   899 				<# } #>
   521 			<# } #>
   900 			<# } #>
   522 		</div>
   901 		</div>
   523 	</div>
   902 	</div>
   524 </script>
   903 </script>
   525 
   904 
   542 
   921 
   543 			<div class="theme-info">
   922 			<div class="theme-info">
   544 				<# if ( data.active ) { #>
   923 				<# if ( data.active ) { #>
   545 					<span class="current-label"><?php _e( 'Current Theme' ); ?></span>
   924 					<span class="current-label"><?php _e( 'Current Theme' ); ?></span>
   546 				<# } #>
   925 				<# } #>
   547 				<h2 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></span></h2>
   926 				<h2 class="theme-name">{{{ data.name }}}<span class="theme-version">
   548 				<p class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' ); ?></p>
   927 					<?php
       
   928 					/* translators: %s: Theme version. */
       
   929 					printf( __( 'Version: %s' ), '{{ data.version }}' );
       
   930 					?>
       
   931 				</span></h2>
       
   932 				<p class="theme-author">
       
   933 					<?php
       
   934 					/* translators: %s: Theme author link. */
       
   935 					printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' );
       
   936 					?>
       
   937 				</p>
       
   938 
       
   939 				<# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
       
   940 					<div class="notice notice-error notice-alt notice-large"><p>
       
   941 						<# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
       
   942 							<?php
       
   943 							_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
       
   944 							if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
       
   945 								printf(
       
   946 									/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
       
   947 									' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
       
   948 									self_admin_url( 'update-core.php' ),
       
   949 									esc_url( wp_get_update_php_url() )
       
   950 								);
       
   951 								wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   952 							} elseif ( current_user_can( 'update_core' ) ) {
       
   953 								printf(
       
   954 									/* translators: %s: URL to WordPress Updates screen. */
       
   955 									' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   956 									self_admin_url( 'update-core.php' )
       
   957 								);
       
   958 							} elseif ( current_user_can( 'update_php' ) ) {
       
   959 								printf(
       
   960 									/* translators: %s: URL to Update PHP page. */
       
   961 									' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   962 									esc_url( wp_get_update_php_url() )
       
   963 								);
       
   964 								wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   965 							}
       
   966 							?>
       
   967 						<# } else if ( ! data.compatibleWP ) { #>
       
   968 							<?php
       
   969 							_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
       
   970 							if ( current_user_can( 'update_core' ) ) {
       
   971 								printf(
       
   972 									/* translators: %s: URL to WordPress Updates screen. */
       
   973 									' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   974 									self_admin_url( 'update-core.php' )
       
   975 								);
       
   976 							}
       
   977 							?>
       
   978 						<# } else if ( ! data.compatiblePHP ) { #>
       
   979 							<?php
       
   980 							_e( 'This theme doesn&#8217;t work with your version of PHP.' );
       
   981 							if ( current_user_can( 'update_php' ) ) {
       
   982 								printf(
       
   983 									/* translators: %s: URL to Update PHP page. */
       
   984 									' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   985 									esc_url( wp_get_update_php_url() )
       
   986 								);
       
   987 								wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   988 							}
       
   989 							?>
       
   990 						<# } #>
       
   991 					</p></div>
       
   992 				<# } #>
   549 
   993 
   550 				<# if ( data.hasUpdate ) { #>
   994 				<# if ( data.hasUpdate ) { #>
   551 				<div class="notice notice-warning notice-alt notice-large">
   995 					<# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
   552 					<h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
   996 						<div class="notice notice-warning notice-alt notice-large">
   553 					{{{ data.update }}}
   997 							<h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
   554 				</div>
   998 							{{{ data.update }}}
   555 				<# } #>
   999 						</div>
       
  1000 					<# } else { #>
       
  1001 						<div class="notice notice-error notice-alt notice-large">
       
  1002 							<h3 class="notice-title"><?php _e( 'Update Incompatible' ); ?></h3>
       
  1003 							<p>
       
  1004 								<# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
       
  1005 									<?php
       
  1006 									printf(
       
  1007 										/* translators: %s: Theme name. */
       
  1008 										__( 'There is a new version of %s available, but it doesn&#8217;t work with your versions of WordPress and PHP.' ),
       
  1009 										'{{{ data.name }}}'
       
  1010 									);
       
  1011 									if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
       
  1012 										printf(
       
  1013 											/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
       
  1014 											' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
       
  1015 											self_admin_url( 'update-core.php' ),
       
  1016 											esc_url( wp_get_update_php_url() )
       
  1017 										);
       
  1018 										wp_update_php_annotation( '</p><p><em>', '</em>' );
       
  1019 									} elseif ( current_user_can( 'update_core' ) ) {
       
  1020 										printf(
       
  1021 											/* translators: %s: URL to WordPress Updates screen. */
       
  1022 											' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
  1023 											self_admin_url( 'update-core.php' )
       
  1024 										);
       
  1025 									} elseif ( current_user_can( 'update_php' ) ) {
       
  1026 										printf(
       
  1027 											/* translators: %s: URL to Update PHP page. */
       
  1028 											' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
  1029 											esc_url( wp_get_update_php_url() )
       
  1030 										);
       
  1031 										wp_update_php_annotation( '</p><p><em>', '</em>' );
       
  1032 									}
       
  1033 									?>
       
  1034 								<# } else if ( ! data.updateResponse.compatibleWP ) { #>
       
  1035 									<?php
       
  1036 									printf(
       
  1037 										/* translators: %s: Theme name. */
       
  1038 										__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of WordPress.' ),
       
  1039 										'{{{ data.name }}}'
       
  1040 									);
       
  1041 									if ( current_user_can( 'update_core' ) ) {
       
  1042 										printf(
       
  1043 											/* translators: %s: URL to WordPress Updates screen. */
       
  1044 											' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
  1045 											self_admin_url( 'update-core.php' )
       
  1046 										);
       
  1047 									}
       
  1048 									?>
       
  1049 								<# } else if ( ! data.updateResponse.compatiblePHP ) { #>
       
  1050 									<?php
       
  1051 									printf(
       
  1052 										/* translators: %s: Theme name. */
       
  1053 										__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of PHP.' ),
       
  1054 										'{{{ data.name }}}'
       
  1055 									);
       
  1056 									if ( current_user_can( 'update_php' ) ) {
       
  1057 										printf(
       
  1058 											/* translators: %s: URL to Update PHP page. */
       
  1059 											' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
  1060 											esc_url( wp_get_update_php_url() )
       
  1061 										);
       
  1062 										wp_update_php_annotation( '</p><p><em>', '</em>' );
       
  1063 									}
       
  1064 									?>
       
  1065 								<# } #>
       
  1066 							</p>
       
  1067 						</div>
       
  1068 					<# } #>
       
  1069 				<# } #>
       
  1070 
       
  1071 				<# if ( data.actions.autoupdate ) { #>
       
  1072 					<?php echo wp_theme_auto_update_setting_template(); ?>
       
  1073 				<# } #>
       
  1074 
   556 				<p class="theme-description">{{{ data.description }}}</p>
  1075 				<p class="theme-description">{{{ data.description }}}</p>
   557 
  1076 
   558 				<# if ( data.parent ) { #>
  1077 				<# if ( data.parent ) { #>
   559 					<p class="parent-theme"><?php printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' ); ?></p>
  1078 					<p class="parent-theme">
       
  1079 						<?php
       
  1080 						/* translators: %s: Theme name. */
       
  1081 						printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' );
       
  1082 						?>
       
  1083 					</p>
   560 				<# } #>
  1084 				<# } #>
   561 
  1085 
   562 				<# if ( data.tags ) { #>
  1086 				<# if ( data.tags ) { #>
   563 					<p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{{ data.tags }}}</p>
  1087 					<p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{{ data.tags }}}</p>
   564 				<# } #>
  1088 				<# } #>
   569 			<div class="active-theme">
  1093 			<div class="active-theme">
   570 				<a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
  1094 				<a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
   571 				<?php echo implode( ' ', $current_theme_actions ); ?>
  1095 				<?php echo implode( ' ', $current_theme_actions ); ?>
   572 			</div>
  1096 			</div>
   573 			<div class="inactive-theme">
  1097 			<div class="inactive-theme">
   574 				<?php
  1098 				<# if ( data.compatibleWP && data.compatiblePHP ) { #>
   575 				/* translators: %s: Theme name */
  1099 					<?php
   576 				$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
  1100 					/* translators: %s: Theme name. */
   577 				?>
  1101 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   578 				<# if ( data.actions.activate ) { #>
  1102 					?>
   579 					<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
  1103 					<# if ( data.actions.activate ) { #>
   580 				<# } #>
  1104 						<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
   581 				<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
  1105 					<# } #>
       
  1106 					<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
       
  1107 				<# } else { #>
       
  1108 					<?php
       
  1109 					/* translators: %s: Theme name. */
       
  1110 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
       
  1111 					?>
       
  1112 					<# if ( data.actions.activate ) { #>
       
  1113 						<a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
       
  1114 					<# } #>
       
  1115 					<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
       
  1116 				<# } #>
   582 			</div>
  1117 			</div>
   583 
  1118 
   584 			<# if ( ! data.active && data.actions['delete'] ) { #>
  1119 			<# if ( ! data.active && data.actions['delete'] ) { #>
   585 				<a href="{{{ data.actions['delete'] }}}" class="button delete-theme"><?php _e( 'Delete' ); ?></a>
  1120 				<a href="{{{ data.actions['delete'] }}}" class="button delete-theme"><?php _e( 'Delete' ); ?></a>
   586 			<# } #>
  1121 			<# } #>
   599 	array(
  1134 	array(
   600 		'totals' => wp_get_update_data(),
  1135 		'totals' => wp_get_update_data(),
   601 	)
  1136 	)
   602 );
  1137 );
   603 
  1138 
   604 require( ABSPATH . 'wp-admin/admin-footer.php' );
  1139 require_once ABSPATH . 'wp-admin/admin-footer.php';