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