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/Modules/Licenser.php +56 -163 4.0.33.10.7 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', 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'] );
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' );
146 146 $error_message = $this->get_error();
147 147 ?>
148 148 <style type="text/css">
149 149 input.themeisle-sdk-text-input-valid {
@@ -265,11 +265,11 @@
265 265 }
266 266
267 267 /**
268 268 * Get license hash.
269 - *
269 + *
270 270 * @param string $key Product key.
271 - *
271 + *
272 272 * @return bool|string
273 273 */
274 274 public static function create_license_hash( $key ) {
275 275 $data = self::get_license_data( $key );
@@ -377,11 +377,11 @@
377 377 return false;
378 378 }
379 379
380 380 $status = $this->get_license_status( true );
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_heading_string', Loader::$labels['licenser']['expired'] );
381 + $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.' );
382 + $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>. ' );
383 + $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.' );
384 384 // No activations left for this license.
385 385 if ( 'valid' != $status && $this->check_activation() ) {
386 386 ?>
387 387 <div class="error">
@@ -402,74 +402,14 @@
402 402 }
403 403
404 404 // Invalid license key.
405 405 if ( 'active_expired' === $status ) {
406 - // Check if the notice was dismissed.
407 - $dismiss_option_key = $this->product->get_key() . '_expired_notice_dismissed';
408 - if ( get_option( $dismiss_option_key, false ) ) {
409 - return false;
410 - }
411 -
412 - $license_data = get_option( $this->product->get_key() . '_license_data', '' );
413 - $expiration_date = '';
414 - if ( is_object( $license_data ) && isset( $license_data->expires ) ) {
415 - $timestamp = strtotime( (string) $license_data->expires );
416 - if ( false !== $timestamp ) {
417 - $expiration_date = gmdate( 'F j, Y', $timestamp );
418 - }
419 - }
420 -
421 - $discount_config = apply_filters( $this->product->get_key() . '_lc_renew_discount', false );
422 -
423 - if ( is_array( $discount_config ) && isset( $discount_config['url'] ) && isset( $discount_config['renew_button'] ) ) {
424 - $renew_url = $discount_config['url'];
425 - $renew_button = $discount_config['renew_button'];
426 - } else {
427 - $renew_url = apply_filters( $this->product->get_key() . '_lc_renew_url', $this->renew_url() );
428 - $renew_button = apply_filters( $this->product->get_key() . '_lc_renew_button_string', Loader::$labels['licenser']['renew_license'] );
429 - }
430 -
431 - $learn_more_url = apply_filters( $this->product->get_key() . '_lc_learn_more_url', $this->get_api_url() );
432 - $learn_more_button = apply_filters( $this->product->get_key() . '_lc_learn_more_button_string', Loader::$labels['licenser']['learn_more'] );
433 - $notice_message = apply_filters( $this->product->get_key() . '_lc_expired_notice_message', Loader::$labels['licenser']['expired_notice'] );
434 -
435 - $expired_date_string = apply_filters( $this->product->get_key() . '_lc_expired_date_string', sprintf( Loader::$labels['licenser']['expired_date'], esc_html( $expiration_date ) ) );
436 - $heading = apply_filters( $this->product->get_key() . '_lc_expired_heading_string', sprintf( Loader::$labels['licenser']['expired'], $this->product->get_name() ) );
437 - $notice_id = $this->product->get_key() . '_expired_notice';
438 406 ?>
439 - <div class="notice notice-warning notice-alt is-dismissible themeisle-sdk-license-notice" id="<?php echo esc_attr( $notice_id ); ?>" data-notice-id="<?php echo esc_attr( $notice_id ); ?>" style="position: relative; border-left: 4px solid #d63638; padding: 12px; background-color: #fff;">
440 - <p style="margin: 0.5em 0; font-size: 13px;">
441 - <strong><?php echo wp_kses_post( $heading ); ?></strong>
442 - · <?php echo esc_html( $expired_date_string ); ?>
407 + <div class="error">
408 + <p>
409 + <strong><?php echo sprintf( wp_kses_data( $expired_license_string ), esc_attr( $this->product->get_name() . ' ' . $this->product->get_type() ), esc_url( $this->get_api_url() . '?license=' . $this->license_key ) ); ?> </strong>
443 410 </p>
444 - <p style="margin: 0.5em 0 1em 0; font-size: 13px;">
445 - <?php echo esc_html( $notice_message ); ?>
446 - </p>
447 - <p style="margin: 0.5em 0;">
448 - <a href="<?php echo esc_url( $renew_url ); ?>" class="button button-primary" target="_blank" rel="noopener noreferrer">
449 - <?php echo esc_html( $renew_button ); ?>
450 - </a>
451 - <a href="<?php echo esc_url( $learn_more_url ); ?>" class="button" target="_blank" rel="noopener noreferrer" style="border: none; background-color: transparent;">
452 - <?php echo esc_html( $learn_more_button ); ?>
453 - </a>
454 - </p>
455 411 </div>
456 - <script type="text/javascript">
457 - jQuery(document).ready(function($) {
458 - $('#<?php echo esc_js( $notice_id ); ?>').on('click', '.notice-dismiss', function(e) {
459 - const noticeId = '<?php echo esc_js( $notice_id ); ?>';
460 - $.ajax({
461 - url: ajaxurl,
462 - type: 'POST',
463 - data: {
464 - action: 'themeisle_sdk_dismiss_license_notice',
465 - notice_id: noticeId,
466 - nonce: '<?php echo esc_js( wp_create_nonce( 'themeisle_sdk_dismiss_license_notice' ) ); ?>'
467 - }
468 - });
469 - });
470 - });
471 - </script>
472 412 <?php
473 413
474 414 return false;
475 415 }
@@ -602,17 +542,17 @@
602 542 * @return bool|\WP_Error
603 543 */
604 544 public function do_license_process( $license, $action = 'toggle' ) {
605 545 if ( strlen( $license ) < 10 ) {
606 - return new \WP_Error( 'themeisle-license-invalid-format', Loader::$labels['licenser']['invalid_msg'] );
546 + return new \WP_Error( 'themeisle-license-invalid-format', 'Invalid license.' );
607 547 }
608 548 $status = $this->get_license_status();
609 549
610 550 if ( 'valid' === $status && 'activate' === $action ) {
611 - return new \WP_Error( 'themeisle-license-already-active', Loader::$labels['licenser']['already_active'] );
551 + return new \WP_Error( 'themeisle-license-already-active', 'License is already active.' );
612 552 }
613 553 if ( 'valid' !== $status && 'deactivate' === $action ) {
614 - return new \WP_Error( 'themeisle-license-already-deactivate', Loader::$labels['licenser']['not_active'] );
554 + return new \WP_Error( 'themeisle-license-already-deactivate', 'License not active.' );
615 555 }
616 556
617 557 if ( 'toggle' === $action ) {
618 558 $action = ( 'valid' !== $status ? ( 'activate' ) : ( 'deactivate' ) );
@@ -638,15 +578,15 @@
638 578 }
639 579
640 580 // make sure the response came back okay.
641 581 if ( is_wp_error( $response ) ) {
642 - return new \WP_Error( 'themeisle-license-500', sprintf( Loader::$labels['licenser']['error_notice'], $response->get_error_message() ) );
582 + 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() ) );
643 583 }
644 584
645 585 $license_data = json_decode( wp_remote_retrieve_body( $response ) );
646 586
647 587 if ( ! is_object( $license_data ) ) {
648 - return new \WP_Error( 'themeisle-license-404', Loader::$labels['licenser']['error_notice2'] );
588 + return new \WP_Error( 'themeisle-license-404', 'ERROR: Failed to validate license. Please try again in one minute.' );
649 589 }
650 590 if ( 'check' === $action ) {
651 591 return $license_data;
652 592 }
@@ -677,9 +617,9 @@
677 617 }
678 618 update_option( $this->product->get_key() . '_license_data', $license_data );
679 619 set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS );
680 620 if ( 'activate' === $action && 'valid' !== $license_data->license ) {
681 - return new \WP_Error( 'themeisle-license-invalid', Loader::$labels['licenser']['error_invalid'] );
621 + return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' );
682 622 }
683 623
684 624 // Remove the versions transient upon activation so that newer version for rollback can be acquired.
685 625 $versions_cache = $this->product->get_cache_key();
@@ -712,9 +652,9 @@
712 652 if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) {
713 653 return;
714 654 }
715 655 if ( ! isset( $_POST[ $this->product->get_key() . 'nonce_field' ] )
716 - || ! 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
717 657 ) {
718 658 return;
719 659 }
720 660 if ( ! current_user_can( 'manage_options' ) ) {
@@ -762,18 +702,20 @@
762 702 if ( false === $api_response || ! isset( $api_response->new_version ) ) {
763 703 return;
764 704 }
765 705 $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&amp;theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() );
766 - $update_message = apply_filters( 'themeisle_sdk_license_update_message', Loader::$labels['licenser']['update_license'] );
706 + $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.' );
767 707 $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"';
768 708 if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) {
769 709 echo '<div id="update-nag">';
770 710 printf(
771 - esc_html( Loader::$labels['licenser']['notice_update'] ),
772 - '<strong>' . esc_attr( $theme->get( 'Name' ) ) . ' ' . esc_attr( $api_response->new_version ) . '</strong>',
773 - '<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' ) ) . '">',
774 - '</a>',
775 - '<a href="' . esc_url( $update_url ) . '" ' . $update_onclick . '>' // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped.
711 + '<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>.',
712 + esc_attr( $theme->get( 'Name' ) ),
713 + esc_attr( $api_response->new_version ),
714 + esc_url( sprintf( '%s&TB_iframe=true&amp;width=1024&amp;height=800', $this->product->get_changelog() ) ),
715 + esc_attr( $theme->get( 'Name' ) ),
716 + esc_url( $update_url ),
717 + $update_onclick // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, Already escaped.
776 718 );
777 719 echo '</div>';
778 720 echo '<div id="' . esc_attr( $this->product->get_slug() ) . '_changelog" style="display:none;">';
779 721 echo wp_kses_data( wpautop( $api_response->sections['changelog'] ) );
@@ -802,9 +744,8 @@
802 744 return $value;
803 745 }
804 746
805 747 $value->response[ $this->product->get_slug() ] = $update_data;
806 -
807 748 return $value;
808 749 }
809 750
810 751 /**
@@ -985,9 +926,9 @@
985 926 * @return bool Should we load the module?
986 927 */
987 928 public function can_load( $product ) {
988 929
989 - if ( ! $product->requires_license() ) {
930 + if ( $product->is_wordpress_available() ) {
990 931 return false;
991 932 }
992 933
993 934 return ( apply_filters( $product->get_key() . '_enable_licenser', true ) === true );
@@ -1034,61 +975,41 @@
1034 975 }
1035 976
1036 977 add_action( 'admin_head', [ $this, 'auto_activate' ] );
1037 978 if ( $this->product->is_plugin() ) {
1038 - if ( ! $product->is_wordpress_available() ) {
979 + add_filter(
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( '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() ) ) {
1039 989 add_filter(
1040 - 'pre_set_site_transient_update_plugins',
1041 - [
1042 - $this,
1043 - 'pre_set_site_transient_update_plugins_filter',
1044 - ]
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 + }
1045 1000 );
1046 - add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
1047 - add_filter( //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
1048 - 'http_request_args',
1049 - array(
1050 - $this,
1051 - 'http_request_args',
1052 - ),
1053 - 10,
1054 - 2
1055 - );
1056 - if ( ! self::is_valid( $product->get_basefile() ) ) {
1057 - add_filter(
1058 - 'plugin_action_links_' . plugin_basename( $product->get_basefile() ),
1059 - function ( $actions ) {
1060 - if ( $this->get_license_status( true ) !== self::STATUS_ACTIVE_EXPIRED ) {
1061 - return $actions;
1062 - }
1063 - $new_actions['deactivate'] = $actions['deactivate'];
1064 - $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>';
1065 -
1066 - return $new_actions;
1067 - }
1068 - );
1069 - }
1070 1001 }
1071 1002
1072 1003 return $this;
1073 1004 }
1074 1005 if ( $this->product->is_theme() ) {
1075 - if ( ! $product->is_wordpress_available() ) {
1076 - add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
1077 - add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
1078 - add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
1079 - add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
1080 - add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
1081 - add_filter( //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
1082 - 'http_request_args',
1083 - array(
1084 - $this,
1085 - 'disable_wporg_update',
1086 - ),
1087 - 5,
1088 - 2
1089 - );
1090 - }
1006 + add_filter( 'site_transient_update_themes', array( &$this, 'theme_update_transient' ) );
1007 + add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) );
1008 + add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) );
1009 + add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) );
1010 + add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) );
1011 + add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args
1091 1012
1092 1013 return $this;
1093 1014
1094 1015 }
@@ -1104,37 +1025,11 @@
1104 1025 add_action( 'admin_init', array( $this, 'process_license' ) );
1105 1026 add_action( 'admin_init', array( $this, 'product_valid' ), 99999999 );
1106 1027 add_action( 'admin_notices', array( $this, 'show_notice' ) );
1107 1028 add_filter( $this->product->get_key() . '_license_status', array( $this, 'get_license_status' ) );
1108 - add_action( 'wp_ajax_themeisle_sdk_dismiss_license_notice', array( $this, 'dismiss_license_notice' ) );
1109 1029 }
1110 1030
1111 1031 /**
1112 - * Handle AJAX request to dismiss the license notice.
1113 - */
1114 - public function dismiss_license_notice() {
1115 - if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_text_field( $_POST['nonce'] ), 'themeisle_sdk_dismiss_license_notice' ) ) {
1116 - wp_send_json_error( 'Invalid nonce' );
1117 - }
1118 -
1119 - if ( ! current_user_can( 'manage_options' ) ) {
1120 - wp_send_json_error( 'Insufficient permissions' );
1121 - }
1122 -
1123 - $notice_id = isset( $_POST['notice_id'] ) ? sanitize_text_field( $_POST['notice_id'] ) : '';
1124 -
1125 - if ( empty( $notice_id ) ) {
1126 - wp_send_json_error( 'Missing notice ID' );
1127 - }
1128 -
1129 - // Save the dismissal option.
1130 - $dismiss_option_key = $notice_id . '_dismissed';
1131 - update_option( $dismiss_option_key, true );
1132 -
1133 - wp_send_json_success();
1134 - }
1135 -
1136 - /**
1137 1032 * Check license on filesystem.
1138 1033 *
1139 1034 * @return mixed License key.
1140 1035 */
@@ -1155,12 +1050,10 @@
1155 1050 }
1156 1051 if ( ! isset( $content->key ) ) {
1157 1052 return false;
1158 1053 }
1159 -
1160 1054 return $content->key;
1161 1055 }
1162 -
1163 1056 /**
1164 1057 * Run license activation on plugin activate.
1165 1058 */
1166 1059 public function auto_activate() {
@@ -1208,9 +1101,9 @@
1208 1101 */
1209 1102 public function autoactivate_notice() {
1210 1103 ?>
1211 1104 <div class="notice notice-success is-dismissible">
1212 - <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>
1105 + <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>
1213 1106 </div>
1214 1107 <?php
1215 1108 }
1216 1109