themes.php 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  1. <?php
  2. /**
  3. * Themes administration panel.
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. /** WordPress Administration Bootstrap */
  9. require_once __DIR__ . '/admin.php';
  10. if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
  11. wp_die(
  12. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  13. '<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>',
  14. 403
  15. );
  16. }
  17. if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) {
  18. if ( 'activate' === $_GET['action'] ) {
  19. check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] );
  20. $theme = wp_get_theme( $_GET['stylesheet'] );
  21. if ( ! $theme->exists() || ! $theme->is_allowed() ) {
  22. wp_die(
  23. '<h1>' . __( 'Something went wrong.' ) . '</h1>' .
  24. '<p>' . __( 'The requested theme does not exist.' ) . '</p>',
  25. 403
  26. );
  27. }
  28. switch_theme( $theme->get_stylesheet() );
  29. wp_redirect( admin_url( 'themes.php?activated=true' ) );
  30. exit;
  31. } elseif ( 'resume' === $_GET['action'] ) {
  32. check_admin_referer( 'resume-theme_' . $_GET['stylesheet'] );
  33. $theme = wp_get_theme( $_GET['stylesheet'] );
  34. if ( ! current_user_can( 'resume_theme', $_GET['stylesheet'] ) ) {
  35. wp_die(
  36. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  37. '<p>' . __( 'Sorry, you are not allowed to resume this theme.' ) . '</p>',
  38. 403
  39. );
  40. }
  41. $result = resume_theme( $theme->get_stylesheet(), self_admin_url( 'themes.php?error=resuming' ) );
  42. if ( is_wp_error( $result ) ) {
  43. wp_die( $result );
  44. }
  45. wp_redirect( admin_url( 'themes.php?resumed=true' ) );
  46. exit;
  47. } elseif ( 'delete' === $_GET['action'] ) {
  48. check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] );
  49. $theme = wp_get_theme( $_GET['stylesheet'] );
  50. if ( ! current_user_can( 'delete_themes' ) ) {
  51. wp_die(
  52. '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
  53. '<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>',
  54. 403
  55. );
  56. }
  57. if ( ! $theme->exists() ) {
  58. wp_die(
  59. '<h1>' . __( 'Something went wrong.' ) . '</h1>' .
  60. '<p>' . __( 'The requested theme does not exist.' ) . '</p>',
  61. 403
  62. );
  63. }
  64. $active = wp_get_theme();
  65. if ( $active->get( 'Template' ) === $_GET['stylesheet'] ) {
  66. wp_redirect( admin_url( 'themes.php?delete-active-child=true' ) );
  67. } else {
  68. delete_theme( $_GET['stylesheet'] );
  69. wp_redirect( admin_url( 'themes.php?deleted=true' ) );
  70. }
  71. exit;
  72. } elseif ( 'enable-auto-update' === $_GET['action'] ) {
  73. if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) {
  74. wp_die( __( 'Sorry, you are not allowed to enable themes automatic updates.' ) );
  75. }
  76. check_admin_referer( 'updates' );
  77. $all_items = wp_get_themes();
  78. $auto_updates = (array) get_site_option( 'auto_update_themes', array() );
  79. $auto_updates[] = $_GET['stylesheet'];
  80. $auto_updates = array_unique( $auto_updates );
  81. // Remove themes that have been deleted since the site option was last updated.
  82. $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
  83. update_site_option( 'auto_update_themes', $auto_updates );
  84. wp_redirect( admin_url( 'themes.php?enabled-auto-update=true' ) );
  85. exit;
  86. } elseif ( 'disable-auto-update' === $_GET['action'] ) {
  87. if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) {
  88. wp_die( __( 'Sorry, you are not allowed to disable themes automatic updates.' ) );
  89. }
  90. check_admin_referer( 'updates' );
  91. $all_items = wp_get_themes();
  92. $auto_updates = (array) get_site_option( 'auto_update_themes', array() );
  93. $auto_updates = array_diff( $auto_updates, array( $_GET['stylesheet'] ) );
  94. // Remove themes that have been deleted since the site option was last updated.
  95. $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) );
  96. update_site_option( 'auto_update_themes', $auto_updates );
  97. wp_redirect( admin_url( 'themes.php?disabled-auto-update=true' ) );
  98. exit;
  99. }
  100. }
  101. // Used in the HTML title tag.
  102. $title = __( 'Themes' );
  103. $parent_file = 'themes.php';
  104. // Help tab: Overview.
  105. if ( current_user_can( 'switch_themes' ) ) {
  106. $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>' .
  107. '<p>' . __( 'From this screen you can:' ) . '</p>' .
  108. '<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' .
  109. '<li>' . __( 'Click on the theme to see the theme name, version, author, description, tags, and the Delete link' ) . '</li>' .
  110. '<li>' . __( 'Click Customize for the active theme or Live Preview for any other theme to see a live preview' ) . '</li></ul>' .
  111. '<p>' . __( 'The active theme is displayed highlighted as the first theme.' ) . '</p>' .
  112. '<p>' . __( 'The search for installed themes will search for terms in their name, description, author, or tag.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>';
  113. get_current_screen()->add_help_tab(
  114. array(
  115. 'id' => 'overview',
  116. 'title' => __( 'Overview' ),
  117. 'content' => $help_overview,
  118. )
  119. );
  120. } // End if 'switch_themes'.
  121. // Help tab: Adding Themes.
  122. if ( current_user_can( 'install_themes' ) ) {
  123. if ( is_multisite() ) {
  124. $help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
  125. } else {
  126. $help_install = '<p>' . sprintf(
  127. /* translators: %s: https://wordpress.org/themes/ */
  128. __( '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!' ),
  129. __( 'https://wordpress.org/themes/' )
  130. ) . '</p>';
  131. }
  132. get_current_screen()->add_help_tab(
  133. array(
  134. 'id' => 'adding-themes',
  135. 'title' => __( 'Adding Themes' ),
  136. 'content' => $help_install,
  137. )
  138. );
  139. } // End if 'install_themes'.
  140. // Help tab: Previewing and Customizing.
  141. if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
  142. $help_customize =
  143. '<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>' .
  144. '<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 Activate &amp; Publish button above the menu.' ) . '</p>' .
  145. '<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>';
  146. get_current_screen()->add_help_tab(
  147. array(
  148. 'id' => 'customize-preview-themes',
  149. 'title' => __( 'Previewing and Customizing' ),
  150. 'content' => $help_customize,
  151. )
  152. );
  153. } // End if 'edit_theme_options' && 'customize'.
  154. $help_sidebar_autoupdates = '';
  155. // Help tab: Auto-updates.
  156. if ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) {
  157. $help_tab_autoupdates =
  158. '<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>' .
  159. '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>';
  160. get_current_screen()->add_help_tab(
  161. array(
  162. 'id' => 'plugins-themes-auto-updates',
  163. 'title' => __( 'Auto-updates' ),
  164. 'content' => $help_tab_autoupdates,
  165. )
  166. );
  167. $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>';
  168. } // End if 'update_themes' && 'wp_is_auto_update_enabled_for_type'.
  169. get_current_screen()->set_help_sidebar(
  170. '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
  171. '<p>' . __( '<a href="https://wordpress.org/support/article/using-themes/">Documentation on Using Themes</a>' ) . '</p>' .
  172. '<p>' . __( '<a href="https://wordpress.org/support/article/appearance-themes-screen/">Documentation on Managing Themes</a>' ) . '</p>' .
  173. $help_sidebar_autoupdates .
  174. '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
  175. );
  176. if ( current_user_can( 'switch_themes' ) ) {
  177. $themes = wp_prepare_themes_for_js();
  178. } else {
  179. $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
  180. }
  181. wp_reset_vars( array( 'theme', 'search' ) );
  182. wp_localize_script(
  183. 'theme',
  184. '_wpThemeSettings',
  185. array(
  186. 'themes' => $themes,
  187. 'settings' => array(
  188. 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ),
  189. 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
  190. 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
  191. 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ),
  192. ),
  193. 'l10n' => array(
  194. 'addNew' => __( 'Add New Theme' ),
  195. 'search' => __( 'Search Installed Themes' ),
  196. 'searchPlaceholder' => __( 'Search installed themes...' ), // Placeholder (no ellipsis).
  197. /* translators: %d: Number of themes. */
  198. 'themesFound' => __( 'Number of Themes found: %d' ),
  199. 'noThemesFound' => __( 'No themes found. Try a different search.' ),
  200. ),
  201. )
  202. );
  203. add_thickbox();
  204. wp_enqueue_script( 'theme' );
  205. wp_enqueue_script( 'updates' );
  206. require_once ABSPATH . 'wp-admin/admin-header.php';
  207. ?>
  208. <div class="wrap">
  209. <h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
  210. <span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
  211. </h1>
  212. <?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
  213. <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>
  214. <?php endif; ?>
  215. <form class="search-form"></form>
  216. <hr class="wp-header-end">
  217. <?php
  218. if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
  219. ?>
  220. <div id="message1" class="updated notice is-dismissible"><p><?php _e( 'The active theme is broken. Reverting to the default theme.' ); ?></p></div>
  221. <?php
  222. } elseif ( isset( $_GET['activated'] ) ) {
  223. if ( isset( $_GET['previewed'] ) ) {
  224. ?>
  225. <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'Settings saved and theme activated.' ); ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
  226. <?php
  227. } else {
  228. ?>
  229. <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'New theme activated.' ); ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
  230. <?php
  231. }
  232. } elseif ( isset( $_GET['deleted'] ) ) {
  233. ?>
  234. <div id="message3" class="updated notice is-dismissible"><p><?php _e( 'Theme deleted.' ); ?></p></div>
  235. <?php
  236. } elseif ( isset( $_GET['delete-active-child'] ) ) {
  237. ?>
  238. <div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div>
  239. <?php
  240. } elseif ( isset( $_GET['resumed'] ) ) {
  241. ?>
  242. <div id="message5" class="updated notice is-dismissible"><p><?php _e( 'Theme resumed.' ); ?></p></div>
  243. <?php
  244. } elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
  245. ?>
  246. <div id="message6" class="error"><p><?php _e( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ); ?></p></div>
  247. <?php
  248. } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
  249. ?>
  250. <div id="message7" class="updated notice is-dismissible"><p><?php _e( 'Theme will be auto-updated.' ); ?></p></div>
  251. <?php
  252. } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
  253. ?>
  254. <div id="message8" class="updated notice is-dismissible"><p><?php _e( 'Theme will no longer be auto-updated.' ); ?></p></div>
  255. <?php
  256. }
  257. $current_theme = wp_get_theme();
  258. if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
  259. echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message() . '</p></div>';
  260. }
  261. $current_theme_actions = array();
  262. if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
  263. $forbidden_paths = array(
  264. 'themes.php',
  265. 'theme-editor.php',
  266. 'site-editor.php',
  267. 'edit.php?post_type=wp_navigation',
  268. );
  269. foreach ( (array) $submenu['themes.php'] as $item ) {
  270. $class = '';
  271. if ( in_array( $item[2], $forbidden_paths, true ) || str_starts_with( $item[2], 'customize.php' ) ) {
  272. continue;
  273. }
  274. // 0 = name, 1 = capability, 2 = file.
  275. if ( 0 === strcmp( $self, $item[2] ) && empty( $parent_file )
  276. || $parent_file && $item[2] === $parent_file
  277. ) {
  278. $class = ' current';
  279. }
  280. if ( ! empty( $submenu[ $item[2] ] ) ) {
  281. $submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index.
  282. $menu_hook = get_plugin_page_hook( $submenu[ $item[2] ][0][2], $item[2] );
  283. if ( file_exists( WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}" ) || ! empty( $menu_hook ) ) {
  284. $current_theme_actions[] = "<a class='button$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
  285. } else {
  286. $current_theme_actions[] = "<a class='button$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
  287. }
  288. } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
  289. $menu_file = $item[2];
  290. if ( current_user_can( 'customize' ) ) {
  291. if ( 'custom-header' === $menu_file ) {
  292. $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
  293. } elseif ( 'custom-background' === $menu_file ) {
  294. $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
  295. }
  296. }
  297. $pos = strpos( $menu_file, '?' );
  298. if ( false !== $pos ) {
  299. $menu_file = substr( $menu_file, 0, $pos );
  300. }
  301. if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
  302. $current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>";
  303. } else {
  304. $current_theme_actions[] = "<a class='button$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
  305. }
  306. }
  307. }
  308. }
  309. $class_name = 'theme-browser';
  310. if ( ! empty( $_GET['search'] ) ) {
  311. $class_name .= ' search-loading';
  312. }
  313. ?>
  314. <div class="<?php echo esc_attr( $class_name ); ?>">
  315. <div class="themes wp-clearfix">
  316. <?php
  317. /*
  318. * This PHP is synchronized with the tmpl-theme template below!
  319. */
  320. foreach ( $themes as $theme ) :
  321. $aria_action = $theme['id'] . '-action';
  322. $aria_name = $theme['id'] . '-name';
  323. $active_class = '';
  324. if ( $theme['active'] ) {
  325. $active_class = ' active';
  326. }
  327. ?>
  328. <div class="theme<?php echo $active_class; ?>">
  329. <?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
  330. <div class="theme-screenshot">
  331. <img src="<?php echo esc_url( $theme['screenshot'][0] . '?ver=' . $theme['version'] ); ?>" alt="" />
  332. </div>
  333. <?php } else { ?>
  334. <div class="theme-screenshot blank"></div>
  335. <?php } ?>
  336. <?php if ( $theme['hasUpdate'] ) : ?>
  337. <?php if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) : ?>
  338. <div class="update-message notice inline notice-warning notice-alt"><p>
  339. <?php if ( $theme['hasPackage'] ) : ?>
  340. <?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
  341. <?php else : ?>
  342. <?php _e( 'New version available.' ); ?>
  343. <?php endif; ?>
  344. </p></div>
  345. <?php else : ?>
  346. <div class="update-message notice inline notice-error notice-alt"><p>
  347. <?php
  348. if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
  349. printf(
  350. /* translators: %s: Theme name. */
  351. __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
  352. $theme['name']
  353. );
  354. if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
  355. printf(
  356. /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
  357. ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
  358. self_admin_url( 'update-core.php' ),
  359. esc_url( wp_get_update_php_url() )
  360. );
  361. wp_update_php_annotation( '</p><p><em>', '</em>' );
  362. } elseif ( current_user_can( 'update_core' ) ) {
  363. printf(
  364. /* translators: %s: URL to WordPress Updates screen. */
  365. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  366. self_admin_url( 'update-core.php' )
  367. );
  368. } elseif ( current_user_can( 'update_php' ) ) {
  369. printf(
  370. /* translators: %s: URL to Update PHP page. */
  371. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  372. esc_url( wp_get_update_php_url() )
  373. );
  374. wp_update_php_annotation( '</p><p><em>', '</em>' );
  375. }
  376. } elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
  377. printf(
  378. /* translators: %s: Theme name. */
  379. __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
  380. $theme['name']
  381. );
  382. if ( current_user_can( 'update_core' ) ) {
  383. printf(
  384. /* translators: %s: URL to WordPress Updates screen. */
  385. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  386. self_admin_url( 'update-core.php' )
  387. );
  388. }
  389. } elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
  390. printf(
  391. /* translators: %s: Theme name. */
  392. __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
  393. $theme['name']
  394. );
  395. if ( current_user_can( 'update_php' ) ) {
  396. printf(
  397. /* translators: %s: URL to Update PHP page. */
  398. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  399. esc_url( wp_get_update_php_url() )
  400. );
  401. wp_update_php_annotation( '</p><p><em>', '</em>' );
  402. }
  403. }
  404. ?>
  405. </p></div>
  406. <?php endif; ?>
  407. <?php endif; ?>
  408. <?php
  409. if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
  410. echo '<div class="notice inline notice-error notice-alt"><p>';
  411. if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
  412. _e( 'This theme does not work with your versions of WordPress and PHP.' );
  413. if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
  414. printf(
  415. /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
  416. ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
  417. self_admin_url( 'update-core.php' ),
  418. esc_url( wp_get_update_php_url() )
  419. );
  420. wp_update_php_annotation( '</p><p><em>', '</em>' );
  421. } elseif ( current_user_can( 'update_core' ) ) {
  422. printf(
  423. /* translators: %s: URL to WordPress Updates screen. */
  424. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  425. self_admin_url( 'update-core.php' )
  426. );
  427. } elseif ( current_user_can( 'update_php' ) ) {
  428. printf(
  429. /* translators: %s: URL to Update PHP page. */
  430. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  431. esc_url( wp_get_update_php_url() )
  432. );
  433. wp_update_php_annotation( '</p><p><em>', '</em>' );
  434. }
  435. } elseif ( ! $theme['compatibleWP'] ) {
  436. _e( 'This theme does not work with your version of WordPress.' );
  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['compatiblePHP'] ) {
  445. _e( 'This theme does not work with your version of PHP.' );
  446. if ( current_user_can( 'update_php' ) ) {
  447. printf(
  448. /* translators: %s: URL to Update PHP page. */
  449. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  450. esc_url( wp_get_update_php_url() )
  451. );
  452. wp_update_php_annotation( '</p><p><em>', '</em>' );
  453. }
  454. }
  455. echo '</p></div>';
  456. }
  457. ?>
  458. <?php
  459. /* translators: %s: Theme name. */
  460. $details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
  461. ?>
  462. <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>
  463. <div class="theme-author">
  464. <?php
  465. /* translators: %s: Theme author name. */
  466. printf( __( 'By %s' ), $theme['author'] );
  467. ?>
  468. </div>
  469. <div class="theme-id-container">
  470. <?php if ( $theme['active'] ) { ?>
  471. <h2 class="theme-name" id="<?php echo esc_attr( $aria_name ); ?>">
  472. <span><?php _ex( 'Active:', 'theme' ); ?></span> <?php echo $theme['name']; ?>
  473. </h2>
  474. <?php } else { ?>
  475. <h2 class="theme-name" id="<?php echo esc_attr( $aria_name ); ?>"><?php echo $theme['name']; ?></h2>
  476. <?php } ?>
  477. <div class="theme-actions">
  478. <?php if ( $theme['active'] ) { ?>
  479. <?php
  480. if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
  481. /* translators: %s: Theme name. */
  482. $customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), $theme['name'] );
  483. ?>
  484. <a aria-label="<?php echo esc_attr( $customize_aria_label ); ?>" class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
  485. <?php } ?>
  486. <?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
  487. <?php
  488. /* translators: %s: Theme name. */
  489. $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
  490. ?>
  491. <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
  492. <?php
  493. if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
  494. /* translators: %s: Theme name. */
  495. $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
  496. ?>
  497. <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>
  498. <?php } ?>
  499. <?php } else { ?>
  500. <?php
  501. /* translators: %s: Theme name. */
  502. $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
  503. ?>
  504. <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
  505. <?php if ( ! $theme['blockTheme'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
  506. <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
  507. <?php } ?>
  508. <?php } ?>
  509. </div>
  510. </div>
  511. </div>
  512. <?php endforeach; ?>
  513. </div>
  514. </div>
  515. <div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div>
  516. <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
  517. <?php
  518. // List broken themes, if any.
  519. $broken_themes = wp_get_themes( array( 'errors' => true ) );
  520. if ( ! is_multisite() && $broken_themes ) {
  521. ?>
  522. <div class="broken-themes">
  523. <h3><?php _e( 'Broken Themes' ); ?></h3>
  524. <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
  525. <?php
  526. $can_resume = current_user_can( 'resume_themes' );
  527. $can_delete = current_user_can( 'delete_themes' );
  528. $can_install = current_user_can( 'install_themes' );
  529. ?>
  530. <table>
  531. <tr>
  532. <th><?php _ex( 'Name', 'theme name' ); ?></th>
  533. <th><?php _e( 'Description' ); ?></th>
  534. <?php if ( $can_resume ) { ?>
  535. <td></td>
  536. <?php } ?>
  537. <?php if ( $can_delete ) { ?>
  538. <td></td>
  539. <?php } ?>
  540. <?php if ( $can_install ) { ?>
  541. <td></td>
  542. <?php } ?>
  543. </tr>
  544. <?php foreach ( $broken_themes as $broken_theme ) : ?>
  545. <tr>
  546. <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
  547. <td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
  548. <?php
  549. if ( $can_resume ) {
  550. if ( 'theme_paused' === $broken_theme->errors()->get_error_code() ) {
  551. $stylesheet = $broken_theme->get_stylesheet();
  552. $resume_url = add_query_arg(
  553. array(
  554. 'action' => 'resume',
  555. 'stylesheet' => urlencode( $stylesheet ),
  556. ),
  557. admin_url( 'themes.php' )
  558. );
  559. $resume_url = wp_nonce_url( $resume_url, 'resume-theme_' . $stylesheet );
  560. ?>
  561. <td><a href="<?php echo esc_url( $resume_url ); ?>" class="button resume-theme"><?php _e( 'Resume' ); ?></a></td>
  562. <?php
  563. } else {
  564. ?>
  565. <td></td>
  566. <?php
  567. }
  568. }
  569. if ( $can_delete ) {
  570. $stylesheet = $broken_theme->get_stylesheet();
  571. $delete_url = add_query_arg(
  572. array(
  573. 'action' => 'delete',
  574. 'stylesheet' => urlencode( $stylesheet ),
  575. ),
  576. admin_url( 'themes.php' )
  577. );
  578. $delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet );
  579. ?>
  580. <td><a href="<?php echo esc_url( $delete_url ); ?>" class="button delete-theme"><?php _e( 'Delete' ); ?></a></td>
  581. <?php
  582. }
  583. if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
  584. $parent_theme_name = $broken_theme->get( 'Template' );
  585. $parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
  586. if ( ! is_wp_error( $parent_theme ) ) {
  587. $install_url = add_query_arg(
  588. array(
  589. 'action' => 'install-theme',
  590. 'theme' => urlencode( $parent_theme_name ),
  591. ),
  592. admin_url( 'update.php' )
  593. );
  594. $install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
  595. ?>
  596. <td><a href="<?php echo esc_url( $install_url ); ?>" class="button install-theme"><?php _e( 'Install Parent Theme' ); ?></a></td>
  597. <?php
  598. }
  599. }
  600. ?>
  601. </tr>
  602. <?php endforeach; ?>
  603. </table>
  604. </div>
  605. <?php
  606. }
  607. ?>
  608. </div><!-- .wrap -->
  609. <?php
  610. /**
  611. * Returns the JavaScript template used to display the auto-update setting for a theme.
  612. *
  613. * @since 5.5.0
  614. *
  615. * @return string The template for displaying the auto-update setting link.
  616. */
  617. function wp_theme_auto_update_setting_template() {
  618. $template = '
  619. <div class="theme-autoupdate">
  620. <# if ( data.autoupdate.supported ) { #>
  621. <# if ( data.autoupdate.forced === false ) { #>
  622. ' . __( 'Auto-updates disabled' ) . '
  623. <# } else if ( data.autoupdate.forced ) { #>
  624. ' . __( 'Auto-updates enabled' ) . '
  625. <# } else if ( data.autoupdate.enabled ) { #>
  626. <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable">
  627. <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span>
  628. </button>
  629. <# } else { #>
  630. <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable">
  631. <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span>
  632. </button>
  633. <# } #>
  634. <# } #>
  635. <# if ( data.hasUpdate ) { #>
  636. <# if ( data.autoupdate.supported && data.autoupdate.enabled ) { #>
  637. <span class="auto-update-time">
  638. <# } else { #>
  639. <span class="auto-update-time hidden">
  640. <# } #>
  641. <br />' . wp_get_auto_update_message() . '</span>
  642. <# } #>
  643. <div class="notice notice-error notice-alt inline hidden"><p></p></div>
  644. </div>
  645. ';
  646. /**
  647. * Filters the JavaScript template used to display the auto-update setting for a theme (in the overlay).
  648. *
  649. * See {@see wp_prepare_themes_for_js()} for the properties of the `data` object.
  650. *
  651. * @since 5.5.0
  652. *
  653. * @param string $template The template for displaying the auto-update setting link.
  654. */
  655. return apply_filters( 'theme_auto_update_setting_template', $template );
  656. }
  657. /*
  658. * The tmpl-theme template is synchronized with PHP above!
  659. */
  660. ?>
  661. <script id="tmpl-theme" type="text/template">
  662. <# if ( data.screenshot[0] ) { #>
  663. <div class="theme-screenshot">
  664. <img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" />
  665. </div>
  666. <# } else { #>
  667. <div class="theme-screenshot blank"></div>
  668. <# } #>
  669. <# if ( data.hasUpdate ) { #>
  670. <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
  671. <div class="update-message notice inline notice-warning notice-alt"><p>
  672. <# if ( data.hasPackage ) { #>
  673. <?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
  674. <# } else { #>
  675. <?php _e( 'New version available.' ); ?>
  676. <# } #>
  677. </p></div>
  678. <# } else { #>
  679. <div class="update-message notice inline notice-error notice-alt"><p>
  680. <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
  681. <?php
  682. printf(
  683. /* translators: %s: Theme name. */
  684. __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
  685. '{{{ data.name }}}'
  686. );
  687. if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
  688. printf(
  689. /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
  690. ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
  691. self_admin_url( 'update-core.php' ),
  692. esc_url( wp_get_update_php_url() )
  693. );
  694. wp_update_php_annotation( '</p><p><em>', '</em>' );
  695. } elseif ( current_user_can( 'update_core' ) ) {
  696. printf(
  697. /* translators: %s: URL to WordPress Updates screen. */
  698. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  699. self_admin_url( 'update-core.php' )
  700. );
  701. } elseif ( current_user_can( 'update_php' ) ) {
  702. printf(
  703. /* translators: %s: URL to Update PHP page. */
  704. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  705. esc_url( wp_get_update_php_url() )
  706. );
  707. wp_update_php_annotation( '</p><p><em>', '</em>' );
  708. }
  709. ?>
  710. <# } else if ( ! data.updateResponse.compatibleWP ) { #>
  711. <?php
  712. printf(
  713. /* translators: %s: Theme name. */
  714. __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
  715. '{{{ data.name }}}'
  716. );
  717. if ( current_user_can( 'update_core' ) ) {
  718. printf(
  719. /* translators: %s: URL to WordPress Updates screen. */
  720. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  721. self_admin_url( 'update-core.php' )
  722. );
  723. }
  724. ?>
  725. <# } else if ( ! data.updateResponse.compatiblePHP ) { #>
  726. <?php
  727. printf(
  728. /* translators: %s: Theme name. */
  729. __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
  730. '{{{ data.name }}}'
  731. );
  732. if ( current_user_can( 'update_php' ) ) {
  733. printf(
  734. /* translators: %s: URL to Update PHP page. */
  735. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  736. esc_url( wp_get_update_php_url() )
  737. );
  738. wp_update_php_annotation( '</p><p><em>', '</em>' );
  739. }
  740. ?>
  741. <# } #>
  742. </p></div>
  743. <# } #>
  744. <# } #>
  745. <# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
  746. <div class="notice notice-error notice-alt"><p>
  747. <# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
  748. <?php
  749. _e( 'This theme does not work with your versions of WordPress and PHP.' );
  750. if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
  751. printf(
  752. /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
  753. ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
  754. self_admin_url( 'update-core.php' ),
  755. esc_url( wp_get_update_php_url() )
  756. );
  757. wp_update_php_annotation( '</p><p><em>', '</em>' );
  758. } elseif ( current_user_can( 'update_core' ) ) {
  759. printf(
  760. /* translators: %s: URL to WordPress Updates screen. */
  761. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  762. self_admin_url( 'update-core.php' )
  763. );
  764. } elseif ( current_user_can( 'update_php' ) ) {
  765. printf(
  766. /* translators: %s: URL to Update PHP page. */
  767. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  768. esc_url( wp_get_update_php_url() )
  769. );
  770. wp_update_php_annotation( '</p><p><em>', '</em>' );
  771. }
  772. ?>
  773. <# } else if ( ! data.compatibleWP ) { #>
  774. <?php
  775. _e( 'This theme does not work with your version of WordPress.' );
  776. if ( current_user_can( 'update_core' ) ) {
  777. printf(
  778. /* translators: %s: URL to WordPress Updates screen. */
  779. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  780. self_admin_url( 'update-core.php' )
  781. );
  782. }
  783. ?>
  784. <# } else if ( ! data.compatiblePHP ) { #>
  785. <?php
  786. _e( 'This theme does not work with your version of PHP.' );
  787. if ( current_user_can( 'update_php' ) ) {
  788. printf(
  789. /* translators: %s: URL to Update PHP page. */
  790. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  791. esc_url( wp_get_update_php_url() )
  792. );
  793. wp_update_php_annotation( '</p><p><em>', '</em>' );
  794. }
  795. ?>
  796. <# } #>
  797. </p></div>
  798. <# } #>
  799. <?php
  800. /* translators: %s: Theme name. */
  801. $details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), '{{ data.name }}' );
  802. ?>
  803. <button type="button" aria-label="<?php echo esc_attr( $details_aria_label ); ?>" class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></button>
  804. <div class="theme-author">
  805. <?php
  806. /* translators: %s: Theme author name. */
  807. printf( __( 'By %s' ), '{{{ data.author }}}' );
  808. ?>
  809. </div>
  810. <div class="theme-id-container">
  811. <# if ( data.active ) { #>
  812. <h2 class="theme-name" id="{{ data.id }}-name">
  813. <span><?php _ex( 'Active:', 'theme' ); ?></span> {{{ data.name }}}
  814. </h2>
  815. <# } else { #>
  816. <h2 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h2>
  817. <# } #>
  818. <div class="theme-actions">
  819. <# if ( data.active ) { #>
  820. <# if ( data.actions.customize ) { #>
  821. <?php
  822. /* translators: %s: Theme name. */
  823. $customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), '{{ data.name }}' );
  824. ?>
  825. <a aria-label="<?php echo esc_attr( $customize_aria_label ); ?>" class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
  826. <# } #>
  827. <# } else { #>
  828. <# if ( data.compatibleWP && data.compatiblePHP ) { #>
  829. <?php
  830. /* translators: %s: Theme name. */
  831. $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
  832. ?>
  833. <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
  834. <# if ( ! data.blockTheme ) { #>
  835. <?php
  836. /* translators: %s: Theme name. */
  837. $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
  838. ?>
  839. <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>
  840. <# } #>
  841. <# } else { #>
  842. <?php
  843. /* translators: %s: Theme name. */
  844. $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
  845. ?>
  846. <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
  847. <# if ( ! data.blockTheme ) { #>
  848. <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
  849. <# } #>
  850. <# } #>
  851. <# } #>
  852. </div>
  853. </div>
  854. </script>
  855. <script id="tmpl-theme-single" type="text/template">
  856. <div class="theme-backdrop"></div>
  857. <div class="theme-wrap wp-clearfix" role="document">
  858. <div class="theme-header">
  859. <button class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
  860. <button class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
  861. <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button>
  862. </div>
  863. <div class="theme-about wp-clearfix">
  864. <div class="theme-screenshots">
  865. <# if ( data.screenshot[0] ) { #>
  866. <div class="screenshot"><img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" /></div>
  867. <# } else { #>
  868. <div class="screenshot blank"></div>
  869. <# } #>
  870. </div>
  871. <div class="theme-info">
  872. <# if ( data.active ) { #>
  873. <span class="current-label"><?php _e( 'Active Theme' ); ?></span>
  874. <# } #>
  875. <h2 class="theme-name">{{{ data.name }}}<span class="theme-version">
  876. <?php
  877. /* translators: %s: Theme version. */
  878. printf( __( 'Version: %s' ), '{{ data.version }}' );
  879. ?>
  880. </span></h2>
  881. <p class="theme-author">
  882. <?php
  883. /* translators: %s: Theme author link. */
  884. printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' );
  885. ?>
  886. </p>
  887. <# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
  888. <div class="notice notice-error notice-alt notice-large"><p>
  889. <# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
  890. <?php
  891. _e( 'This theme does not work with your versions of WordPress and PHP.' );
  892. if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
  893. printf(
  894. /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
  895. ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
  896. self_admin_url( 'update-core.php' ),
  897. esc_url( wp_get_update_php_url() )
  898. );
  899. wp_update_php_annotation( '</p><p><em>', '</em>' );
  900. } elseif ( current_user_can( 'update_core' ) ) {
  901. printf(
  902. /* translators: %s: URL to WordPress Updates screen. */
  903. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  904. self_admin_url( 'update-core.php' )
  905. );
  906. } elseif ( current_user_can( 'update_php' ) ) {
  907. printf(
  908. /* translators: %s: URL to Update PHP page. */
  909. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  910. esc_url( wp_get_update_php_url() )
  911. );
  912. wp_update_php_annotation( '</p><p><em>', '</em>' );
  913. }
  914. ?>
  915. <# } else if ( ! data.compatibleWP ) { #>
  916. <?php
  917. _e( 'This theme does not work with your version of WordPress.' );
  918. if ( current_user_can( 'update_core' ) ) {
  919. printf(
  920. /* translators: %s: URL to WordPress Updates screen. */
  921. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  922. self_admin_url( 'update-core.php' )
  923. );
  924. }
  925. ?>
  926. <# } else if ( ! data.compatiblePHP ) { #>
  927. <?php
  928. _e( 'This theme does not work with your version of PHP.' );
  929. if ( current_user_can( 'update_php' ) ) {
  930. printf(
  931. /* translators: %s: URL to Update PHP page. */
  932. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  933. esc_url( wp_get_update_php_url() )
  934. );
  935. wp_update_php_annotation( '</p><p><em>', '</em>' );
  936. }
  937. ?>
  938. <# } #>
  939. </p></div>
  940. <# } #>
  941. <# if ( data.hasUpdate ) { #>
  942. <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
  943. <div class="notice notice-warning notice-alt notice-large">
  944. <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
  945. {{{ data.update }}}
  946. </div>
  947. <# } else { #>
  948. <div class="notice notice-error notice-alt notice-large">
  949. <h3 class="notice-title"><?php _e( 'Update Incompatible' ); ?></h3>
  950. <p>
  951. <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
  952. <?php
  953. printf(
  954. /* translators: %s: Theme name. */
  955. __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
  956. '{{{ data.name }}}'
  957. );
  958. if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
  959. printf(
  960. /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
  961. ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
  962. self_admin_url( 'update-core.php' ),
  963. esc_url( wp_get_update_php_url() )
  964. );
  965. wp_update_php_annotation( '</p><p><em>', '</em>' );
  966. } elseif ( current_user_can( 'update_core' ) ) {
  967. printf(
  968. /* translators: %s: URL to WordPress Updates screen. */
  969. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  970. self_admin_url( 'update-core.php' )
  971. );
  972. } elseif ( current_user_can( 'update_php' ) ) {
  973. printf(
  974. /* translators: %s: URL to Update PHP page. */
  975. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  976. esc_url( wp_get_update_php_url() )
  977. );
  978. wp_update_php_annotation( '</p><p><em>', '</em>' );
  979. }
  980. ?>
  981. <# } else if ( ! data.updateResponse.compatibleWP ) { #>
  982. <?php
  983. printf(
  984. /* translators: %s: Theme name. */
  985. __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
  986. '{{{ data.name }}}'
  987. );
  988. if ( current_user_can( 'update_core' ) ) {
  989. printf(
  990. /* translators: %s: URL to WordPress Updates screen. */
  991. ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
  992. self_admin_url( 'update-core.php' )
  993. );
  994. }
  995. ?>
  996. <# } else if ( ! data.updateResponse.compatiblePHP ) { #>
  997. <?php
  998. printf(
  999. /* translators: %s: Theme name. */
  1000. __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
  1001. '{{{ data.name }}}'
  1002. );
  1003. if ( current_user_can( 'update_php' ) ) {
  1004. printf(
  1005. /* translators: %s: URL to Update PHP page. */
  1006. ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
  1007. esc_url( wp_get_update_php_url() )
  1008. );
  1009. wp_update_php_annotation( '</p><p><em>', '</em>' );
  1010. }
  1011. ?>
  1012. <# } #>
  1013. </p>
  1014. </div>
  1015. <# } #>
  1016. <# } #>
  1017. <# if ( data.actions.autoupdate ) { #>
  1018. <?php echo wp_theme_auto_update_setting_template(); ?>
  1019. <# } #>
  1020. <p class="theme-description">{{{ data.description }}}</p>
  1021. <# if ( data.parent ) { #>
  1022. <p class="parent-theme">
  1023. <?php
  1024. /* translators: %s: Theme name. */
  1025. printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' );
  1026. ?>
  1027. </p>
  1028. <# } #>
  1029. <# if ( data.tags ) { #>
  1030. <p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{{ data.tags }}}</p>
  1031. <# } #>
  1032. </div>
  1033. </div>
  1034. <div class="theme-actions">
  1035. <div class="active-theme">
  1036. <a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
  1037. <?php echo implode( ' ', $current_theme_actions ); ?>
  1038. </div>
  1039. <div class="inactive-theme">
  1040. <# if ( data.compatibleWP && data.compatiblePHP ) { #>
  1041. <?php
  1042. /* translators: %s: Theme name. */
  1043. $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
  1044. ?>
  1045. <# if ( data.actions.activate ) { #>
  1046. <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
  1047. <# } #>
  1048. <# if ( ! data.blockTheme ) { #>
  1049. <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
  1050. <# } #>
  1051. <# } else { #>
  1052. <?php
  1053. /* translators: %s: Theme name. */
  1054. $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
  1055. ?>
  1056. <# if ( data.actions.activate ) { #>
  1057. <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
  1058. <# } #>
  1059. <# if ( ! data.blockTheme ) { #>
  1060. <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
  1061. <# } #>
  1062. <# } #>
  1063. </div>
  1064. <# if ( ! data.active && data.actions['delete'] ) { #>
  1065. <?php
  1066. /* translators: %s: Theme name. */
  1067. $aria_label = sprintf( _x( 'Delete %s', 'theme' ), '{{ data.name }}' );
  1068. ?>
  1069. <a href="{{{ data.actions['delete'] }}}" class="button delete-theme" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Delete' ); ?></a>
  1070. <# } #>
  1071. </div>
  1072. </div>
  1073. </script>
  1074. <?php
  1075. wp_print_request_filesystem_credentials_modal();
  1076. wp_print_admin_notice_templates();
  1077. wp_print_update_row_templates();
  1078. wp_localize_script(
  1079. 'updates',
  1080. '_wpUpdatesItemCounts',
  1081. array(
  1082. 'totals' => wp_get_update_data(),
  1083. )
  1084. );
  1085. require_once ABSPATH . 'wp-admin/admin-footer.php';