Skip to content

Commit ceec65f

Browse files
committed
Fixed an implementation bug
The previous solution did not handle placeholders like %a in $button, which caused test errors. This update fixes the % placeholder parsing issue in $button, building upon the previous commit. This submission uses AI only as a search engine to provide references and has proven that the previous AI-generated solutions were partially flawed. Signed-off-by: Chunhui Ouyang <jack9603301@qhjack.top>
1 parent ecb094f commit ceec65f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎src/wp-includes/general-template.php‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,20 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
536536
if ( 'tooltip' === $args['type'] ) {
537537
// Tooltips are only used to visually display labels.
538538
$label = wp_strip_all_tags( $content, true );
539-
$markup = sprintf(
540-
'<span class="%1$s">%6$s<span popover="hint" id="%2$s" class="wp-tooltip__bubble" role="tooltip">' .
541-
'<span id="%2$s-text" class="wp-tooltip__text">%5$s</span>' .
539+
if ( is_string( $button ) ) {
540+
$button = str_replace(
541+
array( '%1$s', '%2$s', '%3$s', '%4$s' ),
542+
array( esc_attr( $classes ), esc_attr( $id ), esc_attr( $label ), esc_attr( $icon ) ),
543+
$button
544+
);
545+
}
546+
$markup = sprintf(
547+
'<span class="%1$s">%4$s<span popover="hint" id="%2$s" class="wp-tooltip__bubble" role="tooltip">' .
548+
'<span id="%2$s-text" class="wp-tooltip__text">%3$s</span>' .
542549
'</span>' .
543550
'</span>',
544551
esc_attr( $classes ),
545552
esc_attr( $id ),
546-
esc_attr( $label ),
547-
esc_attr( $icon ),
548553
esc_html( $content ),
549554
$button
550555
);

0 commit comments

Comments
 (0)