Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion includes/classes/class-enqueue-frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public static function maybe_enqueue_frontend_highlighter() {
'appCssUrl' => EDAC_PLUGIN_URL . 'build/css/frontendHighlighterApp.css?ver=' . EDAC_VERSION,
'widgetPosition' => get_option( 'edac_frontend_highlighter_position', 'right' ),
'editorLink' => get_edit_post_link( $post_id ),
'scannerBundleUrl' => plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/pageScanner.bundle.js',
'scannerBundleUrl' => esc_url_raw( add_query_arg( 'ver', EDAC_VERSION, plugin_dir_url( __FILE__ ) . 'build/pageScanner.bundle.js' ) ),
'adminThemeColor' => self::get_admin_theme_color(),
]
);
Expand Down
22 changes: 22 additions & 0 deletions tests/phpunit/includes/classes/EnqueueFrontendTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ protected function tearDown(): void {
parent::tearDown();
}

/**
* Ensure the localized scannerBundleUrl includes the plugin version as a query string parameter.
*/
public function testScannerBundleUrlIncludesVersionQueryString(): void {
$admin_id = $this->factory()->user->create( [ 'role' => 'administrator' ] );
wp_set_current_user( $admin_id );

$created_post = $this->factory()->post->create_and_get( [ 'post_type' => 'post' ] );

global $post;
$post = $created_post;

Enqueue_Frontend::maybe_enqueue_frontend_highlighter();

global $wp_scripts;
$localized_data = $wp_scripts->get_data( 'edac-frontend-highlighter-app', 'data' );

$this->assertNotEmpty( $localized_data );
$this->assertStringContainsString( 'scannerBundleUrl', $localized_data );
$this->assertStringContainsString( 'ver=' . EDAC_VERSION, $localized_data );
}

/**
* Ensure the highlighter uses the filtered post ID when determining scannable post types.
*/
Expand Down
Loading