Ticket #10511: 10511.diff
File 10511.diff, 2.3 KB (added by , 15 years ago) |
---|
-
wp-includes/functions.php
1107 1107 /** 1108 1108 * Check content for video and audio links to add as enclosures. 1109 1109 * 1110 * Will not add enclosures that have already been added and will 1111 * remove enclosures that are no longer in the post. This is called as 1110 * Will not add enclosures that have already been added. This is called as 1112 1111 * pingbacks and trackbacks. 1113 1112 * 1114 1113 * @package WordPress … … 1139 1138 debug_fwrite( $log, 'Post contents:' ); 1140 1139 debug_fwrite( $log, $content . "\n" ); 1141 1140 1142 foreach ( $pung as $link_test ) {1143 if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post1144 $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 . '%') );1145 do_action( 'delete_postmeta', $mid );1146 $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->postmeta WHERE post_id IN(%s)", implode( ',', $mid ) ) );1147 do_action( 'deleted_postmeta', $mid );1148 }1149 }1150 1151 1141 foreach ( (array) $post_links_temp[0] as $link_test ) { 1152 1142 if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already 1153 1143 $test = parse_url( $link_test ); … … 1162 1152 if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, $url . '%' ) ) ) { 1163 1153 if ( $headers = wp_get_http_headers( $url) ) { 1164 1154 $len = (int) $headers['content-length']; 1165 $type = $ headers['content-type'];1155 $type = $wpdb->escape( $headers['content-type'] ); 1166 1156 $allowed_types = array( 'video', 'audio' ); 1167 1157 if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) { 1168 1158 $meta_value = "$url\n$len\n$type\n"; 1169 $wpdb-> insert($wpdb->postmeta, array('post_id' => $post_ID, 'meta_key' => 'enclosure', 'meta_value' => $meta_value) );1170 do_action( 'added_postmeta', $wpdb->insert_id, $post_ID, 'enclosure', $meta_value);1159 $wpdb->query( $wpdb->prepare( "INSERT INTO `$wpdb->postmeta` ( `post_id` , `meta_key` , `meta_value` ) 1160 VALUES ( %d, 'enclosure' , %s)", $post_ID, $meta_value ) ); 1171 1161 } 1172 1162 } 1173 1163 }