| @@ -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 | */ |
| @@ -112,18 +106,11 @@ | ||
| 112 | 106 | * @var string $version The product version. |
| 113 | 107 | */ |
| 114 | 108 | private $version; |
| 115 | 109 | /** |
| 116 | - * Holds a map of loaded products objects. | |
| 117 | - * | |
| 118 | - * @var array Array of loaded products. | |
| 119 | - */ | |
| 120 | - private static $cached_products = []; | |
| 121 | - /** | |
| 122 | 110 | * Root api endpoint. |
| 123 | 111 | */ |
| 124 | 112 | const API_URL = 'https://api.themeisle.com/'; |
| 125 | - | |
| 126 | 113 | /** |
| 127 | 114 | * ThemeIsle_SDK_Product constructor. |
| 128 | 115 | * |
| 129 | 116 | * @param string $basefile Product basefile. |
| @@ -138,58 +125,15 @@ | ||
| 138 | 125 | } |
| 139 | 126 | $install = get_option( $this->get_key() . '_install', 0 ); |
| 140 | 127 | if ( 0 === $install ) { |
| 141 | 128 | $install = time(); |
| 142 | - /** | |
| 143 | - * Action to be triggered when the product is first activated. | |
| 144 | - * | |
| 145 | - * @param string $basefile The basefile of the product. | |
| 146 | - */ | |
| 147 | - do_action( 'themeisle_sdk_first_activation', $basefile ); | |
| 148 | - | |
| 149 | 129 | update_option( $this->get_key() . '_install', time() ); |
| 150 | 130 | } |
| 151 | - $this->install = (int) $install; | |
| 152 | - self::$cached_products[ crc32( $basefile ) ] = $this; | |
| 153 | - $current_version = get_option( $this->slug . '_version', '' ); | |
| 131 | + $this->install = $install; | |
| 154 | 132 | |
| 155 | - if ( $current_version !== $this->version && wp_cache_get( "{$this->slug}_version_upgrade" ) === false ) { | |
| 156 | - // Set the cache lock to avoid multiple calls. | |
| 157 | - wp_cache_set( "{$this->slug}_version_upgrade", true, HOUR_IN_SECONDS ); | |
| 158 | - /** | |
| 159 | - * Action to be triggered when the product is updated. | |
| 160 | - * | |
| 161 | - * @param string $current_version The current version of the product. | |
| 162 | - * @param string $new_version The new version of the product. | |
| 163 | - * @param string $basefile The basefile of the product. | |
| 164 | - */ | |
| 165 | - do_action( "themeisle_sdk_update_{$this->slug}", $current_version, $this->version, $basefile ); | |
| 166 | - | |
| 167 | - // Update the version of the product. | |
| 168 | - update_option( "{$this->slug}_version", $this->version ); | |
| 169 | - // Delete the cache lock. | |
| 170 | - wp_cache_delete( "{$this->slug}_version_upgrade" ); | |
| 171 | - } | |
| 172 | 133 | } |
| 173 | 134 | |
| 174 | 135 | /** |
| 175 | - * Return a product. | |
| 176 | - * | |
| 177 | - * @param string $basefile Product basefile. | |
| 178 | - * | |
| 179 | - * @return Product Product Object. | |
| 180 | - */ | |
| 181 | - public static function get( $basefile ) { | |
| 182 | - $key = crc32( $basefile ); | |
| 183 | - if ( isset( self::$cached_products[ $key ] ) ) { | |
| 184 | - return self::$cached_products[ $key ]; | |
| 185 | - } | |
| 186 | - self::$cached_products[ $key ] = new Product( $basefile ); | |
| 187 | - | |
| 188 | - return self::$cached_products[ $key ]; | |
| 189 | - } | |
| 190 | - | |
| 191 | - /** | |
| 192 | 136 | * Setup props from path. |
| 193 | 137 | */ |
| 194 | 138 | public function setup_from_path() { |
| 195 | 139 | $this->file = basename( $this->basefile ); |
| @@ -371,19 +315,9 @@ | ||
| 371 | 315 | * |
| 372 | 316 | * @return string Friendly name. |
| 373 | 317 | */ |
| 374 | 318 | public function get_friendly_name() { |
| 375 | - $name = trim( str_replace( 'Lite', '', $this->get_name() ) ); | |
| 376 | - if ( defined( 'OTTER_BLOCKS_BASEFILE' ) && OTTER_BLOCKS_BASEFILE === $this->basefile ) { | |
| 377 | - $name = 'Otter Blocks'; | |
| 378 | - } | |
| 379 | - if ( defined( 'OPTML_BASEFILE' ) && OPTML_BASEFILE === $this->basefile ) { | |
| 380 | - $name = 'Optimole'; | |
| 381 | - } | |
| 382 | - if ( defined( 'WPMM_FILE' ) && WPMM_FILE === $this->basefile ) { | |
| 383 | - $name = 'LightStart'; | |
| 384 | - } | |
| 385 | - $name = apply_filters( $this->get_key() . '_friendly_name', $name ); | |
| 319 | + $name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) ); | |
| 386 | 320 | $name = rtrim( $name, '- ()' ); |
| 387 | 321 | |
| 388 | 322 | return $name; |
| 389 | 323 | } |
| @@ -388,17 +322,8 @@ | ||
| 388 | 322 | return $name; |
| 389 | 323 | } |
| 390 | 324 | |
| 391 | 325 | /** |
| 392 | - * Return the product version cache key. | |
| 393 | - * | |
| 394 | - * @return string The product version cache key. | |
| 395 | - */ | |
| 396 | - public function get_cache_key() { | |
| 397 | - return $this->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->get_version() ) . 'versions'; | |
| 398 | - } | |
| 399 | - | |
| 400 | - /** | |
| 401 | 326 | * Getter for product name. |
| 402 | 327 | * |
| 403 | 328 | * @return string The product name. |
| 404 | 329 | */ |
| @@ -447,9 +372,8 @@ | ||
| 447 | 372 | return add_query_arg( |
| 448 | 373 | [ |
| 449 | 374 | 'name' => rawurlencode( $this->get_name() ), |
| 450 | 375 | 'edd_action' => 'view_changelog', |
| 451 | - 'locale' => get_user_locale(), | |
| 452 | 376 | ], |
| 453 | 377 | $this->get_store_url() |
| 454 | 378 | ); |
| 455 | 379 | } |