PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.10.7
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.10.7
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 +80 -3 3.1.33.10.7 View file →
@@ -70,8 +70,14 @@
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 + /**
74 80 * Product store url.
75 81 *
76 82 * @var string $store_url The store url.
77 83 */
@@ -105,8 +111,18 @@
105 111 *
106 112 * @var string $version The product version.
107 113 */
108 114 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/';
109 125
110 126 /**
111 127 * ThemeIsle_SDK_Product constructor.
112 128 *
@@ -113,9 +129,9 @@
113 129 * @param string $basefile Product basefile.
114 130 */
115 131 public function __construct( $basefile ) {
116 132 if ( ! empty( $basefile ) ) {
117 - if ( is_readable( $basefile ) ) {
133 + if ( is_file( $basefile ) ) {
118 134 $this->basefile = $basefile;
119 135 $this->setup_from_path();
120 136 $this->setup_from_fileheaders();
121 137 }
@@ -124,10 +140,27 @@
124 140 if ( 0 === $install ) {
125 141 $install = time();
126 142 update_option( $this->get_key() . '_install', time() );
127 143 }
128 - $this->install = $install;
144 + $this->install = $install;
145 + self::$cached_products[ crc32( $basefile ) ] = $this;
146 + }
129 147
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 ];
130 163 }
131 164
132 165 /**
133 166 * Setup props from path.
@@ -153,9 +186,9 @@
153 186 * @param string $string the String to be normalized for cron handler.
154 187 *
155 188 * @return string $name The normalized string.
156 189 */
157 - static function key_ready_name( $string ) {
190 + public static function key_ready_name( $string ) {
158 191 return str_replace( '-', '_', strtolower( trim( $string ) ) );
159 192 }
160 193
161 194 /**
@@ -199,8 +232,9 @@
199 232 */
200 233 public function get_key() {
201 234 return $this->key;
202 235 }
236 +
203 237 /**
204 238 * Check if the product is either theme or plugin.
205 239 *
206 240 * @return string Product type.
@@ -318,8 +352,17 @@
318 352 return $name;
319 353 }
320 354
321 355 /**
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 + /**
322 365 * Getter for product name.
323 366 *
324 367 * @return string The product name.
325 368 */
@@ -341,8 +384,13 @@
341 384 *
342 385 * @return string The store url.
343 386 */
344 387 public function get_store_url() {
388 +
389 + if ( strpos( $this->store_url, '/themeisle.com' ) !== false ) {
390 + return 'https://store.themeisle.com/';
391 + }
392 +
345 393 return $this->store_url;
346 394 }
347 395
348 396 /**
@@ -354,8 +402,23 @@
354 402 return $this->basefile;
355 403 }
356 404
357 405 /**
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 + ],
416 + $this->get_store_url()
417 + );
418 + }
419 +
420 + /**
358 421 * Returns product filename.
359 422 *
360 423 * @return string The product filename.
361 424 */
@@ -361,8 +424,9 @@
361 424 */
362 425 public function get_file() {
363 426 return $this->file;
364 427 }
428 +
365 429 /**
366 430 * Returns the pro slug, if available.
367 431 *
368 432 * @return string The pro slug.
@@ -377,7 +441,20 @@
377 441 * @return int The install timestamp.
378 442 */
379 443 public function get_install_time() {
380 444 return $this->install;
445 + }
446 +
447 + /**
448 + * Returns the URL of the product base file.
449 + *
450 + * @param string $path The path to the file.
451 + *
452 + * @return string The URL of the product base file.
453 + */
454 + public function get_base_url( $path = '/' ) {
455 + if ( $this->type ) {
456 + return plugins_url( $path, $this->basefile );
457 + }
381 458 }
382 459
383 460 }