I might be too dumb, so I wanted to ask someone to put another pair of eyes on this.
Use this code to hook into the wp_delete_post
:
add_action( 'before_delete_post', 'my_delete_post_cb', 10, 2 );
function my_delete_post_cb( $postid, $post ) {
error_log(print_r($postid));
error_log(print_r($post));
}
Make sure WP Debug is enabled.
Delete a Post from within the WP Admin (delete, not trash). Or use wp_delete_post
to programmatically a post of your choice.
Check the error logs.
It will tell you that both variables return 1
(???)
It should be the Post ID and Post Object instead.
I have tried this on all possible priorities – and checking the code at https://github.com/WordPress/wordpress-develop/blob/9690aa7f7b0b7acd5acad54278952622585dec16/src/wp-includes/post.php#L3407-L3407, clearly the $post
is used by core after this hook.
So it is available.
Why however does it not return the Post Object but what seems to be (probably) boolean true when hooking in with before_delete_post
?
This makes no sense to me. It seems broken, yet if it were, then core couldn’t delete the revisions, for example, but it does (of course it does!).
So… I am missing something. Priority? If so, what would be the proper priority?
- This topic was modified 1 hour, 21 minutes ago by . Reason: italics
- This topic was modified 1 hour, 20 minutes ago by . Reason: italics!