Skip to content

Commit

Permalink
[not verified] Site Scan & AMP: Include toolbar scripts for Site Scan…
Browse files Browse the repository at this point in the history
… have data-ampdevmode on AMP requests (#17034)
  • Loading branch information
westonruter authored and pereirinha committed Sep 10, 2020
1 parent b2252d7 commit 01f2487
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/scan/class-admin-bar-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ private function init_hooks() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_toolbar_script' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_toolbar_script' ) );
add_action( 'admin_bar_menu', array( $this, 'add_threats_to_toolbar' ), 999 );

// Inject the data-ampdevmode attribute into the inline <script> output via wp_localize_script(). To revisit after https://github.com/ampproject/amp-wp/issues/4598.
add_filter(
'amp_dev_mode_element_xpaths',
static function ( $expressions ) {
$expressions[] = '//script[ contains( text(), "Jetpack_Scan" ) ]';
return $expressions;
}
);
}

/**
Expand Down Expand Up @@ -90,7 +99,7 @@ public function enqueue_toolbar_script() {
}

// We don't know about threats in the cache lets load the JS that fetches the info and updates the admin bar.
Assets::enqueue_async_script( self::SCRIPT_NAME, '_inc/build/scan/admin-bar-notice.min.js', 'modules/scan/admin-bar-notice.js', array(), self::SCRIPT_VERSION, true );
Assets::enqueue_async_script( self::SCRIPT_NAME, '_inc/build/scan/admin-bar-notice.min.js', 'modules/scan/admin-bar-notice.js', array( 'admin-bar' ), self::SCRIPT_VERSION, true );

$script_data = array(
'nonce' => wp_create_nonce( 'wp_rest' ),
Expand Down

0 comments on commit 01f2487

Please sign in to comment.