Changeset 4612 for trunk/wp-includes/post.php
- Timestamp:
- 12/05/2006 10:37:19 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r4606 r4612 5 5 // 6 6 7 function get_attached_file($attachment_id) { 8 return get_post_meta($attachment_id, '_wp_attached_file', true); 7 function get_attached_file( $attachment_id, $unfiltered = false ) { 8 $file = get_post_meta( $attachment_id, '_wp_attached_file', true ); 9 if ( $unfiltered ) 10 return $file; 11 return apply_filters( 'get_attached_file', $file, $attachment_id ); 12 } 13 14 function update_attached_file( $attachment_id, $file ) { 15 if ( !get_post( $attachment_id ) ) 16 return false; 17 18 $old_file = get_attached_file( $attachment_id, true ); 19 20 $file = apply_filters( 'update_attached_file', $file, $attachment_id ); 21 22 if ( $old_file ) 23 return update_post_meta( $attachment_id, '_wp_attached_file', $file, $old_file ); 24 else 25 return add_post_meta( $attachment_id, '_wp_attached_file', $file ); 9 26 } 10 27 … … 1332 1349 1333 1350 if ( $file ) 1334 add_post_meta($post_ID, '_wp_attached_file', $file);1351 update_attached_file( $post_ID, $file ); 1335 1352 1336 1353 clean_post_cache($post_ID); … … 1355 1372 return false; 1356 1373 1357 $meta = get_post_meta($postid, '_wp_attachment_metadata', true);1358 $file = get_ post_meta($postid, '_wp_attached_file', true);1374 $meta = wp_get_attachment_metadata( $postid ); 1375 $file = get_attached_file( $postid ); 1359 1376 1360 1377 $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = '$postid'"); … … 1385 1402 } 1386 1403 1404 function wp_get_attachment_metadata( $post_id, $unfiltered = false ) { 1405 $post_id = (int) $post_id; 1406 1407 $data = get_post_meta( $post_id, '_wp_attachment_metadata', true ); 1408 if ( $unfiltered ) 1409 return $data; 1410 return apply_filters( 'wp_get_attachment_metadata', $data, $post_id ); 1411 } 1412 1413 function wp_update_attachment_metadata( $post_id, $data ) { 1414 if ( !get_post( $post_id ) ) 1415 return false; 1416 1417 $old_data = wp_get_attachment_metadata( $post_id, true ); 1418 1419 $data = apply_filters( 'wp_update_attachment_metadata', $data, $post_id ); 1420 1421 if ( $old_data ) 1422 return update_post_meta( $post_id, '_wp_attachment_metadata', $data, $old_data ); 1423 else 1424 return add_post_meta( $post_id, '_wp_attachment_metadata', $data ); 1425 } 1426 1387 1427 ?>
Note: See TracChangeset
for help on using the changeset viewer.