| 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 |
|
| 11 |
declare( strict_types = 1 ); |
| 12 |
|
| 13 |
namespace BeyondWords\Core; |
| 14 |
|
| 15 |
defined( '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 |
*/ |
| 22 |
class 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 |
} |
| 97 |
|