Skip to content

Commit

Permalink
Merge pull request #6126 from ampproject/fix/amp-admin-menu-item-tool…
Browse files Browse the repository at this point in the history
…tips

Fix AMP admin menu item link tooltips when DevTools disabled
  • Loading branch information
westonruter authored Apr 27, 2021
2 parents 0627a15 + 2b376e8 commit 5e65134
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1758,13 +1758,16 @@ function amp_add_admin_bar_view_link( $wp_admin_bar ) {
'class' => 'ab-icon',
];

$non_amp_view_title = __( 'View non-AMP version', 'amp' );
$amp_view_title = __( 'View AMP version', 'amp' );

$wp_admin_bar->add_node(
[
'id' => 'amp',
'title' => $icon->to_html( $attr ) . ' ' . esc_html__( 'AMP', 'amp' ),
'href' => esc_url( $is_amp_request ? $non_amp_url : $amp_url ),
'meta' => [
'title' => esc_attr( $is_amp_request ? __( 'Validate URL', 'amp' ) : __( 'View AMP version', 'amp' ) ),
'title' => esc_attr( $is_amp_request ? $non_amp_view_title : $amp_view_title ),
],
]
);
Expand All @@ -1773,7 +1776,7 @@ function amp_add_admin_bar_view_link( $wp_admin_bar ) {
[
'parent' => 'amp',
'id' => 'amp-view',
'title' => esc_html( $is_amp_request ? __( 'View non-AMP version', 'amp' ) : __( 'View AMP version', 'amp' ) ),
'title' => esc_html( $is_amp_request ? $non_amp_view_title : $amp_view_title ),
'href' => esc_url( $is_amp_request ? $non_amp_url : $amp_url ),
]
);
Expand Down
7 changes: 6 additions & 1 deletion includes/validation/class-amp-validation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ public static function add_admin_bar_menu_items( $wp_admin_bar ) {
]
);

$validate_url_title = __( 'Validate URL', 'amp' );

$parent = [
'id' => 'amp',
'title' => sprintf(
Expand All @@ -364,13 +366,16 @@ public static function add_admin_bar_menu_items( $wp_admin_bar ) {
esc_html__( 'AMP', 'amp' )
),
'href' => esc_url( $href ),
'meta' => [
'title' => esc_attr( $is_amp_request ? $validate_url_title : __( 'View AMP version', 'amp' ) ),
],
];

// Construct admin bar item for validation.
$validate_item = [
'parent' => 'amp',
'id' => 'amp-validity',
'title' => esc_html__( 'Validate URL', 'amp' ),
'title' => esc_html( $validate_url_title ),
'href' => esc_url( $validate_url ),
];

Expand Down

0 comments on commit 5e65134

Please sign in to comment.