Make WordPress Core

Changeset 44542


Ignore:
Timestamp:
01/10/2019 03:27:09 PM (8 years ago)
Author:
desrosj
Message:

Media: Introduce the has_post_thumbnail filter.

Props rzen, desrosj.
Fixes #44859.

File:
1 edited

Legend:

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

    r42843 r44542  
    2424 */
    2525function has_post_thumbnail( $post = null ) {
    26         return (bool) get_post_thumbnail_id( $post );
     26        $thumbnail_id  = get_post_thumbnail_id( $post );
     27        $has_thumbnail = (bool) $thumbnail_id;
     28
     29        /**
     30         * Filters whether a post has a post thumbnail.
     31         *
     32         * @since 5.1.0
     33         *
     34         * @param bool             $has_thumbnail true if the post has a post thumbnail, otherwise false.
     35         * @param int|WP_Post|null $post          Post ID or WP_Post object. Default is global `$post`.
     36         * @param int|string       $thumbnail_id  Post thumbnail ID or empty string.
     37         */
     38        return (bool) apply_filters( 'has_post_thumbnail', $has_thumbnail, $post, $thumbnail_id );
    2739}
    2840
Note: See TracChangeset for help on using the changeset viewer.