[wp-trac] [WordPress Trac] #31813: delete_post_{post_type}

WordPress Trac noreply at wordpress.org
Tue Sep 15 01:41:47 UTC 2015


#31813: delete_post_{post_type}
-----------------------------------+-----------------------------
 Reporter:  GunGeekATX             |       Owner:  wonderboymusic
     Type:  enhancement            |      Status:  assigned
 Priority:  normal                 |   Milestone:  4.4
Component:  Posts, Post Types      |     Version:
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+-----------------------------

Comment (by mattheweppelsheimer):

 I believe that it is very useful to have the `delete_post{post_type}` hook
 in addition to extending `delete_post` to pass the post type.

 Here's my use case:

 My (rather infant) transient-clearing manager
 [https://github.com/MatthewEppelsheimer/wp-scrubber-
 plugin/blob/master/inc/class.scrubber.php Scrubber] allows you to register
 a transient to be cleared when any action hook is fired.

 In the places where I'm using this to update cached post data when a post
 is deleted, I have been just using `delete_post`. That works — but will
 clear transients much more often than needed that way. It's not the end of
 the world, but it would be nice to be more targeted, and limit the scope
 of the transient clearing.

 I've tried to figure out how I could use `delete_post` differently in this
 context if it passed the post type, and I don't see a way that I like.

 The transient-clearing method [https://github.com/MatthewEppelsheimer/wp-
 scrubber-plugin/blob/master/inc/class.scrubber.php#L95
 `Scrubber::scrub()`] does not currently accept any parameters. I could add
 calls to `doing_action()` and interpret parameters from there, but that
 would open up a pandora's box — adding hook-specific logic to a method
 that might run on '''any''' hook — and make it much more complicated and
 less manageable.

 Whereas, a `delete_post{post_type}` hook will allow that simple targeting,
 without complicating the method's logic.

 I'm wide open to suggestions if there's something I haven't thought of.

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


More information about the wp-trac mailing list