Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
add_filter( 'wp_redirect', 'baw_hack_delete_post_redirect' );
function baw_hack_delete_post_redirect( $url ) {
$ref = wp_get_referer();
if ( strpos( $ref, admin_url() ) === false
&& isset( $_GET['action'], $_GET['post'] )
&& ( ( 'delete' == $_GET['action'] && check_admin_referer('delete-post_' . $_GET['post'] ) )
|| ( 'trash' == $_GET['action'] && check_admin_referer('trash-post_' . $_GET['post'] ) )
)
) {
return home_url();
}
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment