diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index b626b5ca605ce..bec5c81386101 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -530,18 +530,22 @@ 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( - ' - ' . $button . ' - ' . - '%5$s' . - '' . + '%4$s' . + '%3$s' . + '' . '', esc_attr( $classes ), esc_attr( $id ), - esc_attr( $label ), - esc_attr( $icon ), esc_html( $content ), + $button ); } else { /* @@ -549,22 +553,27 @@ function wp_get_tooltip_helper( $content, $args = array() ) { * 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( - ' - ' . $button . ' - ' . - '%5$s' . - '' . - '' . + '%6$s' . + '%4$s' . + '' . + '' . '', esc_attr( $classes ), esc_attr( $id ), esc_attr( $args['label'] ), - esc_attr( $icon ), esc_html( $content ), esc_attr( $args['close_label'] ), + $button ); }