$site_url, 'return_url' => $return_url, 'state' => $state, 'code_challenge' => $code_challenge, 'code_challenge_method' => 'S256', ) ); } /** * The domains list, where a site is added and its domain verified. * * Needed because two of the plugin's dead ends were "this site is not * registered in AccessiBit yet" and "this domain is not verified", neither * of which carried a link to the one page that resolves them. * * @param string $base The dashboard origin. * @return string */ public static function sites_for( string $base ): string { return self::build( $base, '/domains' ); } /** * Where a site's own audits live, for "see the full report". * * @param string $base The dashboard origin. * @param string $site_id The AccessiBit site id, or '' for the dashboard root. * @return string */ public static function site_for( string $base, string $site_id ): string { return '' === $site_id ? self::build( $base, '/' ) : self::build( $base, '/domain/' . rawurlencode( $site_id ) . '/audit' ); } /** * Where a site's domain is verified, for "we cannot scan an unverified domain". * * The site's OWN verification screen, not the domains list: the list was what * this notice linked to, which left the administrator to find their site among * however many they have and then find the verification step inside it — to do * the one thing the notice had just told them to do. The plugin knows the site * id, so it can say exactly where to go. * * Falls back to the domains list rather than the dashboard root, which is the * nearest page that can still get the job done. Unreachable from the notice * itself — the free-scan panel only renders once `is_site_linked()`, which * requires a site id — so this is about the helper being safe to reuse. * * @param string $base The dashboard origin. * @param string $site_id The AccessiBit site id, or '' for the domains list. * @return string */ public static function verification_for( string $base, string $site_id ): string { return '' === $site_id ? self::sites_for( $base ) : self::build( $base, '/domain/' . rawurlencode( $site_id ) . '/verification' ); } /** * The API keys page, where an administrator sees and revokes the key this * site's connection issued. * * Linked from the Disconnect notice when the key could not be revoked from * here (ACC-583): a legacy pasted key, or a revocation that failed. * * @param string $base The dashboard origin. * @return string */ public static function api_keys_for( string $base ): string { return self::build( $base, '/account/api-keys' ); } /** * The audit-api origin, from the API base the build injected. * * The base ends in `/api/v1`, and the public statement route is mounted * beside `/api/v1` under the same origin, so cutting that suffix off is the * origin the admin bundle expects for its "public link". * * @param string $api_base `ACCESSIBIT_API_BASE_URL`. * @return string */ public static function api_origin_for( string $api_base ): string { return (string) preg_replace( '~/api/v1/?$~', '', rtrim( $api_base, '/' ) ); } /** * The statement's public address: audit-api's entry point, which serves the * visitor's language unless `lang` names one — the address the dashboard's * embed snippet uses, so whatever AccessiBit decides later (a temporary * statement, a withdrawn one) reaches this site too. * * @param string $api_base `ACCESSIBIT_API_BASE_URL`. * @param string $statement_id The statement. * @param string $lang `en`, `it`, `es`, or '' for the visitor's. * @return string */ public static function statement_public_for( string $api_base, string $statement_id, string $lang = '' ): string { $url = self::api_origin_for( $api_base ) . '/api/public/statements/' . rawurlencode( $statement_id ); return '' === $lang ? $url : $url . '?lang=' . rawurlencode( $lang ); } /** * The plugin's own Widget screen. * * @return string */ public static function widget_screen(): string { return admin_url( 'admin.php?page=' . Accessibit_Admin::WIDGET_PAGE ); } /** * The plugin's own Statement screen. * * @return string */ public static function statement_screen(): string { return admin_url( 'admin.php?page=' . Accessibit_Admin::STATEMENT_PAGE ); } /** * Purchase wizard for the configured dashboard. * * @return string */ public static function buy(): string { return self::buy_for( ACCESSIBIT_DASHBOARD_URL ); } /** * The connect approval screen for this install's current request. * * @param string $state A random token this install stored. * @param string $code_challenge The PKCE challenge of the stored verifier. * @return string */ public static function connect( string $state, string $code_challenge ): string { return self::connect_for( ACCESSIBIT_DASHBOARD_URL, home_url(), Accessibit_Admin::connect_return_url(), $state, $code_challenge ); } /** * Domains list for the configured dashboard. * * @return string */ public static function sites(): string { return self::sites_for( ACCESSIBIT_DASHBOARD_URL ); } /** * Audit list for the site this install is bound to. * * @return string */ public static function site(): string { return self::site_for( ACCESSIBIT_DASHBOARD_URL, Accessibit_Settings::get_site_id() ); } /** * This site's verification screen, named in the unverified-domain notice. * * @return string */ public static function verification(): string { return self::verification_for( ACCESSIBIT_DASHBOARD_URL, Accessibit_Settings::get_site_id() ); } /** * The site's Tracker in the dashboard, and its sections (ACC-412). * * Pure, for the unit suite. Addressed without a language, like the other * dashboard links here: the dashboard adds the customer's own. * * @param string $base The dashboard URL. * @param string $site_id The bound site. * @return array{tracker: string, notifications: string, pages: string, subdomains: string, activate: string} */ public static function tracker_for( string $base, string $site_id ): array { $tracker = self::build( $base, '/domain/' . rawurlencode( $site_id ) . '/tracker' ); return array( 'tracker' => $tracker, 'notifications' => $tracker . '/notifications', 'pages' => $tracker . '/pages', 'subdomains' => $tracker . '/subdomains', // The wizard with the Tracker and this site preselected, as the // dashboard's own upsell opens it. 'activate' => self::build( $base, '/wizard' ) . '?' . http_build_query( array( 'product' => 'tracker', 'site' => $site_id, ) ), ); } /** * What the Tracker screen links to (`trackerLinks` in the bundle's config): * the dashboard's pages for this site, and this plugin's Setup, where the * site is reconnected. * * @return array */ public static function tracker_links(): array { return self::tracker_for( ACCESSIBIT_DASHBOARD_URL, Accessibit_Settings::get_site_id() ) + array( 'reconnect' => admin_url( 'admin.php?page=accessibit' ) ); } /** * API keys page for the configured dashboard. * * @return string */ public static function api_keys(): string { return self::api_keys_for( ACCESSIBIT_DASHBOARD_URL ); } }