/wp-admin/includes/class-wp-ms-themes-list-table.php

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