| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
/** |
| 6 |
* BeyondWords Environment. |
| 7 |
* |
| 8 |
* @package Beyondwords\Wordpress |
| 9 |
* @author Stuart McAlpine <stu@beyondwords.io> |
| 10 |
* @since 3.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace Beyondwords\Wordpress\Core; |
| 14 |
|
| 15 |
use Beyondwords\Wordpress\Component; |
| 16 |
|
| 17 |
/** |
| 18 |
* Environment setup |
| 19 |
* |
| 20 |
* @since 3.0.0 |
| 21 |
*/ |
| 22 |
class Environment |
| 23 |
{ |
| 24 |
/** |
| 25 |
* The BeyondWords API URL. |
| 26 |
* |
| 27 |
* Override with BEYONDWORDS_API_URL in wp-config.php. |
| 28 |
* |
| 29 |
* @since 3.0.0 |
| 30 |
* @access private |
| 31 |
* @var string |
| 32 |
*/ |
| 33 |
public const BEYONDWORDS_API_URL = 'https://api.beyondwords.io/v1'; |
| 34 |
|
| 35 |
/** |
| 36 |
* The BeyondWords Backend URL. |
| 37 |
* |
| 38 |
* Override with BEYONDWORDS_BACKEND_URL in wp-config.php. |
| 39 |
* |
| 40 |
* @since 3.0.0 |
| 41 |
* @access private |
| 42 |
* @var string |
| 43 |
*/ |
| 44 |
public const BEYONDWORDS_BACKEND_URL = ''; |
| 45 |
|
| 46 |
/** |
| 47 |
* The BeyondWords JS SDK URL. |
| 48 |
* |
| 49 |
* Override with BEYONDWORDS_JS_SDK_URL in wp-config.php. |
| 50 |
* |
| 51 |
* @since 3.0.0 |
| 52 |
* @access private |
| 53 |
* @var string |
| 54 |
*/ |
| 55 |
public const BEYONDWORDS_JS_SDK_URL = 'https://proxy.beyondwords.io/npm/@beyondwords/player@latest/dist/umd.js'; // phpcs:ignore Generic.Files.LineLength.TooLong |
| 56 |
|
| 57 |
/** |
| 58 |
* The BeyondWords JS SDK URL (Legacy). |
| 59 |
* |
| 60 |
* Override with BEYONDWORDS_JS_SDK_URL_LEGACY in wp-config.php. |
| 61 |
* |
| 62 |
* @since 4.0.0 |
| 63 |
* @access private |
| 64 |
* @var string |
| 65 |
*/ |
| 66 |
public const BEYONDWORDS_JS_SDK_URL_LEGACY = 'https://proxy.beyondwords.io/npm/@beyondwords/audio-player@latest/dist/module/index.js'; // phpcs:ignore Generic.Files.LineLength.TooLong |
| 67 |
|
| 68 |
/** |
| 69 |
* The BeyondWords AMP Player URL. |
| 70 |
* |
| 71 |
* Override with BEYONDWORDS_AMP_PLAYER_URL in wp-config.php. |
| 72 |
* |
| 73 |
* @since 3.0.0 |
| 74 |
* @access private |
| 75 |
* @var string |
| 76 |
*/ |
| 77 |
public const BEYONDWORDS_AMP_PLAYER_URL = 'https://audio.beyondwords.io/amp/%d?podcast_id=%s'; |
| 78 |
|
| 79 |
/** |
| 80 |
* The BeyondWords AMP image URL. |
| 81 |
* |
| 82 |
* Override with BEYONDWORDS_AMP_IMG_URL in wp-config.php. |
| 83 |
* |
| 84 |
* @since 3.0.0 |
| 85 |
* @access private |
| 86 |
* @var string |
| 87 |
*/ |
| 88 |
public const BEYONDWORDS_AMP_IMG_URL = 'https://s3-eu-west-1.amazonaws.com/beyondwords-assets/logo.svg'; |
| 89 |
|
| 90 |
/** |
| 91 |
* The BeyondWords dashboard URL. |
| 92 |
* |
| 93 |
* Override with BEYONDWORDS_DASHBOARD_URL in wp-config.php. |
| 94 |
* |
| 95 |
* @since 3.0.0 |
| 96 |
* @access private |
| 97 |
* @var string |
| 98 |
*/ |
| 99 |
public const BEYONDWORDS_DASHBOARD_URL = 'https://dash.beyondwords.io'; |
| 100 |
|
| 101 |
/** |
| 102 |
* @return string |
| 103 |
*/ |
| 104 |
public static function getApiUrl() |
| 105 |
{ |
| 106 |
if (defined('BEYONDWORDS_API_URL') && strlen(BEYONDWORDS_API_URL)) { |
| 107 |
return BEYONDWORDS_API_URL; |
| 108 |
} |
| 109 |
|
| 110 |
return static::BEYONDWORDS_API_URL; |
| 111 |
} |
| 112 |
|
| 113 |
/** |
| 114 |
* @return string |
| 115 |
*/ |
| 116 |
public static function getBackendUrl() |
| 117 |
{ |
| 118 |
if (defined('BEYONDWORDS_BACKEND_URL') && strlen(BEYONDWORDS_BACKEND_URL)) { |
| 119 |
return BEYONDWORDS_BACKEND_URL; |
| 120 |
} |
| 121 |
|
| 122 |
return static::BEYONDWORDS_BACKEND_URL; |
| 123 |
} |
| 124 |
|
| 125 |
/** |
| 126 |
* @return string |
| 127 |
*/ |
| 128 |
public static function getJsSdkUrl() |
| 129 |
{ |
| 130 |
if (defined('BEYONDWORDS_JS_SDK_URL') && strlen(BEYONDWORDS_JS_SDK_URL)) { |
| 131 |
return BEYONDWORDS_JS_SDK_URL; |
| 132 |
} |
| 133 |
|
| 134 |
return static::BEYONDWORDS_JS_SDK_URL; |
| 135 |
} |
| 136 |
|
| 137 |
/** |
| 138 |
* @return string |
| 139 |
*/ |
| 140 |
public static function getJsSdkUrlLegacy() |
| 141 |
{ |
| 142 |
if (defined('BEYONDWORDS_JS_SDK_URL_LEGACY') && strlen(BEYONDWORDS_JS_SDK_URL_LEGACY)) { |
| 143 |
return BEYONDWORDS_JS_SDK_URL_LEGACY; |
| 144 |
} |
| 145 |
|
| 146 |
return static::BEYONDWORDS_JS_SDK_URL_LEGACY; |
| 147 |
} |
| 148 |
|
| 149 |
/** |
| 150 |
* @return string |
| 151 |
*/ |
| 152 |
public static function getAmpPlayerUrl() |
| 153 |
{ |
| 154 |
if (defined('BEYONDWORDS_AMP_PLAYER_URL') && strlen(BEYONDWORDS_AMP_PLAYER_URL)) { |
| 155 |
return BEYONDWORDS_AMP_PLAYER_URL; |
| 156 |
} |
| 157 |
|
| 158 |
return static::BEYONDWORDS_AMP_PLAYER_URL; |
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* @return string |
| 163 |
*/ |
| 164 |
public static function getAmpImgUrl() |
| 165 |
{ |
| 166 |
if (defined('BEYONDWORDS_AMP_IMG_URL') && strlen(BEYONDWORDS_AMP_IMG_URL)) { |
| 167 |
return BEYONDWORDS_AMP_IMG_URL; |
| 168 |
} |
| 169 |
|
| 170 |
return static::BEYONDWORDS_AMP_IMG_URL; |
| 171 |
} |
| 172 |
|
| 173 |
/** |
| 174 |
* @return string |
| 175 |
*/ |
| 176 |
public static function getDashboardUrl() |
| 177 |
{ |
| 178 |
if (defined('BEYONDWORDS_DASHBOARD_URL') && strlen(BEYONDWORDS_DASHBOARD_URL)) { |
| 179 |
return BEYONDWORDS_DASHBOARD_URL; |
| 180 |
} |
| 181 |
|
| 182 |
return static::BEYONDWORDS_DASHBOARD_URL; |
| 183 |
} |
| 184 |
} |
| 185 |
|