Edit File by line
/home/zeestwma/ajeebong.../wp-admin/includes
File: plugin.php
$dropins = array(
[500] Fix | Delete
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
[501] Fix | Delete
'db.php' => array( __( 'Custom database class.' ), true ), // Auto on load.
[502] Fix | Delete
'db-error.php' => array( __( 'Custom database error message.' ), true ), // Auto on error.
[503] Fix | Delete
'install.php' => array( __( 'Custom installation script.' ), true ), // Auto on installation.
[504] Fix | Delete
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // Auto on maintenance.
[505] Fix | Delete
'object-cache.php' => array( __( 'External object cache.' ), true ), // Auto on load.
[506] Fix | Delete
'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // Auto on error.
[507] Fix | Delete
'fatal-error-handler.php' => array( __( 'Custom PHP fatal error handler.' ), true ), // Auto on error.
[508] Fix | Delete
);
[509] Fix | Delete
[510] Fix | Delete
if ( is_multisite() ) {
[511] Fix | Delete
$dropins['sunrise.php'] = array( __( 'Executed before Multisite is loaded.' ), 'SUNRISE' ); // SUNRISE
[512] Fix | Delete
$dropins['blog-deleted.php'] = array( __( 'Custom site deleted message.' ), true ); // Auto on deleted blog.
[513] Fix | Delete
$dropins['blog-inactive.php'] = array( __( 'Custom site inactive message.' ), true ); // Auto on inactive blog.
[514] Fix | Delete
$dropins['blog-suspended.php'] = array( __( 'Custom site suspended message.' ), true ); // Auto on archived or spammed blog.
[515] Fix | Delete
}
[516] Fix | Delete
[517] Fix | Delete
return $dropins;
[518] Fix | Delete
}
[519] Fix | Delete
[520] Fix | Delete
/**
[521] Fix | Delete
* Determines whether a plugin is active.
[522] Fix | Delete
*
[523] Fix | Delete
* Only plugins installed in the plugins/ folder can be active.
[524] Fix | Delete
*
[525] Fix | Delete
* Plugins in the mu-plugins/ folder can't be "activated," so this function will
[526] Fix | Delete
* return false for those plugins.
[527] Fix | Delete
*
[528] Fix | Delete
* For more information on this and similar theme functions, check out
[529] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[530] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[531] Fix | Delete
*
[532] Fix | Delete
* @since 2.5.0
[533] Fix | Delete
*
[534] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[535] Fix | Delete
* @return bool True, if in the active plugins list. False, not in the list.
[536] Fix | Delete
*/
[537] Fix | Delete
function is_plugin_active( $plugin ) {
[538] Fix | Delete
return in_array( $plugin, (array) get_option( 'active_plugins', array() ), true ) || is_plugin_active_for_network( $plugin );
[539] Fix | Delete
}
[540] Fix | Delete
[541] Fix | Delete
/**
[542] Fix | Delete
* Determines whether the plugin is inactive.
[543] Fix | Delete
*
[544] Fix | Delete
* Reverse of is_plugin_active(). Used as a callback.
[545] Fix | Delete
*
[546] Fix | Delete
* For more information on this and similar theme functions, check out
[547] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[548] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[549] Fix | Delete
*
[550] Fix | Delete
* @since 3.1.0
[551] Fix | Delete
*
[552] Fix | Delete
* @see is_plugin_active()
[553] Fix | Delete
*
[554] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[555] Fix | Delete
* @return bool True if inactive. False if active.
[556] Fix | Delete
*/
[557] Fix | Delete
function is_plugin_inactive( $plugin ) {
[558] Fix | Delete
return ! is_plugin_active( $plugin );
[559] Fix | Delete
}
[560] Fix | Delete
[561] Fix | Delete
/**
[562] Fix | Delete
* Determines whether the plugin is active for the entire network.
[563] Fix | Delete
*
[564] Fix | Delete
* Only plugins installed in the plugins/ folder can be active.
[565] Fix | Delete
*
[566] Fix | Delete
* Plugins in the mu-plugins/ folder can't be "activated," so this function will
[567] Fix | Delete
* return false for those plugins.
[568] Fix | Delete
*
[569] Fix | Delete
* For more information on this and similar theme functions, check out
[570] Fix | Delete
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
[571] Fix | Delete
* Conditional Tags} article in the Theme Developer Handbook.
[572] Fix | Delete
*
[573] Fix | Delete
* @since 3.0.0
[574] Fix | Delete
*
[575] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[576] Fix | Delete
* @return bool True if active for the network, otherwise false.
[577] Fix | Delete
*/
[578] Fix | Delete
function is_plugin_active_for_network( $plugin ) {
[579] Fix | Delete
if ( ! is_multisite() ) {
[580] Fix | Delete
return false;
[581] Fix | Delete
}
[582] Fix | Delete
[583] Fix | Delete
$plugins = get_site_option( 'active_sitewide_plugins' );
[584] Fix | Delete
if ( isset( $plugins[ $plugin ] ) ) {
[585] Fix | Delete
return true;
[586] Fix | Delete
}
[587] Fix | Delete
[588] Fix | Delete
return false;
[589] Fix | Delete
}
[590] Fix | Delete
[591] Fix | Delete
/**
[592] Fix | Delete
* Checks for "Network: true" in the plugin header to see if this should
[593] Fix | Delete
* be activated only as a network wide plugin. The plugin would also work
[594] Fix | Delete
* when Multisite is not enabled.
[595] Fix | Delete
*
[596] Fix | Delete
* Checks for "Site Wide Only: true" for backward compatibility.
[597] Fix | Delete
*
[598] Fix | Delete
* @since 3.0.0
[599] Fix | Delete
*
[600] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[601] Fix | Delete
* @return bool True if plugin is network only, false otherwise.
[602] Fix | Delete
*/
[603] Fix | Delete
function is_network_only_plugin( $plugin ) {
[604] Fix | Delete
$plugin_data = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
[605] Fix | Delete
if ( $plugin_data ) {
[606] Fix | Delete
return $plugin_data['Network'];
[607] Fix | Delete
}
[608] Fix | Delete
return false;
[609] Fix | Delete
}
[610] Fix | Delete
[611] Fix | Delete
/**
[612] Fix | Delete
* Attempts activation of plugin in a "sandbox" and redirects on success.
[613] Fix | Delete
*
[614] Fix | Delete
* A plugin that is already activated will not attempt to be activated again.
[615] Fix | Delete
*
[616] Fix | Delete
* The way it works is by setting the redirection to the error before trying to
[617] Fix | Delete
* include the plugin file. If the plugin fails, then the redirection will not
[618] Fix | Delete
* be overwritten with the success message. Also, the options will not be
[619] Fix | Delete
* updated and the activation hook will not be called on plugin error.
[620] Fix | Delete
*
[621] Fix | Delete
* It should be noted that in no way the below code will actually prevent errors
[622] Fix | Delete
* within the file. The code should not be used elsewhere to replicate the
[623] Fix | Delete
* "sandbox", which uses redirection to work.
[624] Fix | Delete
* {@source 13 1}
[625] Fix | Delete
*
[626] Fix | Delete
* If any errors are found or text is outputted, then it will be captured to
[627] Fix | Delete
* ensure that the success redirection will update the error redirection.
[628] Fix | Delete
*
[629] Fix | Delete
* @since 2.5.0
[630] Fix | Delete
* @since 5.2.0 Test for WordPress version and PHP version compatibility.
[631] Fix | Delete
*
[632] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[633] Fix | Delete
* @param string $redirect Optional. URL to redirect to.
[634] Fix | Delete
* @param bool $network_wide Optional. Whether to enable the plugin for all sites in the network
[635] Fix | Delete
* or just the current site. Multisite only. Default false.
[636] Fix | Delete
* @param bool $silent Optional. Whether to prevent calling activation hooks. Default false.
[637] Fix | Delete
* @return null|WP_Error Null on success, WP_Error on invalid file.
[638] Fix | Delete
*/
[639] Fix | Delete
function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {
[640] Fix | Delete
$plugin = plugin_basename( trim( $plugin ) );
[641] Fix | Delete
[642] Fix | Delete
if ( is_multisite() && ( $network_wide || is_network_only_plugin( $plugin ) ) ) {
[643] Fix | Delete
$network_wide = true;
[644] Fix | Delete
$current = get_site_option( 'active_sitewide_plugins', array() );
[645] Fix | Delete
$_GET['networkwide'] = 1; // Back compat for plugins looking for this value.
[646] Fix | Delete
} else {
[647] Fix | Delete
$current = get_option( 'active_plugins', array() );
[648] Fix | Delete
}
[649] Fix | Delete
[650] Fix | Delete
$valid = validate_plugin( $plugin );
[651] Fix | Delete
if ( is_wp_error( $valid ) ) {
[652] Fix | Delete
return $valid;
[653] Fix | Delete
}
[654] Fix | Delete
[655] Fix | Delete
$requirements = validate_plugin_requirements( $plugin );
[656] Fix | Delete
if ( is_wp_error( $requirements ) ) {
[657] Fix | Delete
return $requirements;
[658] Fix | Delete
}
[659] Fix | Delete
[660] Fix | Delete
if ( $network_wide && ! isset( $current[ $plugin ] )
[661] Fix | Delete
|| ! $network_wide && ! in_array( $plugin, $current, true )
[662] Fix | Delete
) {
[663] Fix | Delete
if ( ! empty( $redirect ) ) {
[664] Fix | Delete
// We'll override this later if the plugin can be included without fatal error.
[665] Fix | Delete
wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin ), $redirect ) );
[666] Fix | Delete
}
[667] Fix | Delete
[668] Fix | Delete
ob_start();
[669] Fix | Delete
[670] Fix | Delete
// Load the plugin to test whether it throws any errors.
[671] Fix | Delete
plugin_sandbox_scrape( $plugin );
[672] Fix | Delete
[673] Fix | Delete
if ( ! $silent ) {
[674] Fix | Delete
/**
[675] Fix | Delete
* Fires before a plugin is activated.
[676] Fix | Delete
*
[677] Fix | Delete
* If a plugin is silently activated (such as during an update),
[678] Fix | Delete
* this hook does not fire.
[679] Fix | Delete
*
[680] Fix | Delete
* @since 2.9.0
[681] Fix | Delete
*
[682] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[683] Fix | Delete
* @param bool $network_wide Whether to enable the plugin for all sites in the network
[684] Fix | Delete
* or just the current site. Multisite only. Default false.
[685] Fix | Delete
*/
[686] Fix | Delete
do_action( 'activate_plugin', $plugin, $network_wide );
[687] Fix | Delete
[688] Fix | Delete
/**
[689] Fix | Delete
* Fires as a specific plugin is being activated.
[690] Fix | Delete
*
[691] Fix | Delete
* This hook is the "activation" hook used internally by register_activation_hook().
[692] Fix | Delete
* The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
[693] Fix | Delete
*
[694] Fix | Delete
* If a plugin is silently activated (such as during an update), this hook does not fire.
[695] Fix | Delete
*
[696] Fix | Delete
* @since 2.0.0
[697] Fix | Delete
*
[698] Fix | Delete
* @param bool $network_wide Whether to enable the plugin for all sites in the network
[699] Fix | Delete
* or just the current site. Multisite only. Default false.
[700] Fix | Delete
*/
[701] Fix | Delete
do_action( "activate_{$plugin}", $network_wide );
[702] Fix | Delete
}
[703] Fix | Delete
[704] Fix | Delete
if ( $network_wide ) {
[705] Fix | Delete
$current = get_site_option( 'active_sitewide_plugins', array() );
[706] Fix | Delete
$current[ $plugin ] = time();
[707] Fix | Delete
update_site_option( 'active_sitewide_plugins', $current );
[708] Fix | Delete
} else {
[709] Fix | Delete
$current = get_option( 'active_plugins', array() );
[710] Fix | Delete
$current[] = $plugin;
[711] Fix | Delete
sort( $current );
[712] Fix | Delete
update_option( 'active_plugins', $current );
[713] Fix | Delete
}
[714] Fix | Delete
[715] Fix | Delete
if ( ! $silent ) {
[716] Fix | Delete
/**
[717] Fix | Delete
* Fires after a plugin has been activated.
[718] Fix | Delete
*
[719] Fix | Delete
* If a plugin is silently activated (such as during an update),
[720] Fix | Delete
* this hook does not fire.
[721] Fix | Delete
*
[722] Fix | Delete
* @since 2.9.0
[723] Fix | Delete
*
[724] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[725] Fix | Delete
* @param bool $network_wide Whether to enable the plugin for all sites in the network
[726] Fix | Delete
* or just the current site. Multisite only. Default false.
[727] Fix | Delete
*/
[728] Fix | Delete
do_action( 'activated_plugin', $plugin, $network_wide );
[729] Fix | Delete
}
[730] Fix | Delete
[731] Fix | Delete
if ( ob_get_length() > 0 ) {
[732] Fix | Delete
$output = ob_get_clean();
[733] Fix | Delete
return new WP_Error( 'unexpected_output', __( 'The plugin generated unexpected output.' ), $output );
[734] Fix | Delete
}
[735] Fix | Delete
[736] Fix | Delete
ob_end_clean();
[737] Fix | Delete
}
[738] Fix | Delete
[739] Fix | Delete
return null;
[740] Fix | Delete
}
[741] Fix | Delete
[742] Fix | Delete
/**
[743] Fix | Delete
* Deactivates a single plugin or multiple plugins.
[744] Fix | Delete
*
[745] Fix | Delete
* The deactivation hook is disabled by the plugin upgrader by using the $silent
[746] Fix | Delete
* parameter.
[747] Fix | Delete
*
[748] Fix | Delete
* @since 2.5.0
[749] Fix | Delete
*
[750] Fix | Delete
* @param string|string[] $plugins Single plugin or list of plugins to deactivate.
[751] Fix | Delete
* @param bool $silent Prevent calling deactivation hooks. Default false.
[752] Fix | Delete
* @param bool|null $network_wide Whether to deactivate the plugin for all sites in the network.
[753] Fix | Delete
* A value of null will deactivate plugins for both the network
[754] Fix | Delete
* and the current site. Multisite only. Default null.
[755] Fix | Delete
*/
[756] Fix | Delete
function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
[757] Fix | Delete
if ( is_multisite() ) {
[758] Fix | Delete
$network_current = get_site_option( 'active_sitewide_plugins', array() );
[759] Fix | Delete
}
[760] Fix | Delete
$current = get_option( 'active_plugins', array() );
[761] Fix | Delete
$do_blog = false;
[762] Fix | Delete
$do_network = false;
[763] Fix | Delete
[764] Fix | Delete
foreach ( (array) $plugins as $plugin ) {
[765] Fix | Delete
$plugin = plugin_basename( trim( $plugin ) );
[766] Fix | Delete
if ( ! is_plugin_active( $plugin ) ) {
[767] Fix | Delete
continue;
[768] Fix | Delete
}
[769] Fix | Delete
[770] Fix | Delete
$network_deactivating = ( false !== $network_wide ) && is_plugin_active_for_network( $plugin );
[771] Fix | Delete
[772] Fix | Delete
if ( ! $silent ) {
[773] Fix | Delete
/**
[774] Fix | Delete
* Fires before a plugin is deactivated.
[775] Fix | Delete
*
[776] Fix | Delete
* If a plugin is silently deactivated (such as during an update),
[777] Fix | Delete
* this hook does not fire.
[778] Fix | Delete
*
[779] Fix | Delete
* @since 2.9.0
[780] Fix | Delete
*
[781] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[782] Fix | Delete
* @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
[783] Fix | Delete
* or just the current site. Multisite only. Default false.
[784] Fix | Delete
*/
[785] Fix | Delete
do_action( 'deactivate_plugin', $plugin, $network_deactivating );
[786] Fix | Delete
}
[787] Fix | Delete
[788] Fix | Delete
if ( false !== $network_wide ) {
[789] Fix | Delete
if ( is_plugin_active_for_network( $plugin ) ) {
[790] Fix | Delete
$do_network = true;
[791] Fix | Delete
unset( $network_current[ $plugin ] );
[792] Fix | Delete
} elseif ( $network_wide ) {
[793] Fix | Delete
continue;
[794] Fix | Delete
}
[795] Fix | Delete
}
[796] Fix | Delete
[797] Fix | Delete
if ( true !== $network_wide ) {
[798] Fix | Delete
$key = array_search( $plugin, $current, true );
[799] Fix | Delete
if ( false !== $key ) {
[800] Fix | Delete
$do_blog = true;
[801] Fix | Delete
unset( $current[ $key ] );
[802] Fix | Delete
}
[803] Fix | Delete
}
[804] Fix | Delete
[805] Fix | Delete
if ( $do_blog && wp_is_recovery_mode() ) {
[806] Fix | Delete
list( $extension ) = explode( '/', $plugin );
[807] Fix | Delete
wp_paused_plugins()->delete( $extension );
[808] Fix | Delete
}
[809] Fix | Delete
[810] Fix | Delete
if ( ! $silent ) {
[811] Fix | Delete
/**
[812] Fix | Delete
* Fires as a specific plugin is being deactivated.
[813] Fix | Delete
*
[814] Fix | Delete
* This hook is the "deactivation" hook used internally by register_deactivation_hook().
[815] Fix | Delete
* The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
[816] Fix | Delete
*
[817] Fix | Delete
* If a plugin is silently deactivated (such as during an update), this hook does not fire.
[818] Fix | Delete
*
[819] Fix | Delete
* @since 2.0.0
[820] Fix | Delete
*
[821] Fix | Delete
* @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
[822] Fix | Delete
* or just the current site. Multisite only. Default false.
[823] Fix | Delete
*/
[824] Fix | Delete
do_action( "deactivate_{$plugin}", $network_deactivating );
[825] Fix | Delete
[826] Fix | Delete
/**
[827] Fix | Delete
* Fires after a plugin is deactivated.
[828] Fix | Delete
*
[829] Fix | Delete
* If a plugin is silently deactivated (such as during an update),
[830] Fix | Delete
* this hook does not fire.
[831] Fix | Delete
*
[832] Fix | Delete
* @since 2.9.0
[833] Fix | Delete
*
[834] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[835] Fix | Delete
* @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
[836] Fix | Delete
* or just the current site. Multisite only. Default false.
[837] Fix | Delete
*/
[838] Fix | Delete
do_action( 'deactivated_plugin', $plugin, $network_deactivating );
[839] Fix | Delete
}
[840] Fix | Delete
}
[841] Fix | Delete
[842] Fix | Delete
if ( $do_blog ) {
[843] Fix | Delete
update_option( 'active_plugins', $current );
[844] Fix | Delete
}
[845] Fix | Delete
if ( $do_network ) {
[846] Fix | Delete
update_site_option( 'active_sitewide_plugins', $network_current );
[847] Fix | Delete
}
[848] Fix | Delete
}
[849] Fix | Delete
[850] Fix | Delete
/**
[851] Fix | Delete
* Activates multiple plugins.
[852] Fix | Delete
*
[853] Fix | Delete
* When WP_Error is returned, it does not mean that one of the plugins had
[854] Fix | Delete
* errors. It means that one or more of the plugin file paths were invalid.
[855] Fix | Delete
*
[856] Fix | Delete
* The execution will be halted as soon as one of the plugins has an error.
[857] Fix | Delete
*
[858] Fix | Delete
* @since 2.6.0
[859] Fix | Delete
*
[860] Fix | Delete
* @param string|string[] $plugins Single plugin or list of plugins to activate.
[861] Fix | Delete
* @param string $redirect Redirect to page after successful activation.
[862] Fix | Delete
* @param bool $network_wide Whether to enable the plugin for all sites in the network.
[863] Fix | Delete
* Default false.
[864] Fix | Delete
* @param bool $silent Prevent calling activation hooks. Default false.
[865] Fix | Delete
* @return true|WP_Error True when finished or WP_Error if there were errors during a plugin activation.
[866] Fix | Delete
*/
[867] Fix | Delete
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
[868] Fix | Delete
if ( ! is_array( $plugins ) ) {
[869] Fix | Delete
$plugins = array( $plugins );
[870] Fix | Delete
}
[871] Fix | Delete
[872] Fix | Delete
$errors = array();
[873] Fix | Delete
foreach ( $plugins as $plugin ) {
[874] Fix | Delete
if ( ! empty( $redirect ) ) {
[875] Fix | Delete
$redirect = add_query_arg( 'plugin', $plugin, $redirect );
[876] Fix | Delete
}
[877] Fix | Delete
$result = activate_plugin( $plugin, $redirect, $network_wide, $silent );
[878] Fix | Delete
if ( is_wp_error( $result ) ) {
[879] Fix | Delete
$errors[ $plugin ] = $result;
[880] Fix | Delete
}
[881] Fix | Delete
}
[882] Fix | Delete
[883] Fix | Delete
if ( ! empty( $errors ) ) {
[884] Fix | Delete
return new WP_Error( 'plugins_invalid', __( 'One of the plugins is invalid.' ), $errors );
[885] Fix | Delete
}
[886] Fix | Delete
[887] Fix | Delete
return true;
[888] Fix | Delete
}
[889] Fix | Delete
[890] Fix | Delete
/**
[891] Fix | Delete
* Removes directory and files of a plugin for a list of plugins.
[892] Fix | Delete
*
[893] Fix | Delete
* @since 2.6.0
[894] Fix | Delete
*
[895] Fix | Delete
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
[896] Fix | Delete
*
[897] Fix | Delete
* @param string[] $plugins List of plugin paths to delete, relative to the plugins directory.
[898] Fix | Delete
* @param string $deprecated Not used.
[899] Fix | Delete
* @return bool|null|WP_Error True on success, false if `$plugins` is empty, `WP_Error` on failure.
[900] Fix | Delete
* `null` if filesystem credentials are required to proceed.
[901] Fix | Delete
*/
[902] Fix | Delete
function delete_plugins( $plugins, $deprecated = '' ) {
[903] Fix | Delete
global $wp_filesystem;
[904] Fix | Delete
[905] Fix | Delete
if ( empty( $plugins ) ) {
[906] Fix | Delete
return false;
[907] Fix | Delete
}
[908] Fix | Delete
[909] Fix | Delete
$checked = array();
[910] Fix | Delete
foreach ( $plugins as $plugin ) {
[911] Fix | Delete
$checked[] = 'checked[]=' . $plugin;
[912] Fix | Delete
}
[913] Fix | Delete
[914] Fix | Delete
$url = wp_nonce_url( 'plugins.php?action=delete-selected&verify-delete=1&' . implode( '&', $checked ), 'bulk-plugins' );
[915] Fix | Delete
[916] Fix | Delete
ob_start();
[917] Fix | Delete
$credentials = request_filesystem_credentials( $url );
[918] Fix | Delete
$data = ob_get_clean();
[919] Fix | Delete
[920] Fix | Delete
if ( false === $credentials ) {
[921] Fix | Delete
if ( ! empty( $data ) ) {
[922] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[923] Fix | Delete
echo $data;
[924] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[925] Fix | Delete
exit;
[926] Fix | Delete
}
[927] Fix | Delete
return;
[928] Fix | Delete
}
[929] Fix | Delete
[930] Fix | Delete
if ( ! WP_Filesystem( $credentials ) ) {
[931] Fix | Delete
ob_start();
[932] Fix | Delete
// Failed to connect. Error and request again.
[933] Fix | Delete
request_filesystem_credentials( $url, '', true );
[934] Fix | Delete
$data = ob_get_clean();
[935] Fix | Delete
[936] Fix | Delete
if ( ! empty( $data ) ) {
[937] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[938] Fix | Delete
echo $data;
[939] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[940] Fix | Delete
exit;
[941] Fix | Delete
}
[942] Fix | Delete
return;
[943] Fix | Delete
}
[944] Fix | Delete
[945] Fix | Delete
if ( ! is_object( $wp_filesystem ) ) {
[946] Fix | Delete
return new WP_Error( 'fs_unavailable', __( 'Could not access filesystem.' ) );
[947] Fix | Delete
}
[948] Fix | Delete
[949] Fix | Delete
if ( is_wp_error( $wp_filesystem->errors ) && $wp_filesystem->errors->has_errors() ) {
[950] Fix | Delete
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
[951] Fix | Delete
}
[952] Fix | Delete
[953] Fix | Delete
// Get the base plugin folder.
[954] Fix | Delete
$plugins_dir = $wp_filesystem->wp_plugins_dir();
[955] Fix | Delete
if ( empty( $plugins_dir ) ) {
[956] Fix | Delete
return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) );
[957] Fix | Delete
}
[958] Fix | Delete
[959] Fix | Delete
$plugins_dir = trailingslashit( $plugins_dir );
[960] Fix | Delete
[961] Fix | Delete
$plugin_translations = wp_get_installed_translations( 'plugins' );
[962] Fix | Delete
[963] Fix | Delete
$errors = array();
[964] Fix | Delete
[965] Fix | Delete
foreach ( $plugins as $plugin_file ) {
[966] Fix | Delete
// Run Uninstall hook.
[967] Fix | Delete
if ( is_uninstallable_plugin( $plugin_file ) ) {
[968] Fix | Delete
uninstall_plugin( $plugin_file );
[969] Fix | Delete
}
[970] Fix | Delete
[971] Fix | Delete
/**
[972] Fix | Delete
* Fires immediately before a plugin deletion attempt.
[973] Fix | Delete
*
[974] Fix | Delete
* @since 4.4.0
[975] Fix | Delete
*
[976] Fix | Delete
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
[977] Fix | Delete
*/
[978] Fix | Delete
do_action( 'delete_plugin', $plugin_file );
[979] Fix | Delete
[980] Fix | Delete
$this_plugin_dir = trailingslashit( dirname( $plugins_dir . $plugin_file ) );
[981] Fix | Delete
[982] Fix | Delete
/*
[983] Fix | Delete
* If plugin is in its own directory, recursively delete the directory.
[984] Fix | Delete
* Base check on if plugin includes directory separator AND that it's not the root plugin folder.
[985] Fix | Delete
*/
[986] Fix | Delete
if ( strpos( $plugin_file, '/' ) && $this_plugin_dir !== $plugins_dir ) {
[987] Fix | Delete
$deleted = $wp_filesystem->delete( $this_plugin_dir, true );
[988] Fix | Delete
} else {
[989] Fix | Delete
$deleted = $wp_filesystem->delete( $plugins_dir . $plugin_file );
[990] Fix | Delete
}
[991] Fix | Delete
[992] Fix | Delete
/**
[993] Fix | Delete
* Fires immediately after a plugin deletion attempt.
[994] Fix | Delete
*
[995] Fix | Delete
* @since 4.4.0
[996] Fix | Delete
*
[997] Fix | Delete
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
[998] Fix | Delete
* @param bool $deleted Whether the plugin deletion was successful.
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function