equalizedigital / accessibility-checker

GNU General Public License v2.0
15 stars 8 forks source link

Purge the post data if the saved post is in or is moving to trash #692

Open pattonwebz opened 1 week ago

pattonwebz commented 1 week ago

This PR calls the method to delete issues when a post is trashed during the validate method at the point it would early bail since post is trashed.

I moved the trash bail later in the method to ensure that any other quicker bail checks can run before it runs database queries for deleting issues.

This is needed here because Gutenberg editor does not fire the wp_trash_post hook because it uses rest API which updates a post with trash status where as classic editor and the quick actions in post lists invoke the actual trash functions. Deleting via rest does have a different action we could bind to - rest_delete_{$post_type} but using it is less clean than the way wp_trash_post works so I decided to use the method in this PR to solve this instead.