| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | * Plugin Name: LearnPress |
| 4 | 4 | * Plugin URI: https://thimpress.com/learnpress |
| 5 | 5 | * Description: LearnPress is a WordPress complete solution for creating a Learning Management System (LMS). It can help you to create courses, lessons and quizzes. |
| 6 | 6 | * Author: ThimPress |
| 7 | - * Version: 4.4.9 | |
| 7 | + * Version: 4.4.9.1 | |
| 8 | 8 | * Author URI: http://thimpress.com |
| 9 | 9 | * Requires at least: 6.0 |
| 10 | 10 | * Requires PHP: 7.4 |
| 11 | 11 | * Text Domain: learnpress |
| @@ -815,33 +815,40 @@ | ||
| 815 | 815 | if ( is_admin() ) { |
| 816 | 816 | add_action( 'before_thim_core_init', array( $this, 'check_thim_core_version_require' ) ); |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - // Save key purchase addon when install via file download from Thimpress. | |
| 819 | + // Check and save key purchase addon when install via file download from Thimpress. | |
| 820 | 820 | add_action( |
| 821 | 821 | 'upgrader_process_complete', |
| 822 | 822 | function ( $plugin_upgrader ) { |
| 823 | - if ( ! empty( $plugin_upgrader->result ) ) { | |
| 824 | - $res = $plugin_upgrader->result; | |
| 825 | - $path_source = $res['destination'] ?? ''; | |
| 826 | - if ( empty( $path_source ) ) { | |
| 827 | - return; | |
| 828 | - } | |
| 829 | - | |
| 830 | - $key_purchase_path = realpath( $path_source . '/purchase-code.txt' ); | |
| 831 | - if ( file_exists( $key_purchase_path ) ) { | |
| 832 | - $purchase_code_content = file_get_contents( $key_purchase_path ); | |
| 833 | - if ( empty( $purchase_code_content ) ) { | |
| 823 | + if ( ! empty( | |
| 824 | + $plugin_upgrader->result | |
| 825 | + || ! isset( $_POST['lp-load-ajax'] ) | |
| 826 | + ) ) { | |
| 827 | + try { | |
| 828 | + $res = $plugin_upgrader->result; | |
| 829 | + $path_source = $res['destination'] ?? ''; | |
| 830 | + if ( empty( $path_source ) ) { | |
| 834 | 831 | return; |
| 835 | 832 | } |
| 836 | 833 | |
| 837 | - $addon_slug = $res['destination_name'] ?? ''; | |
| 838 | - if ( empty( $addon_slug ) ) { | |
| 839 | - return; | |
| 834 | + $key_purchase_path = realpath( $path_source . '/purchase-code.txt' ); | |
| 835 | + if ( file_exists( $key_purchase_path ) ) { | |
| 836 | + $purchase_code_content = file_get_contents( $key_purchase_path ); | |
| 837 | + if ( empty( $purchase_code_content ) ) { | |
| 838 | + return; | |
| 839 | + } | |
| 840 | + | |
| 841 | + $addon_slug = $res['destination_name'] ?? ''; | |
| 842 | + if ( empty( $addon_slug ) ) { | |
| 843 | + return; | |
| 844 | + } | |
| 845 | + | |
| 846 | + // Call active purchase code for site. | |
| 847 | + AddonService::instance()->active_site( $addon_slug, $purchase_code_content ); | |
| 840 | 848 | } |
| 841 | - | |
| 842 | - // Call active purchase code for site. | |
| 843 | - AddonService::instance()->active_site( $addon_slug, $purchase_code_content ); | |
| 849 | + } catch ( Throwable $e ) { | |
| 850 | + LP_Debug::error_log( $e ); | |
| 844 | 851 | } |
| 845 | 852 | } |
| 846 | 853 | } |
| 847 | 854 | ); |