$data Keys this screen contributes. */ public static function merge(string $handle, array $data): void { $json = wp_json_encode($data); if ($json === false) { return; } wp_add_inline_script( $handle, 'window.' . self::GLOBAL_NAME . ' = Object.assign( window.' . self::GLOBAL_NAME . ' || {}, ' . $json . ' );', 'before' ); } /** * The keys every screen needs: where the REST API is, and the nonce to call it with. * * @return array */ public static function base(): array { return [ 'root' => esc_url_raw(rest_url()), 'nonce' => wp_create_nonce('wp_rest'), ]; } }