[wp-trac] [WordPress Trac] #57320: Revisions: add filter before deleting revisions

WordPress Trac noreply at wordpress.org
Mon Dec 12 17:51:12 UTC 2022


#57320: Revisions: add filter before deleting revisions
-------------------------+------------------------------
 Reporter:  jhned        |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Revisions    |     Version:  trunk
 Severity:  trivial      |  Resolution:
 Keywords:               |     Focuses:  administration
-------------------------+------------------------------

Comment (by jhned):

 Hi @costdev, thanks for the thought. I tried both `the_posts` and
 `pre_get_posts` in coming up with this idea. In `pre_get_posts` I was able
 to modify the query and set the "exclude" or "post_not_^^_in" args, but
 the `wp_get_post_revisions` call still returned all the revisions. With
 `the_posts`, for some reason it wasn't hitting my breakpoint for the
 `wp_get_post_revisions` call; I tried your example as well and it's not
 intercepting the revision deletion process.

 When using either `pre_get_posts` or `the_posts`, however, we'd have to do
 extra work to make sure that the query in question is one that's getting
 ready to delete some revisions after it gets them. Using `pre_get_posts`
 or `the_posts` wouldn't give us that context. We could try
 `debug_backtrace`, but that seems like overkill compared to adding a new
 hook.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57320#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list