[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-admin/ -> themes.php (source)

   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>' . __( 'An error occurred.' ) . '</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>' . __( 'An error occurred while deleting the theme.' ) . '</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  // Used in the HTML title tag.
 127  $title       = __( 'Themes' );
 128  $parent_file = 'themes.php';
 129  
 130  // Help tab: Overview.
 131  if ( current_user_can( 'switch_themes' ) ) {
 132      $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>' .
 133          '<p>' . __( 'From this screen you can:' ) . '</p>' .
 134          '<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons.' ) . '</li>' .
 135          '<li>' . __( 'Click Customize for the active theme or Live Preview for any other theme to see a live preview.' ) . '</li>' .
 136          '<li>' . __( 'Click on a theme to open the Theme Details dialog and see the theme name, version, author, description, tags, and the Delete link.' ) . '</li>' .
 137          '<li>' . __( 'Use the buttons at the top of the dialog, or <code>alt</code>/<code>option</code> plus the left or right arrow keys on your keyboard, to navigate between themes quickly.' ) . '</li></ul>' .
 138          '<p>' . __( 'The active theme is displayed highlighted as the first theme.' ) . '</p>' .
 139          '<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>';
 140  
 141      get_current_screen()->add_help_tab(
 142          array(
 143              'id'      => 'overview',
 144              'title'   => __( 'Overview' ),
 145              'content' => $help_overview,
 146          )
 147      );
 148  } // End if 'switch_themes'.
 149  
 150  // Help tab: Adding Themes.
 151  if ( current_user_can( 'install_themes' ) ) {
 152      if ( is_multisite() ) {
 153          $help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
 154      } else {
 155          $help_install = '<p>' . sprintf(
 156              /* translators: %s: https://wordpress.org/themes/ */
 157              __( 'If you would like to see more themes to choose from, click on the &#8220;Add Theme&#8221; button and you will be able to browse or search for additional themes from the <a href="%s">WordPress Theme Directory</a>. Themes in the WordPress Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they are free!' ),
 158              __( 'https://wordpress.org/themes/' )
 159          ) . '</p>';
 160      }
 161  
 162      get_current_screen()->add_help_tab(
 163          array(
 164              'id'      => 'adding-themes',
 165              'title'   => __( 'Adding Themes' ),
 166              'content' => $help_install,
 167          )
 168      );
 169  } // End if 'install_themes'.
 170  
 171  // Help tab: Previewing and Customizing.
 172  if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
 173      $help_customize =
 174          '<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>' .
 175          '<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>' .
 176          '<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>';
 177  
 178      get_current_screen()->add_help_tab(
 179          array(
 180              'id'      => 'customize-preview-themes',
 181              'title'   => __( 'Previewing and Customizing' ),
 182              'content' => $help_customize,
 183          )
 184      );
 185  } // End if 'edit_theme_options' && 'customize'.
 186  
 187  $help_sidebar_autoupdates = '';
 188  
 189  // Help tab: Auto-updates.
 190  if ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) {
 191      $help_tab_autoupdates =
 192          '<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>' .
 193          '<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>';
 194  
 195      get_current_screen()->add_help_tab(
 196          array(
 197              'id'      => 'plugins-themes-auto-updates',
 198              'title'   => __( 'Auto-updates' ),
 199              'content' => $help_tab_autoupdates,
 200          )
 201      );
 202  
 203      $help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/documentation/article/plugins-themes-auto-updates/">Documentation on Auto-updates</a>' ) . '</p>';
 204  } // End if 'update_themes' && 'wp_is_auto_update_enabled_for_type'.
 205  
 206  get_current_screen()->set_help_sidebar(
 207      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 208      '<p>' . __( '<a href="https://wordpress.org/documentation/article/work-with-themes/">Documentation on Using Themes</a>' ) . '</p>' .
 209      '<p>' . __( '<a href="https://wordpress.org/documentation/article/appearance-themes-screen/">Documentation on Managing Themes</a>' ) . '</p>' .
 210      $help_sidebar_autoupdates .
 211      '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
 212  );
 213  
 214  if ( current_user_can( 'switch_themes' ) ) {
 215      $themes = wp_prepare_themes_for_js();
 216  } else {
 217      $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
 218  }
 219  
 220  $theme  = ! empty( $_REQUEST['theme'] ) ? sanitize_text_field( $_REQUEST['theme'] ) : '';
 221  $search = ! empty( $_REQUEST['search'] ) ? sanitize_text_field( $_REQUEST['search'] ) : '';
 222  
 223  wp_localize_script(
 224      'theme',
 225      '_wpThemeSettings',
 226      array(
 227          'themes'   => $themes,
 228          'settings' => array(
 229              'canInstall'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ),
 230              'installURI'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
 231              'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
 232              'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
 233          ),
 234          'l10n'     => array(
 235              'addNew'        => __( 'Add Theme' ),
 236              'search'        => __( 'Search installed themes' ),
 237              /* translators: %d: Number of themes. */
 238              'themesFound'   => __( 'Number of Themes found: %d' ),
 239              'noThemesFound' => __( 'No themes found. Try a different search.' ),
 240              /* translators: %s: Theme name. */
 241              'themeViewed'   => __( 'Theme details: %s' ),
 242          ),
 243      )
 244  );
 245  
 246  add_thickbox();
 247  wp_enqueue_script( 'theme' );
 248  wp_enqueue_script( 'updates' );
 249  
 250  require_once  ABSPATH . 'wp-admin/admin-header.php';
 251  
 252  /**
 253   * @global string $self        The current admin page, set in wp-admin/menu-header.php.
 254   * @global string $parent_file The parent menu file, filtered in wp-admin/menu-header.php.
 255   * @global array<string, array<int, array{ 0: string, 1: string, 2: string, 3?: string, 4?: string }>> $submenu The admin submenu items keyed by parent slug, set in wp-admin/menu.php.
 256   */
 257  global $self, $parent_file, $submenu;
 258  ?>
 259  
 260  <div class="wrap">
 261      <h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
 262          <span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
 263      </h1>
 264      <?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
 265          <a href="<?php echo esc_url( admin_url( 'theme-install.php' ) ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html__( 'Add Theme' ); ?></a>
 266      <?php endif; ?>
 267      <hr class="wp-header-end">
 268      <form class="search-form search-themes"><p class="search-box"></p></form>
 269  
 270  <?php
 271  if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
 272      wp_admin_notice(
 273          __( 'The active theme is broken. Reverting to the default theme.' ),
 274          array(
 275              'id'                 => 'message1',
 276              'additional_classes' => array( 'updated' ),
 277              'dismissible'        => true,
 278          )
 279      );
 280  } elseif ( isset( $_GET['activated'] ) ) {
 281      if ( isset( $_GET['previewed'] ) ) {
 282          wp_admin_notice(
 283              __( 'Settings saved and theme activated.' ) . ' <a href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Visit site' ) . '</a>',
 284              array(
 285                  'id'                 => 'message2',
 286                  'additional_classes' => array( 'updated' ),
 287                  'dismissible'        => true,
 288              )
 289          );
 290      } else {
 291          wp_admin_notice(
 292              __( 'New theme activated.' ) . ' <a href="' . esc_url( home_url( '/' ) ) . '">' . __( 'Visit site' ) . '</a>',
 293              array(
 294                  'id'                 => 'message2',
 295                  'additional_classes' => array( 'updated' ),
 296                  'dismissible'        => true,
 297              )
 298          );
 299      }
 300  } elseif ( isset( $_GET['deleted'] ) ) {
 301      wp_admin_notice(
 302          __( 'Theme deleted.' ),
 303          array(
 304              'id'                 => 'message3',
 305              'additional_classes' => array( 'updated' ),
 306              'dismissible'        => true,
 307          )
 308      );
 309  } elseif ( isset( $_GET['delete-active-child'] ) ) {
 310      wp_admin_notice(
 311          __( 'You cannot delete a theme while it has an active child theme.' ),
 312          array(
 313              'id'                 => 'message4',
 314              'additional_classes' => array( 'error' ),
 315          )
 316      );
 317  } elseif ( isset( $_GET['resumed'] ) ) {
 318      wp_admin_notice(
 319          __( 'Theme resumed.' ),
 320          array(
 321              'id'                 => 'message5',
 322              'additional_classes' => array( 'updated' ),
 323              'dismissible'        => true,
 324          )
 325      );
 326  } elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
 327      wp_admin_notice(
 328          __( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ),
 329          array(
 330              'id'                 => 'message6',
 331              'additional_classes' => array( 'error' ),
 332          )
 333      );
 334  } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
 335      wp_admin_notice(
 336          __( 'Theme will be auto-updated.' ),
 337          array(
 338              'id'                 => 'message7',
 339              'additional_classes' => array( 'updated' ),
 340              'dismissible'        => true,
 341          )
 342      );
 343  } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
 344      wp_admin_notice(
 345          __( 'Theme will no longer be auto-updated.' ),
 346          array(
 347              'id'                 => 'message8',
 348              'additional_classes' => array( 'updated' ),
 349              'dismissible'        => true,
 350          )
 351      );
 352  }
 353  
 354  $current_theme = wp_get_theme();
 355  
 356  if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
 357      wp_admin_notice(
 358          '<strong>' . __( 'Error:' ) . '</strong> ' . $current_theme->errors()->get_error_message(),
 359          array(
 360              'additional_classes' => array( 'error' ),
 361          )
 362      );
 363  }
 364  
 365  $current_theme_actions = array();
 366  
 367  if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
 368      $forbidden_paths = array(
 369          'themes.php',
 370          'theme-editor.php',
 371          'site-editor.php',
 372          'edit.php?post_type=wp_navigation',
 373      );
 374  
 375      foreach ( (array) $submenu['themes.php'] as $item ) {
 376          $class = '';
 377  
 378          if ( in_array( $item[2], $forbidden_paths, true ) || str_starts_with( $item[2], 'customize.php' ) ) {
 379              continue;
 380          }
 381  
 382          // 0 = name, 1 = capability, 2 = file.
 383          if ( 0 === strcmp( $self, $item[2] ) && empty( $parent_file )
 384              || $parent_file && $item[2] === $parent_file
 385          ) {
 386              $class = ' current';
 387          }
 388  
 389          if ( ! empty( $submenu[ $item[2] ] ) ) {
 390              $submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index.
 391              $menu_hook           = get_plugin_page_hook( $submenu[ $item[2] ][0][2], $item[2] );
 392  
 393              if ( file_exists( WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}" ) || ! empty( $menu_hook ) ) {
 394                  $current_theme_actions[] = "<a class='button button-compact$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
 395              } else {
 396                  $current_theme_actions[] = "<a class='button button-compact$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
 397              }
 398          } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
 399              $menu_file = $item[2];
 400  
 401              if ( current_user_can( 'customize' ) ) {
 402                  if ( 'custom-header' === $menu_file ) {
 403                      $current_theme_actions[] = "<a class='button button-compact hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
 404                  } elseif ( 'custom-background' === $menu_file ) {
 405                      $current_theme_actions[] = "<a class='button button-compact hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
 406                  }
 407              }
 408  
 409              $pos = strpos( $menu_file, '?' );
 410              if ( false !== $pos ) {
 411                  $menu_file = substr( $menu_file, 0, $pos );
 412              }
 413  
 414              if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
 415                  $current_theme_actions[] = "<a class='button button-compact$class' href='{$item[2]}'>{$item[0]}</a>";
 416              } else {
 417                  $current_theme_actions[] = "<a class='button button-compact$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
 418              }
 419          }
 420      }
 421  }
 422  
 423  $class_name = 'theme-browser';
 424  if ( ! empty( $_GET['search'] ) ) {
 425      $class_name .= ' search-loading';
 426  }
 427  ?>
 428  <div class="<?php echo esc_attr( $class_name ); ?>">
 429      <div class="themes wp-clearfix">
 430  
 431  <?php
 432  /*
 433   * This PHP is synchronized with the tmpl-theme template below!
 434   */
 435  
 436  foreach ( $themes as $theme ) :
 437      $aria_action = $theme['id'] . '-action';
 438      $aria_name   = $theme['id'] . '-name';
 439  
 440      $active_class = '';
 441      if ( $theme['active'] ) {
 442          $active_class = ' active';
 443      }
 444      ?>
 445  <div class="theme<?php echo $active_class; ?>">
 446      <?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
 447          <div class="theme-screenshot">
 448              <img src="<?php echo esc_url( $theme['screenshot'][0] . '?ver=' . $theme['version'] ); ?>" alt="" />
 449          </div>
 450      <?php } else { ?>
 451          <div class="theme-screenshot blank"></div>
 452      <?php } ?>
 453  
 454      <?php if ( $theme['hasUpdate'] ) : ?>
 455          <?php
 456          if ( $theme['updateResponse']['compatibleWP'] && $theme['updateResponse']['compatiblePHP'] ) :
 457              if ( $theme['hasPackage'] ) {
 458                  $new_version_available = __( 'New version available. <button class="button-link" type="button">Update now</button>' );
 459              } else {
 460                  $new_version_available = __( 'New version available.' );
 461              }
 462              wp_admin_notice(
 463                  $new_version_available,
 464                  array(
 465                      'type'               => 'warning',
 466                      'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
 467                  )
 468              );
 469          else :
 470              $theme_update_error = '';
 471              if ( ! $theme['updateResponse']['compatibleWP'] && ! $theme['updateResponse']['compatiblePHP'] ) {
 472                  $theme_update_error .= sprintf(
 473                      /* translators: %s: Theme name. */
 474                      __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
 475                      $theme['name']
 476                  );
 477                  if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 478                      $theme_update_error .= sprintf(
 479                          /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 480                          ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 481                          self_admin_url( 'update-core.php' ),
 482                          esc_url( wp_get_update_php_url() )
 483                      );
 484                      wp_update_php_annotation( '</p><p><em>', '</em>', false );
 485                  } elseif ( current_user_can( 'update_core' ) ) {
 486                      $theme_update_error .= sprintf(
 487                          /* translators: %s: URL to WordPress Updates screen. */
 488                          ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 489                          self_admin_url( 'update-core.php' )
 490                      );
 491                  } elseif ( current_user_can( 'update_php' ) ) {
 492                      $theme_update_error .= sprintf(
 493                          /* translators: %s: URL to Update PHP page. */
 494                          ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 495                          esc_url( wp_get_update_php_url() )
 496                      );
 497                      wp_update_php_annotation( '</p><p><em>', '</em>', false );
 498                  }
 499              } elseif ( ! $theme['updateResponse']['compatibleWP'] ) {
 500                  $theme_update_error .= sprintf(
 501                      /* translators: %s: Theme name. */
 502                      __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
 503                      $theme['name']
 504                  );
 505                  if ( current_user_can( 'update_core' ) ) {
 506                      $theme_update_error .= sprintf(
 507                          /* translators: %s: URL to WordPress Updates screen. */
 508                          ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 509                          self_admin_url( 'update-core.php' )
 510                      );
 511                  }
 512              } elseif ( ! $theme['updateResponse']['compatiblePHP'] ) {
 513                  $theme_update_error .= sprintf(
 514                      /* translators: %s: Theme name. */
 515                      __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
 516                      $theme['name']
 517                  );
 518                  if ( current_user_can( 'update_php' ) ) {
 519                      $theme_update_error .= sprintf(
 520                          /* translators: %s: URL to Update PHP page. */
 521                          ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 522                          esc_url( wp_get_update_php_url() )
 523                      );
 524                      wp_update_php_annotation( '</p><p><em>', '</em>', false );
 525                  }
 526              }
 527              wp_admin_notice(
 528                  $theme_update_error,
 529                  array(
 530                      'type'               => 'error',
 531                      'additional_classes' => array( 'notice-alt', 'inline', 'update-message' ),
 532                  )
 533              );
 534          endif;
 535      endif;
 536  
 537      if ( ! $theme['compatibleWP'] || ! $theme['compatiblePHP'] ) {
 538          $message = '';
 539          if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) {
 540              $message = __( 'This theme does not work with your versions of WordPress and PHP.' );
 541              if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 542                  $message .= sprintf(
 543                      /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 544                      ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 545                      self_admin_url( 'update-core.php' ),
 546                      esc_url( wp_get_update_php_url() )
 547                  );
 548                  $message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
 549              } elseif ( current_user_can( 'update_core' ) ) {
 550                  $message .= sprintf(
 551                      /* translators: %s: URL to WordPress Updates screen. */
 552                      ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 553                      self_admin_url( 'update-core.php' )
 554                  );
 555              } elseif ( current_user_can( 'update_php' ) ) {
 556                  $message .= sprintf(
 557                      /* translators: %s: URL to Update PHP page. */
 558                      ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 559                      esc_url( wp_get_update_php_url() )
 560                  );
 561                  $message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
 562              }
 563          } elseif ( ! $theme['compatibleWP'] ) {
 564              $message .= __( 'This theme does not work with your version of WordPress.' );
 565              if ( current_user_can( 'update_core' ) ) {
 566                  $message .= sprintf(
 567                      /* translators: %s: URL to WordPress Updates screen. */
 568                      ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 569                      self_admin_url( 'update-core.php' )
 570                  );
 571              }
 572          } elseif ( ! $theme['compatiblePHP'] ) {
 573              $message .= __( 'This theme does not work with your version of PHP.' );
 574              if ( current_user_can( 'update_php' ) ) {
 575                  $message .= sprintf(
 576                      /* translators: %s: URL to Update PHP page. */
 577                      ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 578                      esc_url( wp_get_update_php_url() )
 579                  );
 580                  $message .= wp_update_php_annotation( '</p><p><em>', '</em>', false );
 581              }
 582          }
 583  
 584          wp_admin_notice(
 585              $message,
 586              array(
 587                  'type'               => 'error',
 588                  'additional_classes' => array( 'inline', 'notice-alt' ),
 589              )
 590          );
 591      }
 592  
 593      /* translators: %s: Theme name. */
 594      $details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
 595      ?>
 596      <button type="button" class="more-details" id="<?php echo esc_attr( $aria_action ); ?>"
 597          aria-label="<?php echo esc_attr( $details_aria_label ); ?>"
 598      ><?php _e( 'Theme Details' ); ?></button>
 599      <div class="theme-author">
 600          <?php
 601          /* translators: %s: Theme author name. */
 602          printf( __( 'By %s' ), $theme['author'] );
 603          ?>
 604      </div>
 605  
 606      <div class="theme-id-container">
 607          <?php if ( $theme['active'] ) { ?>
 608              <h2 class="theme-name" id="<?php echo esc_attr( $aria_name ); ?>">
 609                  <span><?php _ex( 'Active:', 'theme' ); ?></span> <?php echo $theme['name']; ?>
 610              </h2>
 611          <?php } else { ?>
 612              <h2 class="theme-name" id="<?php echo esc_attr( $aria_name ); ?>"><?php echo $theme['name']; ?></h2>
 613          <?php } ?>
 614  
 615          <div class="theme-actions">
 616          <?php if ( $theme['active'] ) { ?>
 617              <?php
 618              if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
 619                  /* translators: %s: Theme name. */
 620                  $customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), $theme['name'] );
 621                  ?>
 622                  <a class="button button-compact button-primary customize load-customize hide-if-no-customize"
 623                      href="<?php echo esc_url( $theme['actions']['customize'] ); ?>"
 624                      aria-label="<?php echo esc_attr( $customize_aria_label ); ?>"
 625                  ><?php _e( 'Customize' ); ?></a>
 626              <?php } ?>
 627          <?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
 628              <?php
 629              /* translators: %s: Theme name. */
 630              $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
 631              ?>
 632              <a class="button button-compact activate"
 633                  href="<?php echo esc_url( $theme['actions']['activate'] ); ?>"
 634                  aria-label="<?php echo esc_attr( $aria_label ); ?>"
 635              ><?php _e( 'Activate' ); ?></a>
 636  
 637              <?php
 638              // Only classic themes require the "customize" capability.
 639              if ( current_user_can( 'edit_theme_options' ) && ( $theme['blockTheme'] || current_user_can( 'customize' ) ) ) {
 640                  /* translators: %s: Theme name. */
 641                  $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
 642                  ?>
 643                  <a class="button button-compact button-primary load-customize hide-if-no-customize"
 644                      href="<?php echo esc_url( $theme['actions']['customize'] ); ?>"
 645                      aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
 646                  ><?php _e( 'Live Preview' ); ?></a>
 647              <?php } ?>
 648          <?php } else { ?>
 649              <?php
 650              /* translators: %s: Theme name. */
 651              $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
 652              ?>
 653              <a class="button button-compact disabled"
 654                  aria-label="<?php echo esc_attr( $aria_label ); ?>"
 655              ><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
 656  
 657              <?php
 658              if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
 659                  /* translators: %s: Theme name. */
 660                  $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
 661                  ?>
 662                  <a class="button button-compact button-primary hide-if-no-customize disabled"
 663                      aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
 664                  ><?php _e( 'Live Preview' ); ?></a>
 665              <?php } ?>
 666          <?php } ?>
 667  
 668          </div>
 669      </div>
 670  </div>
 671  <?php endforeach; ?>
 672      </div>
 673  </div>
 674  <div class="theme-overlay theme-overlay-initial" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div>
 675  
 676  <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
 677  
 678  <?php
 679  // List broken themes, if any.
 680  $broken_themes = wp_get_themes( array( 'errors' => true ) );
 681  if ( ! is_multisite() && $broken_themes ) {
 682      ?>
 683  
 684  <div class="broken-themes">
 685  <h3><?php _e( 'Broken Themes' ); ?></h3>
 686  <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
 687  
 688      <?php
 689      $can_resume  = current_user_can( 'resume_themes' );
 690      $can_delete  = current_user_can( 'delete_themes' );
 691      $can_install = current_user_can( 'install_themes' );
 692      ?>
 693  <table>
 694      <tr>
 695          <th><?php _ex( 'Name', 'theme name' ); ?></th>
 696          <th><?php _e( 'Description' ); ?></th>
 697          <?php if ( $can_resume ) { ?>
 698              <td></td>
 699          <?php } ?>
 700          <?php if ( $can_delete ) { ?>
 701              <td></td>
 702          <?php } ?>
 703          <?php if ( $can_install ) { ?>
 704              <td></td>
 705          <?php } ?>
 706      </tr>
 707      <?php
 708      foreach ( $broken_themes as $broken_theme ) :
 709          ?>
 710          <tr>
 711              <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?></td>
 712              <td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
 713              <?php
 714              if ( $can_resume ) {
 715                  if ( 'theme_paused' === $broken_theme->errors()->get_error_code() ) {
 716                      $stylesheet = $broken_theme->get_stylesheet();
 717                      $resume_url = add_query_arg(
 718                          array(
 719                              'action'     => 'resume',
 720                              'stylesheet' => urlencode( $stylesheet ),
 721                          ),
 722                          admin_url( 'themes.php' )
 723                      );
 724                      $resume_url = wp_nonce_url( $resume_url, 'resume-theme_' . $stylesheet );
 725                      ?>
 726                      <td><a href="<?php echo esc_url( $resume_url ); ?>" class="button resume-theme"><?php _e( 'Resume' ); ?></a></td>
 727                      <?php
 728                  } else {
 729                      ?>
 730                      <td></td>
 731                      <?php
 732                  }
 733              }
 734  
 735              if ( $can_delete ) {
 736                  $stylesheet = $broken_theme->get_stylesheet();
 737                  $delete_url = add_query_arg(
 738                      array(
 739                          'action'     => 'delete',
 740                          'stylesheet' => urlencode( $stylesheet ),
 741                      ),
 742                      admin_url( 'themes.php' )
 743                  );
 744                  $delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet );
 745                  ?>
 746                  <td><a href="<?php echo esc_url( $delete_url ); ?>" class="button delete-theme"><?php _e( 'Delete' ); ?></a></td>
 747                  <?php
 748              }
 749  
 750              if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
 751                  $parent_theme_name = $broken_theme->get( 'Template' );
 752                  $parent_theme      = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
 753  
 754                  if ( ! is_wp_error( $parent_theme ) ) {
 755                      $install_url = add_query_arg(
 756                          array(
 757                              'action' => 'install-theme',
 758                              'theme'  => urlencode( $parent_theme_name ),
 759                          ),
 760                          admin_url( 'update.php' )
 761                      );
 762                      $install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
 763                      ?>
 764                      <td><a href="<?php echo esc_url( $install_url ); ?>" class="button install-theme"><?php _e( 'Install Parent Theme' ); ?></a></td>
 765                      <?php
 766                  }
 767              }
 768              ?>
 769          </tr>
 770          <?php
 771      endforeach;
 772      ?>
 773  </table>
 774  </div>
 775  
 776      <?php
 777  }
 778  ?>
 779  </div><!-- .wrap -->
 780  
 781  <?php
 782  
 783  /**
 784   * Returns the JavaScript template used to display the auto-update setting for a theme.
 785   *
 786   * @since 5.5.0
 787   *
 788   * @return string The template for displaying the auto-update setting link.
 789   */
 790  function wp_theme_auto_update_setting_template() {
 791      $notice   = wp_get_admin_notice(
 792          '',
 793          array(
 794              'type'               => 'error',
 795              'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
 796          )
 797      );
 798      $template = '
 799          <div class="theme-autoupdate">
 800              <# if ( data.autoupdate.supported ) { #>
 801                  <# if ( data.autoupdate.forced === false ) { #>
 802                      ' . __( 'Auto-updates disabled' ) . '
 803                  <# } else if ( data.autoupdate.forced ) { #>
 804                      ' . __( 'Auto-updates enabled' ) . '
 805                  <# } else if ( data.autoupdate.enabled ) { #>
 806                      <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="disable">
 807                          <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Disable auto-updates' ) . '</span>
 808                      </button>
 809                  <# } else { #>
 810                      <button type="button" class="toggle-auto-update button-link" data-slug="{{ data.id }}" data-wp-action="enable">
 811                          <span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span><span class="label">' . __( 'Enable auto-updates' ) . '</span>
 812                      </button>
 813                  <# } #>
 814              <# } #>
 815              <# if ( data.hasUpdate ) { #>
 816                  <# if ( data.autoupdate.supported && data.autoupdate.enabled ) { #>
 817                      <span class="auto-update-time">
 818                  <# } else { #>
 819                      <span class="auto-update-time hidden">
 820                  <# } #>
 821                  <br />' . wp_get_auto_update_message( 'theme' ) . '</span>
 822              <# } #>
 823              ' . $notice . '
 824          </div>
 825      ';
 826  
 827      /**
 828       * Filters the JavaScript template used to display the auto-update setting for a theme (in the overlay).
 829       *
 830       * See {@see wp_prepare_themes_for_js()} for the properties of the `data` object.
 831       *
 832       * @since 5.5.0
 833       *
 834       * @param string $template The template for displaying the auto-update setting link.
 835       */
 836      return apply_filters( 'theme_auto_update_setting_template', $template );
 837  }
 838  
 839  /*
 840   * The tmpl-theme template is synchronized with PHP above!
 841   */
 842  ?>
 843  <script id="tmpl-theme" type="text/template">
 844      <# if ( data.screenshot[0] ) { #>
 845          <div class="theme-screenshot">
 846              <img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" />
 847          </div>
 848      <# } else { #>
 849          <div class="theme-screenshot blank"></div>
 850      <# } #>
 851  
 852      <# if ( data.hasUpdate ) { #>
 853          <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
 854              <div class="update-message notice inline notice-warning notice-alt"><p>
 855                  <# if ( data.hasPackage ) { #>
 856                      <?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?>
 857                  <# } else { #>
 858                      <?php _e( 'New version available.' ); ?>
 859                  <# } #>
 860              </p></div>
 861          <# } else { #>
 862              <div class="update-message notice inline notice-error notice-alt"><p>
 863                  <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
 864                      <?php
 865                      printf(
 866                          /* translators: %s: Theme name. */
 867                          __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
 868                          '{{{ data.name }}}'
 869                      );
 870                      if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 871                          printf(
 872                              /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 873                              ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 874                              self_admin_url( 'update-core.php' ),
 875                              esc_url( wp_get_update_php_url() )
 876                          );
 877                          wp_update_php_annotation( '</p><p><em>', '</em>' );
 878                      } elseif ( current_user_can( 'update_core' ) ) {
 879                          printf(
 880                              /* translators: %s: URL to WordPress Updates screen. */
 881                              ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 882                              self_admin_url( 'update-core.php' )
 883                          );
 884                      } elseif ( current_user_can( 'update_php' ) ) {
 885                          printf(
 886                              /* translators: %s: URL to Update PHP page. */
 887                              ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 888                              esc_url( wp_get_update_php_url() )
 889                          );
 890                          wp_update_php_annotation( '</p><p><em>', '</em>' );
 891                      }
 892                      ?>
 893                  <# } else if ( ! data.updateResponse.compatibleWP ) { #>
 894                      <?php
 895                      printf(
 896                          /* translators: %s: Theme name. */
 897                          __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
 898                          '{{{ data.name }}}'
 899                      );
 900                      if ( 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                      }
 907                      ?>
 908                  <# } else if ( ! data.updateResponse.compatiblePHP ) { #>
 909                      <?php
 910                      printf(
 911                          /* translators: %s: Theme name. */
 912                          __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
 913                          '{{{ data.name }}}'
 914                      );
 915                      if ( current_user_can( 'update_php' ) ) {
 916                          printf(
 917                              /* translators: %s: URL to Update PHP page. */
 918                              ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 919                              esc_url( wp_get_update_php_url() )
 920                          );
 921                          wp_update_php_annotation( '</p><p><em>', '</em>' );
 922                      }
 923                      ?>
 924                  <# } #>
 925              </p></div>
 926          <# } #>
 927      <# } #>
 928  
 929      <# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
 930          <div class="notice notice-error notice-alt"><p>
 931              <# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
 932                  <?php
 933                  _e( 'This theme does not work with your versions of WordPress and PHP.' );
 934                  if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 935                      printf(
 936                          /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 937                          ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 938                          self_admin_url( 'update-core.php' ),
 939                          esc_url( wp_get_update_php_url() )
 940                      );
 941                      wp_update_php_annotation( '</p><p><em>', '</em>' );
 942                  } elseif ( current_user_can( 'update_core' ) ) {
 943                      printf(
 944                          /* translators: %s: URL to WordPress Updates screen. */
 945                          ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 946                          self_admin_url( 'update-core.php' )
 947                      );
 948                  } elseif ( current_user_can( 'update_php' ) ) {
 949                      printf(
 950                          /* translators: %s: URL to Update PHP page. */
 951                          ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 952                          esc_url( wp_get_update_php_url() )
 953                      );
 954                      wp_update_php_annotation( '</p><p><em>', '</em>' );
 955                  }
 956                  ?>
 957              <# } else if ( ! data.compatibleWP ) { #>
 958                  <?php
 959                  _e( 'This theme does not work with your version of WordPress.' );
 960                  if ( current_user_can( 'update_core' ) ) {
 961                      printf(
 962                          /* translators: %s: URL to WordPress Updates screen. */
 963                          ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 964                          self_admin_url( 'update-core.php' )
 965                      );
 966                  }
 967                  ?>
 968              <# } else if ( ! data.compatiblePHP ) { #>
 969                  <?php
 970                  _e( 'This theme does not work with your version of PHP.' );
 971                  if ( current_user_can( 'update_php' ) ) {
 972                      printf(
 973                          /* translators: %s: URL to Update PHP page. */
 974                          ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 975                          esc_url( wp_get_update_php_url() )
 976                      );
 977                      wp_update_php_annotation( '</p><p><em>', '</em>' );
 978                  }
 979                  ?>
 980              <# } #>
 981          </p></div>
 982      <# } #>
 983  
 984      <?php
 985      /* translators: %s: Theme name. */
 986      $details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), '{{ data.name }}' );
 987      ?>
 988      <button type="button" class="more-details" id="{{ data.id }}-action"
 989          aria-label="<?php echo esc_attr( $details_aria_label ); ?>"
 990      ><?php _e( 'Theme Details' ); ?></button>
 991      <div class="theme-author">
 992          <?php
 993          /* translators: %s: Theme author name. */
 994          printf( __( 'By %s' ), '{{{ data.author }}}' );
 995          ?>
 996      </div>
 997  
 998      <div class="theme-id-container">
 999          <# if ( data.active ) { #>
1000              <h2 class="theme-name" id="{{ data.id }}-name">
1001                  <span><?php _ex( 'Active:', 'theme' ); ?></span> {{{ data.name }}}
1002              </h2>
1003          <# } else { #>
1004              <h2 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h2>
1005          <# } #>
1006  
1007          <div class="theme-actions">
1008              <# if ( data.active ) { #>
1009                  <# if ( data.actions.customize ) { #>
1010                      <?php
1011                      /* translators: %s: Theme name. */
1012                      $customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), '{{ data.name }}' );
1013                      ?>
1014                      <a class="button button-compact button-primary customize load-customize hide-if-no-customize"
1015                          href="{{{ data.actions.customize }}}"
1016                          aria-label="<?php echo esc_attr( $customize_aria_label ); ?>"
1017                      ><?php _e( 'Customize' ); ?></a>
1018                  <# } #>
1019              <# } else { #>
1020                  <# if ( data.compatibleWP && data.compatiblePHP ) { #>
1021                      <?php
1022                      /* translators: %s: Theme name. */
1023                      $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
1024                      ?>
1025                      <a class="button button-compact activate"
1026                          href="{{{ data.actions.activate }}}"
1027                          aria-label="<?php echo esc_attr( $aria_label ); ?>"
1028                      ><?php _e( 'Activate' ); ?></a>
1029  
1030                      <?php
1031                      /* translators: %s: Theme name. */
1032                      $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
1033                      ?>
1034                      <a class="button button-compact button-primary load-customize hide-if-no-customize"
1035                          href="{{{ data.actions.customize }}}"
1036                          aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1037                      ><?php _e( 'Live Preview' ); ?></a>
1038                  <# } else { #>
1039                      <?php
1040                      /* translators: %s: Theme name. */
1041                      $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
1042                      ?>
1043                      <a class="button button-compact disabled"
1044                          aria-label="<?php echo esc_attr( $aria_label ); ?>"
1045                      ><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
1046  
1047                      <?php
1048                      /* translators: %s: Theme name. */
1049                      $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
1050                      ?>
1051                      <a class="button button-compact button-primary hide-if-no-customize disabled"
1052                          aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1053                      ><?php _e( 'Live Preview' ); ?></a>
1054                  <# } #>
1055              <# } #>
1056          </div>
1057      </div>
1058  </script>
1059  
1060  <script id="tmpl-theme-single" type="text/template">
1061      <div class="theme-backdrop"></div>
1062      <div class="theme-wrap wp-clearfix" role="document">
1063          <div class="theme-header">
1064              <button class="left dashicons dashicons-no"><span class="screen-reader-text">
1065                  <?php
1066                  /* translators: Hidden accessibility text. */
1067                  _ex( 'Previous', 'theme' );
1068                  ?>
1069              </span></button>
1070              <button class="right dashicons dashicons-no"><span class="screen-reader-text">
1071                  <?php
1072                  /* translators: Hidden accessibility text. */
1073                  _ex( 'Next', 'theme' );
1074                  ?>
1075              </span></button>
1076              <button class="close dashicons dashicons-no"><span class="screen-reader-text">
1077                  <?php
1078                  /* translators: Hidden accessibility text. */
1079                  _e( 'Close' );
1080                  ?>
1081              </span></button>
1082          </div>
1083          <div class="theme-about wp-clearfix">
1084              <div class="theme-screenshots">
1085              <# if ( data.screenshot[0] ) { #>
1086                  <div class="screenshot"><img src="{{ data.screenshot[0] }}?ver={{ data.version }}" alt="" /></div>
1087              <# } else { #>
1088                  <div class="screenshot blank"></div>
1089              <# } #>
1090              </div>
1091  
1092              <div class="theme-info">
1093                  <# if ( data.active ) { #>
1094                      <span class="current-label"><?php _e( 'Active Theme' ); ?></span>
1095                  <# } #>
1096                  <h2 class="theme-name">{{{ data.name }}}<span class="theme-version">
1097                      <?php
1098                      /* translators: %s: Theme version. */
1099                      printf( __( 'Version: %s' ), '{{ data.version }}' );
1100                      ?>
1101                  </span></h2>
1102                  <p class="theme-author">
1103                      <?php
1104                      /* translators: %s: Theme author link. */
1105                      printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' );
1106                      ?>
1107                  </p>
1108  
1109                  <# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #>
1110                      <div class="notice notice-error notice-alt notice-large"><p>
1111                          <# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #>
1112                              <?php
1113                              _e( 'This theme does not work with your versions of WordPress and PHP.' );
1114                              if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
1115                                  printf(
1116                                      /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
1117                                      ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
1118                                      self_admin_url( 'update-core.php' ),
1119                                      esc_url( wp_get_update_php_url() )
1120                                  );
1121                                  wp_update_php_annotation( '</p><p><em>', '</em>' );
1122                              } elseif ( current_user_can( 'update_core' ) ) {
1123                                  printf(
1124                                      /* translators: %s: URL to WordPress Updates screen. */
1125                                      ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
1126                                      self_admin_url( 'update-core.php' )
1127                                  );
1128                              } elseif ( current_user_can( 'update_php' ) ) {
1129                                  printf(
1130                                      /* translators: %s: URL to Update PHP page. */
1131                                      ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
1132                                      esc_url( wp_get_update_php_url() )
1133                                  );
1134                                  wp_update_php_annotation( '</p><p><em>', '</em>' );
1135                              }
1136                              ?>
1137                          <# } else if ( ! data.compatibleWP ) { #>
1138                              <?php
1139                              _e( 'This theme does not work with your version of WordPress.' );
1140                              if ( current_user_can( 'update_core' ) ) {
1141                                  printf(
1142                                      /* translators: %s: URL to WordPress Updates screen. */
1143                                      ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
1144                                      self_admin_url( 'update-core.php' )
1145                                  );
1146                              }
1147                              ?>
1148                          <# } else if ( ! data.compatiblePHP ) { #>
1149                              <?php
1150                              _e( 'This theme does not work with your version of PHP.' );
1151                              if ( current_user_can( 'update_php' ) ) {
1152                                  printf(
1153                                      /* translators: %s: URL to Update PHP page. */
1154                                      ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
1155                                      esc_url( wp_get_update_php_url() )
1156                                  );
1157                                  wp_update_php_annotation( '</p><p><em>', '</em>' );
1158                              }
1159                              ?>
1160                          <# } #>
1161                      </p></div>
1162                  <# } #>
1163  
1164                  <# if ( data.hasUpdate ) { #>
1165                      <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #>
1166                          <div class="notice notice-warning notice-alt notice-large">
1167                              <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
1168                              {{{ data.update }}}
1169                          </div>
1170                      <# } else { #>
1171                          <div class="notice notice-error notice-alt notice-large">
1172                              <h3 class="notice-title"><?php _e( 'Update Incompatible' ); ?></h3>
1173                              <p>
1174                                  <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #>
1175                                      <?php
1176                                      printf(
1177                                          /* translators: %s: Theme name. */
1178                                          __( 'There is a new version of %s available, but it does not work with your versions of WordPress and PHP.' ),
1179                                          '{{{ data.name }}}'
1180                                      );
1181                                      if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
1182                                          printf(
1183                                              /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
1184                                              ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
1185                                              self_admin_url( 'update-core.php' ),
1186                                              esc_url( wp_get_update_php_url() )
1187                                          );
1188                                          wp_update_php_annotation( '</p><p><em>', '</em>' );
1189                                      } elseif ( current_user_can( 'update_core' ) ) {
1190                                          printf(
1191                                              /* translators: %s: URL to WordPress Updates screen. */
1192                                              ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
1193                                              self_admin_url( 'update-core.php' )
1194                                          );
1195                                      } elseif ( current_user_can( 'update_php' ) ) {
1196                                          printf(
1197                                              /* translators: %s: URL to Update PHP page. */
1198                                              ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
1199                                              esc_url( wp_get_update_php_url() )
1200                                          );
1201                                          wp_update_php_annotation( '</p><p><em>', '</em>' );
1202                                      }
1203                                      ?>
1204                                  <# } else if ( ! data.updateResponse.compatibleWP ) { #>
1205                                      <?php
1206                                      printf(
1207                                          /* translators: %s: Theme name. */
1208                                          __( 'There is a new version of %s available, but it does not work with your version of WordPress.' ),
1209                                          '{{{ data.name }}}'
1210                                      );
1211                                      if ( current_user_can( 'update_core' ) ) {
1212                                          printf(
1213                                              /* translators: %s: URL to WordPress Updates screen. */
1214                                              ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
1215                                              self_admin_url( 'update-core.php' )
1216                                          );
1217                                      }
1218                                      ?>
1219                                  <# } else if ( ! data.updateResponse.compatiblePHP ) { #>
1220                                      <?php
1221                                      printf(
1222                                          /* translators: %s: Theme name. */
1223                                          __( 'There is a new version of %s available, but it does not work with your version of PHP.' ),
1224                                          '{{{ data.name }}}'
1225                                      );
1226                                      if ( current_user_can( 'update_php' ) ) {
1227                                          printf(
1228                                              /* translators: %s: URL to Update PHP page. */
1229                                              ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
1230                                              esc_url( wp_get_update_php_url() )
1231                                          );
1232                                          wp_update_php_annotation( '</p><p><em>', '</em>' );
1233                                      }
1234                                      ?>
1235                                  <# } #>
1236                              </p>
1237                          </div>
1238                      <# } #>
1239                  <# } #>
1240  
1241                  <# if ( data.actions.autoupdate ) { #>
1242                      <?php echo wp_theme_auto_update_setting_template(); ?>
1243                  <# } #>
1244  
1245                  <p class="theme-description">{{{ data.description }}}</p>
1246  
1247                  <# if ( data.parent ) { #>
1248                      <p class="parent-theme">
1249                          <?php
1250                          /* translators: %s: Theme name. */
1251                          printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' );
1252                          ?>
1253                      </p>
1254                  <# } #>
1255  
1256                  <# if ( data.tags ) { #>
1257                      <p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{{ data.tags }}}</p>
1258                  <# } #>
1259              </div>
1260          </div>
1261  
1262          <div class="theme-actions">
1263              <div class="active-theme">
1264                  <a class="button button-compact button-primary customize load-customize hide-if-no-customize"
1265                      href="{{{ data.actions.customize }}}"
1266                  ><?php _e( 'Customize' ); ?></a>
1267                  <?php echo implode( ' ', $current_theme_actions ); ?>
1268              </div>
1269  
1270              <div class="inactive-theme">
1271                  <# if ( data.compatibleWP && data.compatiblePHP ) { #>
1272                      <?php
1273                      /* translators: %s: Theme name. */
1274                      $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
1275                      ?>
1276                      <a class="button button-compact button-primary load-customize hide-if-no-customize"
1277                          href="{{{ data.actions.customize }}}"
1278                          aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1279                      ><?php _e( 'Live Preview' ); ?></a>
1280  
1281                      <# if ( data.actions.activate ) { #>
1282                          <?php
1283                          /* translators: %s: Theme name. */
1284                          $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
1285                          ?>
1286                          <a class="button button-compact activate"
1287                              href="{{{ data.actions.activate }}}"
1288                              aria-label="<?php echo esc_attr( $aria_label ); ?>"
1289                          ><?php _e( 'Activate' ); ?></a>
1290                      <# } #>
1291                  <# } else { #>
1292                      <?php
1293                      /* translators: %s: Theme name. */
1294                      $live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
1295                      ?>
1296                      <a class="button button-compact button-primary hide-if-no-customize disabled"
1297                          aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>"
1298                      ><?php _e( 'Live Preview' ); ?></a>
1299  
1300                      <# if ( data.actions.activate ) { #>
1301                          <?php
1302                          /* translators: %s: Theme name. */
1303                          $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
1304                          ?>
1305                          <a class="button button-compact disabled"
1306                              aria-label="<?php echo esc_attr( $aria_label ); ?>"
1307                          ><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
1308                      <# } #>
1309                  <# } #>
1310              </div>
1311  
1312              <# if ( ! data.active && data.actions['delete'] ) { #>
1313                  <?php
1314                  /* translators: %s: Theme name. */
1315                  $aria_label = sprintf( _x( 'Delete %s', 'theme' ), '{{ data.name }}' );
1316                  ?>
1317                  <a class="button button-compact delete-theme"
1318                      href="{{{ data.actions['delete'] }}}"
1319                      aria-label="<?php echo esc_attr( $aria_label ); ?>"
1320                  ><?php _e( 'Delete' ); ?></a>
1321              <# } #>
1322          </div>
1323      </div>
1324  </script>
1325  
1326  <?php
1327  wp_print_request_filesystem_credentials_modal();
1328  wp_print_admin_notice_templates();
1329  wp_print_update_row_templates();
1330  
1331  wp_localize_script(
1332      'updates',
1333      '_wpUpdatesItemCounts',
1334      array(
1335          'totals' => wp_get_update_data(),
1336      )
1337  );
1338  
1339  require_once  ABSPATH . 'wp-admin/admin-footer.php';


Generated : Thu Nov 12 08:20:02 2026 Cross-referenced by PHPXref