add_action( 'abds_seo_highlight_mode_active', $this, 'enqueue', 10, 1 ); } /** * Enqueues the overlay's assets and localizes the config * src/highlight-overlay.js reads as window.abdsSeoHighlight. * * @param int $post_id The current singular post's ID (already * capability/nonce-checked by the caller). */ public function enqueue( int $post_id ): void { $asset_file = ABDS_SEO_PLUGIN_DIR . 'build/highlight-overlay.asset.php'; if ( ! file_exists( $asset_file ) ) { return; } $asset = require $asset_file; wp_enqueue_style( 'abds-seo-highlight-overlay', ABDS_SEO_PLUGIN_URL . 'assets/css/highlight-overlay.css', array(), $asset['version'] ); wp_enqueue_script( 'abds-seo-highlight-overlay', ABDS_SEO_PLUGIN_URL . 'build/highlight-overlay.js', $asset['dependencies'], $asset['version'], true ); wp_set_script_translations( 'abds-seo-highlight-overlay', 'abds-seo', ABDS_SEO_PLUGIN_DIR . 'languages' ); wp_localize_script( 'abds-seo-highlight-overlay', 'abdsSeoHighlight', array( 'restUrl' => esc_url_raw( rest_url( ABDS_SEO_REST_Base::NAMESPACE_V1 . '/audit/current-page-issues' ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), 'postId' => $post_id, 'editUrl' => esc_url_raw( (string) get_edit_post_link( $post_id, 'raw' ) ), 'settingsUrl' => esc_url_raw( admin_url( 'admin.php?page=' . self::MENU_SLUG . '-settings' ) ), ) ); } }