Changeset 11968
- Timestamp:
- 09/24/2009 05:10:28 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/post.php
r11930 r11968 589 589 590 590 $wpdb->query( $wpdb->prepare("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value ) VALUES (%s, %s, %s)", $post_ID, $metakey, $metavalue) ); 591 do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, $metakey, $metavalue ); 592 591 593 return $wpdb->insert_id; 592 594 } … … 609 611 wp_cache_delete($post_id, 'post_meta'); 610 612 611 return $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id = %d", $mid) ); 613 do_action( 'delete_postmeta', $mid ); 614 $rval = $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id = %d", $mid) ); 615 do_action( 'deleted_postmeta', $mid ); 616 617 return $rval; 612 618 } 613 619 … … 698 704 $where = compact( 'meta_id' ); 699 705 700 return $wpdb->update( $wpdb->postmeta, $data, $where ); 706 do_action( 'update_postmeta', $meta_id, $post_id, $meta_key, $meta_value ); 707 $rval = $wpdb->update( $wpdb->postmeta, $data, $where ); 708 do_action( 'updated_postmeta', $meta_id, $post_id, $meta_key, $meta_value ); 709 710 return $rval; 701 711 } 702 712 -
trunk/wp-includes/comment.php
r11945 r11968 1450 1450 // Do pingbacks 1451 1451 while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) { 1452 $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';"); 1452 $mid = $wpdb->get_var( "SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme' LIMIT 1"); 1453 do_action( 'delete_postmeta', $mid ); 1454 $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->postmeta} WHERE meta_id = %d", $mid ) ); 1455 do_action( 'deleted_postmeta', $mid ); 1453 1456 pingback($ping->post_content, $ping->ID); 1454 1457 } … … 1456 1459 // Do Enclosures 1457 1460 while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) { 1458 $wpdb->query( $wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_encloseme';", $enclosure->ID) ); 1461 $mid = $wpdb->get_var( $wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d AND meta_key = '_encloseme'", $enclosure->ID) ); 1462 do_action( 'delete_postmeta', $mid ); 1463 $wpdb->query( $wpdb->prepare("DELETE FROM {$wpdb->postmeta} WHERE meta_id = %d", $mid) ); 1464 do_action( 'deleted_postmeta', $mid ); 1459 1465 do_enclose($enclosure->post_content, $enclosure->ID); 1460 1466 } -
trunk/wp-includes/functions.php
r11961 r11968 1164 1164 foreach ( $pung as $link_test ) { 1165 1165 if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post 1166 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $link_test . '%') ); 1166 $mid = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $link_test . '%') ); 1167 do_action( 'delete_postmeta', $mid ); 1168 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id IN(%s)", implode( ',', $mid ) ) ); 1169 do_action( 'deleted_postmeta', $mid ); 1167 1170 } 1168 1171 } … … 1187 1190 $meta_value = "$url\n$len\n$type\n"; 1188 1191 $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) ); 1192 do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value ); 1189 1193 } 1190 1194 } -
trunk/wp-includes/meta.php
r11948 r11968 58 58 $meta_key = stripslashes($meta_key); 59 59 60 if ( ! $ wpdb->get_var( $wpdb->prepare( "SELECT meta_keyFROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) )60 if ( ! $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $table WHERE meta_key = %s AND $column = %d", $meta_key, $object_id ) ) ) 61 61 return add_metadata($meta_type, $object_id, $meta_key, $meta_value); 62 62 … … 71 71 } 72 72 73 do_action( "update_{$meta_type}_meta", $object_id, $meta_key, $meta_value );73 do_action( "update_{$meta_type}_meta", $object_id, $meta_key, $meta_value, $meta_id ); 74 74 75 75 $wpdb->update( $table, $data, $where ); 76 76 wp_cache_delete($object_id, $meta_type . '_meta'); 77 77 78 do_action( "updated_{$meta_type}_meta", $object_id, $meta_key, $meta_value );78 do_action( "updated_{$meta_type}_meta", $object_id, $meta_key, $meta_value, $meta_id ); 79 79 80 80 return true; … … 96 96 $meta_value = maybe_serialize( stripslashes_deep($meta_value) ); 97 97 98 $query = $wpdb->prepare( " DELETEFROM $table WHERE meta_key = %s", $meta_key );99 98 $query = $wpdb->prepare( "SELECT meta_id FROM $table WHERE meta_key = %s", $meta_key ); 99 100 100 if ( $meta_value ) 101 101 $query .= $wpdb->prepare("AND meta_value = %s", $meta_value ); 102 103 $meta_ids = $wpdb->get_col( $query ); 104 if ( !count( $meta_ids ) ) 105 return false; 106 107 $query = "DELETE FROM $table WHERE meta_id IN( " . implode( ',', $meta_ids ) . " )"; 102 108 103 109 $count = $wpdb->query($query); … … 108 114 wp_cache_delete($object_id, $meta_type . '_meta'); 109 115 110 do_action( "deleted_{$meta_type}_meta", $object_id, $meta_key, $meta_value );116 do_action( "deleted_{$meta_type}_meta", $object_id, $meta_key, $meta_value, $meta_ids ); 111 117 112 118 return true; -
trunk/wp-includes/post.php
r11965 r11968 602 602 $post_ids = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = %s", $post_meta_key)); 603 603 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 ); 605 608 foreach ( $post_ids as $post_id ) 606 609 wp_cache_delete($post_id, 'post_meta'); … … 1103 1106 $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) ); 1104 1107 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 ); 1109 1119 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $postid )); 1120 do_action( 'deleted_post', $post_id ); 1110 1121 1111 1122 if ( 'page' == $post->post_type ) { … … 2585 2596 wp_delete_object_term_relationships($post_id, array('category', 'post_tag')); 2586 2597 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 ); 2591 2609 $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->posts WHERE ID = %d", $post_id )); 2610 do_action( 'deleted_post', $post_id ); 2592 2611 2593 2612 $uploadpath = wp_upload_dir(); … … 3271 3290 3272 3291 $data = array( 'post_id' => $post_id, 'meta_value' => '1' ); 3273 if ( get_option('default_pingback_flag') ) 3292 if ( get_option('default_pingback_flag') ) { 3274 3293 $wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_pingme' ) ); 3294 do_action( 'added_postmeta', $wpdb->insert_id, $post_id, '_pingme', 1 ); 3295 } 3275 3296 $wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_encloseme' ) ); 3297 do_action( 'added_postmeta', $wpdb->insert_id, $post_id, '_encloseme', 1 ); 3298 3276 3299 wp_schedule_single_event(time(), 'do_pings'); 3277 3300 }
Note: See TracChangeset
for help on using the changeset viewer.