Make WordPress Core


Ignore:
Timestamp:
02/02/2020 03:06:31 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Post Thumbnails: Make sure get_post_thumbnail_id() returns an integer, to match the documented return value.

This makes the function more consistent with get_the_ID() or wp_get_post_parent_id(), both returning an integer.

Props 0v3rth3d4wn.
Fixes #40096.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-thumbnail-template.php

    r45739 r47160  
    4646 *
    4747 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
    48  * @return string|int Post thumbnail ID or empty string.
     48 * @return int|string Post thumbnail ID or empty string if the post does not exist.
    4949 */
    5050function get_post_thumbnail_id( $post = null ) {
     
    5353        return '';
    5454    }
    55     return get_post_meta( $post->ID, '_thumbnail_id', true );
     55    return (int) get_post_meta( $post->ID, '_thumbnail_id', true );
    5656}
    5757
Note: See TracChangeset for help on using the changeset viewer.