Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: edit_category

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

This hook occurs 2 times in this file.

Line Code
413
414      do_action('delete_post', $postid);
415
416      if ( 'publish' == $post->post_status && 'post' == $post->post_type ) {
417           $categories = wp_get_post_categories($post->ID);
418           if( is_array( $categories ) ) {
419                foreach ( $categories as $cat_id ) {
420                     $wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'");
421                     wp_cache_delete($cat_id, 'category');
422                     do_action('edit_category', $cat_id);
423                }
424           }
425      }
426
427      if ( 'page' == $post->post_type )
428           $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'page'");
429
430      $wpdb->query("UPDATE $wpdb->posts SET post_parent = $post->post_parent WHERE post_parent = $postid AND post_type = 'attachment'");
431
 
Line Code
806           }
807      }
808
809      // Update category counts.
810      $all_affected_cats = array_unique(array_merge($post_categories, $old_categories));
811      foreach ( $all_affected_cats as $cat_id ) {
812           $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
813           $wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
814           clean_category_cache($cat_id);
815           do_action('edit_category', $cat_id);
816      }
817 }     // wp_set_post_categories()
818
819 //
820 // Trackback and ping functions
821 //
822
823 function add_ping($post_id, $uri) { // Add a URL to those already pung
824      global $wpdb;