[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

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


Generated : Thu May 9 08:20:02 2024 Cross-referenced by PHPXref