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