Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
12 / 18
0.00% covered (danger)
0.00%
0 / 6
CRAP
0.00% covered (danger)
0.00%
0 / 1
Urls
66.67% covered (warning)
66.67%
12 / 18
0.00% covered (danger)
0.00%
0 / 6
30.00
0.00% covered (danger)
0.00%
0 / 1
 get_api_url
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
 get_backend_url
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
 get_js_sdk_url
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
 get_amp_player_url
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
 get_amp_img_url
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
 get_dashboard_url
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
1<?php
2/**
3 * BeyondWords URL registry: production defaults with optional `wp-config.php` overrides.
4 *
5 * @package BeyondWords\Core
6 * @since   3.0.0
7 * @since   7.0.0 Refactored to BeyondWords namespace with snake_case methods.
8 *                Renamed from BeyondWords\Core\Environment to BeyondWords\Core\Urls.
9 */
10
11declare( strict_types = 1 );
12
13namespace BeyondWords\Core;
14
15defined( 'ABSPATH' ) || exit;
16
17/**
18 * URL registry — production defaults with optional `wp-config.php` overrides.
19 *
20 * @since 7.0.0 Refactored to BeyondWords namespace with snake_case methods.
21 */
22class Urls {
23
24    const BEYONDWORDS_API_URL        = 'https://api.beyondwords.io/v1';
25    const BEYONDWORDS_BACKEND_URL    = '';
26    const BEYONDWORDS_JS_SDK_URL     = 'https://proxy.beyondwords.io/npm/@beyondwords/player@latest/dist/umd.js';
27    const BEYONDWORDS_AMP_PLAYER_URL = 'https://audio.beyondwords.io/amp/%d?podcast_id=%s';
28    const BEYONDWORDS_AMP_IMG_URL    = 'https://beyondwords-cdn-b7fyckdeejejb6dj.a03.azurefd.net/assets/logo.svg';
29    const BEYONDWORDS_DASHBOARD_URL  = 'https://dash.beyondwords.io';
30
31    /**
32     * BeyondWords REST API base URL.
33     */
34    public static function get_api_url(): string {
35        if ( defined( 'BEYONDWORDS_API_URL' ) && strlen( \BEYONDWORDS_API_URL ) ) {
36            return \BEYONDWORDS_API_URL;
37        }
38
39        return static::BEYONDWORDS_API_URL;
40    }
41
42    /**
43     * BeyondWords backend URL (legacy; usually empty).
44     */
45    public static function get_backend_url(): string {
46        if ( defined( 'BEYONDWORDS_BACKEND_URL' ) && strlen( \BEYONDWORDS_BACKEND_URL ) ) {
47            return \BEYONDWORDS_BACKEND_URL;
48        }
49
50        return static::BEYONDWORDS_BACKEND_URL;
51    }
52
53    /**
54     * Front-end JS SDK script URL.
55     */
56    public static function get_js_sdk_url(): string {
57        if ( defined( 'BEYONDWORDS_JS_SDK_URL' ) && strlen( \BEYONDWORDS_JS_SDK_URL ) ) {
58            return \BEYONDWORDS_JS_SDK_URL;
59        }
60
61        return static::BEYONDWORDS_JS_SDK_URL;
62    }
63
64    /**
65     * AMP iframe player URL pattern (`%d` for project ID, `%s` for content ID).
66     */
67    public static function get_amp_player_url(): string {
68        if ( defined( 'BEYONDWORDS_AMP_PLAYER_URL' ) && strlen( \BEYONDWORDS_AMP_PLAYER_URL ) ) {
69            return \BEYONDWORDS_AMP_PLAYER_URL;
70        }
71
72        return static::BEYONDWORDS_AMP_PLAYER_URL;
73    }
74
75    /**
76     * Placeholder image URL for AMP players.
77     */
78    public static function get_amp_img_url(): string {
79        if ( defined( 'BEYONDWORDS_AMP_IMG_URL' ) && strlen( \BEYONDWORDS_AMP_IMG_URL ) ) {
80            return \BEYONDWORDS_AMP_IMG_URL;
81        }
82
83        return static::BEYONDWORDS_AMP_IMG_URL;
84    }
85
86    /**
87     * BeyondWords dashboard URL.
88     */
89    public static function get_dashboard_url(): string {
90        if ( defined( 'BEYONDWORDS_DASHBOARD_URL' ) && strlen( \BEYONDWORDS_DASHBOARD_URL ) ) {
91            return \BEYONDWORDS_DASHBOARD_URL;
92        }
93
94        return static::BEYONDWORDS_DASHBOARD_URL;
95    }
96}