home *** CD-ROM | disk | FTP | other *** search
/ HTML Examples / WP.iso / wordpress / wp-admin / includes / class-wp-ms-themes-list-table.php < prev    next >
Encoding:
PHP Script  |  2017-10-02  |  19.8 KB  |  727 lines

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