admin_bar_delete_page() WPSCache 1.0
Delete cache for a specific page.
No Hooks.
Return
Null. Nothing.
Usage
admin_bar_delete_page();
Code of admin_bar_delete_page() admin bar delete page WPSCache 1.7.1
function admin_bar_delete_page() {
if ( ! current_user_can( 'delete_others_posts' ) ) {
return false;
}
$req_path = isset( $_GET['path'] ) ? sanitize_text_field( stripslashes( $_GET['path'] ) ) : '';
$referer = wp_get_referer();
$valid_nonce = ( $req_path && isset( $_GET['_wpnonce'] ) ) ? wp_verify_nonce( $_GET['_wpnonce'], 'delete-cache' ) : false;
$path = $valid_nonce ? realpath( trailingslashit( get_supercache_dir() . str_replace( '..', '', preg_replace( '/:.*$/', '', $req_path ) ) ) ) : false;
if ( $path ) {
$path = trailingslashit( $path );
$supercachepath = realpath( get_supercache_dir() );
if ( false === wp_cache_confirm_delete( $path ) ||
0 !== strpos( $path, $supercachepath )
) {
wp_die( 'Could not delete directory' );
}
wpsc_delete_files( $path );
}
if ( $referer && $req_path && ( false !== stripos( $referer, $req_path ) || 0 === stripos( $referer, wp_login_url() ) ) ) {
wp_safe_redirect( esc_url_raw( home_url( $req_path ) ) );
exit;
}
}