PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
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 +89 -51 3.10.23.11.10 View file →
@@ -137,13 +137,13 @@
137 137 public function license_view() {
138 138 $status = $this->get_license_status();
139 139 $value = $this->license_key;
140 140
141 - $activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', 'Activate' );
142 - $deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', 'Deactivate' );
143 - $valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', 'Valid' );
144 - $invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', 'Invalid' );
145 - $license_message = apply_filters( $this->product->get_key() . '_lc_license_message', 'Enter your license from %s purchase history in order to get %s updates' );
141 + $activate_string = apply_filters( $this->product->get_key() . '_lc_activate_string', Loader::$labels['licenser']['activate'] );
142 + $deactivate_string = apply_filters( $this->product->get_key() . '_lc_deactivate_string', Loader::$labels['licenser']['deactivate'] );
143 + $valid_string = apply_filters( $this->product->get_key() . '_lc_valid_string', Loader::$labels['licenser']['valid'] );
144 + $invalid_string = apply_filters( $this->product->get_key() . '_lc_invalid_string', Loader::$labels['licenser']['invalid'] );
145 + $license_message = apply_filters( $this->product->get_key() . '_lc_license_message', Loader::$labels['licenser']['notice'] );
146 146 $error_message = $this->get_error();
147 147 ?>
148 148 <style type="text/css">
149 149 input.themeisle-sdk-text-input-valid {
@@ -264,8 +264,25 @@
264 264 return isset( $license_data->license ) ? $license_data : false;
265 265 }
266 266
267 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 + /**
268 285 * Check if license is valid.
269 286 *
270 287 * @param string $product_file Product basefile.
271 288 *
@@ -360,11 +377,11 @@
360 377 return false;
361 378 }
362 379
363 380 $status = $this->get_license_status( true );
364 - $no_activations_string = apply_filters( $this->product->get_key() . '_lc_no_activations_string', 'No more activations left for %s. You need to upgrade your plan in order to use %s on more websites. If you need assistance, please get in touch with %s staff.' );
365 - $no_valid_string = apply_filters( $this->product->get_key() . '_lc_no_valid_string', 'In order to benefit from updates and support for %s, please add your license code from your <a href="%s" target="_blank">purchase history</a> and validate it <a href="%s">here</a>. ' );
366 - $expired_license_string = apply_filters( $this->product->get_key() . '_lc_expired_string', 'Your %s\'s License Key has expired. In order to continue receiving support and software updates you must <a href="%s" target="_blank">renew</a> your license key.' );
381 + $no_activations_string = apply_filters( $this->product->get_key() . '_lc_no_activations_string', Loader::$labels['licenser']['no_activations'] );
382 + $no_valid_string = apply_filters( $this->product->get_key() . '_lc_no_valid_string', sprintf( Loader::$labels['licenser']['inactive'], '%s', '<a href="%s" target="_blank">', '</a>', '<a href="%s">', '</a>' ) );
383 + $expired_license_string = apply_filters( $this->product->get_key() . '_lc_expired_string', sprintf( Loader::$labels['licenser']['expired'], '%s', '<a href="%s" target="_blank">', '</a>' ) );
367 384 // No activations left for this license.
368 385 if ( 'valid' != $status && $this->check_activation() ) {
369 386 ?>
370 387 <div class="error">
@@ -525,17 +542,17 @@
525 542 * @return bool|\WP_Error
526 543 */
527 544 public function do_license_process( $license, $action = 'toggle' ) {
528 545 if ( strlen( $license ) < 10 ) {
529 - return new \WP_Error( 'themeisle-license-invalid-format', 'Invalid license.' );
546 + return new \WP_Error( 'themeisle-license-invalid-format', Loader::$labels['licenser']['invalid_msg'] );
530 547 }
531 548 $status = $this->get_license_status();
532 549
533 550 if ( 'valid' === $status && 'activate' === $action ) {
534 - return new \WP_Error( 'themeisle-license-already-active', 'License is already active.' );
551 + return new \WP_Error( 'themeisle-license-already-active', Loader::$labels['licenser']['already_active'] );
535 552 }
536 553 if ( 'valid' !== $status && 'deactivate' === $action ) {
537 - return new \WP_Error( 'themeisle-license-already-deactivate', 'License not active.' );
554 + return new \WP_Error( 'themeisle-license-already-deactivate', Loader::$labels['licenser']['not_active'] );
538 555 }
539 556
540 557 if ( 'toggle' === $action ) {
541 558 $action = ( 'valid' !== $status ? ( 'activate' ) : ( 'deactivate' ) );
@@ -561,15 +578,15 @@
561 578 }
562 579
563 580 // make sure the response came back okay.
564 581 if ( is_wp_error( $response ) ) {
565 - return new \WP_Error( 'themeisle-license-500', sprintf( 'ERROR: Failed to connect to the license service. Please try again later. Reason: %s', $response->get_error_message() ) );
582 + return new \WP_Error( 'themeisle-license-500', sprintf( Loader::$labels['licenser']['error_notice'], $response->get_error_message() ) );
566 583 }
567 584
568 585 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
569 586
570 587 if ( ! is_object( $license_data ) ) {
571 - return new \WP_Error( 'themeisle-license-404', 'ERROR: Failed to validate license. Please try again in one minute.' );
588 + return new \WP_Error( 'themeisle-license-404', Loader::$labels['licenser']['error_notice2'] );
572 589 }
573 590 if ( 'check' === $action ) {
574 591 return $license_data;
575 592 }
@@ -600,9 +617,9 @@
600 617 }
601 618 update_option( $this->product->get_key() . '_license_data', $license_data );
602 619 set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS );
603 620 if ( 'activate' === $action && 'valid' !== $license_data->license ) {
604 - return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' );
621 + return new \WP_Error( 'themeisle-license-invalid', Loader::$labels['licenser']['error_invalid'] );
605 622 }
606 623
607 624 // Remove the versions transient upon activation so that newer version for rollback can be acquired.
608 625 $versions_cache = $this->product->get_cache_key();
@@ -635,9 +652,9 @@
635 652 if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) {
636 653 return;
637 654 }
638 655 if ( ! isset( $_POST[ $this->product->get_key() . 'nonce_field' ] )
639 - || ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
656 + || ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
640 657 ) {
641 658 return;
642 659 }
643 660 if ( ! current_user_can( 'manage_options' ) ) {
@@ -685,20 +702,18 @@
685 702 if ( false === $api_response || ! isset( $api_response->new_version ) ) {
686 703 return;
687 704 }
688 705 $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() );
689 - $update_message = apply_filters( 'themeisle_sdk_license_update_message', 'Updating this theme will lose any customizations you have made. Cancel to stop, OK to update.' );
706 + $update_message = apply_filters( 'themeisle_sdk_license_update_message', Loader::$labels['licenser']['update_license'] );
690 707 $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"';
691 708 if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
692 709 echo '<div id="update-nag">';
693 710 printf(
694 - '<strong>%1$s %2$s</strong> is available. <a href="%3$s" class="thickbox" title="%4s">Check out what\'s new</a> or <a href="%5$s"%6$s>update now</a>.',
695 - esc_attr( $theme->get( 'Name' ) ),
696 - esc_attr( $api_response->new_version ),
697 - esc_url( sprintf( '%s&TB_iframe=true&amp;width=1024&amp;height=800', $this->product->get_changelog() ) ),
698 - esc_attr( $theme->get( 'Name' ) ),
699 - esc_url( $update_url ),
700 - $update_onclick // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped.
711 + esc_html( Loader::$labels['licenser']['notice_update'] ),
712 + '<strong>' . esc_attr( $theme->get( 'Name' ) ) . ' ' . esc_attr( $api_response->new_version ) . '</strong>',
713 + '<a href="' . esc_url( sprintf( '%s&TB_iframe=true&amp;width=1024&amp;height=800', $this->product->get_changelog() ) ) . '" class="thickbox" title="' . esc_attr( $theme->get( 'Name' ) ) . '">',
714 + '</a>',
715 + '<a href="' . esc_url( $update_url ) . '" ' . $update_onclick . '>' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped.
701 716 );
702 717 echo '</div>';
703 718 echo '<div id="' . esc_attr( $this->product->get_slug() ) . '_changelog" style="display:none;">';
704 719 echo wp_kses_data( wpautop( $api_response->sections['changelog'] ) );
@@ -727,8 +742,9 @@
727 742 return $value;
728 743 }
729 744
730 745 $value->response[ $this->product->get_slug() ] = $update_data;
746 +
731 747 return $value;
732 748 }
733 749
734 750 /**
@@ -909,9 +925,9 @@
909 925 * @return bool Should we load the module?
910 926 */
911 927 public function can_load( $product ) {
912 928
913 - if ( $product->is_wordpress_available() ) {
929 + if ( ! $product->requires_license() ) {
914 930 return false;
915 931 }
916 932
917 933 return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true );
@@ -958,41 +974,61 @@
958 974 }
959 975
960 976 add_action( 'admin_head', [ $this, 'auto_activate' ] );
961 977 if ( $this->product->is_plugin() ) {
962 - add_filter(
963 - 'pre_set_site_transient_update_plugins',
964 - [
965 - $this,
966 - 'pre_set_site_transient_update_plugins_filter',
967 - ]
968 - );
969 - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
970 - 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() ) ) {
978 + if ( ! $product->is_wordpress_available() ) {
972 979 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;
980 + 'pre_set_site_transient_update_plugins',
981 + [
982 + $this,
983 + 'pre_set_site_transient_update_plugins_filter',
984 + ]
985 + );
986 + add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
987 + add_filter( //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
988 + 'http_request_args',
989 + array(
990 + $this,
991 + 'http_request_args',
992 + ),
993 + 10,
994 + 2
995 + );
996 + if ( ! self::is_valid( $product->get_basefile() ) ) {
997 + add_filter(
998 + 'plugin_action_links_' . plugin_basename( $product->get_basefile() ),
999 + function ( $actions ) {
1000 + if ( $this->get_license_status( true ) !== self::STATUS_ACTIVE_EXPIRED ) {
1001 + return $actions;
1002 + }
1003 + $new_actions['deactivate'] = $actions['deactivate'];
1004 + $new_actions['renew_link'] = '<a style="color:#d63638" href="' . esc_url( $this->renew_url() ) . '" target="_blank" rel="external noopener noreferrer">' . esc_html( Loader::$labels['licenser']['renew_cta'] ) . '</a>';
1005 +
1006 + return $new_actions;
977 1007 }
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 - );
1008 + );
1009 + }
984 1010 }
985 1011
986 1012 return $this;
987 1013 }
988 1014 if ( $this->product->is_theme() ) {
989 - add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
990 - add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
991 - add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
992 - add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
993 - add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
994 - add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
1015 + if ( ! $product->is_wordpress_available() ) {
1016 + add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
1017 + add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
1018 + add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
1019 + add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
1020 + add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
1021 + add_filter( //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
1022 + 'http_request_args',
1023 + array(
1024 + $this,
1025 + 'disable_wporg_update',
1026 + ),
1027 + 5,
1028 + 2
1029 + );
1030 + }
995 1031
996 1032 return $this;
997 1033
998 1034 }
@@ -1033,10 +1069,12 @@
1033 1069 }
1034 1070 if ( ! isset( $content->key ) ) {
1035 1071 return false;
1036 1072 }
1073 +
1037 1074 return $content->key;
1038 1075 }
1076 +
1039 1077 /**
1040 1078 * Run license activation on plugin activate.
1041 1079 */
1042 1080 public function auto_activate() {
@@ -1084,9 +1122,9 @@
1084 1122 */
1085 1123 public function autoactivate_notice() {
1086 1124 ?>
1087 1125 <div class="notice notice-success is-dismissible">
1088 - <p><?php echo sprintf( '<strong>%s</strong> has been successfully activated using <strong>%s</strong> license !', esc_attr( $this->product->get_name() ), esc_attr( str_repeat( '*', 20 ) . substr( $this->license_local, - 10 ) ) ); ?></p>
1126 + <p><?php echo sprintf( esc_html( Loader::$labels['licenser']['autoactivate_notice'] ), '<strong>' . esc_attr( $this->product->get_name() ) . '</strong>', '<strong>' . esc_attr( str_repeat( '*', 20 ) . substr( $this->license_local, - 10 ) ) . '</strong>' ); ?></p>
1089 1127 </div>
1090 1128 <?php
1091 1129 }
1092 1130