← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Licenser.php
+30
-47
3.10.13
→
3.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']['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 { |
| @@ -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_string', sprintf( Loader::$labels['licenser']['expired'], '%s', '<a href="%s" target="_blank">', '</a>' ) ); | |
| 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"> |
| @@ -542,17 +542,17 @@ | ||
| 542 | 542 | * @return bool|\WP_Error |
| 543 | 543 | */ |
| 544 | 544 | public function do_license_process( $license, $action = 'toggle' ) { |
| 545 | 545 | if ( strlen( $license ) < 10 ) { |
| 546 | - return new \WP_Error( 'themeisle-license-invalid-format', Loader::$labels['licenser']['invalid_msg'] ); | |
| 546 | + return new \WP_Error( 'themeisle-license-invalid-format', 'Invalid license.' ); | |
| 547 | 547 | } |
| 548 | 548 | $status = $this->get_license_status(); |
| 549 | 549 | |
| 550 | 550 | if ( 'valid' === $status && 'activate' === $action ) { |
| 551 | - 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.' ); | |
| 552 | 552 | } |
| 553 | 553 | if ( 'valid' !== $status && 'deactivate' === $action ) { |
| 554 | - 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.' ); | |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | if ( 'toggle' === $action ) { |
| 558 | 558 | $action = ( 'valid' !== $status ? ( 'activate' ) : ( 'deactivate' ) ); |
| @@ -578,15 +578,15 @@ | ||
| 578 | 578 | } |
| 579 | 579 | |
| 580 | 580 | // make sure the response came back okay. |
| 581 | 581 | if ( is_wp_error( $response ) ) { |
| 582 | - 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() ) ); | |
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
| 586 | 586 | |
| 587 | 587 | if ( ! is_object( $license_data ) ) { |
| 588 | - 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.' ); | |
| 589 | 589 | } |
| 590 | 590 | if ( 'check' === $action ) { |
| 591 | 591 | return $license_data; |
| 592 | 592 | } |
| @@ -617,9 +617,9 @@ | ||
| 617 | 617 | } |
| 618 | 618 | update_option( $this->product->get_key() . '_license_data', $license_data ); |
| 619 | 619 | set_transient( $this->product->get_key() . '_license_data', $license_data, 12 * HOUR_IN_SECONDS ); |
| 620 | 620 | if ( 'activate' === $action && 'valid' !== $license_data->license ) { |
| 621 | - return new \WP_Error( 'themeisle-license-invalid', Loader::$labels['licenser']['error_invalid'] ); | |
| 621 | + return new \WP_Error( 'themeisle-license-invalid', 'ERROR: Invalid license provided.' ); | |
| 622 | 622 | } |
| 623 | 623 | |
| 624 | 624 | // Remove the versions transient upon activation so that newer version for rollback can be acquired. |
| 625 | 625 | $versions_cache = $this->product->get_cache_key(); |
| @@ -652,9 +652,9 @@ | ||
| 652 | 652 | if ( ! isset( $_POST[ $this->product->get_key() . '_btn_trigger' ] ) ) { |
| 653 | 653 | return; |
| 654 | 654 | } |
| 655 | 655 | 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 | |
| 656 | + || ! wp_verify_nonce( $_POST[ $this->product->get_key() . 'nonce_field' ], $this->product->get_key() . 'nonce' ) //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 657 | 657 | ) { |
| 658 | 658 | return; |
| 659 | 659 | } |
| 660 | 660 | if ( ! current_user_can( 'manage_options' ) ) { |
| @@ -702,18 +702,20 @@ | ||
| 702 | 702 | if ( false === $api_response || ! isset( $api_response->new_version ) ) { |
| 703 | 703 | return; |
| 704 | 704 | } |
| 705 | 705 | $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'] ); | |
| 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.' ); | |
| 707 | 707 | $update_onclick = ' onclick="if ( confirm(\'' . esc_js( $update_message ) . '\') ) {return true;}return false;"'; |
| 708 | 708 | if ( version_compare( $this->product->get_version(), $api_response->new_version, '<' ) ) { |
| 709 | 709 | echo '<div id="update-nag">'; |
| 710 | 710 | 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. | |
| 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&width=1024&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. | |
| 716 | 718 | ); |
| 717 | 719 | echo '</div>'; |
| 718 | 720 | echo '<div id="' . esc_attr( $this->product->get_slug() ) . '_changelog" style="display:none;">'; |
| 719 | 721 | echo wp_kses_data( wpautop( $api_response->sections['changelog'] ) ); |
| @@ -742,9 +744,8 @@ | ||
| 742 | 744 | return $value; |
| 743 | 745 | } |
| 744 | 746 | |
| 745 | 747 | $value->response[ $this->product->get_slug() ] = $update_data; |
| 746 | - | |
| 747 | 748 | return $value; |
| 748 | 749 | } |
| 749 | 750 | |
| 750 | 751 | /** |
| @@ -982,17 +983,9 @@ | ||
| 982 | 983 | 'pre_set_site_transient_update_plugins_filter', |
| 983 | 984 | ] |
| 984 | 985 | ); |
| 985 | 986 | 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 | - ); | |
| 987 | + add_filter( 'http_request_args', array( $this, 'http_request_args' ), 10, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args | |
| 995 | 988 | if ( ! self::is_valid( $product->get_basefile() ) ) { |
| 996 | 989 | add_filter( |
| 997 | 990 | 'plugin_action_links_' . plugin_basename( $product->get_basefile() ), |
| 998 | 991 | function ( $actions ) { |
| @@ -999,12 +992,12 @@ | ||
| 999 | 992 | if ( $this->get_license_status( true ) !== self::STATUS_ACTIVE_EXPIRED ) { |
| 1000 | 993 | return $actions; |
| 1001 | 994 | } |
| 1002 | 995 | $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>'; | |
| 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>'; | |
| 1004 | 997 | |
| 1005 | 998 | return $new_actions; |
| 1006 | - } | |
| 999 | + } | |
| 1007 | 1000 | ); |
| 1008 | 1001 | } |
| 1009 | 1002 | |
| 1010 | 1003 | return $this; |
| @@ -1014,17 +1007,9 @@ | ||
| 1014 | 1007 | add_action( 'delete_site_transient_update_themes', array( &$this, 'delete_theme_update_transient' ) ); |
| 1015 | 1008 | add_action( 'load-update-core.php', array( &$this, 'delete_theme_update_transient' ) ); |
| 1016 | 1009 | add_action( 'load-themes.php', array( &$this, 'delete_theme_update_transient' ) ); |
| 1017 | 1010 | 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 | - ); | |
| 1011 | + add_filter( 'http_request_args', array( $this, 'disable_wporg_update' ), 5, 2 ); //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args | |
| 1027 | 1012 | |
| 1028 | 1013 | return $this; |
| 1029 | 1014 | |
| 1030 | 1015 | } |
| @@ -1065,12 +1050,10 @@ | ||
| 1065 | 1050 | } |
| 1066 | 1051 | if ( ! isset( $content->key ) ) { |
| 1067 | 1052 | return false; |
| 1068 | 1053 | } |
| 1069 | - | |
| 1070 | 1054 | return $content->key; |
| 1071 | 1055 | } |
| 1072 | - | |
| 1073 | 1056 | /** |
| 1074 | 1057 | * Run license activation on plugin activate. |
| 1075 | 1058 | */ |
| 1076 | 1059 | public function auto_activate() { |
| @@ -1118,9 +1101,9 @@ | ||
| 1118 | 1101 | */ |
| 1119 | 1102 | public function autoactivate_notice() { |
| 1120 | 1103 | ?> |
| 1121 | 1104 | <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> | |
| 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> | |
| 1123 | 1106 | </div> |
| 1124 | 1107 | <?php |
| 1125 | 1108 | } |
| 1126 | 1109 | |