author | ymh <ymh.work@gmail.com> |
Thu, 29 Sep 2022 08:06:27 +0200 | |
changeset 20 | 7b1b88e27a20 |
parent 19 | 3d72ae0968f4 |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* Plugins administration panel. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** WordPress Administration Bootstrap */ |
|
16 | 10 |
require_once __DIR__ . '/admin.php'; |
0 | 11 |
|
9 | 12 |
if ( ! current_user_can( 'activate_plugins' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) ); |
9 | 14 |
} |
0 | 15 |
|
9 | 16 |
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
17 |
$pagenum = $wp_list_table->get_pagenum(); |
|
0 | 18 |
|
19 |
$action = $wp_list_table->current_action(); |
|
20 |
||
9 | 21 |
$plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : ''; |
22 |
$s = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
0 | 23 |
|
24 |
// Clean up request URI from temporary args for screen options/paging uri's to work as expected. |
|
16 | 25 |
$query_args_to_remove = array( |
26 |
'error', |
|
27 |
'deleted', |
|
28 |
'activate', |
|
29 |
'activate-multi', |
|
30 |
'deactivate', |
|
31 |
'deactivate-multi', |
|
32 |
'enabled-auto-update', |
|
33 |
'disabled-auto-update', |
|
34 |
'enabled-auto-update-multi', |
|
35 |
'disabled-auto-update-multi', |
|
36 |
'_error_nonce', |
|
37 |
); |
|
38 |
||
39 |
$_SERVER['REQUEST_URI'] = remove_query_arg( $query_args_to_remove, $_SERVER['REQUEST_URI'] ); |
|
0 | 40 |
|
5 | 41 |
wp_enqueue_script( 'updates' ); |
42 |
||
0 | 43 |
if ( $action ) { |
44 |
||
45 |
switch ( $action ) { |
|
46 |
case 'activate': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
if ( ! current_user_can( 'activate_plugin', $plugin ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
} |
0 | 50 |
|
51 |
if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) { |
|
9 | 52 |
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); |
0 | 53 |
exit; |
54 |
} |
|
55 |
||
9 | 56 |
check_admin_referer( 'activate-plugin_' . $plugin ); |
0 | 57 |
|
9 | 58 |
$result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() ); |
0 | 59 |
if ( is_wp_error( $result ) ) { |
16 | 60 |
if ( 'unexpected_output' === $result->get_error_code() ) { |
9 | 61 |
$redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" ); |
62 |
wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) ); |
|
0 | 63 |
exit; |
64 |
} else { |
|
9 | 65 |
wp_die( $result ); |
0 | 66 |
} |
67 |
} |
|
68 |
||
69 |
if ( ! is_network_admin() ) { |
|
70 |
$recent = (array) get_option( 'recently_activated' ); |
|
71 |
unset( $recent[ $plugin ] ); |
|
72 |
update_option( 'recently_activated', $recent ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
$recent = (array) get_site_option( 'recently_activated' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
unset( $recent[ $plugin ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
update_site_option( 'recently_activated', $recent ); |
0 | 77 |
} |
78 |
||
16 | 79 |
if ( isset( $_GET['from'] ) && 'import' === $_GET['from'] ) { |
80 |
// Overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix. |
|
81 |
wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) ); |
|
82 |
} elseif ( isset( $_GET['from'] ) && 'press-this' === $_GET['from'] ) { |
|
9 | 83 |
wp_redirect( self_admin_url( 'press-this.php' ) ); |
0 | 84 |
} else { |
16 | 85 |
// Overrides the ?error=true one above. |
86 |
wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) ); |
|
0 | 87 |
} |
88 |
exit; |
|
5 | 89 |
|
0 | 90 |
case 'activate-selected': |
9 | 91 |
if ( ! current_user_can( 'activate_plugins' ) ) { |
92 |
wp_die( __( 'Sorry, you are not allowed to activate plugins for this site.' ) ); |
|
93 |
} |
|
0 | 94 |
|
9 | 95 |
check_admin_referer( 'bulk-plugins' ); |
0 | 96 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); |
0 | 98 |
|
99 |
if ( is_network_admin() ) { |
|
100 |
foreach ( $plugins as $i => $plugin ) { |
|
5 | 101 |
// Only activate plugins which are not already network activated. |
102 |
if ( is_plugin_active_for_network( $plugin ) ) { |
|
0 | 103 |
unset( $plugins[ $i ] ); |
5 | 104 |
} |
0 | 105 |
} |
106 |
} else { |
|
107 |
foreach ( $plugins as $i => $plugin ) { |
|
5 | 108 |
// Only activate plugins which are not already active and are not network-only when on Multisite. |
109 |
if ( is_plugin_active( $plugin ) || ( is_multisite() && is_network_only_plugin( $plugin ) ) ) { |
|
0 | 110 |
unset( $plugins[ $i ] ); |
5 | 111 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
// Only activate plugins which the user can activate. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
if ( ! current_user_can( 'activate_plugin', $plugin ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
unset( $plugins[ $i ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
} |
0 | 116 |
} |
117 |
} |
|
118 |
||
9 | 119 |
if ( empty( $plugins ) ) { |
120 |
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); |
|
0 | 121 |
exit; |
122 |
} |
|
123 |
||
9 | 124 |
activate_plugins( $plugins, self_admin_url( 'plugins.php?error=true' ), is_network_admin() ); |
0 | 125 |
|
126 |
if ( ! is_network_admin() ) { |
|
9 | 127 |
$recent = (array) get_option( 'recently_activated' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
} else { |
9 | 129 |
$recent = (array) get_site_option( 'recently_activated' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
foreach ( $plugins as $plugin ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
unset( $recent[ $plugin ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
if ( ! is_network_admin() ) { |
0 | 137 |
update_option( 'recently_activated', $recent ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
update_site_option( 'recently_activated', $recent ); |
0 | 140 |
} |
141 |
||
9 | 142 |
wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) ); |
0 | 143 |
exit; |
5 | 144 |
|
9 | 145 |
case 'update-selected': |
0 | 146 |
check_admin_referer( 'bulk-plugins' ); |
147 |
||
9 | 148 |
if ( isset( $_GET['plugins'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
$plugins = explode( ',', wp_unslash( $_GET['plugins'] ) ); |
9 | 150 |
} elseif ( isset( $_POST['checked'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
$plugins = (array) wp_unslash( $_POST['checked'] ); |
9 | 152 |
} else { |
0 | 153 |
$plugins = array(); |
9 | 154 |
} |
0 | 155 |
|
19 | 156 |
// Used in the HTML title tag. |
9 | 157 |
$title = __( 'Update Plugins' ); |
0 | 158 |
$parent_file = 'plugins.php'; |
159 |
||
5 | 160 |
wp_enqueue_script( 'updates' ); |
16 | 161 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 162 |
|
163 |
echo '<div class="wrap">'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
echo '<h1>' . esc_html( $title ) . '</h1>'; |
0 | 165 |
|
18 | 166 |
$url = self_admin_url( 'update.php?action=update-selected&plugins=' . urlencode( implode( ',', $plugins ) ) ); |
9 | 167 |
$url = wp_nonce_url( $url, 'bulk-update-plugins' ); |
0 | 168 |
|
169 |
echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>"; |
|
170 |
echo '</div>'; |
|
16 | 171 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
0 | 172 |
exit; |
5 | 173 |
|
0 | 174 |
case 'error_scrape': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
if ( ! current_user_can( 'activate_plugin', $plugin ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
} |
0 | 178 |
|
9 | 179 |
check_admin_referer( 'plugin-activation-error_' . $plugin ); |
0 | 180 |
|
9 | 181 |
$valid = validate_plugin( $plugin ); |
182 |
if ( is_wp_error( $valid ) ) { |
|
183 |
wp_die( $valid ); |
|
184 |
} |
|
0 | 185 |
|
186 |
if ( ! WP_DEBUG ) { |
|
187 |
error_reporting( E_CORE_ERROR | E_CORE_WARNING | E_COMPILE_ERROR | E_ERROR | E_WARNING | E_PARSE | E_USER_ERROR | E_USER_WARNING | E_RECOVERABLE_ERROR ); |
|
188 |
} |
|
189 |
||
16 | 190 |
ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed. |
191 |
// Go back to "sandbox" scope so we get the same errors as before. |
|
0 | 192 |
plugin_sandbox_scrape( $plugin ); |
5 | 193 |
/** This action is documented in wp-admin/includes/plugin.php */ |
194 |
do_action( "activate_{$plugin}" ); |
|
0 | 195 |
exit; |
5 | 196 |
|
0 | 197 |
case 'deactivate': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
} |
0 | 201 |
|
9 | 202 |
check_admin_referer( 'deactivate-plugin_' . $plugin ); |
0 | 203 |
|
204 |
if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) { |
|
9 | 205 |
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); |
0 | 206 |
exit; |
207 |
} |
|
208 |
||
209 |
deactivate_plugins( $plugin, false, is_network_admin() ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
210 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
if ( ! is_network_admin() ) { |
0 | 212 |
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
|
9 | 217 |
if ( headers_sent() ) { |
0 | 218 |
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />"; |
9 | 219 |
} else { |
220 |
wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) ); |
|
221 |
} |
|
0 | 222 |
exit; |
5 | 223 |
|
0 | 224 |
case 'deactivate-selected': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
if ( ! current_user_can( 'deactivate_plugins' ) ) { |
9 | 226 |
wp_die( __( 'Sorry, you are not allowed to deactivate plugins for this site.' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
227 |
} |
0 | 228 |
|
9 | 229 |
check_admin_referer( 'bulk-plugins' ); |
0 | 230 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
231 |
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); |
0 | 232 |
// Do not deactivate plugins which are already deactivated. |
233 |
if ( is_network_admin() ) { |
|
234 |
$plugins = array_filter( $plugins, 'is_plugin_active_for_network' ); |
|
235 |
} else { |
|
236 |
$plugins = array_filter( $plugins, 'is_plugin_active' ); |
|
237 |
$plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
foreach ( $plugins as $i => $plugin ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
// Only deactivate plugins which the user can deactivate. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
242 |
unset( $plugins[ $i ] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
243 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
244 |
} |
0 | 245 |
} |
9 | 246 |
if ( empty( $plugins ) ) { |
247 |
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); |
|
0 | 248 |
exit; |
249 |
} |
|
250 |
||
251 |
deactivate_plugins( $plugins, false, is_network_admin() ); |
|
252 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
$deactivated = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
foreach ( $plugins as $plugin ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
$deactivated[ $plugin ] = time(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
|
0 | 258 |
if ( ! is_network_admin() ) { |
259 |
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) ); |
0 | 262 |
} |
263 |
||
9 | 264 |
wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) ); |
0 | 265 |
exit; |
5 | 266 |
|
0 | 267 |
case 'delete-selected': |
9 | 268 |
if ( ! current_user_can( 'delete_plugins' ) ) { |
269 |
wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) ); |
|
5 | 270 |
} |
0 | 271 |
|
9 | 272 |
check_admin_referer( 'bulk-plugins' ); |
0 | 273 |
|
16 | 274 |
// $_POST = from the plugin form; $_GET = from the FTP details screen. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
$plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array(); |
0 | 276 |
if ( empty( $plugins ) ) { |
9 | 277 |
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); |
0 | 278 |
exit; |
279 |
} |
|
280 |
||
16 | 281 |
$plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete activated plugins. |
0 | 282 |
if ( empty( $plugins ) ) { |
283 |
wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) ); |
|
284 |
exit; |
|
285 |
} |
|
286 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
// Bail on all if any paths are invalid. |
16 | 288 |
// validate_file() returns truthy for invalid files. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
$invalid_plugin_files = array_filter( $plugins, 'validate_file' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
if ( $invalid_plugin_files ) { |
9 | 291 |
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
exit; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
293 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
294 |
|
16 | 295 |
require ABSPATH . 'wp-admin/update.php'; |
0 | 296 |
|
297 |
$parent_file = 'plugins.php'; |
|
298 |
||
9 | 299 |
if ( ! isset( $_REQUEST['verify-delete'] ) ) { |
300 |
wp_enqueue_script( 'jquery' ); |
|
16 | 301 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
302 |
||
0 | 303 |
?> |
16 | 304 |
<div class="wrap"> |
0 | 305 |
<?php |
16 | 306 |
|
307 |
$plugin_info = array(); |
|
308 |
$have_non_network_plugins = false; |
|
309 |
||
9 | 310 |
foreach ( (array) $plugins as $plugin ) { |
311 |
$plugin_slug = dirname( $plugin ); |
|
5 | 312 |
|
16 | 313 |
if ( '.' === $plugin_slug ) { |
314 |
$data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin ); |
|
315 |
if ( $data ) { |
|
9 | 316 |
$plugin_info[ $plugin ] = $data; |
317 |
$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); |
|
318 |
if ( ! $plugin_info[ $plugin ]['Network'] ) { |
|
319 |
$have_non_network_plugins = true; |
|
320 |
} |
|
321 |
} |
|
322 |
} else { |
|
323 |
// Get plugins list from that folder. |
|
16 | 324 |
$folder_plugins = get_plugins( '/' . $plugin_slug ); |
325 |
if ( $folder_plugins ) { |
|
9 | 326 |
foreach ( $folder_plugins as $plugin_file => $data ) { |
327 |
$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data ); |
|
328 |
$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin ); |
|
329 |
if ( ! $plugin_info[ $plugin_file ]['Network'] ) { |
|
0 | 330 |
$have_non_network_plugins = true; |
5 | 331 |
} |
0 | 332 |
} |
333 |
} |
|
334 |
} |
|
9 | 335 |
} |
16 | 336 |
|
337 |
$plugins_to_delete = count( $plugin_info ); |
|
338 |
||
0 | 339 |
?> |
16 | 340 |
<?php if ( 1 === $plugins_to_delete ) : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
<h1><?php _e( 'Delete Plugin' ); ?></h1> |
5 | 342 |
<?php if ( $have_non_network_plugins && is_network_admin() ) : ?> |
343 |
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div> |
|
344 |
<?php endif; ?> |
|
345 |
<p><?php _e( 'You are about to remove the following plugin:' ); ?></p> |
|
9 | 346 |
<?php else : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
<h1><?php _e( 'Delete Plugins' ); ?></h1> |
5 | 348 |
<?php if ( $have_non_network_plugins && is_network_admin() ) : ?> |
349 |
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div> |
|
350 |
<?php endif; ?> |
|
351 |
<p><?php _e( 'You are about to remove the following plugins:' ); ?></p> |
|
0 | 352 |
<?php endif; ?> |
353 |
<ul class="ul-disc"> |
|
354 |
<?php |
|
16 | 355 |
|
0 | 356 |
$data_to_delete = false; |
16 | 357 |
|
0 | 358 |
foreach ( $plugin_info as $plugin ) { |
359 |
if ( $plugin['is_uninstallable'] ) { |
|
16 | 360 |
/* translators: 1: Plugin name, 2: Plugin author. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
echo '<li>', sprintf( __( '%1$s by %2$s (will also <strong>delete its data</strong>)' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] . '</em>' ), '</li>'; |
0 | 362 |
$data_to_delete = true; |
363 |
} else { |
|
16 | 364 |
/* translators: 1: Plugin name, 2: Plugin author. */ |
9 | 365 |
echo '<li>', sprintf( _x( '%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>'; |
0 | 366 |
} |
367 |
} |
|
16 | 368 |
|
0 | 369 |
?> |
370 |
</ul> |
|
9 | 371 |
<p> |
372 |
<?php |
|
16 | 373 |
|
9 | 374 |
if ( $data_to_delete ) { |
16 | 375 |
_e( 'Are you sure you want to delete these files and data?' ); |
9 | 376 |
} else { |
16 | 377 |
_e( 'Are you sure you want to delete these files?' ); |
9 | 378 |
} |
16 | 379 |
|
9 | 380 |
?> |
381 |
</p> |
|
382 |
<form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;"> |
|
0 | 383 |
<input type="hidden" name="verify-delete" value="1" /> |
384 |
<input type="hidden" name="action" value="delete-selected" /> |
|
385 |
<?php |
|
16 | 386 |
|
9 | 387 |
foreach ( (array) $plugins as $plugin ) { |
388 |
echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />'; |
|
389 |
} |
|
16 | 390 |
|
0 | 391 |
?> |
9 | 392 |
<?php wp_nonce_field( 'bulk-plugins' ); ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
<?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), '', 'submit', false ); ?> |
0 | 394 |
</form> |
5 | 395 |
<?php |
16 | 396 |
|
5 | 397 |
$referer = wp_get_referer(); |
16 | 398 |
|
5 | 399 |
?> |
400 |
<form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;"> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
<?php submit_button( __( 'No, return me to the plugin list' ), '', 'submit', false ); ?> |
0 | 402 |
</form> |
16 | 403 |
</div> |
0 | 404 |
<?php |
16 | 405 |
|
406 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |
|
0 | 407 |
exit; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
$plugins_to_delete = count( $plugins ); |
16 | 410 |
} // End if verify-delete. |
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 |
$delete_result = delete_plugins( $plugins ); |
0 | 413 |
|
16 | 414 |
// Store the result in a cache rather than a URL param due to object type & length. |
415 |
set_transient( 'plugins_delete_result_' . $user_ID, $delete_result ); |
|
9 | 416 |
wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) ); |
0 | 417 |
exit; |
418 |
case 'clear-recent-list': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
if ( ! is_network_admin() ) { |
0 | 420 |
update_option( 'recently_activated', array() ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
update_site_option( 'recently_activated', array() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
} |
16 | 424 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
break; |
9 | 426 |
case 'resume': |
427 |
if ( is_multisite() ) { |
|
428 |
return; |
|
429 |
} |
|
430 |
||
431 |
if ( ! current_user_can( 'resume_plugin', $plugin ) ) { |
|
432 |
wp_die( __( 'Sorry, you are not allowed to resume this plugin.' ) ); |
|
433 |
} |
|
434 |
||
435 |
check_admin_referer( 'resume-plugin_' . $plugin ); |
|
436 |
||
437 |
$result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$s" ) ); |
|
438 |
||
439 |
if ( is_wp_error( $result ) ) { |
|
440 |
wp_die( $result ); |
|
441 |
} |
|
442 |
||
443 |
wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) ); |
|
444 |
exit; |
|
16 | 445 |
case 'enable-auto-update': |
446 |
case 'disable-auto-update': |
|
447 |
case 'enable-auto-update-selected': |
|
448 |
case 'disable-auto-update-selected': |
|
449 |
if ( ! current_user_can( 'update_plugins' ) || ! wp_is_auto_update_enabled_for_type( 'plugin' ) ) { |
|
450 |
wp_die( __( 'Sorry, you are not allowed to manage plugins automatic updates.' ) ); |
|
451 |
} |
|
9 | 452 |
|
16 | 453 |
if ( is_multisite() && ! is_network_admin() ) { |
454 |
wp_die( __( 'Please connect to your network admin to manage plugins automatic updates.' ) ); |
|
455 |
} |
|
456 |
||
457 |
$redirect = self_admin_url( "plugins.php?plugin_status={$status}&paged={$page}&s={$s}" ); |
|
458 |
||
459 |
if ( 'enable-auto-update' === $action || 'disable-auto-update' === $action ) { |
|
460 |
if ( empty( $plugin ) ) { |
|
461 |
wp_redirect( $redirect ); |
|
462 |
exit; |
|
463 |
} |
|
464 |
||
465 |
check_admin_referer( 'updates' ); |
|
466 |
} else { |
|
467 |
if ( empty( $_POST['checked'] ) ) { |
|
468 |
wp_redirect( $redirect ); |
|
469 |
exit; |
|
470 |
} |
|
471 |
||
472 |
check_admin_referer( 'bulk-plugins' ); |
|
473 |
} |
|
474 |
||
475 |
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() ); |
|
476 |
||
477 |
if ( 'enable-auto-update' === $action ) { |
|
478 |
$auto_updates[] = $plugin; |
|
479 |
$auto_updates = array_unique( $auto_updates ); |
|
480 |
$redirect = add_query_arg( array( 'enabled-auto-update' => 'true' ), $redirect ); |
|
481 |
} elseif ( 'disable-auto-update' === $action ) { |
|
482 |
$auto_updates = array_diff( $auto_updates, array( $plugin ) ); |
|
483 |
$redirect = add_query_arg( array( 'disabled-auto-update' => 'true' ), $redirect ); |
|
484 |
} else { |
|
485 |
$plugins = (array) wp_unslash( $_POST['checked'] ); |
|
486 |
||
487 |
if ( 'enable-auto-update-selected' === $action ) { |
|
488 |
$new_auto_updates = array_merge( $auto_updates, $plugins ); |
|
489 |
$new_auto_updates = array_unique( $new_auto_updates ); |
|
490 |
$query_args = array( 'enabled-auto-update-multi' => 'true' ); |
|
491 |
} else { |
|
492 |
$new_auto_updates = array_diff( $auto_updates, $plugins ); |
|
493 |
$query_args = array( 'disabled-auto-update-multi' => 'true' ); |
|
494 |
} |
|
495 |
||
496 |
// Return early if all selected plugins already have auto-updates enabled or disabled. |
|
497 |
// Must use non-strict comparison, so that array order is not treated as significant. |
|
498 |
if ( $new_auto_updates == $auto_updates ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison |
|
499 |
wp_redirect( $redirect ); |
|
500 |
exit; |
|
501 |
} |
|
502 |
||
503 |
$auto_updates = $new_auto_updates; |
|
504 |
$redirect = add_query_arg( $query_args, $redirect ); |
|
505 |
} |
|
506 |
||
507 |
/** This filter is documented in wp-admin/includes/class-wp-plugins-list-table.php */ |
|
508 |
$all_items = apply_filters( 'all_plugins', get_plugins() ); |
|
509 |
||
510 |
// Remove plugins that don't exist or have been deleted since the option was last updated. |
|
511 |
$auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) ); |
|
512 |
||
513 |
update_site_option( 'auto_update_plugins', $auto_updates ); |
|
514 |
||
515 |
wp_redirect( $redirect ); |
|
516 |
exit; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
default: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
if ( isset( $_POST['checked'] ) ) { |
9 | 519 |
check_admin_referer( 'bulk-plugins' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
|
16 | 521 |
$screen = get_current_screen()->id; |
522 |
$sendback = wp_get_referer(); |
|
523 |
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array(); |
|
524 |
||
525 |
/** This action is documented in wp-admin/edit.php */ |
|
526 |
$sendback = apply_filters( "handle_bulk_actions-{$screen}", $sendback, $action, $plugins ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
527 |
wp_safe_redirect( $sendback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
528 |
exit; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
529 |
} |
0 | 530 |
break; |
531 |
} |
|
532 |
} |
|
533 |
||
534 |
$wp_list_table->prepare_items(); |
|
535 |
||
9 | 536 |
wp_enqueue_script( 'plugin-install' ); |
0 | 537 |
add_thickbox(); |
538 |
||
5 | 539 |
add_screen_option( 'per_page', array( 'default' => 999 ) ); |
0 | 540 |
|
9 | 541 |
get_current_screen()->add_help_tab( |
542 |
array( |
|
543 |
'id' => 'overview', |
|
544 |
'title' => __( 'Overview' ), |
|
545 |
'content' => |
|
16 | 546 |
'<p>' . __( 'Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.' ) . '</p>' . |
547 |
'<p>' . __( 'The search for installed plugins will search for terms in their name, description, or author.' ) . ' <span id="live-search-desc" class="hide-if-no-js">' . __( 'The search results will be updated as you type.' ) . '</span></p>' . |
|
9 | 548 |
'<p>' . sprintf( |
16 | 549 |
/* translators: %s: WordPress Plugin Directory URL. */ |
550 |
__( 'If you would like to see more plugins to choose from, click on the “Add New” button and you will be able to browse or search for additional plugins from the <a href="%s">WordPress Plugin Directory</a>. Plugins in the WordPress Plugin Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they’re free!' ), |
|
9 | 551 |
__( 'https://wordpress.org/plugins/' ) |
552 |
) . '</p>', |
|
553 |
) |
|
554 |
); |
|
555 |
get_current_screen()->add_help_tab( |
|
556 |
array( |
|
557 |
'id' => 'compatibility-problems', |
|
558 |
'title' => __( 'Troubleshooting' ), |
|
559 |
'content' => |
|
16 | 560 |
'<p>' . __( 'Most of the time, plugins play nicely with the core of WordPress and with other plugins. Sometimes, though, a plugin’s code will get in the way of another plugin, causing compatibility issues. If your site starts doing strange things, this may be the problem. Try deactivating all your plugins and re-activating them in various combinations until you isolate which one(s) caused the issue.' ) . '</p>' . |
9 | 561 |
'<p>' . sprintf( |
16 | 562 |
/* translators: %s: WP_PLUGIN_DIR constant value. */ |
19 | 563 |
__( 'If something goes wrong with a plugin and you cannot use WordPress, delete or rename that file in the %s directory and it will be automatically deactivated.' ), |
9 | 564 |
'<code>' . WP_PLUGIN_DIR . '</code>' |
565 |
) . '</p>', |
|
566 |
) |
|
567 |
); |
|
0 | 568 |
|
16 | 569 |
$help_sidebar_autoupdates = ''; |
570 |
||
571 |
if ( current_user_can( 'update_plugins' ) && wp_is_auto_update_enabled_for_type( 'plugin' ) ) { |
|
572 |
get_current_screen()->add_help_tab( |
|
573 |
array( |
|
574 |
'id' => 'plugins-themes-auto-updates', |
|
575 |
'title' => __( 'Auto-updates' ), |
|
576 |
'content' => |
|
577 |
'<p>' . __( 'Auto-updates can be enabled or disabled for each individual plugin. Plugins with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '</p>' . |
|
578 |
'<p>' . __( 'Auto-updates are only available for plugins recognized by WordPress.org, or that include a compatible update system.' ) . '</p>' . |
|
579 |
'<p>' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '</p>', |
|
580 |
) |
|
581 |
); |
|
582 |
||
583 |
$help_sidebar_autoupdates = '<p>' . __( '<a href="https://wordpress.org/support/article/plugins-themes-auto-updates/">Learn more: Auto-updates documentation</a>' ) . '</p>'; |
|
584 |
} |
|
585 |
||
0 | 586 |
get_current_screen()->set_help_sidebar( |
9 | 587 |
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
16 | 588 |
'<p>' . __( '<a href="https://wordpress.org/support/article/managing-plugins/">Documentation on Managing Plugins</a>' ) . '</p>' . |
589 |
$help_sidebar_autoupdates . |
|
9 | 590 |
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
0 | 591 |
); |
592 |
||
9 | 593 |
get_current_screen()->set_screen_reader_content( |
594 |
array( |
|
595 |
'heading_views' => __( 'Filter plugins list' ), |
|
596 |
'heading_pagination' => __( 'Plugins list navigation' ), |
|
597 |
'heading_list' => __( 'Plugins list' ), |
|
598 |
) |
|
599 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
|
19 | 601 |
// Used in the HTML title tag. |
9 | 602 |
$title = __( 'Plugins' ); |
0 | 603 |
$parent_file = 'plugins.php'; |
604 |
||
16 | 605 |
require_once ABSPATH . 'wp-admin/admin-header.php'; |
0 | 606 |
|
607 |
$invalid = validate_active_plugins(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
if ( ! empty( $invalid ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
foreach ( $invalid as $plugin_file => $error ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
echo '<div id="message" class="error"><p>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
printf( |
16 | 612 |
/* translators: 1: Plugin file, 2: Error message. */ |
613 |
__( 'The plugin %1$s has been deactivated due to an error: %2$s' ), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
'<code>' . esc_html( $plugin_file ) . '</code>', |
19 | 615 |
esc_html( $error->get_error_message() ) |
9 | 616 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
echo '</p></div>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
} |
0 | 620 |
|
9 | 621 |
if ( isset( $_GET['error'] ) ) : |
0 | 622 |
|
9 | 623 |
if ( isset( $_GET['main'] ) ) { |
0 | 624 |
$errmsg = __( 'You cannot delete a plugin while it is active on the main site.' ); |
9 | 625 |
} elseif ( isset( $_GET['charsout'] ) ) { |
16 | 626 |
$errmsg = sprintf( |
627 |
/* translators: %d: Number of characters. */ |
|
9 | 628 |
_n( |
629 |
'The plugin generated %d character of <strong>unexpected output</strong> during activation.', |
|
630 |
'The plugin generated %d characters of <strong>unexpected output</strong> during activation.', |
|
631 |
$_GET['charsout'] |
|
632 |
), |
|
633 |
$_GET['charsout'] |
|
634 |
); |
|
635 |
$errmsg .= ' ' . __( 'If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.' ); |
|
636 |
} elseif ( 'resuming' === $_GET['error'] ) { |
|
637 |
$errmsg = __( 'Plugin could not be resumed because it triggered a <strong>fatal error</strong>.' ); |
|
638 |
} else { |
|
639 |
$errmsg = __( 'Plugin could not be activated because it triggered a <strong>fatal error</strong>.' ); |
|
640 |
} |
|
16 | 641 |
|
0 | 642 |
?> |
5 | 643 |
<div id="message" class="error"><p><?php echo $errmsg; ?></p> |
0 | 644 |
<?php |
16 | 645 |
|
18 | 646 |
if ( ! isset( $_GET['main'] ) && ! isset( $_GET['charsout'] ) |
647 |
&& isset( $_GET['_error_nonce'] ) && wp_verify_nonce( $_GET['_error_nonce'], 'plugin-activation-error_' . $plugin ) |
|
648 |
) { |
|
9 | 649 |
$iframe_url = add_query_arg( |
650 |
array( |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
'action' => 'error_scrape', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
'plugin' => urlencode( $plugin ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
'_wpnonce' => urlencode( $_GET['_error_nonce'] ), |
9 | 654 |
), |
655 |
admin_url( 'plugins.php' ) |
|
656 |
); |
|
16 | 657 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
?> |
16 | 659 |
<iframe style="border:0" width="100%" height="70px" src="<?php echo esc_url( $iframe_url ); ?>"></iframe> |
9 | 660 |
<?php |
661 |
} |
|
16 | 662 |
|
0 | 663 |
?> |
664 |
</div> |
|
9 | 665 |
<?php |
666 |
elseif ( isset( $_GET['deleted'] ) ) : |
|
16 | 667 |
$delete_result = get_transient( 'plugins_delete_result_' . $user_ID ); |
668 |
// Delete it once we're done. |
|
669 |
delete_transient( 'plugins_delete_result_' . $user_ID ); |
|
0 | 670 |
|
9 | 671 |
if ( is_wp_error( $delete_result ) ) : |
672 |
?> |
|
16 | 673 |
<div id="message" class="error notice is-dismissible"> |
674 |
<p> |
|
675 |
<?php |
|
676 |
printf( |
|
677 |
/* translators: %s: Error message. */ |
|
678 |
__( 'Plugin could not be deleted due to an error: %s' ), |
|
19 | 679 |
esc_html( $delete_result->get_error_message() ) |
16 | 680 |
); |
681 |
?> |
|
682 |
</p> |
|
683 |
</div> |
|
0 | 684 |
<?php else : ?> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
685 |
<div id="message" class="updated notice is-dismissible"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
<p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
<?php |
16 | 688 |
if ( 1 === (int) $_GET['deleted'] ) { |
689 |
_e( 'The selected plugin has been deleted.' ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
690 |
} else { |
16 | 691 |
_e( 'The selected plugins have been deleted.' ); |
7
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 |
</p> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
</div> |
16 | 696 |
<?php endif; ?> |
9 | 697 |
<?php elseif ( isset( $_GET['activate'] ) ) : ?> |
16 | 698 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin activated.' ); ?></p></div> |
9 | 699 |
<?php elseif ( isset( $_GET['activate-multi'] ) ) : ?> |
16 | 700 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins activated.' ); ?></p></div> |
9 | 701 |
<?php elseif ( isset( $_GET['deactivate'] ) ) : ?> |
16 | 702 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin deactivated.' ); ?></p></div> |
9 | 703 |
<?php elseif ( isset( $_GET['deactivate-multi'] ) ) : ?> |
16 | 704 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins deactivated.' ); ?></p></div> |
705 |
<?php elseif ( 'update-selected' === $action ) : ?> |
|
9 | 706 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'All selected plugins are up to date.' ); ?></p></div> |
707 |
<?php elseif ( isset( $_GET['resume'] ) ) : ?> |
|
16 | 708 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin resumed.' ); ?></p></div> |
709 |
<?php elseif ( isset( $_GET['enabled-auto-update'] ) ) : ?> |
|
710 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin will be auto-updated.' ); ?></p></div> |
|
711 |
<?php elseif ( isset( $_GET['disabled-auto-update'] ) ) : ?> |
|
712 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Plugin will no longer be auto-updated.' ); ?></p></div> |
|
713 |
<?php elseif ( isset( $_GET['enabled-auto-update-multi'] ) ) : ?> |
|
714 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins will be auto-updated.' ); ?></p></div> |
|
715 |
<?php elseif ( isset( $_GET['disabled-auto-update-multi'] ) ) : ?> |
|
716 |
<div id="message" class="updated notice is-dismissible"><p><?php _e( 'Selected plugins will no longer be auto-updated.' ); ?></p></div> |
|
0 | 717 |
<?php endif; ?> |
718 |
||
719 |
<div class="wrap"> |
|
9 | 720 |
<h1 class="wp-heading-inline"> |
721 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
echo esc_html( $title ); |
9 | 723 |
?> |
724 |
</h1> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
725 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
<?php |
9 | 727 |
if ( ( ! is_multisite() || is_network_admin() ) && current_user_can( 'install_plugins' ) ) { |
728 |
?> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
<a href="<?php echo self_admin_url( 'plugin-install.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'plugin' ); ?></a> |
9 | 730 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
if ( strlen( $s ) ) { |
18 | 734 |
echo '<span class="subtitle">'; |
735 |
printf( |
|
736 |
/* translators: %s: Search query. */ |
|
737 |
__( 'Search results for: %s' ), |
|
738 |
'<strong>' . esc_html( urldecode( $s ) ) . '</strong>' |
|
739 |
); |
|
740 |
echo '</span>'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
742 |
?> |
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 |
<hr class="wp-header-end"> |
0 | 745 |
|
5 | 746 |
<?php |
747 |
/** |
|
748 |
* Fires before the plugins list table is rendered. |
|
749 |
* |
|
750 |
* This hook also fires before the plugins list table is rendered in the Network Admin. |
|
751 |
* |
|
752 |
* Please note: The 'active' portion of the hook name does not refer to whether the current |
|
753 |
* view is for active plugins, but rather all plugins actively-installed. |
|
754 |
* |
|
755 |
* @since 3.0.0 |
|
756 |
* |
|
9 | 757 |
* @param array[] $plugins_all An array of arrays containing information on all installed plugins. |
5 | 758 |
*/ |
759 |
do_action( 'pre_current_active_plugins', $plugins['all'] ); |
|
760 |
?> |
|
0 | 761 |
|
762 |
<?php $wp_list_table->views(); ?> |
|
763 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
<form class="search-form search-plugins" method="get"> |
0 | 765 |
<?php $wp_list_table->search_box( __( 'Search Installed Plugins' ), 'plugin' ); ?> |
766 |
</form> |
|
767 |
||
5 | 768 |
<form method="post" id="bulk-action-form"> |
0 | 769 |
|
9 | 770 |
<input type="hidden" name="plugin_status" value="<?php echo esc_attr( $status ); ?>" /> |
771 |
<input type="hidden" name="paged" value="<?php echo esc_attr( $page ); ?>" /> |
|
0 | 772 |
|
773 |
<?php $wp_list_table->display(); ?> |
|
774 |
</form> |
|
775 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
<span class="spinner"></span> |
0 | 777 |
</div> |
778 |
||
779 |
<?php |
|
5 | 780 |
wp_print_request_filesystem_credentials_modal(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
781 |
wp_print_admin_notice_templates(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
782 |
wp_print_update_row_templates(); |
5 | 783 |
|
16 | 784 |
require_once ABSPATH . 'wp-admin/admin-footer.php'; |