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