| @@ -114,8 +114,29 @@ | ||
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
| 118 | + * A URL on the public Templately website, honouring the dev domain. | |
| 119 | + * | |
| 120 | + * The PHP counterpart of `react-src/utils/helper.js#webURL`. A hard-coded | |
| 121 | + * `https://templately.com/...` sends a site running against the dev API to | |
| 122 | + * the live site, where its account does not exist — so build every out-link | |
| 123 | + * through this instead. | |
| 124 | + * | |
| 125 | + * Note this is the *website*, not the API host `get_api_url()` builds. | |
| 126 | + * | |
| 127 | + * @param string $path Path with or without a leading slash. | |
| 128 | + * @param array $args Query args (utm_* etc). | |
| 129 | + * @return string | |
| 130 | + */ | |
| 131 | + public static function web_url( string $path = '', array $args = [] ): string { | |
| 132 | + $base_url = self::is_dev_api() ? 'https://templately.dev' : 'https://templately.com'; | |
| 133 | + $url = $base_url . '/' . ltrim( $path, '/' ); | |
| 134 | + | |
| 135 | + return empty( $args ) ? $url : add_query_arg( $args, $url ); | |
| 136 | + } | |
| 137 | + | |
| 138 | + /** | |
| 118 | 139 | * Get API URL for Templately endpoints |
| 119 | 140 | * |
| 120 | 141 | * @param string $endpoint API endpoint path (e.g., 'v2/import/pack/123') |
| 121 | 142 | * @return string Complete API URL |