Make WordPress Core


Ignore:
Timestamp:
09/24/2009 05:10:28 PM (15 years ago)
Author:
ryan
Message:

Actions for postmeta updates. Props Demitrious Kelly. see #10750

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r11965 r11968  
    602602    $post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
    603603    if ( $post_ids ) {
    604         $wpdb->query($wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key));
     604        $postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key ) );
     605        do_action( 'delete_postmeta', $postmetaids );
     606        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN(%s)", implode( ',', $postmetaids) ) );
     607        do_action( 'deleted_postmeta', $postmetaids );
    605608        foreach ( $post_ids as $post_id )
    606609            wp_cache_delete($post_id, 'post_meta');
     
    11031106    $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) );
    11041107
    1105     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
    1106 
    1107     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d", $postid ));
    1108 
     1108    $commentids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $postid ));
     1109    do_action( 'delete_comment', $commentids );
     1110    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_ID IN(%s)", implode( ',', $commentids ) ));
     1111    do_action( 'deleted_comment', $commentids );
     1112
     1113    $postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
     1114    do_action( 'delete_postmeta', $postmetaids );
     1115    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN(%s)", implode( ',', $postmetaids ) ));
     1116    do_action( 'deleted_postmeta', $postmetaids );
     1117
     1118    do_action( 'delete_post', $post_id );
    11091119    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid ));
     1120    do_action( 'deleted_post', $post_id );
    11101121
    11111122    if ( 'page' == $post->post_type ) {
     
    25852596    wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
    25862597
    2587     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
    2588 
    2589     $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
    2590 
     2598    $commentids = $wpdb->get_col( $wpdb->prepare( "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d", $post_id ));
     2599    do_action( 'delete_comment', $commentids );
     2600    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->comments WHERE comment_ID IN(%s)", implode( ',', $commentids ) ));
     2601    do_action( 'deleted_comment', $commentids );
     2602
     2603    $postmetaids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d ", $post_id ));
     2604    do_action( 'delete_postmeta', $postmetaids );
     2605    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE meta_id IN(%s)", implode( ',', $postmetaids ) ));
     2606    do_action( 'deleted_postmeta', $postmetaids );
     2607
     2608    do_action( 'delete_post', $post_id );
    25912609    $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id ));
     2610    do_action( 'deleted_post', $post_id );
    25922611
    25932612    $uploadpath = wp_upload_dir();
     
    32713290
    32723291    $data = array( 'post_id' => $post_id, 'meta_value' => '1' );
    3273     if ( get_option('default_pingback_flag') )
     3292    if ( get_option('default_pingback_flag') ) {
    32743293        $wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_pingme' ) );
     3294        do_action( 'added_postmeta', $wpdb->insert_id, $post_id, '_pingme', 1 );
     3295    }
    32753296    $wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_encloseme' ) );
     3297    do_action( 'added_postmeta', $wpdb->insert_id, $post_id, '_encloseme', 1 );
     3298
    32763299    wp_schedule_single_event(time(), 'do_pings');
    32773300}
Note: See TracChangeset for help on using the changeset viewer.