[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/includes/ -> class-wp-ms-themes-list-table.php (source)

   1  <?php
   2  /**
   3   * List Table API: WP_MS_Themes_List_Table class
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   * @since 3.1.0
   8   */
   9  
  10  /**
  11   * Core class used to implement displaying themes in a list table for the network admin.
  12   *
  13   * @since 3.1.0
  14   * @access private
  15   *
  16   * @see WP_List_Table
  17   */
  18  class WP_MS_Themes_List_Table extends WP_List_Table {
  19  
  20      public $site_id;
  21      public $is_site_themes;
  22  
  23      private $has_items;
  24  
  25      /**
  26       * Constructor.
  27       *
  28       * @since 3.1.0
  29       *
  30       * @see WP_List_Table::__construct() for more information on default arguments.
  31       *
  32       * @global string $status
  33       * @global int    $page
  34       *
  35       * @param array $args An associative array of arguments.
  36       */
  37  	public function __construct( $args = array() ) {
  38          global $status, $page;
  39  
  40          parent::__construct(
  41              array(
  42                  'plural' => 'themes',
  43                  'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
  44              )
  45          );
  46  
  47          $status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all';
  48          if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) {
  49              $status = 'all';
  50          }
  51  
  52          $page = $this->get_pagenum();
  53  
  54          $this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false;
  55  
  56          if ( $this->is_site_themes ) {
  57              $this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
  58          }
  59      }
  60  
  61      /**
  62       * @return array
  63       */
  64  	protected function get_table_classes() {
  65          // todo: remove and add CSS for .themes
  66          return array( 'widefat', 'plugins' );
  67      }
  68  
  69      /**
  70       * @return bool
  71       */
  72  	public function ajax_user_can() {
  73          if ( $this->is_site_themes ) {
  74              return current_user_can( 'manage_sites' );
  75          } else {
  76              return current_user_can( 'manage_network_themes' );
  77          }
  78      }
  79  
  80      /**
  81       * @global string $status
  82       * @global array $totals
  83       * @global int $page
  84       * @global string $orderby
  85       * @global string $order
  86       * @global string $s
  87       */
  88  	public function prepare_items() {
  89          global $status, $totals, $page, $orderby, $order, $s;
  90  
  91          wp_reset_vars( array( 'orderby', 'order', 's' ) );
  92  
  93          $themes = array(
  94              /**
  95               * Filters the full array of WP_Theme objects to list in the Multisite
  96               * themes list table.
  97               *
  98               * @since 3.1.0
  99               *
 100               * @param WP_Theme[] $all Array of WP_Theme objects to display in the list table.
 101               */
 102              'all'      => apply_filters( 'all_themes', wp_get_themes() ),
 103              'search'   => array(),
 104              'enabled'  => array(),
 105              'disabled' => array(),
 106              'upgrade'  => array(),
 107              'broken'   => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ),
 108          );
 109  
 110          if ( $this->is_site_themes ) {
 111              $themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' );
 112              $allowed_where   = 'site';
 113          } else {
 114              $themes_per_page = $this->get_items_per_page( 'themes_network_per_page' );
 115              $allowed_where   = 'network';
 116          }
 117  
 118          $current      = get_site_transient( 'update_themes' );
 119          $maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current;
 120  
 121          foreach ( (array) $themes['all'] as $key => $theme ) {
 122              if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) {
 123                  unset( $themes['all'][ $key ] );
 124                  continue;
 125              }
 126  
 127              if ( $maybe_update && isset( $current->response[ $key ] ) ) {
 128                  $themes['all'][ $key ]->update = true;
 129                  $themes['upgrade'][ $key ]     = $themes['all'][ $key ];
 130              }
 131  
 132              $filter                    = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled';
 133              $themes[ $filter ][ $key ] = $themes['all'][ $key ];
 134          }
 135  
 136          if ( $s ) {
 137              $status           = 'search';
 138              $themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) );
 139          }
 140  
 141          $totals = array();
 142          foreach ( $themes as $type => $list ) {
 143              $totals[ $type ] = count( $list );
 144          }
 145  
 146          if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) {
 147              $status = 'all';
 148          }
 149  
 150          $this->items = $themes[ $status ];
 151          WP_Theme::sort_by_name( $this->items );
 152  
 153          $this->has_items = ! empty( $themes['all'] );
 154          $total_this_page = $totals[ $status ];
 155  
 156          wp_localize_script(
 157              'updates',
 158              '_wpUpdatesItemCounts',
 159              array(
 160                  'themes' => $totals,
 161                  'totals' => wp_get_update_data(),
 162              )
 163          );
 164  
 165          if ( $orderby ) {
 166              $orderby = ucfirst( $orderby );
 167              $order   = strtoupper( $order );
 168  
 169              if ( $orderby === 'Name' ) {
 170                  if ( 'ASC' === $order ) {
 171                      $this->items = array_reverse( $this->items );
 172                  }
 173              } else {
 174                  uasort( $this->items, array( $this, '_order_callback' ) );
 175              }
 176          }
 177  
 178          $start = ( $page - 1 ) * $themes_per_page;
 179  
 180          if ( $total_this_page > $themes_per_page ) {
 181              $this->items = array_slice( $this->items, $start, $themes_per_page, true );
 182          }
 183  
 184          $this->set_pagination_args(
 185              array(
 186                  'total_items' => $total_this_page,
 187                  'per_page'    => $themes_per_page,
 188              )
 189          );
 190      }
 191  
 192      /**
 193       * @staticvar string $term
 194       * @param WP_Theme $theme
 195       * @return bool
 196       */
 197  	public function _search_callback( $theme ) {
 198          static $term = null;
 199          if ( is_null( $term ) ) {
 200              $term = wp_unslash( $_REQUEST['s'] );
 201          }
 202  
 203          foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) {
 204              // Don't mark up; Do translate.
 205              if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) {
 206                  return true;
 207              }
 208          }
 209  
 210          if ( false !== stripos( $theme->get_stylesheet(), $term ) ) {
 211              return true;
 212          }
 213  
 214          if ( false !== stripos( $theme->get_template(), $term ) ) {
 215              return true;
 216          }
 217  
 218          return false;
 219      }
 220  
 221      // Not used by any core columns.
 222      /**
 223       * @global string $orderby
 224       * @global string $order
 225       * @param array $theme_a
 226       * @param array $theme_b
 227       * @return int
 228       */
 229  	public function _order_callback( $theme_a, $theme_b ) {
 230          global $orderby, $order;
 231  
 232          $a = $theme_a[ $orderby ];
 233          $b = $theme_b[ $orderby ];
 234  
 235          if ( $a == $b ) {
 236              return 0;
 237          }
 238  
 239          if ( 'DESC' === $order ) {
 240              return ( $a < $b ) ? 1 : -1;
 241          } else {
 242              return ( $a < $b ) ? -1 : 1;
 243          }
 244      }
 245  
 246      /**
 247       */
 248  	public function no_items() {
 249          if ( $this->has_items ) {
 250              _e( 'No themes found.' );
 251          } else {
 252              _e( 'You do not appear to have any themes available at this time.' );
 253          }
 254      }
 255  
 256      /**
 257       * @return array
 258       */
 259  	public function get_columns() {
 260          return array(
 261              'cb'          => '<input type="checkbox" />',
 262              'name'        => __( 'Theme' ),
 263              'description' => __( 'Description' ),
 264          );
 265      }
 266  
 267      /**
 268       * @return array
 269       */
 270  	protected function get_sortable_columns() {
 271          return array(
 272              'name' => 'name',
 273          );
 274      }
 275  
 276      /**
 277       * Gets the name of the primary column.
 278       *
 279       * @since 4.3.0
 280       *
 281       * @return string Unalterable name of the primary column name, in this case, 'name'.
 282       */
 283  	protected function get_primary_column_name() {
 284          return 'name';
 285      }
 286  
 287      /**
 288       * @global array $totals
 289       * @global string $status
 290       * @return array
 291       */
 292  	protected function get_views() {
 293          global $totals, $status;
 294  
 295          $status_links = array();
 296          foreach ( $totals as $type => $count ) {
 297              if ( ! $count ) {
 298                  continue;
 299              }
 300  
 301              switch ( $type ) {
 302                  case 'all':
 303                      /* translators: %s: Number of themes. */
 304                      $text = _nx(
 305                          'All <span class="count">(%s)</span>',
 306                          'All <span class="count">(%s)</span>',
 307                          $count,
 308                          'themes'
 309                      );
 310                      break;
 311                  case 'enabled':
 312                      /* translators: %s: Number of themes. */
 313                      $text = _nx(
 314                          'Enabled <span class="count">(%s)</span>',
 315                          'Enabled <span class="count">(%s)</span>',
 316                          $count,
 317                          'themes'
 318                      );
 319                      break;
 320                  case 'disabled':
 321                      /* translators: %s: Number of themes. */
 322                      $text = _nx(
 323                          'Disabled <span class="count">(%s)</span>',
 324                          'Disabled <span class="count">(%s)</span>',
 325                          $count,
 326                          'themes'
 327                      );
 328                      break;
 329                  case 'upgrade':
 330                      /* translators: %s: Number of themes. */
 331                      $text = _nx(
 332                          'Update Available <span class="count">(%s)</span>',
 333                          'Update Available <span class="count">(%s)</span>',
 334                          $count,
 335                          'themes'
 336                      );
 337                      break;
 338                  case 'broken':
 339                      /* translators: %s: Number of themes. */
 340                      $text = _nx(
 341                          'Broken <span class="count">(%s)</span>',
 342                          'Broken <span class="count">(%s)</span>',
 343                          $count,
 344                          'themes'
 345                      );
 346                      break;
 347              }
 348  
 349              if ( $this->is_site_themes ) {
 350                  $url = 'site-themes.php?id=' . $this->site_id;
 351              } else {
 352                  $url = 'themes.php';
 353              }
 354  
 355              if ( 'search' != $type ) {
 356                  $status_links[ $type ] = sprintf(
 357                      "<a href='%s'%s>%s</a>",
 358                      esc_url( add_query_arg( 'theme_status', $type, $url ) ),
 359                      ( $type === $status ) ? ' class="current" aria-current="page"' : '',
 360                      sprintf( $text, number_format_i18n( $count ) )
 361                  );
 362              }
 363          }
 364  
 365          return $status_links;
 366      }
 367  
 368      /**
 369       * @global string $status
 370       *
 371       * @return array
 372       */
 373  	protected function get_bulk_actions() {
 374          global $status;
 375  
 376          $actions = array();
 377          if ( 'enabled' != $status ) {
 378              $actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' );
 379          }
 380          if ( 'disabled' != $status ) {
 381              $actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' );
 382          }
 383          if ( ! $this->is_site_themes ) {
 384              if ( current_user_can( 'update_themes' ) ) {
 385                  $actions['update-selected'] = __( 'Update' );
 386              }
 387              if ( current_user_can( 'delete_themes' ) ) {
 388                  $actions['delete-selected'] = __( 'Delete' );
 389              }
 390          }
 391          return $actions;
 392      }
 393  
 394      /**
 395       */
 396  	public function display_rows() {
 397          foreach ( $this->items as $theme ) {
 398              $this->single_row( $theme );
 399          }
 400      }
 401  
 402      /**
 403       * Handles the checkbox column output.
 404       *
 405       * @since 4.3.0
 406       *
 407       * @param WP_Theme $theme The current WP_Theme object.
 408       */
 409  	public function column_cb( $theme ) {
 410          $checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
 411          ?>
 412          <input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />
 413          <label class="screen-reader-text" for="<?php echo $checkbox_id; ?>" ><?php _e( 'Select' ); ?>  <?php echo $theme->display( 'Name' ); ?></label>
 414          <?php
 415      }
 416  
 417      /**
 418       * Handles the name column output.
 419       *
 420       * @since 4.3.0
 421       *
 422       * @global string $status
 423       * @global int    $page
 424       * @global string $s
 425       *
 426       * @param WP_Theme $theme The current WP_Theme object.
 427       */
 428  	public function column_name( $theme ) {
 429          global $status, $page, $s;
 430  
 431          $context = $status;
 432  
 433          if ( $this->is_site_themes ) {
 434              $url     = "site-themes.php?id={$this->site_id}&amp;";
 435              $allowed = $theme->is_allowed( 'site', $this->site_id );
 436          } else {
 437              $url     = 'themes.php?';
 438              $allowed = $theme->is_allowed( 'network' );
 439          }
 440  
 441          // Pre-order.
 442          $actions = array(
 443              'enable'  => '',
 444              'disable' => '',
 445              'delete'  => '',
 446          );
 447  
 448          $stylesheet = $theme->get_stylesheet();
 449          $theme_key  = urlencode( $stylesheet );
 450  
 451          if ( ! $allowed ) {
 452              if ( ! $theme->errors() ) {
 453                  $url = add_query_arg(
 454                      array(
 455                          'action' => 'enable',
 456                          'theme'  => $theme_key,
 457                          'paged'  => $page,
 458                          's'      => $s,
 459                      ),
 460                      $url
 461                  );
 462  
 463                  if ( $this->is_site_themes ) {
 464                      /* translators: %s: Theme name. */
 465                      $aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) );
 466                  } else {
 467                      /* translators: %s: Theme name. */
 468                      $aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) );
 469                  }
 470  
 471                  $actions['enable'] = sprintf(
 472                      '<a href="%s" class="edit" aria-label="%s">%s</a>',
 473                      esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ),
 474                      esc_attr( $aria_label ),
 475                      ( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) )
 476                  );
 477              }
 478          } else {
 479              $url = add_query_arg(
 480                  array(
 481                      'action' => 'disable',
 482                      'theme'  => $theme_key,
 483                      'paged'  => $page,
 484                      's'      => $s,
 485                  ),
 486                  $url
 487              );
 488  
 489              if ( $this->is_site_themes ) {
 490                  /* translators: %s: Theme name. */
 491                  $aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) );
 492              } else {
 493                  /* translators: %s: Theme name. */
 494                  $aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) );
 495              }
 496  
 497              $actions['disable'] = sprintf(
 498                  '<a href="%s" aria-label="%s">%s</a>',
 499                  esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ),
 500                  esc_attr( $aria_label ),
 501                  ( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) )
 502              );
 503          }
 504  
 505          if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) {
 506              $url = add_query_arg(
 507                  array(
 508                      'action'       => 'delete-selected',
 509                      'checked[]'    => $theme_key,
 510                      'theme_status' => $context,
 511                      'paged'        => $page,
 512                      's'            => $s,
 513                  ),
 514                  'themes.php'
 515              );
 516  
 517              /* translators: %s: Theme name. */
 518              $aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) );
 519  
 520              $actions['delete'] = sprintf(
 521                  '<a href="%s" class="delete" aria-label="%s">%s</a>',
 522                  esc_url( wp_nonce_url( $url, 'bulk-themes' ) ),
 523                  esc_attr( $aria_label ),
 524                  __( 'Delete' )
 525              );
 526          }
 527          /**
 528           * Filters the action links displayed for each theme in the Multisite
 529           * themes list table.
 530           *
 531           * The action links displayed are determined by the theme's status, and
 532           * which Multisite themes list table is being displayed - the Network
 533           * themes list table (themes.php), which displays all installed themes,
 534           * or the Site themes list table (site-themes.php), which displays the
 535           * non-network enabled themes when editing a site in the Network admin.
 536           *
 537           * The default action links for the Network themes list table include
 538           * 'Network Enable', 'Network Disable', and 'Delete'.
 539           *
 540           * The default action links for the Site themes list table include
 541           * 'Enable', and 'Disable'.
 542           *
 543           * @since 2.8.0
 544           *
 545           * @param string[] $actions An array of action links.
 546           * @param WP_Theme $theme   The current WP_Theme object.
 547           * @param string   $context Status of the theme, one of 'all', 'enabled', or 'disabled'.
 548           */
 549          $actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context );
 550  
 551          /**
 552           * Filters the action links of a specific theme in the Multisite themes
 553           * list table.
 554           *
 555           * The dynamic portion of the hook name, `$stylesheet`, refers to the
 556           * directory name of the theme, which in most cases is synonymous
 557           * with the template name.
 558           *
 559           * @since 3.1.0
 560           *
 561           * @param string[] $actions An array of action links.
 562           * @param WP_Theme $theme   The current WP_Theme object.
 563           * @param string   $context Status of the theme, one of 'all', 'enabled', or 'disabled'.
 564           */
 565          $actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context );
 566  
 567          echo $this->row_actions( $actions, true );
 568      }
 569  
 570      /**
 571       * Handles the description column output.
 572       *
 573       * @since 4.3.0
 574       *
 575       * @global string $status
 576       * @global array  $totals
 577       *
 578       * @param WP_Theme $theme The current WP_Theme object.
 579       */
 580  	public function column_description( $theme ) {
 581          global $status, $totals;
 582          if ( $theme->errors() ) {
 583              $pre = $status === 'broken' ? __( 'Broken Theme:' ) . ' ' : '';
 584              echo '<p><strong class="error-message">' . $pre . $theme->errors()->get_error_message() . '</strong></p>';
 585          }
 586  
 587          if ( $this->is_site_themes ) {
 588              $allowed = $theme->is_allowed( 'site', $this->site_id );
 589          } else {
 590              $allowed = $theme->is_allowed( 'network' );
 591          }
 592  
 593          $class = ! $allowed ? 'inactive' : 'active';
 594          if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) {
 595              $class .= ' update';
 596          }
 597  
 598          echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div>
 599              <div class='$class second theme-version-author-uri'>";
 600  
 601          $stylesheet = $theme->get_stylesheet();
 602          $theme_meta = array();
 603  
 604          if ( $theme->get( 'Version' ) ) {
 605              /* translators: %s: Theme version. */
 606              $theme_meta[] = sprintf( __( 'Version %s' ), $theme->display( 'Version' ) );
 607          }
 608  
 609          /* translators: %s: Theme author. */
 610          $theme_meta[] = sprintf( __( 'By %s' ), $theme->display( 'Author' ) );
 611  
 612          if ( $theme->get( 'ThemeURI' ) ) {
 613              /* translators: %s: Theme name. */
 614              $aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) );
 615  
 616              $theme_meta[] = sprintf(
 617                  '<a href="%s" aria-label="%s">%s</a>',
 618                  $theme->display( 'ThemeURI' ),
 619                  esc_attr( $aria_label ),
 620                  __( 'Visit Theme Site' )
 621              );
 622          }
 623          /**
 624           * Filters the array of row meta for each theme in the Multisite themes
 625           * list table.
 626           *
 627           * @since 3.1.0
 628           *
 629           * @param string[] $theme_meta An array of the theme's metadata,
 630           *                             including the version, author, and
 631           *                             theme URI.
 632           * @param string   $stylesheet Directory name of the theme.
 633           * @param WP_Theme $theme      WP_Theme object.
 634           * @param string   $status     Status of the theme.
 635           */
 636          $theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status );
 637          echo implode( ' | ', $theme_meta );
 638  
 639          echo '</div>';
 640      }
 641  
 642      /**
 643       * Handles default column output.
 644       *
 645       * @since 4.3.0
 646       *
 647       * @param WP_Theme $theme       The current WP_Theme object.
 648       * @param string   $column_name The current column name.
 649       */
 650  	public function column_default( $theme, $column_name ) {
 651          $stylesheet = $theme->get_stylesheet();
 652  
 653          /**
 654           * Fires inside each custom column of the Multisite themes list table.
 655           *
 656           * @since 3.1.0
 657           *
 658           * @param string   $column_name Name of the column.
 659           * @param string   $stylesheet  Directory name of the theme.
 660           * @param WP_Theme $theme       Current WP_Theme object.
 661           */
 662          do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
 663      }
 664  
 665      /**
 666       * Handles the output for a single table row.
 667       *
 668       * @since 4.3.0
 669       *
 670       * @param WP_Theme $item The current WP_Theme object.
 671       */
 672  	public function single_row_columns( $item ) {
 673          list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
 674  
 675          foreach ( $columns as $column_name => $column_display_name ) {
 676              $extra_classes = '';
 677              if ( in_array( $column_name, $hidden ) ) {
 678                  $extra_classes .= ' hidden';
 679              }
 680  
 681              switch ( $column_name ) {
 682                  case 'cb':
 683                      echo '<th scope="row" class="check-column">';
 684  
 685                      $this->column_cb( $item );
 686  
 687                      echo '</th>';
 688                      break;
 689  
 690                  case 'name':
 691                      $active_theme_label = '';
 692  
 693                      /* The presence of the site_id property means that this is a subsite view and a label for the active theme needs to be added */
 694                      if ( ! empty( $this->site_id ) ) {
 695                          $stylesheet = get_blog_option( $this->site_id, 'stylesheet' );
 696                          $template   = get_blog_option( $this->site_id, 'template' );
 697  
 698                          /* Add a label for the active template */
 699                          if ( $item->get_template() === $template ) {
 700                              $active_theme_label = ' &mdash; ' . __( 'Active Theme' );
 701                          }
 702  
 703                          /* In case this is a child theme, label it properly */
 704                          if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet ) {
 705                              $active_theme_label = ' &mdash; ' . __( 'Active Child Theme' );
 706                          }
 707                      }
 708  
 709                      echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display( 'Name' ) . $active_theme_label . '</strong>';
 710  
 711                      $this->column_name( $item );
 712  
 713                      echo '</td>';
 714                      break;
 715  
 716                  case 'description':
 717                      echo "<td class='column-description desc{$extra_classes}'>";
 718  
 719                      $this->column_description( $item );
 720  
 721                      echo '</td>';
 722                      break;
 723  
 724                  default:
 725                      echo "<td class='$column_name column-$column_name{$extra_classes}'>";
 726  
 727                      $this->column_default( $item, $column_name );
 728  
 729                      echo '</td>';
 730                      break;
 731              }
 732          }
 733      }
 734  
 735      /**
 736       * @global string $status
 737       * @global array  $totals
 738       *
 739       * @param WP_Theme $theme
 740       */
 741  	public function single_row( $theme ) {
 742          global $status, $totals;
 743  
 744          if ( $this->is_site_themes ) {
 745              $allowed = $theme->is_allowed( 'site', $this->site_id );
 746          } else {
 747              $allowed = $theme->is_allowed( 'network' );
 748          }
 749  
 750          $stylesheet = $theme->get_stylesheet();
 751  
 752          $class = ! $allowed ? 'inactive' : 'active';
 753          if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) {
 754              $class .= ' update';
 755          }
 756  
 757          printf(
 758              '<tr class="%s" data-slug="%s">',
 759              esc_attr( $class ),
 760              esc_attr( $stylesheet )
 761          );
 762  
 763          $this->single_row_columns( $theme );
 764  
 765          echo '</tr>';
 766  
 767          if ( $this->is_site_themes ) {
 768              remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' );
 769          }
 770  
 771          /**
 772           * Fires after each row in the Multisite themes list table.
 773           *
 774           * @since 3.1.0
 775           *
 776           * @param string   $stylesheet Directory name of the theme.
 777           * @param WP_Theme $theme      Current WP_Theme object.
 778           * @param string   $status     Status of the theme.
 779           */
 780          do_action( 'after_theme_row', $stylesheet, $theme, $status );
 781  
 782          /**
 783           * Fires after each specific row in the Multisite themes list table.
 784           *
 785           * The dynamic portion of the hook name, `$stylesheet`, refers to the
 786           * directory name of the theme, most often synonymous with the template
 787           * name of the theme.
 788           *
 789           * @since 3.5.0
 790           *
 791           * @param string   $stylesheet Directory name of the theme.
 792           * @param WP_Theme $theme      Current WP_Theme object.
 793           * @param string   $status     Status of the theme.
 794           */
 795          do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status );
 796      }
 797  }


Generated: Tue Sep 17 01:00:03 2019 Cross-referenced by PHPXref 0.7.1