Source View: delete_post

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: apply_filters( "hook_name", "what_to_filter" ).

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
2537           delete_metadata_by_mid( 'post', $mid );
2538
2539      /**
2540       * Fires immediately before a post is deleted from the database.
2541       *
2542       * @since 1.2.0
2543       *
2544       * @param int $postid Post ID.
2545       */
2546      do_action( 'delete_post', $postid );
2547      $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $postid ) );
2548      if ( ! $result ) {
2549           return false;
2550      }
2551
2552      /**
2553       * Fires immediately after a post is deleted from the database.
2554       *
2555       * @since 2.2.0
 
Line Code
4983      }
4984
4985      wp_defer_comment_counting( false );
4986
4987      $post_meta_ids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
4988      foreach ( $post_meta_ids as $mid )
4989           delete_metadata_by_mid( 'post', $mid );
4990
4991      /** This action is documented in wp-includes/post.php */
4992      do_action( 'delete_post', $post_id );
4993      $result = $wpdb->delete( $wpdb->posts, array( 'ID' => $post_id ) );
4994      if ( ! $result ) {
4995           return false;
4996      }
4997      /** This action is documented in wp-includes/post.php */
4998      do_action( 'deleted_post', $post_id );
4999
5000      $uploadpath = wp_get_upload_dir();
5001