From ba6f1ff56e0cf7c473a8e93c87d4a22a3aaa27ce Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Thu, 10 Jan 2019 15:27:09 +0000 Subject: [PATCH] Media: Introduce the `has_post_thumbnail` filter. Props rzen, desrosj. Fixes #44859. git-svn-id: https://develop.svn.wordpress.org/trunk@44542 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/post-thumbnail-template.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/post-thumbnail-template.php b/src/wp-includes/post-thumbnail-template.php index c20e2df1aa..3293a98d77 100644 --- a/src/wp-includes/post-thumbnail-template.php +++ b/src/wp-includes/post-thumbnail-template.php @@ -23,7 +23,19 @@ * @return bool Whether the post has an image attached. */ function has_post_thumbnail( $post = null ) { - return (bool) get_post_thumbnail_id( $post ); + $thumbnail_id = get_post_thumbnail_id( $post ); + $has_thumbnail = (bool) $thumbnail_id; + + /** + * Filters whether a post has a post thumbnail. + * + * @since 5.1.0 + * + * @param bool $has_thumbnail true if the post has a post thumbnail, otherwise false. + * @param int|WP_Post|null $post Post ID or WP_Post object. Default is global `$post`. + * @param int|string $thumbnail_id Post thumbnail ID or empty string. + */ + return (bool) apply_filters( 'has_post_thumbnail', $has_thumbnail, $post, $thumbnail_id ); } /**