Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions src/wp-includes/general-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,41 +530,50 @@ function wp_get_tooltip_helper( $content, $args = array() ) {
if ( 'tooltip' === $args['type'] ) {
// Tooltips are only used to visually display labels.
$label = wp_strip_all_tags( $content, true );
if ( is_string( $button ) ) {
$button = str_replace(
array( '%1$s', '%2$s', '%3$s', '%4$s' ),
array( esc_attr( $classes ), esc_attr( $id ), esc_attr( $label ), esc_attr( $icon ) ),
$button
);
}
$markup = sprintf(
'<span class="%1$s">
' . $button . '
<span popover="hint" id="%2$s" class="wp-tooltip__bubble" role="tooltip">' .
'<span id="%2$s-text" class="wp-tooltip__text">%5$s</span>' .
'</span>' .
'<span class="%1$s">%4$s<span popover="hint" id="%2$s" class="wp-tooltip__bubble" role="tooltip">' .
'<span id="%2$s-text" class="wp-tooltip__text">%3$s</span>' .
'</span>' .
'</span>',
esc_attr( $classes ),
esc_attr( $id ),
esc_attr( $label ),
esc_attr( $icon ),
esc_html( $content ),
$button
);
} else {
/*
* A `span` with `role="dialog"` is used instead of a `dialog` element to keep the
* markup as phrasing content. The `aria-label`, `tabindex`, and `autofocus`
* attributes reproduce the accessible name and focus handling of the native element.
*/
if ( is_string( $button ) ) {
$button = str_replace(
array( '%1$s', '%2$s', '%3$s', '%4$s' ),
array( esc_attr( $classes ), esc_attr( $id ), esc_attr( $args['label'] ), esc_attr( $icon ) ),
$button
);
}
$markup = sprintf(
'<span class="%1$s">
' . $button . '
<span popover="auto" id="%2$s" class="wp-tooltip__bubble" role="dialog" aria-label="%3$s" tabindex="-1" autofocus>' .
'<span id="%2$s-text" class="wp-tooltip__text">%5$s</span>' .
'<button type="button" class="wp-tooltip__close" popovertarget="%2$s" popovertargetaction="hide" aria-label="%6$s">' .
'<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>' .
'</button>' .
'</span>' .
'<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>' .
'<span id="%2$s-text" class="wp-tooltip__text">%4$s</span>' .
'<button type="button" class="wp-tooltip__close" popovertarget="%2$s" popovertargetaction="hide" aria-label="%5$s">' .
'<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>' .
'</button>' .
'</span>' .
'</span>',
esc_attr( $classes ),
esc_attr( $id ),
esc_attr( $args['label'] ),
esc_attr( $icon ),
esc_html( $content ),
esc_attr( $args['close_label'] ),
$button
);
}

Expand Down
Loading