Make WordPress Core

Ticket #3520: 3520b.diff

File 3520b.diff, 4.1 KB (added by mdawaffe, 20 years ago)
  • wp-includes/post-template.php

     
    378378        if ( !$post = & get_post($id) )
    379379                return false;
    380380
    381         if ( !$src = get_attachment_icon_src( $id, $fullsize ) )
     381        if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) )
    382382                return false;
    383383
    384384        list($src, $src_file) = $src;
     
    415415
    416416function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) {
    417417        $id = (int) $id;
     418        if ( !$post = & get_post($id) )
     419                return false;
    418420
    419         if ( $innerHTML = get_attachment_icon($id, $fullsize, $max_dims))
     421        if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims))
    420422                return $innerHTML;
    421423
    422         $post = & get_post($id);
    423424
    424425        $innerHTML = attribute_escape($post->post_title);
    425426
  • wp-includes/post.php

     
    14021402
    14031403function wp_get_attachment_metadata( $post_id, $unfiltered = false ) {
    14041404        $post_id = (int) $post_id;
     1405        if ( !$post =& get_post( $post_id ) )
     1406                return false;
    14051407
    1406         $data = get_post_meta( $post_id, '_wp_attachment_metadata', true );
     1408        $data = get_post_meta( $post->ID, '_wp_attachment_metadata', true );
    14071409        if ( $unfiltered )
    14081410                return $data;
    1409         return apply_filters( 'wp_get_attachment_metadata', $data, $post_id );
     1411        return apply_filters( 'wp_get_attachment_metadata', $data, $post->ID );
    14101412}
    14111413
    14121414function wp_update_attachment_metadata( $post_id, $data ) {
    14131415        $post_id = (int) $post_id;
    1414         if ( !get_post( $post_id ) )
     1416        if ( !$post =& get_post( $post_id ) )
    14151417                return false;
    14161418
    1417         $old_data = wp_get_attachment_metadata( $post_id, true );
     1419        $old_data = wp_get_attachment_metadata( $post->ID, true );
    14181420
    1419         $data = apply_filters( 'wp_update_attachment_metadata', $data, $post_id );
     1421        $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID );
    14201422
    14211423        if ( $old_data )
    1422                 return update_post_meta( $post_id, '_wp_attachment_metadata', $data, $old_data );
     1424                return update_post_meta( $post->ID, '_wp_attachment_metadata', $data, $old_data );
    14231425        else
    1424                 return add_post_meta( $post_id, '_wp_attachment_metadata', $data );
     1426                return add_post_meta( $post->ID, '_wp_attachment_metadata', $data );
    14251427}
    14261428
    14271429function wp_get_attachment_url( $post_id = 0 ) {
     
    14291431        if ( !$post =& get_post( $post_id ) )
    14301432                return false;
    14311433
    1432         $url = get_the_guid( $post_id );
     1434        $url = get_the_guid( $post->ID );
    14331435
    14341436        if ( 'attachment' != $post->post_type || !$url )
    14351437                return false;
    14361438
    1437         return apply_filters( 'wp_get_attachment_url', $url, $post_id );
     1439        return apply_filters( 'wp_get_attachment_url', $url, $post->ID );
    14381440}
    14391441
    1440 function wp_get_attachment_thumb_file( $post_id ) {
     1442function wp_get_attachment_thumb_file( $post_id = 0 ) {
    14411443        $post_id = (int) $post_id;
    1442         if ( !$imagedata = wp_get_attachment_metadata( $post_id ) )
     1444        if ( !$post =& get_post( $post_id ) )
    14431445                return false;
     1446        if ( !$imagedata = wp_get_attachment_metadata( $post->ID ) )
     1447                return false;
    14441448
    1445         $file = get_attached_file( $post_id );
     1449        $file = get_attached_file( $post->ID );
    14461450
    14471451        if ( !empty($imagedata['thumb']) && ($thumbfile = str_replace(basename($file), $imagedata['thumb'], $file)) && file_exists($thumbfile) )
    1448                 return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post_id );
     1452                return apply_filters( 'wp_get_attachment_thumb_file', $thumbfile, $post->ID );
    14491453        return false;
    14501454}
    14511455
    14521456function wp_get_attachment_thumb_url( $post_id = 0 ) {
    14531457        $post_id = (int) $post_id;
    1454         if ( !$url = wp_get_attachment_url( $post_id ) )
     1458        if ( !$post =& get_post( $post_id ) )
    14551459                return false;
     1460        if ( !$url = wp_get_attachment_url( $post->ID ) )
     1461                return false;
    14561462
    1457         if ( !$thumb = wp_get_attachment_thumb_file( $post_id ) )
     1463        if ( !$thumb = wp_get_attachment_thumb_file( $post->ID ) )
    14581464                return false;
    14591465
    14601466        $url = str_replace(basename($url), basename($thumb), $url);
    14611467
    1462         return apply_filters( 'wp_get_attachment_thumb_url', $url, $post_id );
     1468        return apply_filters( 'wp_get_attachment_thumb_url', $url, $post->ID );
    14631469}
    14641470
    14651471function wp_attachment_is_image( $post_id = 0 ) {