PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.7.2
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.7.2
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 -144 3.10.103.7.2 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,95 +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 - * Get license hash.
269 - *
270 - * @param string $key Product key.
271 - *
272 - * @return bool|string
273 - */
274 - public static function create_license_hash( $key ) {
275 - $data = self::get_license_data( $key );
276 -
277 - if ( ! $data ) {
278 - return false;
279 - }
280 -
281 - return isset( $data->key ) ? wp_hash( $data->key ) : false;
282 - }
283 -
284 - /**
285 - * Check if license is valid.
286 - *
287 - * @param string $product_file Product basefile.
288 - *
289 - * @return bool Is valid?
290 - */
291 - public static function is_valid( $product_file ) {
292 - return self::status( $product_file ) === self::STATUS_VALID;
293 - }
294 -
295 - /**
296 - * Get product plan.
297 - *
298 - * @param string $product_file Product file.
299 - *
300 - * @return int Plan id.
301 - */
302 - public static function plan( $product_file ) {
303 - $product = Product::get( $product_file );
304 - $data = self::get_license_data( $product->get_key() );
305 -
306 - return isset( $data->price_id ) ? (int) $data->price_id : - 1;
307 - }
308 -
309 - /**
310 - * Get product license key.
311 - *
312 - * @param string $product_file Product file.
313 - *
314 - * @return string
315 - */
316 - public static function key( $product_file ) {
317 - $product = Product::get( $product_file );
318 -
319 - return $product->get_license();
320 - }
321 -
322 - /**
323 219 * Return the last error message.
324 220 *
325 221 * @return mixed Error message.
326 222 */
@@ -359,9 +255,14 @@
359 255 *
360 256 * @return int License plan.
361 257 */
362 258 public function get_plan() {
363 - 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;
364 265 }
365 266
366 267 /**
367 268 * Show the admin notice regarding the license status.
@@ -477,9 +378,9 @@
477 378 if ( ! isset( $license_data->download_id ) || ! isset( $license_data->key ) ) {
478 379 return $this->get_api_url();
479 380 }
480 381
481 - 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;
482 383 }
483 384
484 385 /**
485 386 * Run the license check call.
@@ -620,12 +521,8 @@
620 521 if ( 'activate' === $action && 'valid' !== $license_data->license ) {
621 522 return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' );
622 523 }
623 524
624 - // Remove the versions transient upon activation so that newer version for rollback can be acquired.
625 - $versions_cache = $this->product->get_cache_key();
626 - delete_transient( $versions_cache );
627 -
628 525 return true;
629 526 }
630 527
631 528 /**
@@ -731,21 +628,12 @@
731 628 * @return mixed
732 629 */
733 630 public function theme_update_transient( $value ) {
734 631 $update_data = $this->check_for_update();
735 - if ( empty( $value ) ) {
736 - return $value;
632 + if ( $update_data ) {
633 + $value->response[ $this->product->get_slug() ] = $update_data;
737 634 }
738 635
739 - if ( ! isset( $value->response ) ) {
740 - return $value;
741 - }
742 -
743 - if ( ! $update_data ) {
744 - return $value;
745 - }
746 -
747 - $value->response[ $this->product->get_slug() ] = $update_data;
748 636 return $value;
749 637 }
750 638
751 639 /**
@@ -951,15 +839,9 @@
951 839 if ( $this->product->requires_license() ) {
952 840 $this->failed_checks = intval( get_option( $this->product->get_key() . '_failed_checks', 0 ) );
953 841 $this->register_license_hooks();
954 842 }
955 - if ( ! self::$globals_loaded ) {
956 - add_filter( 'themeisle_sdk_license/status', [ __CLASS__, 'status' ], 999, 1 );
957 - add_filter( 'themeisle_sdk_license/is-valid', [ __CLASS__, 'is_valid' ], 999, 1 );
958 - add_filter( 'themeisle_sdk_license/plan', [ __CLASS__, 'plan' ], 999, 1 );
959 - add_filter( 'themeisle_sdk_license/key', [ __CLASS__, 'key' ], 999, 1 );
960 - $globals_loaded = true;
961 - }
843 +
962 844 $namespace = apply_filters( 'themesle_sdk_namespace_' . md5( $product->get_basefile() ), false );
963 845
964 846 if ( false !== $namespace ) {
965 847 $this->namespace = $namespace;
@@ -984,22 +866,8 @@
984 866 ]
985 867 );
986 868 add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
987 869 add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
988 - if ( ! self::is_valid( $product->get_basefile() ) ) {
989 - add_filter(
990 - 'plugin_action_links_' . plugin_basename( $product->get_basefile() ),
991 - function ( $actions ) {
992 - if ( $this->get_license_status( true ) !== self::STATUS_ACTIVE_EXPIRED ) {
993 - return $actions;
994 - }
995 - $new_actions['deactivate'] = $actions['deactivate'];
996 - $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>';
997 -
998 - return $new_actions;
999 - }
1000 - );
1001 - }
1002 870
1003 871 return $this;
1004 872 }
1005 873 if ( $this->product->is_theme() ) {