Make WordPress Core


Ignore:
Timestamp:
09/04/2012 04:29:28 PM (12 years ago)
Author:
ryan
Message:

Use get_post() instead of global $post.
Make the $post argument to get_post() optional, defaulting to the current post in The Loop.

Props nacin
see #21309

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r21651 r21735  
    11221122 *
    11231123 * @param int $thumbnail_id ID of the attachment used for thumbnail
    1124  * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID
     1124 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post.
    11251125 * @return string html
    11261126 */
    1127 function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) {
    1128     global $content_width, $_wp_additional_image_sizes, $post_ID;
    1129 
    1130     if ( empty( $post_id ) )
    1131         $post_id = $post_ID;
    1132 
    1133     $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post_id) );
     1127function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
     1128    global $content_width, $_wp_additional_image_sizes;
     1129
     1130    $post = get_post( $post );
     1131
     1132    $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) );
    11341133    $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>';
    11351134    $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) );
     
    11431142            $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' );
    11441143        if ( !empty( $thumbnail_html ) ) {
    1145             $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id" );
     1144            $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
    11461145            $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html );
    11471146            $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>';
     
    11501149    }
    11511150
    1152     return apply_filters( 'admin_post_thumbnail_html', $content, $post_id );
     1151    return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID );
    11531152}
    11541153
     
    12081207 */
    12091208function _admin_notice_post_locked() {
    1210     global $post;
    1211 
     1209    $post = get_post();
    12121210    $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) );
    12131211    $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true );
Note: See TracChangeset for help on using the changeset viewer.