[ Index ]

PHP Cross Reference of WordPress

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


Generated: Tue Dec 3 01:00:02 2024 Cross-referenced by PHPXref 0.7.1