wp_cache_disable_plugin() WPSCache 1.0
Hooks from the function
Return
Null. Nothing.
Usage
wp_cache_disable_plugin( $delete_config_file );
Code of wp_cache_disable_plugin() wp cache disable plugin WPSCache 1.7.1
function wp_cache_disable_plugin( $delete_config_file = true ) {
global $wp_rewrite;
if ( file_exists( ABSPATH . 'wp-config.php') ) {
$global_config_file = ABSPATH . 'wp-config.php';
} else {
$global_config_file = dirname(ABSPATH) . '/wp-config.php';
}
if ( apply_filters( 'wpsc_enable_wp_config_edit', true ) ) {
$line = 'define(\'WP_CACHE\', true);';
if (
strpos( file_get_contents( $global_config_file ), $line ) &&
(
! is_writeable_ACLSafe( $global_config_file ) ||
! wp_cache_replace_line( 'define*\(*\'WP_CACHE\'', '', $global_config_file )
)
) {
wp_die( "Could not remove WP_CACHE define from $global_config_file. Please edit that file and remove the line containing the text 'WP_CACHE'. Then refresh this page." );
}
$line = 'define( \'WPCACHEHOME\',';
if (
strpos( file_get_contents( $global_config_file ), $line ) &&
(
! is_writeable_ACLSafe( $global_config_file ) ||
! wp_cache_replace_line( 'define *\( *\'WPCACHEHOME\'', '', $global_config_file )
)
) {
wp_die( "Could not remove WPCACHEHOME define from $global_config_file. Please edit that file and remove the line containing the text 'WPCACHEHOME'. Then refresh this page." );
}
} elseif ( function_exists( 'wp_cache_debug' ) ) {
wp_cache_debug( 'wp_cache_disable_plugin: not allowed to edit wp-config.php per configuration.' );
}
uninstall_supercache( WP_CONTENT_DIR . '/cache' );
$file_not_deleted = false;
if ( @file_exists( WP_CONTENT_DIR . "/advanced-cache.php" ) ) {
if ( false == @unlink( WP_CONTENT_DIR . "/advanced-cache.php" ) )
$file_not_deleted[] = 'advanced-cache.php';
}
if ( $delete_config_file && @file_exists( WP_CONTENT_DIR . "/wp-cache-config.php" ) ) {
if ( false == unlink( WP_CONTENT_DIR . "/wp-cache-config.php" ) )
$file_not_deleted[] = 'wp-cache-config.php';
}
if ( $file_not_deleted ) {
$msg = __( "Dear User,\n\nWP Super Cache was removed from your blog or deactivated but some files could\nnot be deleted.\n\n", 'wp-super-cache' );
foreach( (array)$file_not_deleted as $filename ) {
$msg .= WP_CONTENT_DIR . "/{$filename}\n";
}
$msg .= "\n";
$msg .= sprintf( __( "You should delete these files manually.\nYou may need to change the permissions of the files or parent directory.\nYou can read more about this in the Codex at\n%s\n\nThank you.", 'wp-super-cache' ), 'https://codex.wordpress.org/Changing_File_Permissions#About_Chmod' );
if ( apply_filters( 'wpsc_send_uninstall_errors', 1 ) ) {
wp_mail( get_option( 'admin_email' ), __( 'WP Super Cache: could not delete files', 'wp-super-cache' ), $msg );
}
}
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {
$wp_rewrite->flush_rules();
} elseif( $scrules != '' ) {
wp_mail( get_option( 'admin_email' ), __( 'Supercache Uninstall Problems', 'wp-super-cache' ), sprintf( __( "Dear User,\n\nWP Super Cache was removed from your blog but the mod_rewrite rules\nin your .htaccess were not.\n\nPlease edit the following file and remove the code\nbetween 'BEGIN WPSuperCache' and 'END WPSuperCache'. Please backup the file first!\n\n%s\n\nRegards,\nWP Super Cache Plugin\nhttps://wordpress.org/plugins/wp-super-cache/", 'wp-super-cache' ), ABSPATH . '/.htaccess' ) );
}
}