author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
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 { |
|
16 | 19 |
/** |
20 |
* Whether to show the auto-updates UI. |
|
21 |
* |
|
22 |
* @since 5.5.0 |
|
23 |
* |
|
24 |
* @var bool True if auto-updates UI is to be shown, false otherwise. |
|
25 |
*/ |
|
26 |
protected $show_autoupdates = true; |
|
0 | 27 |
|
5 | 28 |
/** |
29 |
* Constructor. |
|
30 |
* |
|
31 |
* @since 3.1.0 |
|
32 |
* |
|
33 |
* @see WP_List_Table::__construct() for more information on default arguments. |
|
34 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
* @global int $page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* |
5 | 38 |
* @param array $args An associative array of arguments. |
39 |
*/ |
|
40 |
public function __construct( $args = array() ) { |
|
0 | 41 |
global $status, $page; |
42 |
||
9 | 43 |
parent::__construct( |
44 |
array( |
|
45 |
'plural' => 'plugins', |
|
46 |
'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
47 |
) |
|
48 |
); |
|
0 | 49 |
|
16 | 50 |
$allowed_statuses = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled' ); |
51 |
||
0 | 52 |
$status = 'all'; |
16 | 53 |
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], $allowed_statuses, true ) ) { |
0 | 54 |
$status = $_REQUEST['plugin_status']; |
9 | 55 |
} |
0 | 56 |
|
9 | 57 |
if ( isset( $_REQUEST['s'] ) ) { |
58 |
$_SERVER['REQUEST_URI'] = add_query_arg( 's', wp_unslash( $_REQUEST['s'] ) ); |
|
59 |
} |
|
0 | 60 |
|
61 |
$page = $this->get_pagenum(); |
|
16 | 62 |
|
63 |
$this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'plugin' ) |
|
64 |
&& current_user_can( 'update_plugins' ) |
|
65 |
&& ( ! is_multisite() || $this->screen->in_admin( 'network' ) ) |
|
66 |
&& ! in_array( $status, array( 'mustuse', 'dropins' ), true ); |
|
0 | 67 |
} |
68 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
*/ |
5 | 72 |
protected function get_table_classes() { |
0 | 73 |
return array( 'widefat', $this->_args['plural'] ); |
74 |
} |
|
75 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
*/ |
5 | 79 |
public function ajax_user_can() { |
9 | 80 |
return current_user_can( 'activate_plugins' ); |
0 | 81 |
} |
82 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
* @global array $plugins |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
* @global int $page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
* @global string $orderby |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
* @global string $order |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
* @global string $s |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
*/ |
5 | 92 |
public function prepare_items() { |
0 | 93 |
global $status, $plugins, $totals, $page, $orderby, $order, $s; |
94 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
wp_reset_vars( array( 'orderby', 'order' ) ); |
0 | 96 |
|
5 | 97 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
* Filters the full array of plugins to list in the Plugins list table. |
5 | 99 |
* |
100 |
* @since 3.0.0 |
|
101 |
* |
|
102 |
* @see get_plugins() |
|
103 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
* @param array $all_plugins An array of plugins to display in the list table. |
5 | 105 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
$all_plugins = apply_filters( 'all_plugins', get_plugins() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
|
0 | 108 |
$plugins = array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
'all' => $all_plugins, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
'search' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
'active' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
'inactive' => array(), |
0 | 113 |
'recently_activated' => array(), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
'upgrade' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
'mustuse' => array(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
'dropins' => array(), |
9 | 117 |
'paused' => array(), |
0 | 118 |
); |
16 | 119 |
if ( $this->show_autoupdates ) { |
120 |
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); |
|
121 |
||
122 |
$plugins['auto-update-enabled'] = array(); |
|
123 |
$plugins['auto-update-disabled'] = array(); |
|
124 |
} |
|
0 | 125 |
|
126 |
$screen = $this->screen; |
|
127 |
||
128 |
if ( ! is_multisite() || ( $screen->in_admin( 'network' ) && current_user_can( 'manage_network_plugins' ) ) ) { |
|
5 | 129 |
|
130 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
* Filters whether to display the advanced plugins list table. |
5 | 132 |
* |
133 |
* There are two types of advanced plugins - must-use and drop-ins - |
|
134 |
* which can be used in a single site or Multisite network. |
|
135 |
* |
|
136 |
* The $type parameter allows you to differentiate between the type of advanced |
|
137 |
* plugins to filter the display of. Contexts include 'mustuse' and 'dropins'. |
|
138 |
* |
|
139 |
* @since 3.0.0 |
|
140 |
* |
|
141 |
* @param bool $show Whether to show the advanced plugins for the specified |
|
142 |
* plugin type. Default true. |
|
143 |
* @param string $type The plugin type. Accepts 'mustuse', 'dropins'. |
|
144 |
*/ |
|
145 |
if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) { |
|
0 | 146 |
$plugins['mustuse'] = get_mu_plugins(); |
5 | 147 |
} |
148 |
||
149 |
/** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */ |
|
9 | 150 |
if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) { |
0 | 151 |
$plugins['dropins'] = get_dropins(); |
9 | 152 |
} |
0 | 153 |
|
154 |
if ( current_user_can( 'update_plugins' ) ) { |
|
155 |
$current = get_site_transient( 'update_plugins' ); |
|
156 |
foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { |
|
157 |
if ( isset( $current->response[ $plugin_file ] ) ) { |
|
158 |
$plugins['all'][ $plugin_file ]['update'] = true; |
|
9 | 159 |
$plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ]; |
0 | 160 |
} |
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
if ( ! $screen->in_admin( 'network' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
$show = current_user_can( 'manage_network_plugins' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
* 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
|
169 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
* 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
|
171 |
* "Network: true" in the plugin header). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
* 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
|
174 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
* @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
|
178 |
* user can manage network plugins (ie. a Super Admin). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
$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
|
181 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
if ( $screen->in_admin( 'network' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
$recently_activated = get_site_option( 'recently_activated', array() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
} else { |
0 | 186 |
$recently_activated = get_option( 'recently_activated', array() ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
} |
0 | 188 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
foreach ( $recently_activated as $key => $time ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
if ( $time + WEEK_IN_SECONDS < time() ) { |
9 | 191 |
unset( $recently_activated[ $key ] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
if ( $screen->in_admin( 'network' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
update_site_option( 'recently_activated', $recently_activated ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
} else { |
0 | 198 |
update_option( 'recently_activated', $recently_activated ); |
199 |
} |
|
200 |
||
5 | 201 |
$plugin_info = get_site_transient( 'update_plugins' ); |
202 |
||
0 | 203 |
foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { |
5 | 204 |
// Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide. |
205 |
if ( isset( $plugin_info->response[ $plugin_file ] ) ) { |
|
16 | 206 |
$plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], array( 'update-supported' => true ), $plugin_data ); |
5 | 207 |
} elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) { |
16 | 208 |
$plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], array( 'update-supported' => true ), $plugin_data ); |
209 |
} elseif ( empty( $plugin_data['update-supported'] ) ) { |
|
210 |
$plugin_data['update-supported'] = false; |
|
5 | 211 |
} |
212 |
||
16 | 213 |
/* |
214 |
* Create the payload that's used for the auto_update_plugin filter. |
|
215 |
* This is the same data contained within $plugin_info->(response|no_update) however |
|
216 |
* not all plugins will be contained in those keys, this avoids unexpected warnings. |
|
217 |
*/ |
|
218 |
$filter_payload = array( |
|
219 |
'id' => $plugin_file, |
|
220 |
'slug' => '', |
|
221 |
'plugin' => $plugin_file, |
|
222 |
'new_version' => '', |
|
223 |
'url' => '', |
|
224 |
'package' => '', |
|
225 |
'icons' => array(), |
|
226 |
'banners' => array(), |
|
227 |
'banners_rtl' => array(), |
|
228 |
'tested' => '', |
|
229 |
'requires_php' => '', |
|
230 |
'compatibility' => new stdClass(), |
|
231 |
); |
|
232 |
||
18 | 233 |
$filter_payload = (object) wp_parse_args( $plugin_data, $filter_payload ); |
234 |
||
235 |
$auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, $filter_payload ); |
|
16 | 236 |
|
237 |
if ( ! is_null( $auto_update_forced ) ) { |
|
238 |
$plugin_data['auto-update-forced'] = $auto_update_forced; |
|
239 |
} |
|
240 |
||
241 |
$plugins['all'][ $plugin_file ] = $plugin_data; |
|
242 |
// Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade. |
|
243 |
if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { |
|
244 |
$plugins['upgrade'][ $plugin_file ] = $plugin_data; |
|
245 |
} |
|
246 |
||
247 |
// Filter into individual sections. |
|
5 | 248 |
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
|
249 |
if ( $show_network_active ) { |
16 | 250 |
// On the non-network screen, show inactive network-only plugins if allowed. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
$plugins['inactive'][ $plugin_file ] = $plugin_data; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
} else { |
16 | 253 |
// On the non-network screen, filter out network-only plugins as long as they're not individually active. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
unset( $plugins['all'][ $plugin_file ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
} |
0 | 256 |
} 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
|
257 |
if ( $show_network_active ) { |
16 | 258 |
// On the non-network screen, show network-active plugins if allowed. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
$plugins['active'][ $plugin_file ] = $plugin_data; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
} else { |
16 | 261 |
// On the non-network screen, filter out network-active plugins. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
unset( $plugins['all'][ $plugin_file ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
} |
0 | 264 |
} elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) ) |
265 |
|| ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) { |
|
16 | 266 |
// On the non-network screen, populate the active list with plugins that are individually activated. |
267 |
// On the network admin screen, populate the active list with plugins that are network-activated. |
|
0 | 268 |
$plugins['active'][ $plugin_file ] = $plugin_data; |
9 | 269 |
|
270 |
if ( ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ) ) { |
|
271 |
$plugins['paused'][ $plugin_file ] = $plugin_data; |
|
272 |
} |
|
0 | 273 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
if ( isset( $recently_activated[ $plugin_file ] ) ) { |
16 | 275 |
// Populate the recently activated list with plugins that have been recently activated. |
0 | 276 |
$plugins['recently_activated'][ $plugin_file ] = $plugin_data; |
5 | 277 |
} |
16 | 278 |
// Populate the inactive list with plugins that aren't activated. |
0 | 279 |
$plugins['inactive'][ $plugin_file ] = $plugin_data; |
280 |
} |
|
16 | 281 |
|
282 |
if ( $this->show_autoupdates ) { |
|
283 |
$enabled = in_array( $plugin_file, $auto_updates, true ) && $plugin_data['update-supported']; |
|
284 |
if ( isset( $plugin_data['auto-update-forced'] ) ) { |
|
285 |
$enabled = (bool) $plugin_data['auto-update-forced']; |
|
286 |
} |
|
287 |
||
288 |
if ( $enabled ) { |
|
289 |
$plugins['auto-update-enabled'][ $plugin_file ] = $plugin_data; |
|
290 |
} else { |
|
291 |
$plugins['auto-update-disabled'][ $plugin_file ] = $plugin_data; |
|
292 |
} |
|
293 |
} |
|
0 | 294 |
} |
295 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
296 |
if ( strlen( $s ) ) { |
9 | 297 |
$status = 'search'; |
0 | 298 |
$plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) ); |
299 |
} |
|
300 |
||
301 |
$totals = array(); |
|
9 | 302 |
foreach ( $plugins as $type => $list ) { |
0 | 303 |
$totals[ $type ] = count( $list ); |
9 | 304 |
} |
0 | 305 |
|
16 | 306 |
if ( empty( $plugins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) { |
0 | 307 |
$status = 'all'; |
9 | 308 |
} |
0 | 309 |
|
310 |
$this->items = array(); |
|
311 |
foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) { |
|
16 | 312 |
// Translate, don't apply markup, sanitize HTML. |
9 | 313 |
$this->items[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true ); |
0 | 314 |
} |
315 |
||
316 |
$total_this_page = $totals[ $status ]; |
|
317 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
$js_plugins = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
foreach ( $plugins as $key => $list ) { |
18 | 320 |
$js_plugins[ $key ] = array_keys( $list ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
|
9 | 323 |
wp_localize_script( |
324 |
'updates', |
|
325 |
'_wpUpdatesItemCounts', |
|
326 |
array( |
|
327 |
'plugins' => $js_plugins, |
|
328 |
'totals' => wp_get_update_data(), |
|
329 |
) |
|
330 |
); |
|
7
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 |
if ( ! $orderby ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
$orderby = 'Name'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
} else { |
0 | 335 |
$orderby = ucfirst( $orderby ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
} |
0 | 337 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
$order = strtoupper( $order ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
uasort( $this->items, array( $this, '_order_callback' ) ); |
0 | 341 |
|
342 |
$plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 ); |
|
343 |
||
344 |
$start = ( $page - 1 ) * $plugins_per_page; |
|
345 |
||
9 | 346 |
if ( $total_this_page > $plugins_per_page ) { |
0 | 347 |
$this->items = array_slice( $this->items, $start, $plugins_per_page ); |
9 | 348 |
} |
0 | 349 |
|
9 | 350 |
$this->set_pagination_args( |
351 |
array( |
|
352 |
'total_items' => $total_this_page, |
|
353 |
'per_page' => $plugins_per_page, |
|
354 |
) |
|
355 |
); |
|
0 | 356 |
} |
357 |
||
5 | 358 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
* @global string $s URL encoded search term. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
* |
5 | 361 |
* @param array $plugin |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
* @return bool |
5 | 363 |
*/ |
364 |
public function _search_callback( $plugin ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
global $s; |
0 | 366 |
|
5 | 367 |
foreach ( $plugin as $value ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
if ( is_string( $value ) && false !== stripos( strip_tags( $value ), urldecode( $s ) ) ) { |
0 | 369 |
return true; |
5 | 370 |
} |
371 |
} |
|
0 | 372 |
|
373 |
return false; |
|
374 |
} |
|
375 |
||
5 | 376 |
/** |
377 |
* @global string $orderby |
|
378 |
* @global string $order |
|
379 |
* @param array $plugin_a |
|
380 |
* @param array $plugin_b |
|
381 |
* @return int |
|
382 |
*/ |
|
383 |
public function _order_callback( $plugin_a, $plugin_b ) { |
|
0 | 384 |
global $orderby, $order; |
385 |
||
9 | 386 |
$a = $plugin_a[ $orderby ]; |
387 |
$b = $plugin_b[ $orderby ]; |
|
0 | 388 |
|
18 | 389 |
if ( $a === $b ) { |
0 | 390 |
return 0; |
9 | 391 |
} |
0 | 392 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
if ( 'DESC' === $order ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
return strcasecmp( $b, $a ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
return strcasecmp( $a, $b ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
} |
0 | 398 |
} |
399 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
* @global array $plugins |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
*/ |
5 | 403 |
public function no_items() { |
0 | 404 |
global $plugins; |
405 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
if ( ! empty( $_REQUEST['s'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
$s = esc_html( wp_unslash( $_REQUEST['s'] ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
|
16 | 409 |
/* translators: %s: Plugin search term. */ |
18 | 410 |
printf( __( 'No plugins found for: %s.' ), '<strong>' . $s . '</strong>' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
// 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
|
413 |
if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
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
|
415 |
} |
9 | 416 |
} elseif ( ! empty( $plugins['all'] ) ) { |
0 | 417 |
_e( 'No plugins found.' ); |
9 | 418 |
} else { |
16 | 419 |
_e( 'No plugins are currently available.' ); |
9 | 420 |
} |
0 | 421 |
} |
422 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
* Displays the search box. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
* @param string $text The 'submit' button label. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
* @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
|
430 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
public function search_box( $text, $input_id ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
$input_id = $input_id . '-search-input'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
if ( ! empty( $_REQUEST['orderby'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
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
|
440 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
if ( ! empty( $_REQUEST['order'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
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
|
443 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
<p class="search-box"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label> |
18 | 447 |
<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...' ); ?>" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
<?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
|
449 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
*/ |
5 | 457 |
public function get_columns() { |
0 | 458 |
global $status; |
459 |
||
16 | 460 |
$columns = array( |
461 |
'cb' => ! in_array( $status, array( 'mustuse', 'dropins' ), true ) ? '<input type="checkbox" />' : '', |
|
0 | 462 |
'name' => __( 'Plugin' ), |
463 |
'description' => __( 'Description' ), |
|
464 |
); |
|
16 | 465 |
|
466 |
if ( $this->show_autoupdates ) { |
|
467 |
$columns['auto-updates'] = __( 'Automatic Updates' ); |
|
468 |
} |
|
469 |
||
470 |
return $columns; |
|
0 | 471 |
} |
472 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
473 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
475 |
*/ |
5 | 476 |
protected function get_sortable_columns() { |
0 | 477 |
return array(); |
478 |
} |
|
479 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
*/ |
5 | 485 |
protected function get_views() { |
0 | 486 |
global $totals, $status; |
487 |
||
488 |
$status_links = array(); |
|
489 |
foreach ( $totals as $type => $count ) { |
|
9 | 490 |
if ( ! $count ) { |
0 | 491 |
continue; |
9 | 492 |
} |
0 | 493 |
|
494 |
switch ( $type ) { |
|
495 |
case 'all': |
|
16 | 496 |
/* translators: %s: Number of plugins. */ |
497 |
$text = _nx( |
|
498 |
'All <span class="count">(%s)</span>', |
|
499 |
'All <span class="count">(%s)</span>', |
|
500 |
$count, |
|
501 |
'plugins' |
|
502 |
); |
|
0 | 503 |
break; |
504 |
case 'active': |
|
16 | 505 |
/* translators: %s: Number of plugins. */ |
506 |
$text = _n( |
|
507 |
'Active <span class="count">(%s)</span>', |
|
508 |
'Active <span class="count">(%s)</span>', |
|
509 |
$count |
|
510 |
); |
|
0 | 511 |
break; |
512 |
case 'recently_activated': |
|
16 | 513 |
/* translators: %s: Number of plugins. */ |
514 |
$text = _n( |
|
515 |
'Recently Active <span class="count">(%s)</span>', |
|
516 |
'Recently Active <span class="count">(%s)</span>', |
|
517 |
$count |
|
518 |
); |
|
0 | 519 |
break; |
520 |
case 'inactive': |
|
16 | 521 |
/* translators: %s: Number of plugins. */ |
522 |
$text = _n( |
|
523 |
'Inactive <span class="count">(%s)</span>', |
|
524 |
'Inactive <span class="count">(%s)</span>', |
|
525 |
$count |
|
526 |
); |
|
0 | 527 |
break; |
528 |
case 'mustuse': |
|
16 | 529 |
/* translators: %s: Number of plugins. */ |
530 |
$text = _n( |
|
531 |
'Must-Use <span class="count">(%s)</span>', |
|
532 |
'Must-Use <span class="count">(%s)</span>', |
|
533 |
$count |
|
534 |
); |
|
0 | 535 |
break; |
536 |
case 'dropins': |
|
16 | 537 |
/* translators: %s: Number of plugins. */ |
538 |
$text = _n( |
|
539 |
'Drop-in <span class="count">(%s)</span>', |
|
540 |
'Drop-ins <span class="count">(%s)</span>', |
|
541 |
$count |
|
542 |
); |
|
9 | 543 |
break; |
544 |
case 'paused': |
|
16 | 545 |
/* translators: %s: Number of plugins. */ |
546 |
$text = _n( |
|
547 |
'Paused <span class="count">(%s)</span>', |
|
548 |
'Paused <span class="count">(%s)</span>', |
|
549 |
$count |
|
550 |
); |
|
0 | 551 |
break; |
552 |
case 'upgrade': |
|
16 | 553 |
/* translators: %s: Number of plugins. */ |
554 |
$text = _n( |
|
555 |
'Update Available <span class="count">(%s)</span>', |
|
556 |
'Update Available <span class="count">(%s)</span>', |
|
557 |
$count |
|
558 |
); |
|
559 |
break; |
|
560 |
case 'auto-update-enabled': |
|
561 |
/* translators: %s: Number of plugins. */ |
|
562 |
$text = _n( |
|
563 |
'Auto-updates Enabled <span class="count">(%s)</span>', |
|
564 |
'Auto-updates Enabled <span class="count">(%s)</span>', |
|
565 |
$count |
|
566 |
); |
|
567 |
break; |
|
568 |
case 'auto-update-disabled': |
|
569 |
/* translators: %s: Number of plugins. */ |
|
570 |
$text = _n( |
|
571 |
'Auto-updates Disabled <span class="count">(%s)</span>', |
|
572 |
'Auto-updates Disabled <span class="count">(%s)</span>', |
|
573 |
$count |
|
574 |
); |
|
0 | 575 |
break; |
576 |
} |
|
577 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
if ( 'search' !== $type ) { |
9 | 579 |
$status_links[ $type ] = sprintf( |
580 |
"<a href='%s'%s>%s</a>", |
|
581 |
add_query_arg( 'plugin_status', $type, 'plugins.php' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
( $type === $status ) ? ' class="current" aria-current="page"' : '', |
0 | 583 |
sprintf( $text, number_format_i18n( $count ) ) |
9 | 584 |
); |
0 | 585 |
} |
586 |
} |
|
587 |
||
588 |
return $status_links; |
|
589 |
} |
|
590 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
591 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
592 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
593 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
*/ |
5 | 595 |
protected function get_bulk_actions() { |
0 | 596 |
global $status; |
597 |
||
598 |
$actions = array(); |
|
599 |
||
16 | 600 |
if ( 'active' !== $status ) { |
0 | 601 |
$actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' ); |
9 | 602 |
} |
0 | 603 |
|
16 | 604 |
if ( 'inactive' !== $status && 'recent' !== $status ) { |
0 | 605 |
$actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' ); |
9 | 606 |
} |
0 | 607 |
|
9 | 608 |
if ( ! is_multisite() || $this->screen->in_admin( 'network' ) ) { |
609 |
if ( current_user_can( 'update_plugins' ) ) { |
|
0 | 610 |
$actions['update-selected'] = __( 'Update' ); |
9 | 611 |
} |
16 | 612 |
|
613 |
if ( current_user_can( 'delete_plugins' ) && ( 'active' !== $status ) ) { |
|
0 | 614 |
$actions['delete-selected'] = __( 'Delete' ); |
9 | 615 |
} |
16 | 616 |
|
617 |
if ( $this->show_autoupdates ) { |
|
618 |
if ( 'auto-update-enabled' !== $status ) { |
|
619 |
$actions['enable-auto-update-selected'] = __( 'Enable Auto-updates' ); |
|
620 |
} |
|
621 |
if ( 'auto-update-disabled' !== $status ) { |
|
622 |
$actions['disable-auto-update-selected'] = __( 'Disable Auto-updates' ); |
|
623 |
} |
|
624 |
} |
|
0 | 625 |
} |
626 |
||
627 |
return $actions; |
|
628 |
} |
|
629 |
||
5 | 630 |
/** |
631 |
* @global string $status |
|
632 |
* @param string $which |
|
633 |
*/ |
|
634 |
public function bulk_actions( $which = '' ) { |
|
0 | 635 |
global $status; |
636 |
||
16 | 637 |
if ( in_array( $status, array( 'mustuse', 'dropins' ), true ) ) { |
0 | 638 |
return; |
9 | 639 |
} |
0 | 640 |
|
5 | 641 |
parent::bulk_actions( $which ); |
0 | 642 |
} |
643 |
||
5 | 644 |
/** |
645 |
* @global string $status |
|
646 |
* @param string $which |
|
647 |
*/ |
|
648 |
protected function extra_tablenav( $which ) { |
|
0 | 649 |
global $status; |
650 |
||
16 | 651 |
if ( ! in_array( $status, array( 'recently_activated', 'mustuse', 'dropins' ), true ) ) { |
0 | 652 |
return; |
9 | 653 |
} |
0 | 654 |
|
655 |
echo '<div class="alignleft actions">'; |
|
656 |
||
16 | 657 |
if ( 'recently_activated' === $status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
submit_button( __( 'Clear List' ), '', 'clear-recent-list', false ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
} elseif ( 'top' === $which && 'mustuse' === $status ) { |
9 | 660 |
echo '<p>' . sprintf( |
16 | 661 |
/* translators: %s: mu-plugins directory name. */ |
9 | 662 |
__( 'Files in the %s directory are executed automatically.' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
'<code>' . str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) . '</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
) . '</p>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
} elseif ( 'top' === $which && 'dropins' === $status ) { |
9 | 666 |
echo '<p>' . sprintf( |
16 | 667 |
/* translators: %s: wp-content directory name. */ |
668 |
__( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
) . '</p>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
} |
0 | 672 |
echo '</div>'; |
673 |
} |
|
674 |
||
7
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 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
*/ |
5 | 678 |
public function current_action() { |
9 | 679 |
if ( isset( $_POST['clear-recent-list'] ) ) { |
0 | 680 |
return 'clear-recent-list'; |
9 | 681 |
} |
0 | 682 |
|
683 |
return parent::current_action(); |
|
684 |
} |
|
685 |
||
7
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 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
688 |
*/ |
5 | 689 |
public function display_rows() { |
0 | 690 |
global $status; |
691 |
||
16 | 692 |
if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ), true ) ) { |
0 | 693 |
return; |
9 | 694 |
} |
0 | 695 |
|
9 | 696 |
foreach ( $this->items as $plugin_file => $plugin_data ) { |
0 | 697 |
$this->single_row( array( $plugin_file, $plugin_data ) ); |
9 | 698 |
} |
0 | 699 |
} |
700 |
||
5 | 701 |
/** |
702 |
* @global string $status |
|
703 |
* @global int $page |
|
704 |
* @global string $s |
|
705 |
* @global array $totals |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
* |
5 | 707 |
* @param array $item |
708 |
*/ |
|
709 |
public function single_row( $item ) { |
|
0 | 710 |
global $status, $page, $s, $totals; |
16 | 711 |
static $plugin_id_attrs = array(); |
0 | 712 |
|
713 |
list( $plugin_file, $plugin_data ) = $item; |
|
16 | 714 |
|
715 |
$plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_data['Name'] ); |
|
716 |
$plugin_id_attr = $plugin_slug; |
|
717 |
||
718 |
// Ensure the ID attribute is unique. |
|
719 |
$suffix = 2; |
|
720 |
while ( in_array( $plugin_id_attr, $plugin_id_attrs, true ) ) { |
|
721 |
$plugin_id_attr = "$plugin_slug-$suffix"; |
|
722 |
$suffix++; |
|
723 |
} |
|
724 |
||
725 |
$plugin_id_attrs[] = $plugin_id_attr; |
|
726 |
||
727 |
$context = $status; |
|
728 |
$screen = $this->screen; |
|
0 | 729 |
|
5 | 730 |
// Pre-order. |
0 | 731 |
$actions = array( |
732 |
'deactivate' => '', |
|
9 | 733 |
'activate' => '', |
734 |
'details' => '', |
|
735 |
'delete' => '', |
|
0 | 736 |
); |
737 |
||
16 | 738 |
// Do not restrict by default. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
$restrict_network_active = false; |
9 | 740 |
$restrict_network_only = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
|
19 | 742 |
$requires_php = isset( $plugin_data['RequiresPHP'] ) ? $plugin_data['RequiresPHP'] : null; |
743 |
$requires_wp = isset( $plugin_data['RequiresWP'] ) ? $plugin_data['RequiresWP'] : null; |
|
744 |
||
745 |
$compatible_php = is_php_version_compatible( $requires_php ); |
|
746 |
$compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
747 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
748 |
if ( 'mustuse' === $context ) { |
0 | 749 |
$is_active = true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
} elseif ( 'dropins' === $context ) { |
9 | 751 |
$dropins = _get_dropins(); |
0 | 752 |
$plugin_name = $plugin_file; |
18 | 753 |
|
754 |
if ( $plugin_file !== $plugin_data['Name'] ) { |
|
0 | 755 |
$plugin_name .= '<br/>' . $plugin_data['Name']; |
9 | 756 |
} |
18 | 757 |
|
16 | 758 |
if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant. |
9 | 759 |
$is_active = true; |
0 | 760 |
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; |
16 | 761 |
} elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true. |
9 | 762 |
$is_active = true; |
0 | 763 |
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; |
764 |
} else { |
|
9 | 765 |
$is_active = false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
$description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __( 'Inactive:' ) . '</span></strong> ' . |
9 | 767 |
sprintf( |
16 | 768 |
/* translators: 1: Drop-in constant name, 2: wp-config.php */ |
9 | 769 |
__( 'Requires %1$s in %2$s file.' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
"<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>", |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
'<code>wp-config.php</code>' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
) . '</p>'; |
0 | 773 |
} |
18 | 774 |
|
9 | 775 |
if ( $plugin_data['Description'] ) { |
0 | 776 |
$description .= '<p>' . $plugin_data['Description'] . '</p>'; |
9 | 777 |
} |
0 | 778 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
if ( $screen->in_admin( 'network' ) ) { |
0 | 780 |
$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
|
781 |
} else { |
9 | 782 |
$is_active = is_plugin_active( $plugin_file ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
783 |
$restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) ); |
9 | 784 |
$restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
785 |
} |
0 | 786 |
|
787 |
if ( $screen->in_admin( 'network' ) ) { |
|
788 |
if ( $is_active ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
789 |
if ( current_user_can( 'manage_network_plugins' ) ) { |
16 | 790 |
$actions['deactivate'] = sprintf( |
791 |
'<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', |
|
792 |
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ), |
|
793 |
esc_attr( $plugin_id_attr ), |
|
794 |
/* translators: %s: Plugin name. */ |
|
795 |
esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ), |
|
796 |
__( 'Network Deactivate' ) |
|
797 |
); |
|
9 | 798 |
} |
0 | 799 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
800 |
if ( current_user_can( 'manage_network_plugins' ) ) { |
19 | 801 |
if ( $compatible_php && $compatible_wp ) { |
802 |
$actions['activate'] = sprintf( |
|
803 |
'<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', |
|
804 |
wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ), |
|
805 |
esc_attr( $plugin_id_attr ), |
|
806 |
/* translators: %s: Plugin name. */ |
|
807 |
esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ), |
|
808 |
__( 'Network Activate' ) |
|
809 |
); |
|
810 |
} else { |
|
811 |
$actions['activate'] = sprintf( |
|
812 |
'<span>%s</span>', |
|
813 |
_x( 'Cannot Activate', 'plugin' ) |
|
814 |
); |
|
815 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
816 |
} |
16 | 817 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
818 |
if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) { |
16 | 819 |
$actions['delete'] = sprintf( |
820 |
'<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', |
|
821 |
wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ), |
|
822 |
esc_attr( $plugin_id_attr ), |
|
823 |
/* translators: %s: Plugin name. */ |
|
824 |
esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ), |
|
825 |
__( 'Delete' ) |
|
826 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
827 |
} |
0 | 828 |
} |
829 |
} else { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
830 |
if ( $restrict_network_active ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
831 |
$actions = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
832 |
'network_active' => __( 'Network Active' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
833 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
834 |
} elseif ( $restrict_network_only ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
835 |
$actions = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
'network_only' => __( 'Network Only' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
837 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
838 |
} elseif ( $is_active ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
839 |
if ( current_user_can( 'deactivate_plugin', $plugin_file ) ) { |
16 | 840 |
$actions['deactivate'] = sprintf( |
841 |
'<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>', |
|
842 |
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ), |
|
843 |
esc_attr( $plugin_id_attr ), |
|
844 |
/* translators: %s: Plugin name. */ |
|
845 |
esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ), |
|
846 |
__( 'Deactivate' ) |
|
847 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
848 |
} |
16 | 849 |
|
9 | 850 |
if ( current_user_can( 'resume_plugin', $plugin_file ) && is_plugin_paused( $plugin_file ) ) { |
16 | 851 |
$actions['resume'] = sprintf( |
852 |
'<a href="%s" id="resume-%s" class="resume-link" aria-label="%s">%s</a>', |
|
853 |
wp_nonce_url( 'plugins.php?action=resume&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'resume-plugin_' . $plugin_file ), |
|
854 |
esc_attr( $plugin_id_attr ), |
|
855 |
/* translators: %s: Plugin name. */ |
|
856 |
esc_attr( sprintf( _x( 'Resume %s', 'plugin' ), $plugin_data['Name'] ) ), |
|
857 |
__( 'Resume' ) |
|
858 |
); |
|
9 | 859 |
} |
0 | 860 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
861 |
if ( current_user_can( 'activate_plugin', $plugin_file ) ) { |
19 | 862 |
if ( $compatible_php && $compatible_wp ) { |
863 |
$actions['activate'] = sprintf( |
|
864 |
'<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>', |
|
865 |
wp_nonce_url( 'plugins.php?action=activate&plugin=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ), |
|
866 |
esc_attr( $plugin_id_attr ), |
|
867 |
/* translators: %s: Plugin name. */ |
|
868 |
esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ), |
|
869 |
__( 'Activate' ) |
|
870 |
); |
|
871 |
} else { |
|
872 |
$actions['activate'] = sprintf( |
|
873 |
'<span>%s</span>', |
|
874 |
_x( 'Cannot Activate', 'plugin' ) |
|
875 |
); |
|
876 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
} |
0 | 878 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) { |
16 | 880 |
$actions['delete'] = sprintf( |
881 |
'<a href="%s" id="delete-%s" class="delete" aria-label="%s">%s</a>', |
|
882 |
wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . urlencode( $plugin_file ) . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ), |
|
883 |
esc_attr( $plugin_id_attr ), |
|
884 |
/* translators: %s: Plugin name. */ |
|
885 |
esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ), |
|
886 |
__( 'Delete' ) |
|
887 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
} |
16 | 889 |
} // End if $is_active. |
890 |
} // End if $screen->in_admin( 'network' ). |
|
891 |
} // End if $context. |
|
0 | 892 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
893 |
$actions = array_filter( $actions ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
894 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
895 |
if ( $screen->in_admin( 'network' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
896 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
897 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
* 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
|
899 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
* |
19 | 902 |
* @param string[] $actions An array of plugin action links. By default this can include |
903 |
* 'activate', 'deactivate', and 'delete'. |
|
9 | 904 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 905 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
906 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
907 |
* of possible values. |
|
908 |
* @param string $context The plugin context. By default this can include 'all', |
|
909 |
* 'active', 'inactive', 'recently_activated', 'upgrade', |
|
910 |
* 'mustuse', 'dropins', and 'search'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
$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
|
913 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
* 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
|
916 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
* 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
|
918 |
* to the plugin file, relative to the plugins directory. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
919 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
920 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
* |
19 | 922 |
* @param string[] $actions An array of plugin action links. By default this can include |
923 |
* 'activate', 'deactivate', and 'delete'. |
|
9 | 924 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 925 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
926 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
927 |
* of possible values. |
|
928 |
* @param string $context The plugin context. By default this can include 'all', |
|
929 |
* 'active', 'inactive', 'recently_activated', 'upgrade', |
|
930 |
* 'mustuse', 'dropins', and 'search'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
932 |
$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
|
933 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
} else { |
5 | 935 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
* 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
|
938 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
* @since 2.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
940 |
* @since 2.6.0 The `$context` parameter was added. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
* @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
|
942 |
* |
19 | 943 |
* @param string[] $actions An array of plugin action links. By default this can include |
944 |
* 'activate', 'deactivate', and 'delete'. With Multisite active |
|
945 |
* this can also include 'network_active' and 'network_only' items. |
|
9 | 946 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 947 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
948 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
949 |
* of possible values. |
|
950 |
* @param string $context The plugin context. By default this can include 'all', |
|
951 |
* 'active', 'inactive', 'recently_activated', 'upgrade', |
|
952 |
* 'mustuse', 'dropins', and 'search'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
$actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); |
5 | 955 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
* 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
|
958 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
959 |
* 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
|
960 |
* to the plugin file, relative to the plugins directory. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
961 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
* @since 2.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
963 |
* @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
|
964 |
* |
19 | 965 |
* @param string[] $actions An array of plugin action links. By default this can include |
966 |
* 'activate', 'deactivate', and 'delete'. With Multisite active |
|
967 |
* this can also include 'network_active' and 'network_only' items. |
|
9 | 968 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 969 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
970 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
971 |
* of possible values. |
|
972 |
* @param string $context The plugin context. By default this can include 'all', |
|
973 |
* 'active', 'inactive', 'recently_activated', 'upgrade', |
|
974 |
* 'mustuse', 'dropins', and 'search'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
976 |
$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
|
977 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
978 |
} |
0 | 979 |
|
19 | 980 |
$class = $is_active ? 'active' : 'inactive'; |
981 |
$checkbox_id = 'checkbox_' . md5( $plugin_file ); |
|
18 | 982 |
|
16 | 983 |
if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ), true ) || ! $compatible_php ) { |
0 | 984 |
$checkbox = ''; |
985 |
} else { |
|
16 | 986 |
$checkbox = sprintf( |
987 |
'<label class="screen-reader-text" for="%1$s">%2$s</label>' . |
|
988 |
'<input type="checkbox" name="checked[]" value="%3$s" id="%1$s" />', |
|
989 |
$checkbox_id, |
|
990 |
/* translators: %s: Plugin name. */ |
|
991 |
sprintf( __( 'Select %s' ), $plugin_data['Name'] ), |
|
992 |
esc_attr( $plugin_file ) |
|
993 |
); |
|
0 | 994 |
} |
18 | 995 |
|
16 | 996 |
if ( 'dropins' !== $context ) { |
0 | 997 |
$description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : ' ' ) . '</p>'; |
998 |
$plugin_name = $plugin_data['Name']; |
|
999 |
} |
|
1000 |
||
19 | 1001 |
if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) |
1002 |
|| ! $compatible_php || ! $compatible_wp |
|
1003 |
) { |
|
0 | 1004 |
$class .= ' update'; |
9 | 1005 |
} |
1006 |
||
1007 |
$paused = ! $screen->in_admin( 'network' ) && is_plugin_paused( $plugin_file ); |
|
1008 |
||
1009 |
if ( $paused ) { |
|
1010 |
$class .= ' paused'; |
|
1011 |
} |
|
0 | 1012 |
|
16 | 1013 |
if ( is_uninstallable_plugin( $plugin_file ) ) { |
1014 |
$class .= ' is-uninstallable'; |
|
1015 |
} |
|
1016 |
||
9 | 1017 |
printf( |
1018 |
'<tr class="%s" data-slug="%s" data-plugin="%s">', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
esc_attr( $class ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
esc_attr( $plugin_slug ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1021 |
esc_attr( $plugin_file ) |
5 | 1022 |
); |
0 | 1023 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
0 | 1025 |
|
16 | 1026 |
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); |
1027 |
$available_updates = get_site_transient( 'update_plugins' ); |
|
1028 |
||
0 | 1029 |
foreach ( $columns as $column_name => $column_display_name ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1030 |
$extra_classes = ''; |
16 | 1031 |
if ( in_array( $column_name, $hidden, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1032 |
$extra_classes = ' hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
} |
0 | 1034 |
|
1035 |
switch ( $column_name ) { |
|
1036 |
case 'cb': |
|
1037 |
echo "<th scope='row' class='check-column'>$checkbox</th>"; |
|
1038 |
break; |
|
1039 |
case 'name': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
echo "<td class='plugin-title column-primary'><strong>$plugin_name</strong>"; |
0 | 1041 |
echo $this->row_actions( $actions, true ); |
9 | 1042 |
echo '</td>'; |
0 | 1043 |
break; |
1044 |
case 'description': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1045 |
$classes = 'column-description desc'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
echo "<td class='$classes{$extra_classes}'> |
0 | 1048 |
<div class='plugin-description'>$description</div> |
1049 |
<div class='$class second plugin-version-author-uri'>"; |
|
1050 |
||
1051 |
$plugin_meta = array(); |
|
9 | 1052 |
if ( ! empty( $plugin_data['Version'] ) ) { |
16 | 1053 |
/* translators: %s: Plugin version number. */ |
0 | 1054 |
$plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); |
9 | 1055 |
} |
1056 |
if ( ! empty( $plugin_data['Author'] ) ) { |
|
0 | 1057 |
$author = $plugin_data['Author']; |
9 | 1058 |
if ( ! empty( $plugin_data['AuthorURI'] ) ) { |
5 | 1059 |
$author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
9 | 1060 |
} |
16 | 1061 |
/* translators: %s: Plugin author name. */ |
0 | 1062 |
$plugin_meta[] = sprintf( __( 'By %s' ), $author ); |
1063 |
} |
|
1064 |
||
16 | 1065 |
// Details link using API info, if available. |
5 | 1066 |
if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) { |
9 | 1067 |
$plugin_meta[] = sprintf( |
1068 |
'<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', |
|
1069 |
esc_url( |
|
1070 |
network_admin_url( |
|
1071 |
'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] . |
|
1072 |
'&TB_iframe=true&width=600&height=550' |
|
1073 |
) |
|
1074 |
), |
|
16 | 1075 |
/* translators: %s: Plugin name. */ |
5 | 1076 |
esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ), |
1077 |
esc_attr( $plugin_name ), |
|
1078 |
__( 'View details' ) |
|
1079 |
); |
|
1080 |
} elseif ( ! empty( $plugin_data['PluginURI'] ) ) { |
|
19 | 1081 |
/* translators: %s: Plugin name. */ |
1082 |
$aria_label = sprintf( __( 'Visit plugin site for %s' ), $plugin_name ); |
|
1083 |
||
9 | 1084 |
$plugin_meta[] = sprintf( |
19 | 1085 |
'<a href="%s" aria-label="%s">%s</a>', |
5 | 1086 |
esc_url( $plugin_data['PluginURI'] ), |
19 | 1087 |
esc_attr( $aria_label ), |
5 | 1088 |
__( 'Visit plugin site' ) |
1089 |
); |
|
1090 |
} |
|
1091 |
||
1092 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
* Filters the array of row meta for each plugin in the Plugins list table. |
5 | 1094 |
* |
1095 |
* @since 2.8.0 |
|
1096 |
* |
|
16 | 1097 |
* @param string[] $plugin_meta An array of the plugin's metadata, including |
1098 |
* the version, author, author URI, and plugin URI. |
|
9 | 1099 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 1100 |
* @param array $plugin_data { |
1101 |
* An array of plugin data. |
|
1102 |
* |
|
1103 |
* @type string $id Plugin ID, e.g. `w.org/plugins/[plugin-name]`. |
|
1104 |
* @type string $slug Plugin slug. |
|
1105 |
* @type string $plugin Plugin basename. |
|
1106 |
* @type string $new_version New plugin version. |
|
1107 |
* @type string $url Plugin URL. |
|
1108 |
* @type string $package Plugin update package URL. |
|
1109 |
* @type string[] $icons An array of plugin icon URLs. |
|
1110 |
* @type string[] $banners An array of plugin banner URLs. |
|
1111 |
* @type string[] $banners_rtl An array of plugin RTL banner URLs. |
|
1112 |
* @type string $requires The version of WordPress which the plugin requires. |
|
1113 |
* @type string $tested The version of WordPress the plugin is tested against. |
|
1114 |
* @type string $requires_php The version of PHP which the plugin requires. |
|
1115 |
* @type string $upgrade_notice The upgrade notice for the new plugin version. |
|
1116 |
* @type bool $update-supported Whether the plugin supports updates. |
|
1117 |
* @type string $Name The human-readable name of the plugin. |
|
1118 |
* @type string $PluginURI Plugin URI. |
|
1119 |
* @type string $Version Plugin version. |
|
1120 |
* @type string $Description Plugin description. |
|
1121 |
* @type string $Author Plugin author. |
|
1122 |
* @type string $AuthorURI Plugin author URI. |
|
1123 |
* @type string $TextDomain Plugin textdomain. |
|
1124 |
* @type string $DomainPath Relative path to the plugin's .mo file(s). |
|
1125 |
* @type bool $Network Whether the plugin can only be activated network-wide. |
|
1126 |
* @type string $RequiresWP The version of WordPress which the plugin requires. |
|
1127 |
* @type string $RequiresPHP The version of PHP which the plugin requires. |
|
1128 |
* @type string $UpdateURI ID of the plugin for update purposes, should be a URI. |
|
1129 |
* @type string $Title The human-readable title of the plugin. |
|
1130 |
* @type string $AuthorName Plugin author's name. |
|
1131 |
* @type bool $update Whether there's an available update. Default null. |
|
1132 |
* } |
|
16 | 1133 |
* @param string $status Status filter currently applied to the plugin list. Possible |
1134 |
* values are: 'all', 'active', 'inactive', 'recently_activated', |
|
1135 |
* 'upgrade', 'mustuse', 'dropins', 'search', 'paused', |
|
1136 |
* 'auto-update-enabled', 'auto-update-disabled'. |
|
5 | 1137 |
*/ |
0 | 1138 |
$plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status ); |
16 | 1139 |
|
0 | 1140 |
echo implode( ' | ', $plugin_meta ); |
1141 |
||
9 | 1142 |
echo '</div>'; |
1143 |
||
1144 |
if ( $paused ) { |
|
1145 |
$notice_text = __( 'This plugin failed to load properly and is paused during recovery mode.' ); |
|
1146 |
||
1147 |
printf( '<p><span class="dashicons dashicons-warning"></span> <strong>%s</strong></p>', $notice_text ); |
|
1148 |
||
1149 |
$error = wp_get_plugin_error( $plugin_file ); |
|
1150 |
||
1151 |
if ( false !== $error ) { |
|
1152 |
printf( '<div class="error-display"><p>%s</p></div>', wp_get_extension_error_description( $error ) ); |
|
1153 |
} |
|
1154 |
} |
|
1155 |
||
1156 |
echo '</td>'; |
|
0 | 1157 |
break; |
16 | 1158 |
case 'auto-updates': |
1159 |
if ( ! $this->show_autoupdates ) { |
|
1160 |
break; |
|
1161 |
} |
|
1162 |
||
1163 |
echo "<td class='column-auto-updates{$extra_classes}'>"; |
|
1164 |
||
1165 |
$html = array(); |
|
1166 |
||
1167 |
if ( isset( $plugin_data['auto-update-forced'] ) ) { |
|
1168 |
if ( $plugin_data['auto-update-forced'] ) { |
|
1169 |
// Forced on. |
|
1170 |
$text = __( 'Auto-updates enabled' ); |
|
1171 |
} else { |
|
1172 |
$text = __( 'Auto-updates disabled' ); |
|
1173 |
} |
|
1174 |
$action = 'unavailable'; |
|
1175 |
$time_class = ' hidden'; |
|
1176 |
} elseif ( empty( $plugin_data['update-supported'] ) ) { |
|
1177 |
$text = ''; |
|
1178 |
$action = 'unavailable'; |
|
1179 |
$time_class = ' hidden'; |
|
1180 |
} elseif ( in_array( $plugin_file, $auto_updates, true ) ) { |
|
1181 |
$text = __( 'Disable auto-updates' ); |
|
1182 |
$action = 'disable'; |
|
1183 |
$time_class = ''; |
|
1184 |
} else { |
|
1185 |
$text = __( 'Enable auto-updates' ); |
|
1186 |
$action = 'enable'; |
|
1187 |
$time_class = ' hidden'; |
|
1188 |
} |
|
1189 |
||
1190 |
$query_args = array( |
|
1191 |
'action' => "{$action}-auto-update", |
|
1192 |
'plugin' => $plugin_file, |
|
1193 |
'paged' => $page, |
|
1194 |
'plugin_status' => $status, |
|
1195 |
); |
|
1196 |
||
1197 |
$url = add_query_arg( $query_args, 'plugins.php' ); |
|
1198 |
||
18 | 1199 |
if ( 'unavailable' === $action ) { |
16 | 1200 |
$html[] = '<span class="label">' . $text . '</span>'; |
1201 |
} else { |
|
1202 |
$html[] = sprintf( |
|
1203 |
'<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', |
|
1204 |
wp_nonce_url( $url, 'updates' ), |
|
1205 |
$action |
|
1206 |
); |
|
1207 |
||
1208 |
$html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; |
|
1209 |
$html[] = '<span class="label">' . $text . '</span>'; |
|
1210 |
$html[] = '</a>'; |
|
1211 |
} |
|
1212 |
||
1213 |
if ( ! empty( $plugin_data['update'] ) ) { |
|
1214 |
$html[] = sprintf( |
|
1215 |
'<div class="auto-update-time%s">%s</div>', |
|
1216 |
$time_class, |
|
1217 |
wp_get_auto_update_message() |
|
1218 |
); |
|
1219 |
} |
|
1220 |
||
1221 |
$html = implode( '', $html ); |
|
1222 |
||
1223 |
/** |
|
1224 |
* Filters the HTML of the auto-updates setting for each plugin in the Plugins list table. |
|
1225 |
* |
|
1226 |
* @since 5.5.0 |
|
1227 |
* |
|
19 | 1228 |
* @param string $html The HTML of the plugin's auto-update column content, |
1229 |
* including toggle auto-update action links and |
|
1230 |
* time to next update. |
|
16 | 1231 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 1232 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
1233 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
1234 |
* of possible values. |
|
16 | 1235 |
*/ |
1236 |
echo apply_filters( 'plugin_auto_update_setting_html', $html, $plugin_file, $plugin_data ); |
|
1237 |
||
1238 |
echo '<div class="notice notice-error notice-alt inline hidden"><p></p></div>'; |
|
1239 |
echo '</td>'; |
|
1240 |
||
1241 |
break; |
|
0 | 1242 |
default: |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
$classes = "$column_name column-$column_name $class"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
echo "<td class='$classes{$extra_classes}'>"; |
5 | 1246 |
|
1247 |
/** |
|
1248 |
* Fires inside each custom column of the Plugins list table. |
|
1249 |
* |
|
1250 |
* @since 3.1.0 |
|
1251 |
* |
|
1252 |
* @param string $column_name Name of the column. |
|
9 | 1253 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 1254 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
1255 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
1256 |
* of possible values. |
|
5 | 1257 |
*/ |
0 | 1258 |
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
|
1259 |
|
9 | 1260 |
echo '</td>'; |
0 | 1261 |
} |
1262 |
} |
|
1263 |
||
9 | 1264 |
echo '</tr>'; |
0 | 1265 |
|
19 | 1266 |
if ( ! $compatible_php || ! $compatible_wp ) { |
1267 |
printf( |
|
1268 |
'<tr class="plugin-update-tr">' . |
|
1269 |
'<td colspan="%s" class="plugin-update colspanchange">' . |
|
1270 |
'<div class="update-message notice inline notice-error notice-alt"><p>', |
|
1271 |
esc_attr( $this->get_column_count() ) |
|
1272 |
); |
|
1273 |
||
1274 |
if ( ! $compatible_php && ! $compatible_wp ) { |
|
1275 |
_e( 'This plugin does not work with your versions of WordPress and PHP.' ); |
|
1276 |
if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
|
1277 |
printf( |
|
1278 |
/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
|
1279 |
' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
|
1280 |
self_admin_url( 'update-core.php' ), |
|
1281 |
esc_url( wp_get_update_php_url() ) |
|
1282 |
); |
|
1283 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
1284 |
} elseif ( current_user_can( 'update_core' ) ) { |
|
1285 |
printf( |
|
1286 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
1287 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
|
1288 |
self_admin_url( 'update-core.php' ) |
|
1289 |
); |
|
1290 |
} elseif ( current_user_can( 'update_php' ) ) { |
|
1291 |
printf( |
|
1292 |
/* translators: %s: URL to Update PHP page. */ |
|
1293 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
1294 |
esc_url( wp_get_update_php_url() ) |
|
1295 |
); |
|
1296 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
1297 |
} |
|
1298 |
} elseif ( ! $compatible_wp ) { |
|
1299 |
_e( 'This plugin does not work with your version of WordPress.' ); |
|
1300 |
if ( current_user_can( 'update_core' ) ) { |
|
1301 |
printf( |
|
1302 |
/* translators: %s: URL to WordPress Updates screen. */ |
|
1303 |
' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
|
1304 |
self_admin_url( 'update-core.php' ) |
|
1305 |
); |
|
1306 |
} |
|
1307 |
} elseif ( ! $compatible_php ) { |
|
1308 |
_e( 'This plugin does not work with your version of PHP.' ); |
|
1309 |
if ( current_user_can( 'update_php' ) ) { |
|
1310 |
printf( |
|
1311 |
/* translators: %s: URL to Update PHP page. */ |
|
1312 |
' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
|
1313 |
esc_url( wp_get_update_php_url() ) |
|
1314 |
); |
|
1315 |
wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
1316 |
} |
|
1317 |
} |
|
1318 |
||
1319 |
echo '</p></div></td></tr>'; |
|
1320 |
} |
|
1321 |
||
5 | 1322 |
/** |
1323 |
* Fires after each row in the Plugins list table. |
|
1324 |
* |
|
1325 |
* @since 2.3.0 |
|
19 | 1326 |
* @since 5.5.0 Added 'auto-update-enabled' and 'auto-update-disabled' |
1327 |
* to possible values for `$status`. |
|
5 | 1328 |
* |
9 | 1329 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 1330 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
1331 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
1332 |
* of possible values. |
|
1333 |
* @param string $status Status filter currently applied to the plugin list. |
|
1334 |
* Possible values are: 'all', 'active', 'inactive', |
|
1335 |
* 'recently_activated', 'upgrade', 'mustuse', 'dropins', |
|
1336 |
* 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled'. |
|
5 | 1337 |
*/ |
0 | 1338 |
do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status ); |
5 | 1339 |
|
1340 |
/** |
|
1341 |
* Fires after each specific row in the Plugins list table. |
|
1342 |
* |
|
1343 |
* The dynamic portion of the hook name, `$plugin_file`, refers to the path |
|
1344 |
* to the plugin file, relative to the plugins directory. |
|
1345 |
* |
|
1346 |
* @since 2.7.0 |
|
19 | 1347 |
* @since 5.5.0 Added 'auto-update-enabled' and 'auto-update-disabled' |
1348 |
* to possible values for `$status`. |
|
5 | 1349 |
* |
9 | 1350 |
* @param string $plugin_file Path to the plugin file relative to the plugins directory. |
19 | 1351 |
* @param array $plugin_data An array of plugin data. See `get_plugin_data()` |
1352 |
* and the {@see 'plugin_row_meta'} filter for the list |
|
1353 |
* of possible values. |
|
1354 |
* @param string $status Status filter currently applied to the plugin list. |
|
1355 |
* Possible values are: 'all', 'active', 'inactive', |
|
1356 |
* 'recently_activated', 'upgrade', 'mustuse', 'dropins', |
|
1357 |
* 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled'. |
|
5 | 1358 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
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
|
1360 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1362 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
* 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
|
1364 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1365 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1366 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1367 |
* @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
|
1368 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1369 |
protected function get_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1370 |
return 'name'; |
0 | 1371 |
} |
1372 |
} |