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


Generated: Thu Oct 21 01:00:03 2021 Cross-referenced by PHPXref 0.7.1