Skip to content

Commit 6faa263

Browse files
committed
Fix condition when the value link is null
1 parent 86f29f6 commit 6faa263

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

inc/Helpers/Formatting/Link.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,20 @@ function get_the_link( array $attributes, array $settings = [] ): string {
159159

160160
$attributes_escaped = [];
161161
foreach ( $attributes as $name => $value ) {
162-
// Use user escape function, or default
163-
$value = escape_attribute_value( $value, $settings['escape'][ $name ] ?? '' );
164-
165162
// Handle single attributes like checked or data-seo-target, if null no attribute value
166-
$attributes_escaped[] = null === $value ? $name : sprintf( '%s="%s"', $name, $value );
163+
if ( null === $value ) {
164+
$attributes_escaped[] = $name;
165+
} else {
166+
// Use user escape function, or default
167+
$value = escape_attribute_value( $value, $settings['escape'][ $name ] ?? '' );
168+
$attributes_escaped[] = sprintf( '%s="%s"', $name, $value );
169+
}
167170
}
168171

169172
// Implode all attributes for display purposes
170173
$attributes_escaped = implode( ' ', $attributes_escaped );
171174
// Escape content for display purposes
172-
$label = escape_content_value( $settings['content'], $settings['escape']['content'] ?? '' );
175+
$label = $settings['content'] ? escape_content_value( $settings['content'], $settings['escape']['content'] ?? '' ) : '';
173176

174177
$link_markup = sprintf( '<a %s>%s%s</a>', $attributes_escaped, $settings['new_window'], $label );
175178

0 commit comments

Comments
 (0)