3 * List Table API: WP_Plugins_List_Table class
6 * @subpackage Administration
11 * Core class used to implement displaying installed plugins in a list table.
18 class WP_Plugins_List_Table extends WP_List_Table {
26 * @see WP_List_Table::__construct() for more information on default arguments.
28 * @global string $status
31 * @param array $args An associative array of arguments.
33 public function __construct( $args = array() ) {
34 global $status, $page;
36 parent::__construct( array(
37 'plural' => 'plugins',
38 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
42 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
43 $status = $_REQUEST['plugin_status'];
45 if ( isset($_REQUEST['s']) )
46 $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) );
48 $page = $this->get_pagenum();
54 protected function get_table_classes() {
55 return array( 'widefat', $this->_args['plural'] );
61 public function ajax_user_can() {
62 return current_user_can('activate_plugins');
67 * @global string $status
68 * @global array $plugins
69 * @global array $totals
71 * @global string $orderby
72 * @global string $order
75 public function prepare_items() {
76 global $status, $plugins, $totals, $page, $orderby, $order, $s;
78 wp_reset_vars( array( 'orderby', 'order' ) );
81 * Filters the full array of plugins to list in the Plugins list table.
87 * @param array $all_plugins An array of plugins to display in the list table.
89 $all_plugins = apply_filters( 'all_plugins', get_plugins() );
92 'all' => $all_plugins,
95 'inactive' => array(),
96 'recently_activated' => array(),
102 $screen = $this->screen;
104 if ( ! is_multisite() || ( $screen->in_admin( 'network' ) && current_user_can( 'manage_network_plugins' ) ) ) {
107 * Filters whether to display the advanced plugins list table.
109 * There are two types of advanced plugins - must-use and drop-ins -
110 * which can be used in a single site or Multisite network.
112 * The $type parameter allows you to differentiate between the type of advanced
113 * plugins to filter the display of. Contexts include 'mustuse' and 'dropins'.
117 * @param bool $show Whether to show the advanced plugins for the specified
118 * plugin type. Default true.
119 * @param string $type The plugin type. Accepts 'mustuse', 'dropins'.
121 if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) {
122 $plugins['mustuse'] = get_mu_plugins();
125 /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */
126 if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
127 $plugins['dropins'] = get_dropins();
129 if ( current_user_can( 'update_plugins' ) ) {
130 $current = get_site_transient( 'update_plugins' );
131 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
132 if ( isset( $current->response[ $plugin_file ] ) ) {
133 $plugins['all'][ $plugin_file ]['update'] = true;
134 $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ];
140 if ( ! $screen->in_admin( 'network' ) ) {
141 $show = current_user_can( 'manage_network_plugins' );
143 * Filters whether to display network-active plugins alongside plugins active for the current site.
145 * This also controls the display of inactive network-only plugins (plugins with
146 * "Network: true" in the plugin header).
148 * Plugins cannot be network-activated or network-deactivated from this screen.
152 * @param bool $show Whether to show network-active plugins. Default is whether the current
153 * user can manage network plugins (ie. a Super Admin).
155 $show_network_active = apply_filters( 'show_network_active_plugins', $show );
158 set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
160 if ( $screen->in_admin( 'network' ) ) {
161 $recently_activated = get_site_option( 'recently_activated', array() );
163 $recently_activated = get_option( 'recently_activated', array() );
166 foreach ( $recently_activated as $key => $time ) {
167 if ( $time + WEEK_IN_SECONDS < time() ) {
168 unset( $recently_activated[$key] );
172 if ( $screen->in_admin( 'network' ) ) {
173 update_site_option( 'recently_activated', $recently_activated );
175 update_option( 'recently_activated', $recently_activated );
178 $plugin_info = get_site_transient( 'update_plugins' );
180 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
181 // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
182 if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
183 $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
184 // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
185 if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
186 $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
189 } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
190 $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
191 // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
192 if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
193 $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
197 // Filter into individual sections
198 if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
199 if ( $show_network_active ) {
200 // On the non-network screen, show inactive network-only plugins if allowed
201 $plugins['inactive'][ $plugin_file ] = $plugin_data;
203 // On the non-network screen, filter out network-only plugins as long as they're not individually active
204 unset( $plugins['all'][ $plugin_file ] );
206 } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
207 if ( $show_network_active ) {
208 // On the non-network screen, show network-active plugins if allowed
209 $plugins['active'][ $plugin_file ] = $plugin_data;
211 // On the non-network screen, filter out network-active plugins
212 unset( $plugins['all'][ $plugin_file ] );
214 } elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
215 || ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) {
216 // On the non-network screen, populate the active list with plugins that are individually activated
217 // On the network-admin screen, populate the active list with plugins that are network activated
218 $plugins['active'][ $plugin_file ] = $plugin_data;
220 if ( isset( $recently_activated[ $plugin_file ] ) ) {
221 // Populate the recently activated list with plugins that have been recently activated
222 $plugins['recently_activated'][ $plugin_file ] = $plugin_data;
224 // Populate the inactive list with plugins that aren't activated
225 $plugins['inactive'][ $plugin_file ] = $plugin_data;
229 if ( strlen( $s ) ) {
231 $plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
235 foreach ( $plugins as $type => $list )
236 $totals[ $type ] = count( $list );
238 if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
241 $this->items = array();
242 foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
243 // Translate, Don't Apply Markup, Sanitize HTML
244 $this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
247 $total_this_page = $totals[ $status ];
249 $js_plugins = array();
250 foreach ( $plugins as $key => $list ) {
251 $js_plugins[ $key ] = array_keys( (array) $list );
254 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
255 'plugins' => $js_plugins,
256 'totals' => wp_get_update_data(),
262 $orderby = ucfirst( $orderby );
265 $order = strtoupper( $order );
267 uasort( $this->items, array( $this, '_order_callback' ) );
269 $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 );
271 $start = ( $page - 1 ) * $plugins_per_page;
273 if ( $total_this_page > $plugins_per_page )
274 $this->items = array_slice( $this->items, $start, $plugins_per_page );
276 $this->set_pagination_args( array(
277 'total_items' => $total_this_page,
278 'per_page' => $plugins_per_page,
283 * @global string $s URL encoded search term.
285 * @param array $plugin
288 public function _search_callback( $plugin ) {
291 foreach ( $plugin as $value ) {
292 if ( is_string( $value ) && false !== stripos( strip_tags( $value ), urldecode( $s ) ) ) {
301 * @global string $orderby
302 * @global string $order
303 * @param array $plugin_a
304 * @param array $plugin_b
307 public function _order_callback( $plugin_a, $plugin_b ) {
308 global $orderby, $order;
310 $a = $plugin_a[$orderby];
311 $b = $plugin_b[$orderby];
316 if ( 'DESC' === $order ) {
317 return strcasecmp( $b, $a );
319 return strcasecmp( $a, $b );
325 * @global array $plugins
327 public function no_items() {
330 if ( ! empty( $_REQUEST['s'] ) ) {
331 $s = esc_html( wp_unslash( $_REQUEST['s'] ) );
333 printf( __( 'No plugins found for “%s”.' ), $s );
335 // We assume that somebody who can install plugins in multisite is experienced enough to not need this helper link.
336 if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) {
337 echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>';
339 } elseif ( ! empty( $plugins['all'] ) )
340 _e( 'No plugins found.' );
342 _e( 'You do not appear to have any plugins available at this time.' );
346 * Displays the search box.
351 * @param string $text The 'submit' button label.
352 * @param string $input_id ID attribute value for the search input field.
354 public function search_box( $text, $input_id ) {
355 if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
359 $input_id = $input_id . '-search-input';
361 if ( ! empty( $_REQUEST['orderby'] ) ) {
362 echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
364 if ( ! empty( $_REQUEST['order'] ) ) {
365 echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
368 <p class="search-box">
369 <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label>
370 <input type="search" id="<?php echo esc_attr( $input_id ); ?>" class="wp-filter-search" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php esc_attr_e( 'Search installed plugins...' ); ?>"/>
371 <?php submit_button( $text, 'hide-if-js', '', false, array( 'id' => 'search-submit' ) ); ?>
378 * @global string $status
381 public function get_columns() {
385 'cb' => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
386 'name' => __( 'Plugin' ),
387 'description' => __( 'Description' ),
394 protected function get_sortable_columns() {
400 * @global array $totals
401 * @global string $status
404 protected function get_views() {
405 global $totals, $status;
407 $status_links = array();
408 foreach ( $totals as $type => $count ) {
414 $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' );
417 $text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count );
419 case 'recently_activated':
420 $text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count );
423 $text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
426 $text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
429 $text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
432 $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
436 if ( 'search' !== $type ) {
437 $status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
438 add_query_arg('plugin_status', $type, 'plugins.php'),
439 ( $type === $status ) ? ' class="current"' : '',
440 sprintf( $text, number_format_i18n( $count ) )
445 return $status_links;
450 * @global string $status
453 protected function get_bulk_actions() {
458 if ( 'active' != $status )
459 $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' );
461 if ( 'inactive' != $status && 'recent' != $status )
462 $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' );
464 if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) {
465 if ( current_user_can( 'update_plugins' ) )
466 $actions['update-selected'] = __( 'Update' );
467 if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
468 $actions['delete-selected'] = __( 'Delete' );
475 * @global string $status
476 * @param string $which
478 public function bulk_actions( $which = '' ) {
481 if ( in_array( $status, array( 'mustuse', 'dropins' ) ) )
484 parent::bulk_actions( $which );
488 * @global string $status
489 * @param string $which
491 protected function extra_tablenav( $which ) {
494 if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) )
497 echo '<div class="alignleft actions">';
499 if ( 'recently_activated' == $status ) {
500 submit_button( __( 'Clear List' ), '', 'clear-recent-list', false );
501 } elseif ( 'top' === $which && 'mustuse' === $status ) {
502 /* translators: %s: mu-plugins directory name */
503 echo '<p>' . sprintf( __( 'Files in the %s directory are executed automatically.' ),
504 '<code>' . str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) . '</code>'
506 } elseif ( 'top' === $which && 'dropins' === $status ) {
507 /* translators: %s: wp-content directory name */
508 echo '<p>' . sprintf( __( 'Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.' ),
509 '<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
518 public function current_action() {
519 if ( isset($_POST['clear-recent-list']) )
520 return 'clear-recent-list';
522 return parent::current_action();
527 * @global string $status
529 public function display_rows() {
532 if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) )
535 foreach ( $this->items as $plugin_file => $plugin_data )
536 $this->single_row( array( $plugin_file, $plugin_data ) );
540 * @global string $status
543 * @global array $totals
547 public function single_row( $item ) {
548 global $status, $page, $s, $totals;
550 list( $plugin_file, $plugin_data ) = $item;
552 $screen = $this->screen;
563 // Do not restrict by default
564 $restrict_network_active = false;
565 $restrict_network_only = false;
567 if ( 'mustuse' === $context ) {
569 } elseif ( 'dropins' === $context ) {
570 $dropins = _get_dropins();
571 $plugin_name = $plugin_file;
572 if ( $plugin_file != $plugin_data['Name'] )
573 $plugin_name .= '<br/>' . $plugin_data['Name'];
574 if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
576 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
577 } elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
579 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
582 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __( 'Inactive:' ) . '</span></strong> ' .
583 /* translators: 1: drop-in constant name, 2: wp-config.php */
584 sprintf( __( 'Requires %1$s in %2$s file.' ),
585 "<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>",
586 '<code>wp-config.php</code>'
589 if ( $plugin_data['Description'] )
590 $description .= '<p>' . $plugin_data['Description'] . '</p>';
592 if ( $screen->in_admin( 'network' ) ) {
593 $is_active = is_plugin_active_for_network( $plugin_file );
595 $is_active = is_plugin_active( $plugin_file );
596 $restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) );
597 $restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active );
600 if ( $screen->in_admin( 'network' ) ) {
602 if ( current_user_can( 'manage_network_plugins' ) ) {
603 /* translators: %s: plugin name */
604 $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Deactivate' ) . '</a>';
607 if ( current_user_can( 'manage_network_plugins' ) ) {
608 /* translators: %s: plugin name */
609 $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Activate' ) . '</a>';
611 if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) {
612 /* translators: %s: plugin name */
613 $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
617 if ( $restrict_network_active ) {
619 'network_active' => __( 'Network Active' ),
621 } elseif ( $restrict_network_only ) {
623 'network_only' => __( 'Network Only' ),
625 } elseif ( $is_active ) {
626 /* translators: %s: plugin name */
627 $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
629 /* translators: %s: plugin name */
630 $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Activate' ) . '</a>';
632 if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) {
633 /* translators: %s: plugin name */
634 $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
636 } // end if $is_active
638 } // end if $screen->in_admin( 'network' )
640 if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can( 'edit_plugins' ) && is_writable( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
641 /* translators: %s: plugin name */
642 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Edit %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Edit' ) . '</a>';
646 $actions = array_filter( $actions );
648 if ( $screen->in_admin( 'network' ) ) {
651 * Filters the action links displayed for each plugin in the Network Admin Plugins list table.
653 * The default action links for the Network plugins list table include
654 * 'Network Activate', 'Network Deactivate', 'Edit', and 'Delete'.
658 * @param array $actions An array of plugin action links.
659 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
660 * @param array $plugin_data An array of plugin data.
661 * @param string $context The plugin context. Defaults are 'All', 'Active',
662 * 'Inactive', 'Recently Activated', 'Upgrade',
663 * 'Must-Use', 'Drop-ins', 'Search'.
665 $actions = apply_filters( 'network_admin_plugin_action_links', $actions, $plugin_file, $plugin_data, $context );
668 * Filters the list of action links displayed for a specific plugin in the Network Admin Plugins list table.
670 * The dynamic portion of the hook name, $plugin_file, refers to the path
671 * to the plugin file, relative to the plugins directory.
675 * @param array $actions An array of plugin action links.
676 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
677 * @param array $plugin_data An array of plugin data.
678 * @param string $context The plugin context. Defaults are 'All', 'Active',
679 * 'Inactive', 'Recently Activated', 'Upgrade',
680 * 'Must-Use', 'Drop-ins', 'Search'.
682 $actions = apply_filters( "network_admin_plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context );
687 * Filters the action links displayed for each plugin in the Plugins list table.
689 * The default action links for the site plugins list table include
690 * 'Activate', 'Deactivate', and 'Edit', for a network site, and
691 * 'Activate', 'Deactivate', 'Edit', and 'Delete' for a single site.
694 * @since 2.6.0 The `$context` parameter was added.
696 * @param array $actions An array of plugin action links.
697 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
698 * @param array $plugin_data An array of plugin data.
699 * @param string $context The plugin context. Defaults are 'All', 'Active',
700 * 'Inactive', 'Recently Activated', 'Upgrade',
701 * 'Must-Use', 'Drop-ins', 'Search'.
703 $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context );
706 * Filters the list of action links displayed for a specific plugin in the Plugins list table.
708 * The dynamic portion of the hook name, $plugin_file, refers to the path
709 * to the plugin file, relative to the plugins directory.
713 * @param array $actions An array of plugin action links.
714 * @param string $plugin_file Path to the plugin file relative to the plugins directory.
715 * @param array $plugin_data An array of plugin data.
716 * @param string $context The plugin context. Defaults are 'All', 'Active',
717 * 'Inactive', 'Recently Activated', 'Upgrade',
718 * 'Must-Use', 'Drop-ins', 'Search'.
720 $actions = apply_filters( "plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context );
724 $class = $is_active ? 'active' : 'inactive';
725 $checkbox_id = "checkbox_" . md5($plugin_data['Name']);
726 if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
729 $checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . "</label>"
730 . "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' />";
732 if ( 'dropins' != $context ) {
733 $description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : ' ' ) . '</p>';
734 $plugin_name = $plugin_data['Name'];
737 if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
740 $plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name );
741 printf( '<tr class="%s" data-slug="%s" data-plugin="%s">',
743 esc_attr( $plugin_slug ),
744 esc_attr( $plugin_file )
747 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
749 foreach ( $columns as $column_name => $column_display_name ) {
751 if ( in_array( $column_name, $hidden ) ) {
752 $extra_classes = ' hidden';
755 switch ( $column_name ) {
757 echo "<th scope='row' class='check-column'>$checkbox</th>";
760 echo "<td class='plugin-title column-primary'><strong>$plugin_name</strong>";
761 echo $this->row_actions( $actions, true );
765 $classes = 'column-description desc';
767 echo "<td class='$classes{$extra_classes}'>
768 <div class='plugin-description'>$description</div>
769 <div class='$class second plugin-version-author-uri'>";
771 $plugin_meta = array();
772 if ( !empty( $plugin_data['Version'] ) )
773 $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
774 if ( !empty( $plugin_data['Author'] ) ) {
775 $author = $plugin_data['Author'];
776 if ( !empty( $plugin_data['AuthorURI'] ) )
777 $author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
778 $plugin_meta[] = sprintf( __( 'By %s' ), $author );
781 // Details link using API info, if available
782 if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) {
783 $plugin_meta[] = sprintf( '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
784 esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] .
785 '&TB_iframe=true&width=600&height=550' ) ),
786 esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ),
787 esc_attr( $plugin_name ),
790 } elseif ( ! empty( $plugin_data['PluginURI'] ) ) {
791 $plugin_meta[] = sprintf( '<a href="%s">%s</a>',
792 esc_url( $plugin_data['PluginURI'] ),
793 __( 'Visit plugin site' )
798 * Filters the array of row meta for each plugin in the Plugins list table.
802 * @param array $plugin_meta An array of the plugin's metadata,
803 * including the version, author,
804 * author URI, and plugin URI.
805 * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
806 * @param array $plugin_data An array of plugin data.
807 * @param string $status Status of the plugin. Defaults are 'All', 'Active',
808 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
809 * 'Drop-ins', 'Search'.
811 $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
812 echo implode( ' | ', $plugin_meta );
817 $classes = "$column_name column-$column_name $class";
819 echo "<td class='$classes{$extra_classes}'>";
822 * Fires inside each custom column of the Plugins list table.
826 * @param string $column_name Name of the column.
827 * @param string $plugin_file Path to the plugin file.
828 * @param array $plugin_data An array of plugin data.
830 do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data );
839 * Fires after each row in the Plugins list table.
843 * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
844 * @param array $plugin_data An array of plugin data.
845 * @param string $status Status of the plugin. Defaults are 'All', 'Active',
846 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
847 * 'Drop-ins', 'Search'.
849 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
852 * Fires after each specific row in the Plugins list table.
854 * The dynamic portion of the hook name, `$plugin_file`, refers to the path
855 * to the plugin file, relative to the plugins directory.
859 * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
860 * @param array $plugin_data An array of plugin data.
861 * @param string $status Status of the plugin. Defaults are 'All', 'Active',
862 * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
863 * 'Drop-ins', 'Search'.
865 do_action( "after_plugin_row_{$plugin_file}", $plugin_file, $plugin_data, $status );
869 * Gets the name of the primary column for this specific list table.
874 * @return string Unalterable name for the primary column, in this case, 'name'.
876 protected function get_primary_column_name() {