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