wpsc_delete_cache_directory()WPSCache 1.0

Хуков нет.

Возвращает

null. Ничего (null).

Использование

wpsc_delete_cache_directory();

Код wpsc_delete_cache_directory() WPSCache 1.12.0

function wpsc_delete_cache_directory() {
	if ( ! current_user_can( 'delete_others_posts' ) ) {
		return false;
	}

	$req_path    = isset( $_POST['path'] ) ? sanitize_text_field( stripslashes( $_POST['path'] ) ) : '';
	$valid_nonce = ( $req_path && isset( $_POST['nonce'] ) ) ? wp_verify_nonce( $_POST['nonce'], 'delete-cache-' . $_POST['path'] . '_' . $_POST['admin'] ) : false;

	if ( ! $valid_nonce ) {
		wp_cache_debug( 'wpsc_delete_cache_directory: nonce was not valid' );
		return false;
	}

	$path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;

	if ( $path ) {
		if ( isset( $_POST['admin'] ) && (int) $_POST['admin'] === 1 ) {
			global $file_prefix;
			wp_cache_debug( 'Cleaning cache for this site.' );
			wp_cache_clean_cache( $file_prefix );
			return;
		}
		$path           = trailingslashit( $path );
		$supercachepath = realpath( get_supercache_dir() );

		if ( false === wp_cache_confirm_delete( $path ) || ! str_starts_with( $path, $supercachepath ) ) {
			wp_cache_debug( 'Could not delete directory: ' . $path );
			define( 'WPSCDELETEERROR', 'Could not delete directory' );
			return false;
		}

		wp_cache_debug( 'Deleting cache files in directory: ' . $path );
		wpsc_delete_files( $path );
		return;
	} else {
		wp_cache_debug( 'wpsc_delete_cache_directory: Could not delete directory. It does not exist: ' . esc_attr( $_POST['path'] ) );
	}
}