WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/05/2020 10:15:40 AM (17 months ago)
Author:
SergeyBiryukov
Message:

Post Thumbnails: Change the return value of get_post_thumbnail_id() for a non-existing post to false instead of an empty string.

This further makes the function more consistent with get_the_ID() or wp_get_post_parent_id(), both returning false for a non-existing post.

Additionally, document that get_post_thumbnail_id() returns 0 if the thumbnail image is not set.

Follow-up to [47160].

Props theMikeD, dingo_d, netpassprodsr, SergeyBiryukov.
Fixes #49832. See #40096.

File:
1 edited

Legend:

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

    r48214 r48310  
    70157015 *
    70167016 * @param int|WP_Post $post Post ID or post object. Defaults to global $post.
    7017  * @return int|false Post parent ID (which can be 0 if there is no parent), or false if the post does not exist.
     7017 * @return int|false Post parent ID (which can be 0 if there is no parent),
     7018 *                   or false if the post does not exist.
    70187019 */
    70197020function wp_get_post_parent_id( $post ) {
Note: See TracChangeset for help on using the changeset viewer.