]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/includes/class-wp-plugins-list-table.php
WordPress 4.3
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-plugins-list-table.php
1 <?php
2 /**
3  * Plugins List Table class.
4  *
5  * @package WordPress
6  * @subpackage List_Table
7  * @since 3.1.0
8  * @access private
9  */
10 class WP_Plugins_List_Table extends WP_List_Table {
11
12         /**
13          * Constructor.
14          *
15          * @since 3.1.0
16          * @access public
17          *
18          * @see WP_List_Table::__construct() for more information on default arguments.
19          *
20          * @global string $status
21          * @global int    $page
22          *
23          * @param array $args An associative array of arguments.
24          */
25         public function __construct( $args = array() ) {
26                 global $status, $page;
27
28                 parent::__construct( array(
29                         'plural' => 'plugins',
30                         'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
31                 ) );
32
33                 $status = 'all';
34                 if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) )
35                         $status = $_REQUEST['plugin_status'];
36
37                 if ( isset($_REQUEST['s']) )
38                         $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) );
39
40                 $page = $this->get_pagenum();
41         }
42
43         /**
44          * @return array
45          */
46         protected function get_table_classes() {
47                 return array( 'widefat', $this->_args['plural'] );
48         }
49
50         /**
51          * @return bool
52          */
53         public function ajax_user_can() {
54                 return current_user_can('activate_plugins');
55         }
56
57         /**
58          *
59          * @global string $status
60          * @global type   $plugins
61          * @global array  $totals
62          * @global int    $page
63          * @global string $orderby
64          * @global string $order
65          * @global string $s
66          */
67         public function prepare_items() {
68                 global $status, $plugins, $totals, $page, $orderby, $order, $s;
69
70                 wp_reset_vars( array( 'orderby', 'order', 's' ) );
71
72                 /**
73                  * Filter the full array of plugins to list in the Plugins list table.
74                  *
75                  * @since 3.0.0
76                  *
77                  * @see get_plugins()
78                  *
79                  * @param array $plugins An array of plugins to display in the list table.
80                  */
81                 $plugins = array(
82                         'all' => apply_filters( 'all_plugins', get_plugins() ),
83                         'search' => array(),
84                         'active' => array(),
85                         'inactive' => array(),
86                         'recently_activated' => array(),
87                         'upgrade' => array(),
88                         'mustuse' => array(),
89                         'dropins' => array()
90                 );
91
92                 $screen = $this->screen;
93
94                 if ( ! is_multisite() || ( $screen->in_admin( 'network' ) && current_user_can( 'manage_network_plugins' ) ) ) {
95
96                         /**
97                          * Filter whether to display the advanced plugins list table.
98                          *
99                          * There are two types of advanced plugins - must-use and drop-ins -
100                          * which can be used in a single site or Multisite network.
101                          *
102                          * The $type parameter allows you to differentiate between the type of advanced
103                          * plugins to filter the display of. Contexts include 'mustuse' and 'dropins'.
104                          *
105                          * @since 3.0.0
106                          *
107                          * @param bool   $show Whether to show the advanced plugins for the specified
108                          *                     plugin type. Default true.
109                          * @param string $type The plugin type. Accepts 'mustuse', 'dropins'.
110                          */
111                         if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) {
112                                 $plugins['mustuse'] = get_mu_plugins();
113                         }
114
115                         /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */
116                         if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) )
117                                 $plugins['dropins'] = get_dropins();
118
119                         if ( current_user_can( 'update_plugins' ) ) {
120                                 $current = get_site_transient( 'update_plugins' );
121                                 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
122                                         if ( isset( $current->response[ $plugin_file ] ) ) {
123                                                 $plugins['all'][ $plugin_file ]['update'] = true;
124                                                 $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ];
125                                         }
126                                 }
127                         }
128                 }
129
130                 set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
131
132                 if ( ! $screen->in_admin( 'network' ) ) {
133                         $recently_activated = get_option( 'recently_activated', array() );
134
135                         foreach ( $recently_activated as $key => $time )
136                                 if ( $time + WEEK_IN_SECONDS < time() )
137                                         unset( $recently_activated[$key] );
138                         update_option( 'recently_activated', $recently_activated );
139                 }
140
141                 $plugin_info = get_site_transient( 'update_plugins' );
142
143                 foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) {
144                         // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide.
145                         if ( isset( $plugin_info->response[ $plugin_file ] ) ) {
146                                 $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
147                                 // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
148                                 if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
149                                         $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data );
150                                 }
151
152                         } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) {
153                                 $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
154                                 // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade
155                                 if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) {
156                                         $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data );
157                                 }
158                         }
159
160                         // Filter into individual sections
161                         if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) {
162                                 // On the non-network screen, filter out network-only plugins as long as they're not individually activated
163                                 unset( $plugins['all'][ $plugin_file ] );
164                         } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) {
165                                 // On the non-network screen, filter out network activated plugins
166                                 unset( $plugins['all'][ $plugin_file ] );
167                         } elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) )
168                                 || ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) {
169                                 // On the non-network screen, populate the active list with plugins that are individually activated
170                                 // On the network-admin screen, populate the active list with plugins that are network activated
171                                 $plugins['active'][ $plugin_file ] = $plugin_data;
172                         } else {
173                                 if ( ! $screen->in_admin( 'network' ) && isset( $recently_activated[ $plugin_file ] ) ) {
174                                         // On the non-network screen, populate the recently activated list with plugins that have been recently activated
175                                         $plugins['recently_activated'][ $plugin_file ] = $plugin_data;
176                                 }
177                                 // Populate the inactive list with plugins that aren't activated
178                                 $plugins['inactive'][ $plugin_file ] = $plugin_data;
179                         }
180                 }
181
182                 if ( $s ) {
183                         $status = 'search';
184                         $plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) );
185                 }
186
187                 $totals = array();
188                 foreach ( $plugins as $type => $list )
189                         $totals[ $type ] = count( $list );
190
191                 if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) )
192                         $status = 'all';
193
194                 $this->items = array();
195                 foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) {
196                         // Translate, Don't Apply Markup, Sanitize HTML
197                         $this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true );
198                 }
199
200                 $total_this_page = $totals[ $status ];
201
202                 if ( ! $orderby ) {
203                         $orderby = 'Name';
204                 } else {
205                         $orderby = ucfirst( $orderby );
206                 }
207
208                 $order = strtoupper( $order );
209
210                 uasort( $this->items, array( $this, '_order_callback' ) );
211
212                 $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 );
213
214                 $start = ( $page - 1 ) * $plugins_per_page;
215
216                 if ( $total_this_page > $plugins_per_page )
217                         $this->items = array_slice( $this->items, $start, $plugins_per_page );
218
219                 $this->set_pagination_args( array(
220                         'total_items' => $total_this_page,
221                         'per_page' => $plugins_per_page,
222                 ) );
223         }
224
225         /**
226          * @staticvar string $term
227          * @param array $plugin
228          * @return bool
229          */
230         public function _search_callback( $plugin ) {
231                 static $term = null;
232                 if ( is_null( $term ) )
233                         $term = wp_unslash( $_REQUEST['s'] );
234
235                 foreach ( $plugin as $value ) {
236                         if ( false !== stripos( strip_tags( $value ), $term ) ) {
237                                 return true;
238                         }
239                 }
240
241                 return false;
242         }
243
244         /**
245          * @global string $orderby
246          * @global string $order
247          * @param array $plugin_a
248          * @param array $plugin_b
249          * @return int
250          */
251         public function _order_callback( $plugin_a, $plugin_b ) {
252                 global $orderby, $order;
253
254                 $a = $plugin_a[$orderby];
255                 $b = $plugin_b[$orderby];
256
257                 if ( $a == $b )
258                         return 0;
259
260                 if ( 'DESC' == $order ) {
261                         return strcasecmp( $b, $a );
262                 } else {
263                         return strcasecmp( $a, $b );
264                 }
265         }
266
267         /**
268          *
269          * @global array $plugins
270          */
271         public function no_items() {
272                 global $plugins;
273
274                 if ( !empty( $plugins['all'] ) )
275                         _e( 'No plugins found.' );
276                 else
277                         _e( 'You do not appear to have any plugins available at this time.' );
278         }
279
280         /**
281          *
282          * @global string $status
283          * @return array
284          */
285         public function get_columns() {
286                 global $status;
287
288                 return array(
289                         'cb'          => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '',
290                         'name'        => __( 'Plugin' ),
291                         'description' => __( 'Description' ),
292                 );
293         }
294
295         /**
296          * @return array
297          */
298         protected function get_sortable_columns() {
299                 return array();
300         }
301
302         /**
303          *
304          * @global array $totals
305          * @global string $status
306          * @return array
307          */
308         protected function get_views() {
309                 global $totals, $status;
310
311                 $status_links = array();
312                 foreach ( $totals as $type => $count ) {
313                         if ( !$count )
314                                 continue;
315
316                         switch ( $type ) {
317                                 case 'all':
318                                         $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' );
319                                         break;
320                                 case 'active':
321                                         $text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count );
322                                         break;
323                                 case 'recently_activated':
324                                         $text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count );
325                                         break;
326                                 case 'inactive':
327                                         $text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count );
328                                         break;
329                                 case 'mustuse':
330                                         $text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count );
331                                         break;
332                                 case 'dropins':
333                                         $text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count );
334                                         break;
335                                 case 'upgrade':
336                                         $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count );
337                                         break;
338                         }
339
340                         if ( 'search' != $type ) {
341                                 $status_links[$type] = sprintf( "<a href='%s' %s>%s</a>",
342                                         add_query_arg('plugin_status', $type, 'plugins.php'),
343                                         ( $type == $status ) ? ' class="current"' : '',
344                                         sprintf( $text, number_format_i18n( $count ) )
345                                         );
346                         }
347                 }
348
349                 return $status_links;
350         }
351
352         /**
353          *
354          * @global string $status
355          * @return array
356          */
357         protected function get_bulk_actions() {
358                 global $status;
359
360                 $actions = array();
361
362                 if ( 'active' != $status )
363                         $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' );
364
365                 if ( 'inactive' != $status && 'recent' != $status )
366                         $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' );
367
368                 if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) {
369                         if ( current_user_can( 'update_plugins' ) )
370                                 $actions['update-selected'] = __( 'Update' );
371                         if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) )
372                                 $actions['delete-selected'] = __( 'Delete' );
373                 }
374
375                 return $actions;
376         }
377
378         /**
379          * @global string $status
380          * @param string $which
381          */
382         public function bulk_actions( $which = '' ) {
383                 global $status;
384
385                 if ( in_array( $status, array( 'mustuse', 'dropins' ) ) )
386                         return;
387
388                 parent::bulk_actions( $which );
389         }
390
391         /**
392          * @global string $status
393          * @param string $which
394          */
395         protected function extra_tablenav( $which ) {
396                 global $status;
397
398                 if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) )
399                         return;
400
401                 echo '<div class="alignleft actions">';
402
403                 if ( ! $this->screen->in_admin( 'network' ) && 'recently_activated' == $status )
404                         submit_button( __( 'Clear List' ), 'button', 'clear-recent-list', false );
405                 elseif ( 'top' == $which && 'mustuse' == $status )
406                         echo '<p>' . sprintf( __( 'Files in the <code>%s</code> directory are executed automatically.' ), str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) ) . '</p>';
407                 elseif ( 'top' == $which && 'dropins' == $status )
408                         echo '<p>' . sprintf( __( 'Drop-ins are advanced plugins in the <code>%s</code> directory that replace WordPress functionality when present.' ), str_replace( ABSPATH, '', WP_CONTENT_DIR ) ) . '</p>';
409
410                 echo '</div>';
411         }
412
413         /**
414          * @return string
415          */
416         public function current_action() {
417                 if ( isset($_POST['clear-recent-list']) )
418                         return 'clear-recent-list';
419
420                 return parent::current_action();
421         }
422
423         /**
424          *
425          * @global string $status
426          */
427         public function display_rows() {
428                 global $status;
429
430                 if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) )
431                         return;
432
433                 foreach ( $this->items as $plugin_file => $plugin_data )
434                         $this->single_row( array( $plugin_file, $plugin_data ) );
435         }
436
437         /**
438          * @global string $status
439          * @global int $page
440          * @global string $s
441          * @global array $totals
442          *
443          * @param array $item
444          */
445         public function single_row( $item ) {
446                 global $status, $page, $s, $totals;
447
448                 list( $plugin_file, $plugin_data ) = $item;
449                 $context = $status;
450                 $screen = $this->screen;
451
452                 // Pre-order.
453                 $actions = array(
454                         'deactivate' => '',
455                         'activate' => '',
456                         'details' => '',
457                         'edit' => '',
458                         'delete' => '',
459                 );
460
461                 if ( 'mustuse' == $context ) {
462                         $is_active = true;
463                 } elseif ( 'dropins' == $context ) {
464                         $dropins = _get_dropins();
465                         $plugin_name = $plugin_file;
466                         if ( $plugin_file != $plugin_data['Name'] )
467                                 $plugin_name .= '<br/>' . $plugin_data['Name'];
468                         if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant
469                                 $is_active = true;
470                                 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
471                         } elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true
472                                 $is_active = true;
473                                 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
474                         } else {
475                                 $is_active = false;
476                                 $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __('Inactive:') . '</span></strong> ' . sprintf( __( 'Requires <code>%s</code> in <code>wp-config.php</code>.' ), "define('" . $dropins[ $plugin_file ][1] . "', true);" ) . '</p>';
477                         }
478                         if ( $plugin_data['Description'] )
479                                 $description .= '<p>' . $plugin_data['Description'] . '</p>';
480                 } else {
481                         if ( $screen->in_admin( 'network' ) )
482                                 $is_active = is_plugin_active_for_network( $plugin_file );
483                         else
484                                 $is_active = is_plugin_active( $plugin_file );
485
486                         if ( $screen->in_admin( 'network' ) ) {
487                                 if ( $is_active ) {
488                                         if ( current_user_can( 'manage_network_plugins' ) ) {
489                                                 /* translators: %s: plugin name */
490                                                 $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( __( 'Network deactivate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Deactivate' ) . '</a>';
491                                                 }
492                                 } else {
493                                         if ( current_user_can( 'manage_network_plugins' ) ) {
494                                                 /* translators: %s: plugin name */
495                                                 $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Network Activate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Activate' ) . '</a>';
496                                         }
497                                         if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) {
498                                                 /* translators: %s: plugin name */
499                                                 $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( __( 'Delete %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
500                                         }
501                                 }
502                         } else {
503                                 if ( $is_active ) {
504                                         /* translators: %s: plugin name */
505                                         $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( __( 'Deactivate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>';
506                                 } else {
507                                         /* translators: %s: plugin name */
508                                         $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Activate %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Activate' ) . '</a>';
509
510                                         if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) {
511                                                 /* translators: %s: plugin name */
512                                                 $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&amp;checked[]=' . $plugin_file . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( __( 'Delete %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>';
513                                         }
514                                 } // end if $is_active
515
516                          } // end if $screen->in_admin( 'network' )
517
518                         if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can( 'edit_plugins' ) && is_writable( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {
519                                 /* translators: %s: plugin name */
520                                 $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Edit %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Edit' ) . '</a>';
521                         }
522                 } // end if $context
523
524                 $prefix = $screen->in_admin( 'network' ) ? 'network_admin_' : '';
525
526                 /**
527                  * Filter the action links displayed for each plugin in the Plugins list table.
528                  *
529                  * The dynamic portion of the hook name, `$prefix`, refers to the context the
530                  * action links are displayed in. The 'network_admin_' prefix is used if the
531                  * current screen is the Network plugins list table. The prefix is empty ('')
532                  * if the current screen is the site plugins list table.
533                  *
534                  * The default action links for the Network plugins list table include
535                  * 'Network Activate', 'Network Deactivate', 'Edit', and 'Delete'.
536                  *
537                  * The default action links for the site plugins list table include
538                  * 'Activate', 'Deactivate', and 'Edit', for a network site, and
539                  * 'Activate', 'Deactivate', 'Edit', and 'Delete' for a single site.
540                  *
541                  * @since 2.5.0
542                  *
543                  * @param array  $actions     An array of plugin action links.
544                  * @param string $plugin_file Path to the plugin file.
545                  * @param array  $plugin_data An array of plugin data.
546                  * @param string $context     The plugin context. Defaults are 'All', 'Active',
547                  *                            'Inactive', 'Recently Activated', 'Upgrade',
548                  *                            'Must-Use', 'Drop-ins', 'Search'.
549                  */
550                 $actions = apply_filters( $prefix . 'plugin_action_links', array_filter( $actions ), $plugin_file, $plugin_data, $context );
551
552                 /**
553                  * Filter the list of action links displayed for a specific plugin.
554                  *
555                  * The first dynamic portion of the hook name, $prefix, refers to the context
556                  * the action links are displayed in. The 'network_admin_' prefix is used if the
557                  * current screen is the Network plugins list table. The prefix is empty ('')
558                  * if the current screen is the site plugins list table.
559                  *
560                  * The second dynamic portion of the hook name, $plugin_file, refers to the path
561                  * to the plugin file, relative to the plugins directory.
562                  *
563                  * @since 2.7.0
564                  *
565                  * @param array  $actions     An array of plugin action links.
566                  * @param string $plugin_file Path to the plugin file.
567                  * @param array  $plugin_data An array of plugin data.
568                  * @param string $context     The plugin context. Defaults are 'All', 'Active',
569                  *                            'Inactive', 'Recently Activated', 'Upgrade',
570                  *                            'Must-Use', 'Drop-ins', 'Search'.
571                  */
572                 $actions = apply_filters( $prefix . "plugin_action_links_$plugin_file", $actions, $plugin_file, $plugin_data, $context );
573
574                 $class = $is_active ? 'active' : 'inactive';
575                 $checkbox_id =  "checkbox_" . md5($plugin_data['Name']);
576                 if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) {
577                         $checkbox = '';
578                 } else {
579                         $checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . "</label>"
580                                 . "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' />";
581                 }
582                 if ( 'dropins' != $context ) {
583                         $description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : '&nbsp;' ) . '</p>';
584                         $plugin_name = $plugin_data['Name'];
585                 }
586
587                 $id = sanitize_title( $plugin_name );
588                 if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) )
589                         $class .= ' update';
590
591                 $plugin_slug = ( isset( $plugin_data['slug'] ) ) ? $plugin_data['slug'] : '';
592                 printf( "<tr id='%s' class='%s' data-slug='%s'>",
593                         $id,
594                         $class,
595                         $plugin_slug
596                 );
597
598                 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
599
600                 foreach ( $columns as $column_name => $column_display_name ) {
601                         $extra_classes = '';
602                         if ( in_array( $column_name, $hidden ) ) {
603                                 $extra_classes = ' hidden';
604                         }
605
606                         switch ( $column_name ) {
607                                 case 'cb':
608                                         echo "<th scope='row' class='check-column'>$checkbox</th>";
609                                         break;
610                                 case 'name':
611                                         echo "<td class='plugin-title column-primary'><strong>$plugin_name</strong>";
612                                         echo $this->row_actions( $actions, true );
613                                         echo "</td>";
614                                         break;
615                                 case 'description':
616                                         $classes = 'column-description desc';
617
618                                         echo "<td class='$classes{$extra_classes}'>
619                                                 <div class='plugin-description'>$description</div>
620                                                 <div class='$class second plugin-version-author-uri'>";
621
622                                         $plugin_meta = array();
623                                         if ( !empty( $plugin_data['Version'] ) )
624                                                 $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] );
625                                         if ( !empty( $plugin_data['Author'] ) ) {
626                                                 $author = $plugin_data['Author'];
627                                                 if ( !empty( $plugin_data['AuthorURI'] ) )
628                                                         $author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
629                                                 $plugin_meta[] = sprintf( __( 'By %s' ), $author );
630                                         }
631
632                                         // Details link using API info, if available
633                                         if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) {
634                                                 $plugin_meta[] = sprintf( '<a href="%s" class="thickbox" aria-label="%s" data-title="%s">%s</a>',
635                                                         esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] .
636                                                                 '&TB_iframe=true&width=600&height=550' ) ),
637                                                         esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ),
638                                                         esc_attr( $plugin_name ),
639                                                         __( 'View details' )
640                                                 );
641                                         } elseif ( ! empty( $plugin_data['PluginURI'] ) ) {
642                                                 $plugin_meta[] = sprintf( '<a href="%s">%s</a>',
643                                                         esc_url( $plugin_data['PluginURI'] ),
644                                                         __( 'Visit plugin site' )
645                                                 );
646                                         }
647
648                                         /**
649                                          * Filter the array of row meta for each plugin in the Plugins list table.
650                                          *
651                                          * @since 2.8.0
652                                          *
653                                          * @param array  $plugin_meta An array of the plugin's metadata,
654                                          *                            including the version, author,
655                                          *                            author URI, and plugin URI.
656                                          * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
657                                          * @param array  $plugin_data An array of plugin data.
658                                          * @param string $status      Status of the plugin. Defaults are 'All', 'Active',
659                                          *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
660                                          *                            'Drop-ins', 'Search'.
661                                          */
662                                         $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status );
663                                         echo implode( ' | ', $plugin_meta );
664
665                                         echo "</div></td>";
666                                         break;
667                                 default:
668                                         $classes = "$column_name column-$column_name$class";
669
670                                         echo "<td class='$classes{$extra_classes}'>";
671
672                                         /**
673                                          * Fires inside each custom column of the Plugins list table.
674                                          *
675                                          * @since 3.1.0
676                                          *
677                                          * @param string $column_name Name of the column.
678                                          * @param string $plugin_file Path to the plugin file.
679                                          * @param array  $plugin_data An array of plugin data.
680                                          */
681                                         do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data );
682
683                                         echo "</td>";
684                         }
685                 }
686
687                 echo "</tr>";
688
689                 /**
690                  * Fires after each row in the Plugins list table.
691                  *
692                  * @since 2.3.0
693                  *
694                  * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
695                  * @param array  $plugin_data An array of plugin data.
696                  * @param string $status      Status of the plugin. Defaults are 'All', 'Active',
697                  *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
698                  *                            'Drop-ins', 'Search'.
699                  */
700                 do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status );
701
702                 /**
703                  * Fires after each specific row in the Plugins list table.
704                  *
705                  * The dynamic portion of the hook name, `$plugin_file`, refers to the path
706                  * to the plugin file, relative to the plugins directory.
707                  *
708                  * @since 2.7.0
709                  *
710                  * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
711                  * @param array  $plugin_data An array of plugin data.
712                  * @param string $status      Status of the plugin. Defaults are 'All', 'Active',
713                  *                            'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use',
714                  *                            'Drop-ins', 'Search'.
715                  */
716                 do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status );
717         }
718
719         /**
720          * Gets the name of the primary column for this specific list table.
721          *
722          * @since 4.3.0
723          * @access protected
724          *
725          * @return string Unalterable name for the primary column, in this case, 'name'.
726          */
727         protected function get_primary_column_name() {
728                 return 'name';
729         }
730 }