[wp-trac] [WordPress Trac] #30940: Extend delete actions arguments

WordPress Trac noreply at wordpress.org
Wed Jan 7 12:51:36 UTC 2015


#30940: Extend delete actions arguments
-------------------------------+-----------------------------
 Reporter:  jadpm              |      Owner:
     Type:  feature request    |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  trunk
 Severity:  normal             |   Keywords:
  Focuses:                     |
-------------------------------+-----------------------------
 When using wp_delete_post(), four actions are fired: before_delete_post,
 delete_post, deleted_post and after_delete_post. All of them get the
 $postid argument.

 In some situations, it might be useful to have some extra information
 about the post being deleted, to perform different actions depending on
 things like the post date or the post type. With extensive usage of custom
 post types, this becomes more evident.

 We can always get that data from the post ID being passed as an argument
 on those four actions, but that will add extra database calls that we can
 easily avoid. Early in wp_delet_post(), we do get the post row object from
 the database to check for things like post type and post parent. It seems
 a waste to recreate that data again if needed, plus it is not there
 anymore on the last two actions due to, well, post deletion. This limits
 what can be done on those last two actions in a granular way (no different
 deleted_post action callback workflow on a per post type basis, for
 example).

 I propose to extend those foud actions to take another optional argument,
 $post, being the post row object.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30940>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list