From 2a8abfef8126c5d9713d91b26878ebff321e8bd3 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 28 Sep 2015 15:34:25 +0000 Subject: [PATCH] Update `get_the_post_thumbnail_url()` so it returns false on failure, to bring it inline with `wp_get_attachment_image_url()`. Correct and introduce new tests. Fixes #33070 Built from https://develop.svn.wordpress.org/trunk@34663 git-svn-id: http://core.svn.wordpress.org/trunk@34627 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-thumbnail-template.php | 12 +++++++++--- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wp-includes/post-thumbnail-template.php b/wp-includes/post-thumbnail-template.php index a648a6f82c..4ae50f288f 100644 --- a/wp-includes/post-thumbnail-template.php +++ b/wp-includes/post-thumbnail-template.php @@ -182,8 +182,11 @@ function get_the_post_thumbnail( $post = null, $size = 'post-thumbnail', $attr = * @return string|false Post thumbnail URL or false if no URL is available. */ function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) { - $image = wp_get_attachment_image_url( get_post_thumbnail_id( $post ), $size ); - return isset( $image ) ? $image : false; + $post_thumbnail_id = get_post_thumbnail_id( $post ); + if ( ! $post_thumbnail_id ) { + return false; + } + return wp_get_attachment_image_url( $post_thumbnail_id, $size ); } /** @@ -195,5 +198,8 @@ function get_the_post_thumbnail_url( $post = null, $size = 'post-thumbnail' ) { * array of height and width dimensions. Default 'post-thumbnail'. */ function the_post_thumbnail_url( $size = 'post-thumbnail' ) { - echo get_the_post_thumbnail_url( null, $size ); + $url = get_the_post_thumbnail_url( null, $size ); + if ( $url ) { + echo esc_url( $url ); + } } diff --git a/wp-includes/version.php b/wp-includes/version.php index c91be878da..ec4bbcc862 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34662'; +$wp_version = '4.4-alpha-34663'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.