Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

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.

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
537      global $wpdb, $wp_rewrite;
538      $postid = (int) $postid;
539
540      if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
541           return $post;
542
543      if ( 'attachment' == $post->post_status )
544           return wp_delete_attachment($postid);
545
546      do_action('delete_post', $postid);
547
548      if ( 'publish' == $post->post_status) {
549           $categories = wp_get_post_cats('', $post->ID);
550           if( is_array( $categories ) ) {
551                foreach ( $categories as $cat_id ) {
552                     $wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'");
553                     wp_cache_delete($cat_id, 'category');
554                }
555           }