Skip to content

Commit

Permalink
Merge pull request #7760 from ampproject/update/post-preview-js-xpath
Browse files Browse the repository at this point in the history
Update post preview script xpath
  • Loading branch information
westonruter committed Mar 18, 2024
2 parents c892176 + 26f7d62 commit 5708e19
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@ function amp_get_content_sanitizers( $post = null ) {
// Mark the script output by wp_post_preview_js() as being in dev mode.
if ( is_preview() && get_queried_object() instanceof WP_Post ) {
$dev_mode_xpaths[] = sprintf(
'//script[ not( @src ) and contains( text(), "document.location.search" ) and contains( text(), "preview=true" ) and contains( text(), "unload" ) and contains( text(), "window.name" ) and contains( text(), "wp-preview-%d" ) ]',
'//script[ not( @src ) and contains( text(), "document.location.search" ) and contains( text(), "preview=true" ) and ( contains( text(), "pagehide" ) or contains( text(), "unload" ) ) and contains( text(), "window.name" ) and contains( text(), "wp-preview-%d" ) ]',
get_queried_object_id()
);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/php/test-amp-helper-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ static function () {
'//*[ @id = "wpadminbar" ]',
'//*[ @id = "wpadminbar" ]//*',
'//style[ @id = "admin-bar-inline-css" ]',
'//script[ not( @src ) and contains( text(), "document.location.search" ) and contains( text(), "preview=true" ) and contains( text(), "unload" ) and contains( text(), "window.name" ) and contains( text(), "wp-preview-' . $post . '" ) ]',
'//script[ not( @src ) and contains( text(), "document.location.search" ) and contains( text(), "preview=true" ) and ( contains( text(), "pagehide" ) or contains( text(), "unload" ) ) and contains( text(), "window.name" ) and contains( text(), "wp-preview-' . $post . '" ) ]',
'//link[@rel="manifest" and contains(@href, "web-app-manifest")]',
],
$sanitizers[ AMP_Dev_Mode_Sanitizer::class ]['element_xpaths']
Expand Down

0 comments on commit 5708e19

Please sign in to comment.