Posts, Post Types: Pass the post object to the delete_attachment
action.
Also add the missing `$post` parameter to the `delete_post` and `deleted_post` actions in `wp_delete_attachment()`. See #30940. git-svn-id: https://develop.svn.wordpress.org/trunk@47856 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2c75752c88
commit
adcf5cf7a3
@ -5717,10 +5717,12 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
||||
* Fires before an attachment is deleted, at the start of wp_delete_attachment().
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @since 5.5.0 Added the `$post` parameter.
|
||||
*
|
||||
* @param int $post_id Attachment ID.
|
||||
* @param int $post_id Attachment ID.
|
||||
* @param WP_Post $post Post object.
|
||||
*/
|
||||
do_action( 'delete_attachment', $post_id );
|
||||
do_action( 'delete_attachment', $post_id, $post );
|
||||
|
||||
wp_delete_object_term_relationships( $post_id, array( 'category', 'post_tag' ) );
|
||||
wp_delete_object_term_relationships( $post_id, get_object_taxonomies( $post->post_type ) );
|
||||
@ -5743,13 +5745,13 @@ function wp_delete_attachment( $post_id, $force_delete = false ) {
|
||||
}
|
||||
|
||||
/** This action is documented in wp-includes/post.php */
|
||||
do_action( 'delete_post', $post_id );
|
||||
do_action( 'delete_post', $post_id, $post );
|
||||
$result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
|
||||
if ( ! $result ) {
|
||||
return false;
|
||||
}
|
||||
/** This action is documented in wp-includes/post.php */
|
||||
do_action( 'deleted_post', $post_id );
|
||||
do_action( 'deleted_post', $post_id, $post );
|
||||
|
||||
wp_delete_attachment_files( $post_id, $meta, $backup_sizes, $file );
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user