Skip to content

Commit 7eb5ebc

Browse files
committed
[Experimental] Complete Repair
The third commit, at least on my end, worked and employs a specific method to prevent %a from being incorrectly parsed by sprintf in URL-encoded non-English strings. If we assume the fix in the third commit works, then the current changes should also work, since the overall layout of sprintf is the same. This commit was not AI-driven. Signed-off-by: Chunhui Ouyang <jack9603301@qhjack.top>
1 parent ceec65f commit 7eb5ebc

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
543543
$button
544544
);
545545
}
546-
$markup = sprintf(
546+
$markup = sprintf(
547547
'<span class="%1$s">%4$s<span popover="hint" id="%2$s" class="wp-tooltip__bubble" role="tooltip">' .
548548
'<span id="%2$s-text" class="wp-tooltip__text">%3$s</span>' .
549549
'</span>' .
@@ -559,22 +559,27 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
559559
* markup as phrasing content. The `aria-label`, `tabindex`, and `autofocus`
560560
* attributes reproduce the accessible name and focus handling of the native element.
561561
*/
562+
if ( is_string( $button ) ) {
563+
$button = str_replace(
564+
array( '%1$s', '%2$s', '%3$s', '%4$s' ),
565+
array( esc_attr( $classes ), esc_attr( $id ), esc_attr( $args['label'] ), esc_attr( $icon ) ),
566+
$button
567+
);
568+
}
562569
$markup = sprintf(
563-
'<span class="%1$s">
564-
' . $button . '
565-
<span popover="auto" id="%2$s" class="wp-tooltip__bubble" role="dialog" aria-label="%3$s" tabindex="-1" autofocus>' .
566-
'<span id="%2$s-text" class="wp-tooltip__text">%5$s</span>' .
567-
'<button type="button" class="wp-tooltip__close" popovertarget="%2$s" popovertargetaction="hide" aria-label="%6$s">' .
568-
'<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>' .
569-
'</button>' .
570-
'</span>' .
570+
'<span class="%1$s">%6$s<span popover="auto" id="%2$s" class="wp-tooltip__bubble" role="dialog" aria-label="%3$s" tabindex="-1" autofocus>' .
571+
'<span id="%2$s-text" class="wp-tooltip__text">%4$s</span>' .
572+
'<button type="button" class="wp-tooltip__close" popovertarget="%2$s" popovertargetaction="hide" aria-label="%5$s">' .
573+
'<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>' .
574+
'</button>' .
575+
'</span>' .
571576
'</span>',
572577
esc_attr( $classes ),
573578
esc_attr( $id ),
574579
esc_attr( $args['label'] ),
575-
esc_attr( $icon ),
576580
esc_html( $content ),
577581
esc_attr( $args['close_label'] ),
582+
$button
578583
);
579584
}
580585

0 commit comments

Comments
 (0)