Edit File by line
/home/barbar84/public_h.../wp-admin
File: plugins.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Plugins administration panel.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/** WordPress Administration Bootstrap */
[8] Fix | Delete
require_once __DIR__ . '/admin.php';
[9] Fix | Delete
[10] Fix | Delete
if ( ! current_user_can( 'activate_plugins' ) ) {
[11] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) );
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
[15] Fix | Delete
$pagenum = $wp_list_table->get_pagenum();
[16] Fix | Delete
[17] Fix | Delete
$action = $wp_list_table->current_action();
[18] Fix | Delete
[19] Fix | Delete
$plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
[20] Fix | Delete
$s = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';
[21] Fix | Delete
[22] Fix | Delete
// Clean up request URI from temporary args for screen options/paging uri's to work as expected.
[23] Fix | Delete
$query_args_to_remove = array(
[24] Fix | Delete
'error',
[25] Fix | Delete
'deleted',
[26] Fix | Delete
'activate',
[27] Fix | Delete
'activate-multi',
[28] Fix | Delete
'deactivate',
[29] Fix | Delete
'deactivate-multi',
[30] Fix | Delete
'enabled-auto-update',
[31] Fix | Delete
'disabled-auto-update',
[32] Fix | Delete
'enabled-auto-update-multi',
[33] Fix | Delete
'disabled-auto-update-multi',
[34] Fix | Delete
'_error_nonce',
[35] Fix | Delete
);
[36] Fix | Delete
[37] Fix | Delete
$_SERVER['REQUEST_URI'] = remove_query_arg( $query_args_to_remove, $_SERVER['REQUEST_URI'] );
[38] Fix | Delete
[39] Fix | Delete
wp_enqueue_script( 'updates' );
[40] Fix | Delete
[41] Fix | Delete
if ( $action ) {
[42] Fix | Delete
[43] Fix | Delete
switch ( $action ) {
[44] Fix | Delete
case 'activate':
[45] Fix | Delete
if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
[46] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
if ( is_multisite() && ! is_network_admin() && is_network_only_plugin( $plugin ) ) {
[50] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
[51] Fix | Delete
exit;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
check_admin_referer( 'activate-plugin_' . $plugin );
[55] Fix | Delete
[56] Fix | Delete
$result = activate_plugin( $plugin, self_admin_url( 'plugins.php?error=true&plugin=' . urlencode( $plugin ) ), is_network_admin() );
[57] Fix | Delete
if ( is_wp_error( $result ) ) {
[58] Fix | Delete
if ( 'unexpected_output' === $result->get_error_code() ) {
[59] Fix | Delete
$redirect = self_admin_url( 'plugins.php?error=true&charsout=' . strlen( $result->get_error_data() ) . '&plugin=' . urlencode( $plugin ) . "&plugin_status=$status&paged=$page&s=$s" );
[60] Fix | Delete
wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
[61] Fix | Delete
exit;
[62] Fix | Delete
} else {
[63] Fix | Delete
wp_die( $result );
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
if ( ! is_network_admin() ) {
[68] Fix | Delete
$recent = (array) get_option( 'recently_activated' );
[69] Fix | Delete
unset( $recent[ $plugin ] );
[70] Fix | Delete
update_option( 'recently_activated', $recent );
[71] Fix | Delete
} else {
[72] Fix | Delete
$recent = (array) get_site_option( 'recently_activated' );
[73] Fix | Delete
unset( $recent[ $plugin ] );
[74] Fix | Delete
update_site_option( 'recently_activated', $recent );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if ( isset( $_GET['from'] ) && 'import' === $_GET['from'] ) {
[78] Fix | Delete
// Overrides the ?error=true one above and redirects to the Imports page, stripping the -importer suffix.
[79] Fix | Delete
wp_redirect( self_admin_url( 'import.php?import=' . str_replace( '-importer', '', dirname( $plugin ) ) ) );
[80] Fix | Delete
} elseif ( isset( $_GET['from'] ) && 'press-this' === $_GET['from'] ) {
[81] Fix | Delete
wp_redirect( self_admin_url( 'press-this.php' ) );
[82] Fix | Delete
} else {
[83] Fix | Delete
// Overrides the ?error=true one above.
[84] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?activate=true&plugin_status=$status&paged=$page&s=$s" ) );
[85] Fix | Delete
}
[86] Fix | Delete
exit;
[87] Fix | Delete
[88] Fix | Delete
case 'activate-selected':
[89] Fix | Delete
if ( ! current_user_can( 'activate_plugins' ) ) {
[90] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to activate plugins for this site.' ) );
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
check_admin_referer( 'bulk-plugins' );
[94] Fix | Delete
[95] Fix | Delete
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
[96] Fix | Delete
[97] Fix | Delete
if ( is_network_admin() ) {
[98] Fix | Delete
foreach ( $plugins as $i => $plugin ) {
[99] Fix | Delete
// Only activate plugins which are not already network activated.
[100] Fix | Delete
if ( is_plugin_active_for_network( $plugin ) ) {
[101] Fix | Delete
unset( $plugins[ $i ] );
[102] Fix | Delete
}
[103] Fix | Delete
}
[104] Fix | Delete
} else {
[105] Fix | Delete
foreach ( $plugins as $i => $plugin ) {
[106] Fix | Delete
// Only activate plugins which are not already active and are not network-only when on Multisite.
[107] Fix | Delete
if ( is_plugin_active( $plugin ) || ( is_multisite() && is_network_only_plugin( $plugin ) ) ) {
[108] Fix | Delete
unset( $plugins[ $i ] );
[109] Fix | Delete
}
[110] Fix | Delete
// Only activate plugins which the user can activate.
[111] Fix | Delete
if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
[112] Fix | Delete
unset( $plugins[ $i ] );
[113] Fix | Delete
}
[114] Fix | Delete
}
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
if ( empty( $plugins ) ) {
[118] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
[119] Fix | Delete
exit;
[120] Fix | Delete
}
[121] Fix | Delete
[122] Fix | Delete
activate_plugins( $plugins, self_admin_url( 'plugins.php?error=true' ), is_network_admin() );
[123] Fix | Delete
[124] Fix | Delete
if ( ! is_network_admin() ) {
[125] Fix | Delete
$recent = (array) get_option( 'recently_activated' );
[126] Fix | Delete
} else {
[127] Fix | Delete
$recent = (array) get_site_option( 'recently_activated' );
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
foreach ( $plugins as $plugin ) {
[131] Fix | Delete
unset( $recent[ $plugin ] );
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
if ( ! is_network_admin() ) {
[135] Fix | Delete
update_option( 'recently_activated', $recent );
[136] Fix | Delete
} else {
[137] Fix | Delete
update_site_option( 'recently_activated', $recent );
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?activate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
[141] Fix | Delete
exit;
[142] Fix | Delete
[143] Fix | Delete
case 'update-selected':
[144] Fix | Delete
check_admin_referer( 'bulk-plugins' );
[145] Fix | Delete
[146] Fix | Delete
if ( isset( $_GET['plugins'] ) ) {
[147] Fix | Delete
$plugins = explode( ',', wp_unslash( $_GET['plugins'] ) );
[148] Fix | Delete
} elseif ( isset( $_POST['checked'] ) ) {
[149] Fix | Delete
$plugins = (array) wp_unslash( $_POST['checked'] );
[150] Fix | Delete
} else {
[151] Fix | Delete
$plugins = array();
[152] Fix | Delete
}
[153] Fix | Delete
[154] Fix | Delete
$title = __( 'Update Plugins' );
[155] Fix | Delete
$parent_file = 'plugins.php';
[156] Fix | Delete
[157] Fix | Delete
wp_enqueue_script( 'updates' );
[158] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[159] Fix | Delete
[160] Fix | Delete
echo '<div class="wrap">';
[161] Fix | Delete
echo '<h1>' . esc_html( $title ) . '</h1>';
[162] Fix | Delete
[163] Fix | Delete
$url = self_admin_url( 'update.php?action=update-selected&amp;plugins=' . urlencode( implode( ',', $plugins ) ) );
[164] Fix | Delete
$url = wp_nonce_url( $url, 'bulk-update-plugins' );
[165] Fix | Delete
[166] Fix | Delete
echo "<iframe src='$url' style='width: 100%; height:100%; min-height:850px;'></iframe>";
[167] Fix | Delete
echo '</div>';
[168] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[169] Fix | Delete
exit;
[170] Fix | Delete
[171] Fix | Delete
case 'error_scrape':
[172] Fix | Delete
if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
[173] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to activate this plugin.' ) );
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
check_admin_referer( 'plugin-activation-error_' . $plugin );
[177] Fix | Delete
[178] Fix | Delete
$valid = validate_plugin( $plugin );
[179] Fix | Delete
if ( is_wp_error( $valid ) ) {
[180] Fix | Delete
wp_die( $valid );
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
if ( ! WP_DEBUG ) {
[184] Fix | Delete
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 );
[185] Fix | Delete
}
[186] Fix | Delete
[187] Fix | Delete
ini_set( 'display_errors', true ); // Ensure that fatal errors are displayed.
[188] Fix | Delete
// Go back to "sandbox" scope so we get the same errors as before.
[189] Fix | Delete
plugin_sandbox_scrape( $plugin );
[190] Fix | Delete
/** This action is documented in wp-admin/includes/plugin.php */
[191] Fix | Delete
do_action( "activate_{$plugin}" );
[192] Fix | Delete
exit;
[193] Fix | Delete
[194] Fix | Delete
case 'deactivate':
[195] Fix | Delete
if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
[196] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to deactivate this plugin.' ) );
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
check_admin_referer( 'deactivate-plugin_' . $plugin );
[200] Fix | Delete
[201] Fix | Delete
if ( ! is_network_admin() && is_plugin_active_for_network( $plugin ) ) {
[202] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
[203] Fix | Delete
exit;
[204] Fix | Delete
}
[205] Fix | Delete
[206] Fix | Delete
deactivate_plugins( $plugin, false, is_network_admin() );
[207] Fix | Delete
[208] Fix | Delete
if ( ! is_network_admin() ) {
[209] Fix | Delete
update_option( 'recently_activated', array( $plugin => time() ) + (array) get_option( 'recently_activated' ) );
[210] Fix | Delete
} else {
[211] Fix | Delete
update_site_option( 'recently_activated', array( $plugin => time() ) + (array) get_site_option( 'recently_activated' ) );
[212] Fix | Delete
}
[213] Fix | Delete
[214] Fix | Delete
if ( headers_sent() ) {
[215] Fix | Delete
echo "<meta http-equiv='refresh' content='" . esc_attr( "0;url=plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) . "' />";
[216] Fix | Delete
} else {
[217] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?deactivate=true&plugin_status=$status&paged=$page&s=$s" ) );
[218] Fix | Delete
}
[219] Fix | Delete
exit;
[220] Fix | Delete
[221] Fix | Delete
case 'deactivate-selected':
[222] Fix | Delete
if ( ! current_user_can( 'deactivate_plugins' ) ) {
[223] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to deactivate plugins for this site.' ) );
[224] Fix | Delete
}
[225] Fix | Delete
[226] Fix | Delete
check_admin_referer( 'bulk-plugins' );
[227] Fix | Delete
[228] Fix | Delete
$plugins = isset( $_POST['checked'] ) ? (array) wp_unslash( $_POST['checked'] ) : array();
[229] Fix | Delete
// Do not deactivate plugins which are already deactivated.
[230] Fix | Delete
if ( is_network_admin() ) {
[231] Fix | Delete
$plugins = array_filter( $plugins, 'is_plugin_active_for_network' );
[232] Fix | Delete
} else {
[233] Fix | Delete
$plugins = array_filter( $plugins, 'is_plugin_active' );
[234] Fix | Delete
$plugins = array_diff( $plugins, array_filter( $plugins, 'is_plugin_active_for_network' ) );
[235] Fix | Delete
[236] Fix | Delete
foreach ( $plugins as $i => $plugin ) {
[237] Fix | Delete
// Only deactivate plugins which the user can deactivate.
[238] Fix | Delete
if ( ! current_user_can( 'deactivate_plugin', $plugin ) ) {
[239] Fix | Delete
unset( $plugins[ $i ] );
[240] Fix | Delete
}
[241] Fix | Delete
}
[242] Fix | Delete
}
[243] Fix | Delete
if ( empty( $plugins ) ) {
[244] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
[245] Fix | Delete
exit;
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
deactivate_plugins( $plugins, false, is_network_admin() );
[249] Fix | Delete
[250] Fix | Delete
$deactivated = array();
[251] Fix | Delete
foreach ( $plugins as $plugin ) {
[252] Fix | Delete
$deactivated[ $plugin ] = time();
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
if ( ! is_network_admin() ) {
[256] Fix | Delete
update_option( 'recently_activated', $deactivated + (array) get_option( 'recently_activated' ) );
[257] Fix | Delete
} else {
[258] Fix | Delete
update_site_option( 'recently_activated', $deactivated + (array) get_site_option( 'recently_activated' ) );
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?deactivate-multi=true&plugin_status=$status&paged=$page&s=$s" ) );
[262] Fix | Delete
exit;
[263] Fix | Delete
[264] Fix | Delete
case 'delete-selected':
[265] Fix | Delete
if ( ! current_user_can( 'delete_plugins' ) ) {
[266] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to delete plugins for this site.' ) );
[267] Fix | Delete
}
[268] Fix | Delete
[269] Fix | Delete
check_admin_referer( 'bulk-plugins' );
[270] Fix | Delete
[271] Fix | Delete
// $_POST = from the plugin form; $_GET = from the FTP details screen.
[272] Fix | Delete
$plugins = isset( $_REQUEST['checked'] ) ? (array) wp_unslash( $_REQUEST['checked'] ) : array();
[273] Fix | Delete
if ( empty( $plugins ) ) {
[274] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
[275] Fix | Delete
exit;
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
$plugins = array_filter( $plugins, 'is_plugin_inactive' ); // Do not allow to delete activated plugins.
[279] Fix | Delete
if ( empty( $plugins ) ) {
[280] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?error=true&main=true&plugin_status=$status&paged=$page&s=$s" ) );
[281] Fix | Delete
exit;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
// Bail on all if any paths are invalid.
[285] Fix | Delete
// validate_file() returns truthy for invalid files.
[286] Fix | Delete
$invalid_plugin_files = array_filter( $plugins, 'validate_file' );
[287] Fix | Delete
if ( $invalid_plugin_files ) {
[288] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?plugin_status=$status&paged=$page&s=$s" ) );
[289] Fix | Delete
exit;
[290] Fix | Delete
}
[291] Fix | Delete
[292] Fix | Delete
require ABSPATH . 'wp-admin/update.php';
[293] Fix | Delete
[294] Fix | Delete
$parent_file = 'plugins.php';
[295] Fix | Delete
[296] Fix | Delete
if ( ! isset( $_REQUEST['verify-delete'] ) ) {
[297] Fix | Delete
wp_enqueue_script( 'jquery' );
[298] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[299] Fix | Delete
[300] Fix | Delete
?>
[301] Fix | Delete
<div class="wrap">
[302] Fix | Delete
<?php
[303] Fix | Delete
[304] Fix | Delete
$plugin_info = array();
[305] Fix | Delete
$have_non_network_plugins = false;
[306] Fix | Delete
[307] Fix | Delete
foreach ( (array) $plugins as $plugin ) {
[308] Fix | Delete
$plugin_slug = dirname( $plugin );
[309] Fix | Delete
[310] Fix | Delete
if ( '.' === $plugin_slug ) {
[311] Fix | Delete
$data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
[312] Fix | Delete
if ( $data ) {
[313] Fix | Delete
$plugin_info[ $plugin ] = $data;
[314] Fix | Delete
$plugin_info[ $plugin ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
[315] Fix | Delete
if ( ! $plugin_info[ $plugin ]['Network'] ) {
[316] Fix | Delete
$have_non_network_plugins = true;
[317] Fix | Delete
}
[318] Fix | Delete
}
[319] Fix | Delete
} else {
[320] Fix | Delete
// Get plugins list from that folder.
[321] Fix | Delete
$folder_plugins = get_plugins( '/' . $plugin_slug );
[322] Fix | Delete
if ( $folder_plugins ) {
[323] Fix | Delete
foreach ( $folder_plugins as $plugin_file => $data ) {
[324] Fix | Delete
$plugin_info[ $plugin_file ] = _get_plugin_data_markup_translate( $plugin_file, $data );
[325] Fix | Delete
$plugin_info[ $plugin_file ]['is_uninstallable'] = is_uninstallable_plugin( $plugin );
[326] Fix | Delete
if ( ! $plugin_info[ $plugin_file ]['Network'] ) {
[327] Fix | Delete
$have_non_network_plugins = true;
[328] Fix | Delete
}
[329] Fix | Delete
}
[330] Fix | Delete
}
[331] Fix | Delete
}
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
$plugins_to_delete = count( $plugin_info );
[335] Fix | Delete
[336] Fix | Delete
?>
[337] Fix | Delete
<?php if ( 1 === $plugins_to_delete ) : ?>
[338] Fix | Delete
<h1><?php _e( 'Delete Plugin' ); ?></h1>
[339] Fix | Delete
<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
[340] Fix | Delete
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'This plugin may be active on other sites in the network.' ); ?></p></div>
[341] Fix | Delete
<?php endif; ?>
[342] Fix | Delete
<p><?php _e( 'You are about to remove the following plugin:' ); ?></p>
[343] Fix | Delete
<?php else : ?>
[344] Fix | Delete
<h1><?php _e( 'Delete Plugins' ); ?></h1>
[345] Fix | Delete
<?php if ( $have_non_network_plugins && is_network_admin() ) : ?>
[346] Fix | Delete
<div class="error"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php _e( 'These plugins may be active on other sites in the network.' ); ?></p></div>
[347] Fix | Delete
<?php endif; ?>
[348] Fix | Delete
<p><?php _e( 'You are about to remove the following plugins:' ); ?></p>
[349] Fix | Delete
<?php endif; ?>
[350] Fix | Delete
<ul class="ul-disc">
[351] Fix | Delete
<?php
[352] Fix | Delete
[353] Fix | Delete
$data_to_delete = false;
[354] Fix | Delete
[355] Fix | Delete
foreach ( $plugin_info as $plugin ) {
[356] Fix | Delete
if ( $plugin['is_uninstallable'] ) {
[357] Fix | Delete
/* translators: 1: Plugin name, 2: Plugin author. */
[358] Fix | Delete
echo '<li>', sprintf( __( '%1$s by %2$s (will also <strong>delete its data</strong>)' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] . '</em>' ), '</li>';
[359] Fix | Delete
$data_to_delete = true;
[360] Fix | Delete
} else {
[361] Fix | Delete
/* translators: 1: Plugin name, 2: Plugin author. */
[362] Fix | Delete
echo '<li>', sprintf( _x( '%1$s by %2$s', 'plugin' ), '<strong>' . $plugin['Name'] . '</strong>', '<em>' . $plugin['AuthorName'] ) . '</em>', '</li>';
[363] Fix | Delete
}
[364] Fix | Delete
}
[365] Fix | Delete
[366] Fix | Delete
?>
[367] Fix | Delete
</ul>
[368] Fix | Delete
<p>
[369] Fix | Delete
<?php
[370] Fix | Delete
[371] Fix | Delete
if ( $data_to_delete ) {
[372] Fix | Delete
_e( 'Are you sure you want to delete these files and data?' );
[373] Fix | Delete
} else {
[374] Fix | Delete
_e( 'Are you sure you want to delete these files?' );
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
?>
[378] Fix | Delete
</p>
[379] Fix | Delete
<form method="post" action="<?php echo esc_url( $_SERVER['REQUEST_URI'] ); ?>" style="display:inline;">
[380] Fix | Delete
<input type="hidden" name="verify-delete" value="1" />
[381] Fix | Delete
<input type="hidden" name="action" value="delete-selected" />
[382] Fix | Delete
<?php
[383] Fix | Delete
[384] Fix | Delete
foreach ( (array) $plugins as $plugin ) {
[385] Fix | Delete
echo '<input type="hidden" name="checked[]" value="' . esc_attr( $plugin ) . '" />';
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
?>
[389] Fix | Delete
<?php wp_nonce_field( 'bulk-plugins' ); ?>
[390] Fix | Delete
<?php submit_button( $data_to_delete ? __( 'Yes, delete these files and data' ) : __( 'Yes, delete these files' ), '', 'submit', false ); ?>
[391] Fix | Delete
</form>
[392] Fix | Delete
<?php
[393] Fix | Delete
[394] Fix | Delete
$referer = wp_get_referer();
[395] Fix | Delete
[396] Fix | Delete
?>
[397] Fix | Delete
<form method="post" action="<?php echo $referer ? esc_url( $referer ) : ''; ?>" style="display:inline;">
[398] Fix | Delete
<?php submit_button( __( 'No, return me to the plugin list' ), '', 'submit', false ); ?>
[399] Fix | Delete
</form>
[400] Fix | Delete
</div>
[401] Fix | Delete
<?php
[402] Fix | Delete
[403] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[404] Fix | Delete
exit;
[405] Fix | Delete
} else {
[406] Fix | Delete
$plugins_to_delete = count( $plugins );
[407] Fix | Delete
} // End if verify-delete.
[408] Fix | Delete
[409] Fix | Delete
$delete_result = delete_plugins( $plugins );
[410] Fix | Delete
[411] Fix | Delete
// Store the result in a cache rather than a URL param due to object type & length.
[412] Fix | Delete
set_transient( 'plugins_delete_result_' . $user_ID, $delete_result );
[413] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?deleted=$plugins_to_delete&plugin_status=$status&paged=$page&s=$s" ) );
[414] Fix | Delete
exit;
[415] Fix | Delete
case 'clear-recent-list':
[416] Fix | Delete
if ( ! is_network_admin() ) {
[417] Fix | Delete
update_option( 'recently_activated', array() );
[418] Fix | Delete
} else {
[419] Fix | Delete
update_site_option( 'recently_activated', array() );
[420] Fix | Delete
}
[421] Fix | Delete
[422] Fix | Delete
break;
[423] Fix | Delete
case 'resume':
[424] Fix | Delete
if ( is_multisite() ) {
[425] Fix | Delete
return;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
if ( ! current_user_can( 'resume_plugin', $plugin ) ) {
[429] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to resume this plugin.' ) );
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
check_admin_referer( 'resume-plugin_' . $plugin );
[433] Fix | Delete
[434] Fix | Delete
$result = resume_plugin( $plugin, self_admin_url( "plugins.php?error=resuming&plugin_status=$status&paged=$page&s=$s" ) );
[435] Fix | Delete
[436] Fix | Delete
if ( is_wp_error( $result ) ) {
[437] Fix | Delete
wp_die( $result );
[438] Fix | Delete
}
[439] Fix | Delete
[440] Fix | Delete
wp_redirect( self_admin_url( "plugins.php?resume=true&plugin_status=$status&paged=$page&s=$s" ) );
[441] Fix | Delete
exit;
[442] Fix | Delete
case 'enable-auto-update':
[443] Fix | Delete
case 'disable-auto-update':
[444] Fix | Delete
case 'enable-auto-update-selected':
[445] Fix | Delete
case 'disable-auto-update-selected':
[446] Fix | Delete
if ( ! current_user_can( 'update_plugins' ) || ! wp_is_auto_update_enabled_for_type( 'plugin' ) ) {
[447] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to manage plugins automatic updates.' ) );
[448] Fix | Delete
}
[449] Fix | Delete
[450] Fix | Delete
if ( is_multisite() && ! is_network_admin() ) {
[451] Fix | Delete
wp_die( __( 'Please connect to your network admin to manage plugins automatic updates.' ) );
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
$redirect = self_admin_url( "plugins.php?plugin_status={$status}&paged={$page}&s={$s}" );
[455] Fix | Delete
[456] Fix | Delete
if ( 'enable-auto-update' === $action || 'disable-auto-update' === $action ) {
[457] Fix | Delete
if ( empty( $plugin ) ) {
[458] Fix | Delete
wp_redirect( $redirect );
[459] Fix | Delete
exit;
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
check_admin_referer( 'updates' );
[463] Fix | Delete
} else {
[464] Fix | Delete
if ( empty( $_POST['checked'] ) ) {
[465] Fix | Delete
wp_redirect( $redirect );
[466] Fix | Delete
exit;
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
check_admin_referer( 'bulk-plugins' );
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
$auto_updates = (array) get_site_option( 'auto_update_plugins', array() );
[473] Fix | Delete
[474] Fix | Delete
if ( 'enable-auto-update' === $action ) {
[475] Fix | Delete
$auto_updates[] = $plugin;
[476] Fix | Delete
$auto_updates = array_unique( $auto_updates );
[477] Fix | Delete
$redirect = add_query_arg( array( 'enabled-auto-update' => 'true' ), $redirect );
[478] Fix | Delete
} elseif ( 'disable-auto-update' === $action ) {
[479] Fix | Delete
$auto_updates = array_diff( $auto_updates, array( $plugin ) );
[480] Fix | Delete
$redirect = add_query_arg( array( 'disabled-auto-update' => 'true' ), $redirect );
[481] Fix | Delete
} else {
[482] Fix | Delete
$plugins = (array) wp_unslash( $_POST['checked'] );
[483] Fix | Delete
[484] Fix | Delete
if ( 'enable-auto-update-selected' === $action ) {
[485] Fix | Delete
$new_auto_updates = array_merge( $auto_updates, $plugins );
[486] Fix | Delete
$new_auto_updates = array_unique( $new_auto_updates );
[487] Fix | Delete
$query_args = array( 'enabled-auto-update-multi' => 'true' );
[488] Fix | Delete
} else {
[489] Fix | Delete
$new_auto_updates = array_diff( $auto_updates, $plugins );
[490] Fix | Delete
$query_args = array( 'disabled-auto-update-multi' => 'true' );
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
// Return early if all selected plugins already have auto-updates enabled or disabled.
[494] Fix | Delete
// Must use non-strict comparison, so that array order is not treated as significant.
[495] Fix | Delete
if ( $new_auto_updates == $auto_updates ) { // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
[496] Fix | Delete
wp_redirect( $redirect );
[497] Fix | Delete
exit;
[498] Fix | Delete
}
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function