PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/df_home/static/test/portalbkd/wp-admin/includes/class-wp-plugins-list-table.php

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