PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.1
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.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/Modules/Licenser.php +12 -127 3.10.33.7.1 View file →
@@ -23,33 +23,16 @@
23 23 /**
24 24 * Licenser module for ThemeIsle SDK.
25 25 */
26 26 class Licenser extends Abstract_Module {
27 +
27 28 /**
28 - * License VALID status string.
29 - */
30 - const STATUS_VALID = 'valid';
31 - /**
32 - * License NOT_ACTIVE status string.
33 - */
34 - const STATUS_NOT_ACTIVE = 'not_active';
35 - /**
36 - * License active expired status string.
37 - */
38 - const STATUS_ACTIVE_EXPIRED = 'active_expired';
39 - /**
40 29 * Number of max failed checks before showing the license message.
41 30 *
42 31 * @var int $max_failed Maximum failed checks allowed before show the notice
43 32 */
44 - private static $max_failed = 1;
33 + private static $max_failed = 2;
45 34 /**
46 - * Flag to check if the global actions were loaded.
47 - *
48 - * @var bool If the globals actions were loaded.
49 - */
50 - private static $globals_loaded = false;
51 - /**
52 35 * License key string.
53 36 *
54 37 * @var string $license_key The license key string
55 38 */
@@ -232,78 +215,8 @@
232 215 return ( 'valid' === $status && isset( $license_data->is_expired ) && 'yes' === $license_data->is_expired ) ? 'active_expired' : $status;
233 216 }
234 217
235 218 /**
236 - * Check status.
237 - *
238 - * @param string $product_file Product basefile.
239 - *
240 - * @return string Status license.
241 - */
242 - public static function status( $product_file ) {
243 - $product = Product::get( $product_file );
244 - if ( ! $product->requires_license() ) {
245 - return self::STATUS_VALID;
246 - }
247 - $license_data = self::get_license_data( $product->get_key() );
248 -
249 - $status = isset( $license_data->license ) ? $license_data->license : self::STATUS_NOT_ACTIVE;
250 -
251 - return ( 'valid' === $status && isset( $license_data->is_expired ) && 'yes' === $license_data->is_expired ) ? 'active_expired' : $status;
252 - }
253 -
254 - /**
255 - * Product license data.
256 - *
257 - * @param string $key Product key.
258 - *
259 - * @return false|mixed|null
260 - */
261 - private static function get_license_data( $key ) {
262 - $license_data = get_option( $key . '_license_data', '' );
263 -
264 - return isset( $license_data->license ) ? $license_data : false;
265 - }
266 -
267 - /**
268 - * Check if license is valid.
269 - *
270 - * @param string $product_file Product basefile.
271 - *
272 - * @return bool Is valid?
273 - */
274 - public static function is_valid( $product_file ) {
275 - return self::status( $product_file ) === self::STATUS_VALID;
276 - }
277 -
278 - /**
279 - * Get product plan.
280 - *
281 - * @param string $product_file Product file.
282 - *
283 - * @return int Plan id.
284 - */
285 - public static function plan( $product_file ) {
286 - $product = Product::get( $product_file );
287 - $data = self::get_license_data( $product->get_key() );
288 -
289 - return isset( $data->price_id ) ? (int) $data->price_id : - 1;
290 - }
291 -
292 - /**
293 - * Get product license key.
294 - *
295 - * @param string $product_file Product file.
296 - *
297 - * @return string
298 - */
299 - public static function key( $product_file ) {
300 - $product = Product::get( $product_file );
301 -
302 - return $product->get_license();
303 - }
304 -
305 - /**
306 219 * Return the last error message.
307 220 *
308 221 * @return mixed Error message.
309 222 */
@@ -342,9 +255,14 @@
342 255 *
343 256 * @return int License plan.
344 257 */
345 258 public function get_plan() {
346 - return self::plan( $this->product->get_basefile() );
259 + $license_data = get_option( $this->product->get_key() . '_license_data', '' );
260 + if ( ! isset( $license_data->price_id ) ) {
261 + return - 1;
262 + }
263 +
264 + return (int) $license_data->price_id;
347 265 }
348 266
349 267 /**
350 268 * Show the admin notice regarding the license status.
@@ -460,9 +378,9 @@
460 378 if ( ! isset( $license_data->download_id ) || ! isset( $license_data->key ) ) {
461 379 return $this->get_api_url();
462 380 }
463 381
464 - return trim( $this->get_api_url(), '/' ) . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id;
382 + return $this->get_api_url() . '/checkout/?edd_license_key=' . $license_data->key . '&download_id=' . $license_data->download_id;
465 383 }
466 384
467 385 /**
468 386 * Run the license check call.
@@ -603,12 +521,8 @@
603 521 if ( 'activate' === $action && 'valid' !== $license_data->license ) {
604 522 return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' );
605 523 }
606 524
607 - // Remove the versions transient upon activation so that newer version for rollback can be acquired.
608 - $versions_cache = $this->product->get_cache_key();
609 - delete_transient( $versions_cache );
610 -
611 525 return true;
612 526 }
613 527
614 528 /**
@@ -714,21 +628,12 @@
714 628 * @return mixed
715 629 */
716 630 public function theme_update_transient( $value ) {
717 631 $update_data = $this->check_for_update();
718 - if ( empty( $value ) ) {
719 - return $value;
632 + if ( $update_data ) {
633 + $value->response[ $this->product->get_slug() ] = $update_data;
720 634 }
721 635
722 - if ( ! isset( $value->response ) ) {
723 - return $value;
724 - }
725 -
726 - if ( ! $update_data ) {
727 - return $value;
728 - }
729 -
730 - $value->response[ $this->product->get_slug() ] = $update_data;
731 636 return $value;
732 637 }
733 638
734 639 /**
@@ -934,15 +839,9 @@
934 839 if ( $this->product->requires_license() ) {
935 840 $this->failed_checks = intval( get_option( $this->product->get_key() . '_failed_checks', 0 ) );
936 841 $this->register_license_hooks();
937 842 }
938 - if ( ! self::$globals_loaded ) {
939 - add_filter( 'themeisle_sdk_license/status', [ __CLASS__, 'status' ], 999, 1 );
940 - add_filter( 'themeisle_sdk_license/is-valid', [ __CLASS__, 'is_valid' ], 999, 1 );
941 - add_filter( 'themeisle_sdk_license/plan', [ __CLASS__, 'plan' ], 999, 1 );
942 - add_filter( 'themeisle_sdk_license/key', [ __CLASS__, 'key' ], 999, 1 );
943 - $globals_loaded = true;
944 - }
843 +
945 844 $namespace = apply_filters( 'themesle_sdk_namespace_' . md5( $product->get_basefile() ), false );
946 845
947 846 if ( false !== $namespace ) {
948 847 $this->namespace = $namespace;
@@ -967,22 +866,8 @@
967 866 ]
968 867 );
969 868 add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
970 869 add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
971 - if ( ! self::is_valid( $product->get_basefile() ) ) {
972 - add_filter(
973 - 'plugin_action_links_' . plugin_basename( $product->get_basefile() ),
974 - function ( $actions ) {
975 - if ( $this->get_license_status( true ) !== self::STATUS_ACTIVE_EXPIRED ) {
976 - return $actions;
977 - }
978 - $new_actions['deactivate'] = $actions['deactivate'];
979 - $new_actions['renew_link'] = '<a style="color:#d63638" href="' . esc_url( $this->renew_url() ) . '" target="_blank" rel="external noopener noreferrer">Renew license to update</a>';
980 -
981 - return $new_actions;
982 - }
983 - );
984 - }
985 870
986 871 return $this;
987 872 }
988 873 if ( $this->product->is_theme() ) {