← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Licenser.php
+28
-62
3.10.14
→
3.9.2
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']['deactivateactivate'] ); | |
| 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 { |
| @@ -264,25 +264,8 @@ | ||
| 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 | - /** | |
| 285 | 268 | * Check if license is valid. |
| 286 | 269 | * |
| 287 | 270 | * @param string $product_file Product basefile. |
| 288 | 271 | * |
| @@ -377,11 +360,11 @@ | ||
| 377 | 360 | return false; |
| 378 | 361 | } |
| 379 | 362 | |
| 380 | 363 | $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_string', sprintf( Loader::$labels['licenser']['expired'], '%s', '<a href="%s" target="_blank">', '</a>' ) ); | |
| 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.' ); | |
| 384 | 367 | // No activations left for this license. |
| 385 | 368 | if ( 'valid' != $status && $this->check_activation() ) { |
| 386 | 369 | ?> |
| 387 | 370 | <div class="error"> |
| @@ -542,17 +525,17 @@ | ||
| 542 | 525 | * @return bool|\WP_Error |
| 543 | 526 | */ |
| 544 | 527 | public function do_license_process( $license, $action = 'toggle' ) { |
| 545 | 528 | if ( strlen( $license ) < 10 ) { |
| 546 | - return new \WP_Error( 'themeisle-license-invalid-format', Loader::$labels['licenser']['invalid_msg'] ); | |
| 529 | + return new \WP_Error( 'themeisle-license-invalid-format', 'Invalid license.' ); | |
| 547 | 530 | } |
| 548 | 531 | $status = $this->get_license_status(); |
| 549 | 532 | |
| 550 | 533 | if ( 'valid' === $status && 'activate' === $action ) { |
| 551 | - return new \WP_Error( 'themeisle-license-already-active', Loader::$labels['licenser']['already_active'] ); | |
| 534 | + return new \WP_Error( 'themeisle-license-already-active', 'License is already active.' ); | |
| 552 | 535 | } |
| 553 | 536 | if ( 'valid' !== $status && 'deactivate' === $action ) { |
| 554 | - return new \WP_Error( 'themeisle-license-already-deactivate', Loader::$labels['licenser']['not_active'] ); | |
| 537 | + return new \WP_Error( 'themeisle-license-already-deactivate', 'License not active.' ); | |
| 555 | 538 | } |
| 556 | 539 | |
| 557 | 540 | if ( 'toggle' === $action ) { |
| 558 | 541 | $action = ( 'valid' !== $status ? ( 'activate' ) : ( 'deactivate' ) ); |
| @@ -578,15 +561,15 @@ | ||
| 578 | 561 | } |
| 579 | 562 | |
| 580 | 563 | // make sure the response came back okay. |
| 581 | 564 | if ( is_wp_error( $response ) ) { |
| 582 | - return new \WP_Error( 'themeisle-license-500', sprintf( Loader::$labels['licenser']['error_notice'], $response->get_error_message() ) ); | |
| 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() ) ); | |
| 583 | 566 | } |
| 584 | 567 | |
| 585 | 568 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 586 | 569 | |
| 587 | 570 | if ( ! is_object( $license_data ) ) { |
| 588 | - return new \WP_Error( 'themeisle-license-404', Loader::$labels['licenser']['error_notice2'] ); | |
| 571 | + return new \WP_Error( 'themeisle-license-404', 'ERROR: Failed to validate license. Please try again in one minute.' ); | |
| 589 | 572 | } |
| 590 | 573 | if ( 'check' === $action ) { |
| 591 | 574 | return $license_data; |
| 592 | 575 | } |
| @@ -617,9 +600,9 @@ | ||
| 617 | 600 | } |
| 618 | 601 | update_option( $this->product->get_key() . '_license_data', $license_data ); |
| 619 | 602 | set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS ); |
| 620 | 603 | if ( 'activate' === $action && 'valid' !== $license_data->license ) { |
| 621 | - return new \WP_Error( 'themeisle-license-invalid', Loader::$labels['licenser']['error_invalid'] ); | |
| 604 | + return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' ); | |
| 622 | 605 | } |
| 623 | 606 | |
| 624 | 607 | // Remove the versions transient upon activation so that newer version for rollback can be acquired. |
| 625 | 608 | $versions_cache = $this->product->get_cache_key(); |
| @@ -652,9 +635,9 @@ | ||
| 652 | 635 | if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) { |
| 653 | 636 | return; |
| 654 | 637 | } |
| 655 | 638 | if ( ! isset( $_POST[ $this->product->get_key() . 'nonce_field' ] ) |
| 656 | - || ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 639 | + || ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 657 | 640 | ) { |
| 658 | 641 | return; |
| 659 | 642 | } |
| 660 | 643 | if ( ! current_user_can( 'manage_options' ) ) { |
| @@ -702,18 +685,20 @@ | ||
| 702 | 685 | if ( false === $api_response || ! isset( $api_response->new_version ) ) { |
| 703 | 686 | return; |
| 704 | 687 | } |
| 705 | 688 | $update_url = wp_nonce_url( 'update.php?action=upgrade-theme&theme=' . urlencode( $this->product->get_slug() ), 'upgrade-theme_' . $this->product->get_slug() ); |
| 706 | - $update_message = apply_filters( 'themeisle_sdk_license_update_message', Loader::$labels['licenser']['update_license'] ); | |
| 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.' ); | |
| 707 | 690 | $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"'; |
| 708 | 691 | if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { |
| 709 | 692 | echo '<div id="update-nag">'; |
| 710 | 693 | printf( |
| 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&width=1024&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. | |
| 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&width=1024&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. | |
| 716 | 701 | ); |
| 717 | 702 | echo '</div>'; |
| 718 | 703 | echo '<div id="' . esc_attr( $this->product->get_slug() ) . '_changelog" style="display:none;">'; |
| 719 | 704 | echo wp_kses_data( wpautop( $api_response->sections['changelog'] ) ); |
| @@ -742,9 +727,8 @@ | ||
| 742 | 727 | return $value; |
| 743 | 728 | } |
| 744 | 729 | |
| 745 | 730 | $value->response[ $this->product->get_slug() ] = $update_data; |
| 746 | - | |
| 747 | 731 | return $value; |
| 748 | 732 | } |
| 749 | 733 | |
| 750 | 734 | /** |
| @@ -982,17 +966,9 @@ | ||
| 982 | 966 | 'pre_set_site_transient_update_plugins_filter', |
| 983 | 967 | ] |
| 984 | 968 | ); |
| 985 | 969 | add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 ); |
| 986 | - add_filter( //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args | |
| 987 | - 'http_request_args', | |
| 988 | - array( | |
| 989 | - $this, | |
| 990 | - 'http_request_args', | |
| 991 | - ), | |
| 992 | - 10, | |
| 993 | - 2 | |
| 994 | - ); | |
| 970 | + add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args | |
| 995 | 971 | if ( ! self::is_valid( $product->get_basefile() ) ) { |
| 996 | 972 | add_filter( |
| 997 | 973 | 'plugin_action_links_' . plugin_basename( $product->get_basefile() ), |
| 998 | 974 | function ( $actions ) { |
| @@ -999,12 +975,12 @@ | ||
| 999 | 975 | if ( $this->get_license_status( true ) !== self::STATUS_ACTIVE_EXPIRED ) { |
| 1000 | 976 | return $actions; |
| 1001 | 977 | } |
| 1002 | 978 | $new_actions['deactivate'] = $actions['deactivate']; |
| 1003 | - $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>'; | |
| 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>'; | |
| 1004 | 980 | |
| 1005 | 981 | return $new_actions; |
| 1006 | - } | |
| 982 | + } | |
| 1007 | 983 | ); |
| 1008 | 984 | } |
| 1009 | 985 | |
| 1010 | 986 | return $this; |
| @@ -1014,17 +990,9 @@ | ||
| 1014 | 990 | add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) ); |
| 1015 | 991 | add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) ); |
| 1016 | 992 | add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) ); |
| 1017 | 993 | add_action( 'load-themes.php', array( &$this, 'load_themes_screen' ) ); |
| 1018 | - add_filter( //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args | |
| 1019 | - 'http_request_args', | |
| 1020 | - array( | |
| 1021 | - $this, | |
| 1022 | - 'disable_wporg_update', | |
| 1023 | - ), | |
| 1024 | - 5, | |
| 1025 | - 2 | |
| 1026 | - ); | |
| 994 | + add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args | |
| 1027 | 995 | |
| 1028 | 996 | return $this; |
| 1029 | 997 | |
| 1030 | 998 | } |
| @@ -1065,12 +1033,10 @@ | ||
| 1065 | 1033 | } |
| 1066 | 1034 | if ( ! isset( $content->key ) ) { |
| 1067 | 1035 | return false; |
| 1068 | 1036 | } |
| 1069 | - | |
| 1070 | 1037 | return $content->key; |
| 1071 | 1038 | } |
| 1072 | - | |
| 1073 | 1039 | /** |
| 1074 | 1040 | * Run license activation on plugin activate. |
| 1075 | 1041 | */ |
| 1076 | 1042 | public function auto_activate() { |
| @@ -1118,9 +1084,9 @@ | ||
| 1118 | 1084 | */ |
| 1119 | 1085 | public function autoactivate_notice() { |
| 1120 | 1086 | ?> |
| 1121 | 1087 | <div class="notice notice-success is-dismissible"> |
| 1122 | - <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> | |
| 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> | |
| 1123 | 1089 | </div> |
| 1124 | 1090 | <?php |
| 1125 | 1091 | } |
| 1126 | 1092 | |