How can I get correct permalink url in before_delete_post hook?
Well, p=1111 style is a valid link to the post 🙂 But not following your defined permastruct. Your callback is passed the post’s object. You could construct your permalink using your own code and the object’s data. Exactly how depends on what your permastruct is. On a basic level, just append the post’s slug to your site URL.
For more flexibility, the permastruct is stored in the “permalink_structure” option. You’d then replace all %tags%-like elements in the structure with their proper values for this particular post.
It probably doesn’t matter, but out of curiosity, why get the permalink of a post that’s going to be deleted?
I need permalink to get local cached static file path to delete them.
I found a way to fix that, just disable TRASH, add below line to wp-config.php
define(‘EMPTY_TRASH_DAYS’,0);