[ 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  $title       = __( 'Manage Themes' );
 127  $parent_file = 'themes.php';
 128  
 129  // Help tab: Overview.
 130  if ( current_user_can( 'switch_themes' ) ) {
 131      $help_overview = '<p>' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) included with your WordPress installation, themes are designed and developed by third parties.' ) . '</p>' .
 132          '<p>' . __( 'From this screen you can:' ) . '</p>' .
 133          '<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' .
 134          '<li>' . __( 'Click on the theme to see the theme name, version, author, description, tags, and the Delete link' ) . '</li>' .
 135          '<li>' . __( 'Click Customize for the current theme or Live Preview for any other theme to see a live preview' ) . '</li></ul>' .
 136          '<p>' . __( 'The current theme is displayed highlighted as the first theme.' ) . '</p>' .
 137          '<p>' . __( 'The search for installed themes will search for terms in their name, description, author, or tag.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>';
 138  
 139      get_current_screen()->add_help_tab(
 140          array(
 141              'id'      => 'overview',
 142              'title'   => __( 'Overview' ),
 143              'content' => $help_overview,
 144          )
 145      );
 146  } // End if 'switch_themes'.
 147  
 148  // Help tab: Adding Themes.
 149  if ( current_user_can( 'install_themes' ) ) {
 150      if ( is_multisite() ) {
 151          $help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
 152      } else {
 153          $help_install = '<p>' . sprintf(
 154              /* translators: %s: https://wordpress.org/themes/ */
 155              __( 'If you would like to see more themes to choose from, click on the &#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!' ),
 156              __( 'https://wordpress.org/themes/' )
 157          ) . '</p>';
 158      }
 159  
 160      get_current_screen()->add_help_tab(
 161          array(
 162              'id'      => 'adding-themes',
 163              'title'   => __( 'Adding Themes' ),
 164              'content' => $help_install,
 165          )
 166      );
 167  } // End if 'install_themes'.
 168  
 169  // Help tab: Previewing and Customizing.
 170  if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
 171      $help_customize =
 172          '<p>' . __( 'Tap or hover on any theme then click the Live Preview button to see a live preview of that theme and change theme options in a separate, full-screen view. You can also find a Live Preview button at the bottom of the theme details screen. Any installed theme can be previewed and customized in this way.' ) . '</p>' .
 173          '<p>' . __( 'The theme being previewed is fully interactive &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 Publish &amp; Activate button above the menu.' ) . '</p>' .
 174          '<p>' . __( 'When previewing on smaller monitors, you can use the collapse icon at the bottom of the left-hand pane. This will hide the pane, giving you more room to preview your site in the new theme. To bring the pane back, click on the collapse icon again.' ) . '</p>';
 175  
 176      get_current_screen()->add_help_tab(
 177          array(
 178              'id'      => 'customize-preview-themes',
 179              'title'   => __( 'Previewing and Customizing' ),
 180              'content' => $help_customize,
 181          )
 182      );
 183  } // End if 'edit_theme_options' && 'customize'.
 184  
 185  get_current_screen()->set_help_sidebar(
 186      '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
 187      '<p>' . __( '<a href="https://wordpress.org/support/article/using-themes/">Documentation on Using Themes</a>' ) . '</p>' .
 188      '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
 189  );
 190  
 191  if ( current_user_can( 'switch_themes' ) ) {
 192      $themes = wp_prepare_themes_for_js();
 193  } else {
 194      $themes = wp_prepare_themes_for_js( array( wp_get_theme() ) );
 195  }
 196  wp_reset_vars( array( 'theme', 'search' ) );
 197  
 198  wp_localize_script(
 199      'theme',
 200      '_wpThemeSettings',
 201      array(
 202          'themes'   => $themes,
 203          'settings' => array(
 204              'canInstall'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ),
 205              'installURI'    => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
 206              'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
 207              'adminUrl'      => parse_url( admin_url(), PHP_URL_PATH ),
 208          ),
 209          'l10n'     => array(
 210              'addNew'            => __( 'Add New Theme' ),
 211              'search'            => __( 'Search Installed Themes' ),
 212              'searchPlaceholder' => __( 'Search installed themes...' ), // Placeholder (no ellipsis).
 213              /* translators: %d: Number of themes. */
 214              'themesFound'       => __( 'Number of Themes found: %d' ),
 215              'noThemesFound'     => __( 'No themes found. Try a different search.' ),
 216          ),
 217      )
 218  );
 219  
 220  add_thickbox();
 221  wp_enqueue_script( 'theme' );
 222  wp_enqueue_script( 'updates' );
 223  
 224  require_once  ABSPATH . 'wp-admin/admin-header.php';
 225  ?>
 226  
 227  <div class="wrap">
 228      <h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
 229          <span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
 230      </h1>
 231  
 232      <?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
 233          <a href="<?php echo admin_url( 'theme-install.php' ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a>
 234      <?php endif; ?>
 235  
 236      <form class="search-form"></form>
 237  
 238      <hr class="wp-header-end">
 239  <?php
 240  if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
 241      ?>
 242      <div id="message1" class="updated notice is-dismissible"><p><?php _e( 'The active theme is broken. Reverting to the default theme.' ); ?></p></div>
 243      <?php
 244  } elseif ( isset( $_GET['activated'] ) ) {
 245      if ( isset( $_GET['previewed'] ) ) {
 246          ?>
 247          <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>
 248          <?php
 249      } else {
 250          ?>
 251          <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>
 252          <?php
 253      }
 254  } elseif ( isset( $_GET['deleted'] ) ) {
 255      ?>
 256      <div id="message3" class="updated notice is-dismissible"><p><?php _e( 'Theme deleted.' ); ?></p></div>
 257      <?php
 258  } elseif ( isset( $_GET['delete-active-child'] ) ) {
 259      ?>
 260      <div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div>
 261      <?php
 262  } elseif ( isset( $_GET['resumed'] ) ) {
 263      ?>
 264      <div id="message5" class="updated notice is-dismissible"><p><?php _e( 'Theme resumed.' ); ?></p></div>
 265      <?php
 266  } elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
 267      ?>
 268      <div id="message6" class="error"><p><?php _e( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ); ?></p></div>
 269      <?php
 270  } elseif ( isset( $_GET['enabled-auto-update'] ) ) {
 271      ?>
 272      <div id="message7" class="updated notice is-dismissible"><p><?php _e( 'Theme will be auto-updated.' ); ?></p></div>
 273      <?php
 274  } elseif ( isset( $_GET['disabled-auto-update'] ) ) {
 275      ?>
 276      <div id="message8" class="updated notice is-dismissible"><p><?php _e( 'Theme will no longer be auto-updated.' ); ?></p></div>
 277      <?php
 278  }
 279  
 280  $ct = wp_get_theme();
 281  
 282  if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
 283      echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $ct->errors()->get_error_message() . '</p></div>';
 284  }
 285  
 286  /*
 287  // Certain error codes are less fatal than others. We can still display theme information in most cases.
 288  if ( ! $ct->errors() || ( 1 === count( $ct->errors()->get_error_codes() )
 289      && in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
 290  */
 291  
 292      // Pretend you didn't see this.
 293      $current_theme_actions = array();
 294  if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
 295      foreach ( (array) $submenu['themes.php'] as $item ) {
 296          $class = '';
 297          if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) {
 298              continue;
 299          }
 300          // 0 = name, 1 = capability, 2 = file.
 301          if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) {
 302              $class = ' current';
 303          }
 304          if ( ! empty( $submenu[ $item[2] ] ) ) {
 305              $submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index.
 306              $menu_hook           = get_plugin_page_hook( $submenu[ $item[2] ][0][2], $item[2] );
 307              if ( file_exists( WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}" ) || ! empty( $menu_hook ) ) {
 308                  $current_theme_actions[] = "<a class='button$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
 309              } else {
 310                  $current_theme_actions[] = "<a class='button$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
 311              }
 312          } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
 313              $menu_file = $item[2];
 314  
 315              if ( current_user_can( 'customize' ) ) {
 316                  if ( 'custom-header' === $menu_file ) {
 317                      $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
 318                  } elseif ( 'custom-background' === $menu_file ) {
 319                      $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
 320                  }
 321              }
 322  
 323              $pos = strpos( $menu_file, '?' );
 324              if ( false !== $pos ) {
 325                  $menu_file = substr( $menu_file, 0, $pos );
 326              }
 327  
 328              if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
 329                  $current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>";
 330              } else {
 331                  $current_theme_actions[] = "<a class='button$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
 332              }
 333          }
 334      }
 335  }
 336  
 337  ?>
 338  
 339  <?php
 340  $class_name = 'theme-browser';
 341  if ( ! empty( $_GET['search'] ) ) {
 342      $class_name .= ' search-loading';
 343  }
 344  ?>
 345  <div class="<?php echo esc_attr( $class_name ); ?>">
 346      <div class="themes wp-clearfix">
 347  
 348  <?php
 349  /*
 350   * This PHP is synchronized with the tmpl-theme template below!
 351   */
 352  
 353  foreach ( $themes as $theme ) :
 354      $aria_action = esc_attr( $theme['id'] . '-action' );
 355      $aria_name   = esc_attr( $theme['id'] . '-name' );
 356  
 357      $active_class = '';
 358      if ( $theme['active'] ) {
 359          $active_class = ' active';
 360      }
 361      ?>
 362  <div class="theme<?php echo $active_class; ?>" tabindex="0" aria-describedby="<?php echo $aria_action . ' ' . $aria_name; ?>">
 363      <?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
 364          <div class="theme-screenshot">
 365              <img src="<?php echo $theme['screenshot'][0]; ?>" alt="" />
 366          </div>
 367      <?php } else { ?>
 368          <div class="theme-screenshot blank"></div>
 369      <?php } ?>
 370  
 371      <?php if ( $theme['hasUpdate'] ) : ?>
 372          <div class="update-message notice inline notice-warning notice-alt">
 373          <?php if ( $theme['hasPackage'] ) : ?>
 374              <p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p>
 375          <?php else : ?>
 376              <p><?php _e( 'New version available.' ); ?></p>
 377          <?php endif; ?>
 378          </div>
 379      <?php endif; ?>
 380  
 381      <span class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></span>
 382      <div class="theme-author">
 383          <?php
 384          /* translators: %s: Theme author name. */
 385          printf( __( 'By %s' ), $theme['author'] );
 386          ?>
 387      </div>
 388  
 389      <div class="theme-id-container">
 390          <?php if ( $theme['active'] ) { ?>
 391              <h2 class="theme-name" id="<?php echo $aria_name; ?>">
 392                  <span><?php _ex( 'Active:', 'theme' ); ?></span> <?php echo $theme['name']; ?>
 393              </h2>
 394          <?php } else { ?>
 395              <h2 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h2>
 396          <?php } ?>
 397  
 398          <div class="theme-actions">
 399          <?php if ( $theme['active'] ) { ?>
 400              <?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
 401                  <a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
 402              <?php } ?>
 403          <?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
 404              <?php
 405              /* translators: %s: Theme name. */
 406              $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
 407              ?>
 408              <a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
 409              <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
 410                  <a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
 411              <?php } ?>
 412          <?php } else { ?>
 413              <?php
 414              /* translators: %s: Theme name. */
 415              $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
 416              ?>
 417              <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
 418              <?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
 419                  <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
 420              <?php } ?>
 421          <?php } ?>
 422  
 423          </div>
 424      </div>
 425  </div>
 426  <?php endforeach; ?>
 427      </div>
 428  </div>
 429  <div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div>
 430  
 431  <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
 432  
 433  <?php
 434  // List broken themes, if any.
 435  $broken_themes = wp_get_themes( array( 'errors' => true ) );
 436  if ( ! is_multisite() && $broken_themes ) {
 437      ?>
 438  
 439  <div class="broken-themes">
 440  <h3><?php _e( 'Broken Themes' ); ?></h3>
 441  <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
 442  
 443      <?php
 444      $can_resume  = current_user_can( 'resume_themes' );
 445      $can_delete  = current_user_can( 'delete_themes' );
 446      $can_install = current_user_can( 'install_themes' );
 447      ?>
 448  <table>
 449      <tr>
 450          <th><?php _ex( 'Name', 'theme name' ); ?></th>
 451          <th><?php _e( 'Description' ); ?></th>
 452          <?php if ( $can_resume ) { ?>
 453              <td></td>
 454          <?php } ?>
 455          <?php if ( $can_delete ) { ?>
 456              <td></td>
 457          <?php } ?>
 458          <?php if ( $can_install ) { ?>
 459              <td></td>
 460          <?php } ?>
 461      </tr>
 462      <?php foreach ( $broken_themes as $broken_theme ) : ?>
 463          <tr>
 464              <td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
 465              <td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
 466              <?php
 467              if ( $can_resume ) {
 468                  if ( 'theme_paused' === $broken_theme->errors()->get_error_code() ) {
 469                      $stylesheet = $broken_theme->get_stylesheet();
 470                      $resume_url = add_query_arg(
 471                          array(
 472                              'action'     => 'resume',
 473                              'stylesheet' => urlencode( $stylesheet ),
 474                          ),
 475                          admin_url( 'themes.php' )
 476                      );
 477                      $resume_url = wp_nonce_url( $resume_url, 'resume-theme_' . $stylesheet );
 478                      ?>
 479                      <td><a href="<?php echo esc_url( $resume_url ); ?>" class="button resume-theme"><?php _e( 'Resume' ); ?></a></td>
 480                      <?php
 481                  } else {
 482                      ?>
 483                      <td></td>
 484                      <?php
 485                  }
 486              }
 487  
 488              if ( $can_delete ) {
 489                  $stylesheet = $broken_theme->get_stylesheet();
 490                  $delete_url = add_query_arg(
 491                      array(
 492                          'action'     => 'delete',
 493                          'stylesheet' => urlencode( $stylesheet ),
 494                      ),
 495                      admin_url( 'themes.php' )
 496                  );
 497                  $delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet );
 498                  ?>
 499                  <td><a href="<?php echo esc_url( $delete_url ); ?>" class="button delete-theme"><?php _e( 'Delete' ); ?></a></td>
 500                  <?php
 501              }
 502  
 503              if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
 504                  $parent_theme_name = $broken_theme->get( 'Template' );
 505                  $parent_theme      = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
 506  
 507                  if ( ! is_wp_error( $parent_theme ) ) {
 508                      $install_url = add_query_arg(
 509                          array(
 510                              'action' => 'install-theme',
 511                              'theme'  => urlencode( $parent_theme_name ),
 512                          ),
 513                          admin_url( 'update.php' )
 514                      );
 515                      $install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
 516                      ?>
 517                      <td><a href="<?php echo esc_url( $install_url ); ?>" class="button install-theme"><?php _e( 'Install Parent Theme' ); ?></a></td>
 518                      <?php
 519                  }
 520              }
 521              ?>
 522          </tr>
 523      <?php endforeach; ?>
 524  </table>
 525  </div>
 526  
 527      <?php
 528  }
 529  ?>
 530  </div><!-- .wrap -->
 531  
 532  <?php
 533  /*
 534   * The tmpl-theme template is synchronized with PHP above!
 535   */
 536  ?>
 537  <script id="tmpl-theme" type="text/template">
 538      <# if ( data.screenshot[0] ) { #>
 539          <div class="theme-screenshot">
 540              <img src="{{ data.screenshot[0] }}" alt="" />
 541          </div>
 542      <# } else { #>
 543          <div class="theme-screenshot blank"></div>
 544      <# } #>
 545  
 546      <# if ( data.hasUpdate ) { #>
 547          <# if ( data.hasPackage ) { #>
 548              <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div>
 549          <# } else { #>
 550              <div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div>
 551          <# } #>
 552      <# } #>
 553  
 554      <span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span>
 555      <div class="theme-author">
 556          <?php
 557          /* translators: %s: Theme author name. */
 558          printf( __( 'By %s' ), '{{{ data.author }}}' );
 559          ?>
 560      </div>
 561  
 562      <div class="theme-id-container">
 563          <# if ( data.active ) { #>
 564              <h2 class="theme-name" id="{{ data.id }}-name">
 565                  <span><?php _ex( 'Active:', 'theme' ); ?></span> {{{ data.name }}}
 566              </h2>
 567          <# } else { #>
 568              <h2 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h2>
 569          <# } #>
 570  
 571          <div class="theme-actions">
 572              <# if ( data.active ) { #>
 573                  <# if ( data.actions.customize ) { #>
 574                      <a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
 575                  <# } #>
 576              <# } else { #>
 577                  <# if ( data.compatibleWP && data.compatiblePHP ) { #>
 578                      <?php
 579                      /* translators: %s: Theme name. */
 580                      $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
 581                      ?>
 582                      <a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
 583                      <a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
 584                  <# } else { #>
 585                      <?php
 586                      /* translators: %s: Theme name. */
 587                      $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
 588                      ?>
 589                      <a class="button disabled" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
 590                      <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
 591                  <# } #>
 592              <# } #>
 593          </div>
 594      </div>
 595  </script>
 596  
 597  <script id="tmpl-theme-single" type="text/template">
 598      <div class="theme-backdrop"></div>
 599      <div class="theme-wrap wp-clearfix" role="document">
 600          <div class="theme-header">
 601              <button class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
 602              <button class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
 603              <button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button>
 604          </div>
 605          <div class="theme-about wp-clearfix">
 606              <div class="theme-screenshots">
 607              <# if ( data.screenshot[0] ) { #>
 608                  <div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div>
 609              <# } else { #>
 610                  <div class="screenshot blank"></div>
 611              <# } #>
 612              </div>
 613  
 614              <div class="theme-info">
 615                  <# if ( data.active ) { #>
 616                      <span class="current-label"><?php _e( 'Current Theme' ); ?></span>
 617                  <# } #>
 618                  <h2 class="theme-name">{{{ data.name }}}<span class="theme-version">
 619                      <?php
 620                      /* translators: %s: Theme version. */
 621                      printf( __( 'Version: %s' ), '{{ data.version }}' );
 622                      ?>
 623                  </span></h2>
 624                  <p class="theme-author">
 625                      <?php
 626                      /* translators: %s: Theme author link. */
 627                      printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' );
 628                      ?>
 629                  </p>
 630  
 631                  <# if ( data.actions.autoupdate ) { #>
 632                  <p class="theme-autoupdate">
 633                  <# if ( data.autoupdate ) { #>
 634                      <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="disable">
 635                          <span class="dashicons dashicons-update spin hidden"></span>
 636                          <span class="label"><?php _e( 'Disable auto-updates' ); ?></span>
 637                      </a>
 638                  <# } else { #>
 639                      <a href="{{{ data.actions.autoupdate }}}" class="toggle-auto-update" data-slug="{{ data.id }}" data-wp-action="enable">
 640                          <span class="dashicons dashicons-update spin hidden"></span>
 641                          <span class="label"><?php _e( 'Enable auto-updates' ); ?></span>
 642                      </a>
 643                  <# } #>
 644                  <# if ( data.hasUpdate ) { #>
 645                      <# if ( data.autoupdate) { #>
 646                      <span class="auto-update-time"><br /><?php echo wp_get_auto_update_message(); ?></span>
 647                      <# } else { #>
 648                      <span class="auto-update-time hidden"><br /><?php echo wp_get_auto_update_message(); ?></span>
 649                      <# } #>
 650                  <# } #>
 651                      <span class="auto-updates-error hidden"><p></p></span>
 652                  </p>
 653                  <# } #>
 654  
 655                  <# if ( data.hasUpdate ) { #>
 656                  <div class="notice notice-warning notice-alt notice-large">
 657                      <h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
 658                      {{{ data.update }}}
 659                  </div>
 660                  <# } #>
 661                  <p class="theme-description">{{{ data.description }}}</p>
 662  
 663                  <# if ( data.parent ) { #>
 664                      <p class="parent-theme">
 665                          <?php
 666                          /* translators: %s: Theme name. */
 667                          printf( __( 'This is a child theme of %s.' ), '<strong>{{{ data.parent }}}</strong>' );
 668                          ?>
 669                      </p>
 670                  <# } #>
 671  
 672                  <# if ( data.tags ) { #>
 673                      <p class="theme-tags"><span><?php _e( 'Tags:' ); ?></span> {{{ data.tags }}}</p>
 674                  <# } #>
 675              </div>
 676          </div>
 677  
 678          <div class="theme-actions">
 679              <div class="active-theme">
 680                  <a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
 681                  <?php echo implode( ' ', $current_theme_actions ); ?>
 682              </div>
 683              <div class="inactive-theme">
 684                  <# if ( data.compatibleWP && data.compatiblePHP ) { #>
 685                      <?php
 686                      /* translators: %s: Theme name. */
 687                      $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
 688                      ?>
 689                      <# if ( data.actions.activate ) { #>
 690                          <a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
 691                      <# } #>
 692                      <a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
 693                  <# } else { #>
 694                      <?php
 695                      /* translators: %s: Theme name. */
 696                      $aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
 697                      ?>
 698                      <# if ( data.actions.activate ) { #>
 699                          <a class="button disabled" aria-label="<?php echo $aria_label; ?>"><?php _ex( 'Cannot Activate', 'theme' ); ?></a>
 700                      <# } #>
 701                      <a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
 702                  <# } #>
 703              </div>
 704  
 705              <# if ( ! data.active && data.actions['delete'] ) { #>
 706                  <a href="{{{ data.actions['delete'] }}}" class="button delete-theme"><?php _e( 'Delete' ); ?></a>
 707              <# } #>
 708          </div>
 709      </div>
 710  </script>
 711  
 712  <?php
 713  wp_print_request_filesystem_credentials_modal();
 714  wp_print_admin_notice_templates();
 715  wp_print_update_row_templates();
 716  
 717  wp_localize_script(
 718      'updates',
 719      '_wpUpdatesItemCounts',
 720      array(
 721          'totals' => wp_get_update_data(),
 722      )
 723  );
 724  
 725  require_once  ABSPATH . 'wp-admin/admin-footer.php';


Generated : Wed Jun 3 08:20:02 2020 Cross-referenced by PHPXref