wpsc_admin_bar_delete_cache()WPSCache 1.0

Хуков нет.

Возвращает

null. Ничего.

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

wpsc_admin_bar_delete_cache();

Код wpsc_admin_bar_delete_cache() WPSCache 1.7.9

function wpsc_admin_bar_delete_cache() {
	$referer = wp_get_referer();

	if ( ! isset( $_GET['admin'] ) ) {
		$_GET['admin'] = 0;
	}

	foreach( array( 'path', 'nonce', 'admin' ) as $part ) {
		if ( isset( $_GET[ $part ] ) ) {
			$_POST[ $part ] = $_GET[ $part ];
		}
	}
	wpsc_delete_cache_directory();

	$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 && $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) {
		if ( $_POST['admin'] ) {
			wp_safe_redirect( $referer );
		} else {
			wp_safe_redirect( esc_url_raw( home_url( $req_path ) ) );
		}
		exit;
	} else {
		die( "Oops. Problem with nonce. Please delete cached page from settings page." );
	}
}