Make WordPress Core


Ignore:
Timestamp:
04/11/2012 08:02:39 PM (13 years ago)
Author:
nacin
Message:

Use the metadata API rather than raw queries and direct do_action calls. see #20417.

File:
1 edited

Legend:

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

    r20209 r20435  
    427427    foreach ( $pung as $link_test ) {
    428428        if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post
    429             $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, like_escape( $link_test ) . '%') );
    430             do_action( 'delete_postmeta', $mid );
    431             $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE meta_id IN(%s)", implode( ',', $mid ) ) );
    432             do_action( 'deleted_postmeta', $mid );
     429            $mids = $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, like_escape( $link_test ) . '%') );
     430            foreach ( $mids as $mid )
     431                delete_metadata_by_mid( 'post', $mid );
    433432        }
    434433    }
     
    470469
    471470                if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
    472                     $meta_value = "$url\n$len\n$type\n";
    473                     $wpdb->insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) );
    474                     do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value );
     471                    add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
    475472                }
    476473            }
Note: See TracChangeset for help on using the changeset viewer.