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

Line Code
1023 function wp_delete_post($postid = 0) {
1024      global $wpdb, $wp_rewrite;
1025
1026      if ( !$post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d", $postid)) )
1027           return $post;
1028
1029      if ( 'attachment' == $post->post_type )
1030           return wp_delete_attachment($postid);
1031
1032      do_action('delete_post', $postid);
1033
1034      /** @todo delete for pluggable post taxonomies too */
1035      wp_delete_object_term_relationships($postid, array('category', 'post_tag'));
1036
1037      $parent_data = array( 'post_parent' => $post->post_parent );
1038      $parent_where = array( 'post_parent' => $postid );
1039
1040      if ( 'page' == $post->post_type) {
1041            // if the page is defined in option page_on_front or post_for_posts,