Widgets: Omit attributes from an Image widget's link when they are empty.
Props subrataemfluence, Nenad Obradovic, westonruter. See #39993. Fixes #41919. Built from https://develop.svn.wordpress.org/trunk@41549 git-svn-id: http://core.svn.wordpress.org/trunk@41382 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6918752529
commit
379e0371dd
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41548';
|
||||
$wp_version = '4.9-alpha-41549';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
@ -240,14 +240,20 @@ class WP_Widget_Media_Image extends WP_Widget_Media {
|
|||
}
|
||||
|
||||
if ( $url ) {
|
||||
$image = sprintf(
|
||||
'<a href="%1$s" class="%2$s" rel="%3$s" target="%4$s">%5$s</a>',
|
||||
esc_url( $url ),
|
||||
esc_attr( $instance['link_classes'] ),
|
||||
esc_attr( $instance['link_rel'] ),
|
||||
! empty( $instance['link_target_blank'] ) ? '_blank' : '',
|
||||
$image
|
||||
);
|
||||
$link = sprintf( '<a href="%s"', esc_url( $url ) );
|
||||
if ( ! empty( $instance['link_classes'] ) ) {
|
||||
$link .= sprintf( ' class="%s"', esc_attr( $instance['link_classes'] ) );
|
||||
}
|
||||
if ( ! empty( $instance['link_rel'] ) ) {
|
||||
$link .= sprintf( ' rel="%s"', esc_attr( $instance['link_rel'] ) );
|
||||
}
|
||||
if ( ! empty( $instance['link_target_blank'] ) ) {
|
||||
$link .= ' target="_blank"';
|
||||
}
|
||||
$link .= '>';
|
||||
$link .= $image;
|
||||
$link .= '</a>';
|
||||
$image = $link;
|
||||
}
|
||||
|
||||
if ( $caption ) {
|
||||
|
|
Loading…
Reference in New Issue