array( 'wp-api-fetch' ), 'version' => A11YFLEET_VERSION, ); wp_enqueue_script( 'a11yfleet-admin', A11YFLEET_URL . 'assets/js/index.js', $asset['dependencies'] ?? array( 'wp-api-fetch' ), (string) ( $asset['version'] ?? A11YFLEET_VERSION ), true ); // Expose REST root + nonce for the dashboard SPA / AJAX calls. wp_localize_script( 'a11yfleet-admin', 'A11yFleet', array( 'restUrl' => esc_url_raw( rest_url( 'a11yfleet/v1' ) ), 'nonce' => wp_create_nonce( 'wp_rest' ), ) ); } } /** * Enqueues the block-editor accessibility panel. * * Runs on enqueue_block_editor_assets. apiFetch is already configured with * the REST nonce inside the editor, so no extra localisation is needed. */ public function enqueueEditor(): void { $jsFile = A11YFLEET_DIR . 'assets/js/editor.js'; if ( ! is_readable( $jsFile ) ) { return; } $assetFile = A11YFLEET_DIR . 'assets/js/editor.asset.php'; $asset = is_readable( $assetFile ) ? (array) require $assetFile : array( 'dependencies' => array(), 'version' => A11YFLEET_VERSION, ); wp_enqueue_script( 'a11yfleet-editor', A11YFLEET_URL . 'assets/js/editor.js', $asset['dependencies'] ?? array(), (string) ( $asset['version'] ?? A11YFLEET_VERSION ), true ); } }