PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.2.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.2.1
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
← All changes | vendor/codeinwp/themeisle-sdk/src/Product.php +4 -102 4.0.73.2.1 View file →
@@ -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 }
@@ -138,55 +122,15 @@
138 122 }
139 123 $install = get_option( $this->get_key() . '_install', 0 );
140 124 if ( 0 === $install ) {
141 125 $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 126 update_option( $this->get_key() . '_install', time() );
150 127 }
151 - $this->install = (int) $install;
152 - self::$cached_products[ crc32( $basefile ) ] = $this;
153 - $current_version = get_option( $this->slug . '_version', '' );
128 + $this->install = $install;
154 129
155 - if ( $current_version !== $this->version && wp_cache_add( "{$this->slug}_version_upgrade", true, '', HOUR_IN_SECONDS ) ) {
156 - /**
157 - * Action to be triggered when the product is updated.
158 - *
159 - * @param string $current_version The current version of the product.
160 - * @param string $new_version The new version of the product.
161 - * @param string $basefile The basefile of the product.
162 - */
163 - do_action( "themeisle_sdk_update_{$this->slug}", $current_version, $this->version, $basefile );
164 -
165 - // Update the version of the product.
166 - update_option( "{$this->slug}_version", $this->version );
167 - wp_cache_delete( "{$this->slug}_version_upgrade" );
168 - }
169 130 }
170 131
171 132 /**
172 - * Return a product.
173 - *
174 - * @param string $basefile Product basefile.
175 - *
176 - * @return Product Product Object.
177 - */
178 - public static function get( $basefile ) {
179 - $key = crc32( $basefile );
180 - if ( isset( self::$cached_products[ $key ] ) ) {
181 - return self::$cached_products[ $key ];
182 - }
183 - self::$cached_products[ $key ] = new Product( $basefile );
184 -
185 - return self::$cached_products[ $key ];
186 - }
187 -
188 - /**
189 133 * Setup props from path.
190 134 */
191 135 public function setup_from_path() {
192 136 $this->file = basename( $this->basefile );
@@ -209,9 +153,9 @@
209 153 * @param string $string the String to be normalized for cron handler.
210 154 *
211 155 * @return string $name The normalized string.
212 156 */
213 - public static function key_ready_name( $string ) {
157 + static function key_ready_name( $string ) {
214 158 return str_replace( '-', '_', strtolower( trim( $string ) ) );
215 159 }
216 160
217 161 /**
@@ -255,9 +199,8 @@
255 199 */
256 200 public function get_key() {
257 201 return $this->key;
258 202 }
259 -
260 203 /**
261 204 * Check if the product is either theme or plugin.
262 205 *
263 206 * @return string Product type.
@@ -368,19 +311,9 @@
368 311 *
369 312 * @return string Friendly name.
370 313 */
371 314 public function get_friendly_name() {
372 - $name = trim( str_replace( 'Lite', '', $this->get_name() ) );
373 - if ( defined( 'OTTER_BLOCKS_BASEFILE' ) && OTTER_BLOCKS_BASEFILE === $this->basefile ) {
374 - $name = 'Otter Blocks';
375 - }
376 - if ( defined( 'OPTML_BASEFILE' ) && OPTML_BASEFILE === $this->basefile ) {
377 - $name = 'Optimole';
378 - }
379 - if ( defined( 'WPMM_FILE' ) && WPMM_FILE === $this->basefile ) {
380 - $name = 'LightStart';
381 - }
382 - $name = apply_filters( $this->get_key() . '_friendly_name', $name );
315 + $name = apply_filters( $this->get_key() . '_friendly_name', trim( str_replace( 'Lite', '', $this->get_name() ) ) );
383 316 $name = rtrim( $name, '- ()' );
384 317
385 318 return $name;
386 319 }
@@ -385,17 +318,8 @@
385 318 return $name;
386 319 }
387 320
388 321 /**
389 - * Return the product version cache key.
390 - *
391 - * @return string The product version cache key.
392 - */
393 - public function get_cache_key() {
394 - return $this->get_key() . '_' . preg_replace( '/[^0-9a-zA-Z ]/m', '', $this->get_version() ) . 'versions';
395 - }
396 -
397 - /**
398 322 * Getter for product name.
399 323 *
400 324 * @return string The product name.
401 325 */
@@ -417,13 +341,8 @@
417 341 *
418 342 * @return string The store url.
419 343 */
420 344 public function get_store_url() {
421 -
422 - if ( strpos( $this->store_url, '/themeisle.com' ) !== false ) {
423 - return 'https://store.themeisle.com/';
424 - }
425 -
426 345 return $this->store_url;
427 346 }
428 347
429 348 /**
@@ -435,24 +354,8 @@
435 354 return $this->basefile;
436 355 }
437 356
438 357 /**
439 - * Get changelog url.
440 - *
441 - * @return string Changelog url.
442 - */
443 - public function get_changelog() {
444 - return add_query_arg(
445 - [
446 - 'name' => rawurlencode( $this->get_name() ),
447 - 'edd_action' => 'view_changelog',
448 - 'locale' => get_user_locale(),
449 - ],
450 - $this->get_store_url()
451 - );
452 - }
453 -
454 - /**
455 358 * Returns product filename.
456 359 *
457 360 * @return string The product filename.
458 361 */
@@ -458,9 +361,8 @@
458 361 */
459 362 public function get_file() {
460 363 return $this->file;
461 364 }
462 -
463 365 /**
464 366 * Returns the pro slug, if available.
465 367 *
466 368 * @return string The pro slug.