| @@ -105,10 +105,13 @@ | ||
| 105 | 105 | * |
| 106 | 106 | * @var string $version The product version. |
| 107 | 107 | */ |
| 108 | 108 | private $version; |
| 109 | - | |
| 110 | 109 | /** |
| 110 | + * Root api endpoint. | |
| 111 | + */ | |
| 112 | + const API_URL = 'https://api.themeisle.com/'; | |
| 113 | + /** | |
| 111 | 114 | * ThemeIsle_SDK_Product constructor. |
| 112 | 115 | * |
| 113 | 116 | * @param string $basefile Product basefile. |
| 114 | 117 | */ |
| @@ -113,9 +116,9 @@ | ||
| 113 | 116 | * @param string $basefile Product basefile. |
| 114 | 117 | */ |
| 115 | 118 | public function __construct( $basefile ) { |
| 116 | 119 | if ( ! empty( $basefile ) ) { |
| 117 | - if ( is_readable( $basefile ) ) { | |
| 120 | + if ( is_file( $basefile ) ) { | |
| 118 | 121 | $this->basefile = $basefile; |
| 119 | 122 | $this->setup_from_path(); |
| 120 | 123 | $this->setup_from_fileheaders(); |
| 121 | 124 | } |
| @@ -153,9 +156,9 @@ | ||
| 153 | 156 | * @param string $string the String to be normalized for cron handler. |
| 154 | 157 | * |
| 155 | 158 | * @return string $name The normalized string. |
| 156 | 159 | */ |
| 157 | - static function key_ready_name( $string ) { | |
| 160 | + public static function key_ready_name( $string ) { | |
| 158 | 161 | return str_replace( '-', '_', strtolower( trim( $string ) ) ); |
| 159 | 162 | } |
| 160 | 163 | |
| 161 | 164 | /** |
| @@ -199,8 +202,9 @@ | ||
| 199 | 202 | */ |
| 200 | 203 | public function get_key() { |
| 201 | 204 | return $this->key; |
| 202 | 205 | } |
| 206 | + | |
| 203 | 207 | /** |
| 204 | 208 | * Check if the product is either theme or plugin. |
| 205 | 209 | * |
| 206 | 210 | * @return string Product type. |
| @@ -341,8 +345,13 @@ | ||
| 341 | 345 | * |
| 342 | 346 | * @return string The store url. |
| 343 | 347 | */ |
| 344 | 348 | public function get_store_url() { |
| 349 | + | |
| 350 | + if ( strpos( $this->store_url, '/themeisle.com' ) !== false ) { | |
| 351 | + return 'https://store.themeisle.com/'; | |
| 352 | + } | |
| 353 | + | |
| 345 | 354 | return $this->store_url; |
| 346 | 355 | } |
| 347 | 356 | |
| 348 | 357 | /** |
| @@ -354,8 +363,23 @@ | ||
| 354 | 363 | return $this->basefile; |
| 355 | 364 | } |
| 356 | 365 | |
| 357 | 366 | /** |
| 367 | + * Get changelog url. | |
| 368 | + * | |
| 369 | + * @return string Changelog url. | |
| 370 | + */ | |
| 371 | + public function get_changelog() { | |
| 372 | + return add_query_arg( | |
| 373 | + [ | |
| 374 | + 'name' => rawurlencode( $this->get_name() ), | |
| 375 | + 'edd_action' => 'view_changelog', | |
| 376 | + ], | |
| 377 | + $this->get_store_url() | |
| 378 | + ); | |
| 379 | + } | |
| 380 | + | |
| 381 | + /** | |
| 358 | 382 | * Returns product filename. |
| 359 | 383 | * |
| 360 | 384 | * @return string The product filename. |
| 361 | 385 | */ |
| @@ -361,8 +385,9 @@ | ||
| 361 | 385 | */ |
| 362 | 386 | public function get_file() { |
| 363 | 387 | return $this->file; |
| 364 | 388 | } |
| 389 | + | |
| 365 | 390 | /** |
| 366 | 391 | * Returns the pro slug, if available. |
| 367 | 392 | * |
| 368 | 393 | * @return string The pro slug. |
| @@ -377,7 +402,20 @@ | ||
| 377 | 402 | * @return int The install timestamp. |
| 378 | 403 | */ |
| 379 | 404 | public function get_install_time() { |
| 380 | 405 | return $this->install; |
| 406 | + } | |
| 407 | + | |
| 408 | + /** | |
| 409 | + * Returns the URL of the product base file. | |
| 410 | + * | |
| 411 | + * @param string $path The path to the file. | |
| 412 | + * | |
| 413 | + * @return string The URL of the product base file. | |
| 414 | + */ | |
| 415 | + public function get_base_url( $path = '/' ) { | |
| 416 | + if ( $this->type ) { | |
| 417 | + return plugins_url( $path, $this->basefile ); | |
| 418 | + } | |
| 381 | 419 | } |
| 382 | 420 | |
| 383 | 421 | } |