Widgets: Prevent showing underlying attachment excerpt as caption when empty caption value is supplied in Image widget.

Allow underlying attachment to display if `caption` is `null`.

Props miyauchi, westonruter.
See #39993.
Fixes #42350.

Built from https://develop.svn.wordpress.org/trunk@42030


git-svn-id: http://core.svn.wordpress.org/trunk@41864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-10-27 05:05:51 +00:00
parent 7b0de1f1b0
commit cb877e10ba
2 changed files with 5 additions and 3 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-beta4-42029';
$wp_version = '4.9-beta4-42030';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -177,8 +177,10 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
$attachment = get_post( $instance['attachment_id'] );
}
if ( $attachment ) {
$caption = '';
if ( ! isset( $instance['caption'] ) ) {
$caption = $attachment->post_excerpt;
if ( $instance['caption'] ) {
} elseif ( trim( $instance['caption'] ) ) {
$caption = $instance['caption'];
}