| @@ -70,14 +70,8 @@ | ||
| 70 | 70 | * @var string $key The product ready key. |
| 71 | 71 | */ |
| 72 | 72 | private $key; |
| 73 | 73 | /** |
| 74 | - * Author URL | |
| 75 | - * | |
| 76 | - * @var string $author_url The author url. | |
| 77 | - */ | |
| 78 | - private $author_url; | |
| 79 | - /** | |
| 80 | 74 | * Product store url. |
| 81 | 75 | * |
| 82 | 76 | * @var string $store_url The store url. |
| 83 | 77 | */ |
| @@ -111,18 +105,8 @@ | ||
| 111 | 105 | * |
| 112 | 106 | * @var string $version The product version. |
| 113 | 107 | */ |
| 114 | 108 | private $version; |
| 115 | - /** | |
| 116 | - * Holds a map of loaded products objects. | |
| 117 | - * | |
| 118 | - * @var array Array of loaded products. | |
| 119 | - */ | |
| 120 | - private static $cached_products = []; | |
| 121 | - /** | |
| 122 | - * Root api endpoint. | |
| 123 | - */ | |
| 124 | - const API_URL = 'https://api.themeisle.com/'; | |
| 125 | 109 | |
| 126 | 110 | /** |
| 127 | 111 | * ThemeIsle_SDK_Product constructor. |
| 128 | 112 | * |
| @@ -129,9 +113,9 @@ | ||
| 129 | 113 | * @param string $basefile Product basefile. |
| 130 | 114 | */ |
| 131 | 115 | public function __construct( $basefile ) { |
| 132 | 116 | if ( ! empty( $basefile ) ) { |
| 133 | - if ( is_file( $basefile ) ) { | |
| 117 | + if ( is_readable( $basefile ) ) { | |
| 134 | 118 | $this->basefile = $basefile; |
| 135 | 119 | $this->setup_from_path(); |
| 136 | 120 | $this->setup_from_fileheaders(); |
| 137 | 121 | } |
| @@ -140,27 +124,10 @@ | ||
| 140 | 124 | if ( 0 === $install ) { |
| 141 | 125 | $install = time(); |
| 142 | 126 | update_option( $this->get_key() . '_install', time() ); |
| 143 | 127 | } |
| 144 | - $this->install = $install; | |
| 145 | - self::$cached_products[ crc32( $basefile ) ] = $this; | |
| 146 | - } | |
| 128 | + $this->install = $install; | |
| 147 | 129 | |
| 148 | - /** | |
| 149 | - * Return a product. | |
| 150 | - * | |
| 151 | - * @param string $basefile Product basefile. | |
| 152 | - * | |
| 153 | - * @return Product Product Object. | |
| 154 | - */ | |
| 155 | - public static function get( $basefile ) { | |
| 156 | - $key = crc32( $basefile ); | |
| 157 | - if ( isset( self::$cached_products[ $key ] ) ) { | |
| 158 | - return self::$cached_products[ $key ]; | |
| 159 | - } | |
| 160 | - self::$cached_products[ $key ] = new Product( $basefile ); | |
| 161 | - | |
| 162 | - return self::$cached_products[ $key ]; | |
| 163 | 130 | } |
| 164 | 131 | |
| 165 | 132 | /** |
| 166 | 133 | * Setup props from path. |
| @@ -186,9 +153,9 @@ | ||
| 186 | 153 | * @param string $string the String to be normalized for cron handler. |
| 187 | 154 | * |
| 188 | 155 | * @return string $name The normalized string. |
| 189 | 156 | */ |
| 190 | - public static function key_ready_name( $string ) { | |
| 157 | + static function key_ready_name( $string ) { | |
| 191 | 158 | return str_replace( '-', '_', strtolower( trim( $string ) ) ); |
| 192 | 159 | } |
| 193 | 160 | |
| 194 | 161 | /** |
| @@ -232,9 +199,8 @@ | ||
| 232 | 199 | */ |
| 233 | 200 | public function get_key() { |
| 234 | 201 | return $this->key; |
| 235 | 202 | } |
| 236 | - | |
| 237 | 203 | /** |
| 238 | 204 | * Check if the product is either theme or plugin. |
| 239 | 205 | * |
| 240 | 206 | * @return string Product type. |
| @@ -352,17 +318,8 @@ | ||
| 352 | 318 | return $name; |
| 353 | 319 | } |
| 354 | 320 | |
| 355 | 321 | /** |
| 356 | - * Return the product version cache key. | |
| 357 | - * | |
| 358 | - * @return string The product version cache key. | |
| 359 | - */ | |
| 360 | - public function get_cache_key() { | |
| 361 | - return $this->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->get_version() ) . 'versions'; | |
| 362 | - } | |
| 363 | - | |
| 364 | - /** | |
| 365 | 322 | * Getter for product name. |
| 366 | 323 | * |
| 367 | 324 | * @return string The product name. |
| 368 | 325 | */ |
| @@ -384,13 +341,8 @@ | ||
| 384 | 341 | * |
| 385 | 342 | * @return string The store url. |
| 386 | 343 | */ |
| 387 | 344 | public function get_store_url() { |
| 388 | - | |
| 389 | - if ( strpos( $this->store_url, '/themeisle.com' ) !== false ) { | |
| 390 | - return 'https://store.themeisle.com/'; | |
| 391 | - } | |
| 392 | - | |
| 393 | 345 | return $this->store_url; |
| 394 | 346 | } |
| 395 | 347 | |
| 396 | 348 | /** |
| @@ -402,24 +354,8 @@ | ||
| 402 | 354 | return $this->basefile; |
| 403 | 355 | } |
| 404 | 356 | |
| 405 | 357 | /** |
| 406 | - * Get changelog url. | |
| 407 | - * | |
| 408 | - * @return string Changelog url. | |
| 409 | - */ | |
| 410 | - public function get_changelog() { | |
| 411 | - return add_query_arg( | |
| 412 | - [ | |
| 413 | - 'name' => rawurlencode( $this->get_name() ), | |
| 414 | - 'edd_action' => 'view_changelog', | |
| 415 | - 'locale' => get_user_locale(), | |
| 416 | - ], | |
| 417 | - $this->get_store_url() | |
| 418 | - ); | |
| 419 | - } | |
| 420 | - | |
| 421 | - /** | |
| 422 | 358 | * Returns product filename. |
| 423 | 359 | * |
| 424 | 360 | * @return string The product filename. |
| 425 | 361 | */ |
| @@ -425,9 +361,8 @@ | ||
| 425 | 361 | */ |
| 426 | 362 | public function get_file() { |
| 427 | 363 | return $this->file; |
| 428 | 364 | } |
| 429 | - | |
| 430 | 365 | /** |
| 431 | 366 | * Returns the pro slug, if available. |
| 432 | 367 | * |
| 433 | 368 | * @return string The pro slug. |