| @@ -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.7 | |
| 7 | + * Version: 4.4.9 | |
| 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 |
| @@ -21,8 +21,10 @@ | ||
| 21 | 21 | use LearnPress\Ajax\BuilderDashboardAjax; |
| 22 | 22 | use LearnPress\Ajax\CourseToolsAjax; |
| 23 | 23 | use LearnPress\Ajax\CourseBuilder\CourseBuilderAjax; |
| 24 | 24 | use LearnPress\Ajax\EditCurriculumAjax; |
| 25 | +use LearnPress\Ajax\AddonsAjax; | |
| 26 | +use LearnPress\Services\AddonService; | |
| 25 | 27 | use LearnPress\Ajax\EditQuestionAjax; |
| 26 | 28 | use LearnPress\Ajax\EditQuizAjax; |
| 27 | 29 | use LearnPress\Ajax\Order\ExportOrderCSVAjax; |
| 28 | 30 | use LearnPress\Ajax\LessonAjax; |
| @@ -49,12 +51,14 @@ | ||
| 49 | 51 | use LearnPress\Shortcodes\CourseMaterialShortcode; |
| 50 | 52 | use LearnPress\Shortcodes\Courses\ListCoursesShortcode; |
| 51 | 53 | use LearnPress\Shortcodes\ListInstructorsShortcode; |
| 52 | 54 | use LearnPress\Shortcodes\SingleInstructorShortcode; |
| 55 | +use LearnPress\TemplateHooks\Admin\AdminAddonsPage; | |
| 53 | 56 | use LearnPress\TemplateHooks\Admin\AdminEditQizTemplate; |
| 54 | 57 | use LearnPress\TemplateHooks\Admin\AdminEditQuestionTemplate; |
| 55 | 58 | use LearnPress\TemplateHooks\Admin\AdminListStudentsEnrolled; |
| 56 | 59 | use LearnPress\TemplateHooks\Admin\AdminStatisticsReportTable; |
| 60 | +use LearnPress\TemplateHooks\Admin\Notices\AdminNotesTemplate; | |
| 57 | 61 | use LearnPress\TemplateHooks\Admin\Tools\AdminCourseTools; |
| 58 | 62 | use LearnPress\Statistics\FilterOptionsProvider; |
| 59 | 63 | use LearnPress\TemplateHooks\Admin\AI\AdminCreateCourseAITemplate; |
| 60 | 64 | use LearnPress\TemplateHooks\Admin\AI\AdminEditCourseCurriculumWithAITemplate; |
| @@ -181,8 +185,15 @@ | ||
| 181 | 185 | public static $doc_link = 'https://learnpresslms.com/docs/'; |
| 182 | 186 | |
| 183 | 187 | /** |
| 184 | 188 | * LearnPress constructor. |
| 189 | + * | |
| 190 | + * Runs on every WordPress bootstrap. Order of operations: | |
| 191 | + * 1. prepare_before_handle() - define constants, autoload, include global files and create the LP_Install instance. | |
| 192 | + * 2. Register activation/deactivation hooks unconditionally so on_activate() fires when the plugin is activated. | |
| 193 | + * 3. Stop here if tables are not installed yet; the activation hook will create them. | |
| 194 | + * 4. On normal requests with tables installed, register the init hook to load CPTs, APIs, settings and integrations. | |
| 195 | + * 5. Register remaining plugin hooks. | |
| 185 | 196 | */ |
| 186 | 197 | private function __construct() { |
| 187 | 198 | /*if ( isset( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) { |
| 188 | 199 | return; |
| @@ -190,19 +201,22 @@ | ||
| 190 | 201 | |
| 191 | 202 | try { |
| 192 | 203 | $this->prepare_before_handle(); |
| 193 | 204 | |
| 205 | + register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) ); | |
| 206 | + register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) ); | |
| 207 | + | |
| 194 | 208 | if ( ! LP_Install::instance()->tables_install_done() ) { |
| 195 | 209 | return; |
| 196 | 210 | } |
| 197 | 211 | |
| 198 | - // Must handle in hook init of WordPress, when loaded plugins, theme, user. | |
| 212 | + // init runs after WordPress core, plugins, theme and user are loaded. | |
| 199 | 213 | add_action( 'init', [ $this, 'lp_main_handle' ], - 1000 ); |
| 200 | 214 | |
| 201 | - // hooks . | |
| 215 | + // Register remaining plugin hooks. | |
| 202 | 216 | $this->hooks(); |
| 203 | 217 | } catch ( Throwable $e ) { |
| 204 | - error_log( __METHOD__ . ': ' . $e->getMessage() ); | |
| 218 | + LP_Debug::error_log( $e ); | |
| 205 | 219 | } |
| 206 | 220 | } |
| 207 | 221 | |
| 208 | 222 | /** |
| @@ -398,8 +412,9 @@ | ||
| 398 | 412 | AdminEditCurriculumTemplate::instance(); |
| 399 | 413 | AdminEditSettingTemplate::instance(); |
| 400 | 414 | AdminEditQizTemplate::instance(); |
| 401 | 415 | AdminEditQuestionTemplate::instance(); |
| 416 | + AdminNotesTemplate::instance(); | |
| 402 | 417 | AdminCourseTools::instance(); |
| 403 | 418 | CourseMaterialTemplate::instance(); |
| 404 | 419 | CourseAIAssistantTemplate::instance(); |
| 405 | 420 | AdminOrderItemsTemplate::instance(); |
| @@ -409,8 +424,9 @@ | ||
| 409 | 424 | AdminEditCourseCurriculumWithAITemplate::instance(); |
| 410 | 425 | AdminListStudentsEnrolled::instance(); |
| 411 | 426 | AdminStatisticsReportTable::instance(); |
| 412 | 427 | FilterOptionsProvider::register_flush_hooks(); |
| 428 | + AdminAddonsPage::instance(); | |
| 413 | 429 | // WP GDPR |
| 414 | 430 | ErasePersonalData::instance(); |
| 415 | 431 | ExportPersonalData::instance(); |
| 416 | 432 | |
| @@ -579,10 +595,8 @@ | ||
| 579 | 595 | } |
| 580 | 596 | |
| 581 | 597 | include_once 'inc/admin/class-lp-admin-ajax.php'; |
| 582 | 598 | |
| 583 | - include_once 'inc/admin/class-lp-admin-notice.php'; | |
| 584 | - | |
| 585 | 599 | // File handle install LP |
| 586 | 600 | include_once 'inc/class-lp-install.php'; |
| 587 | 601 | |
| 588 | 602 | // Meta box helper |
| @@ -762,8 +776,9 @@ | ||
| 762 | 776 | LoadContentViaAjax::catch_lp_ajax(); |
| 763 | 777 | LessonAjax::catch_lp_ajax(); |
| 764 | 778 | SampleDataAJAX::catch_lp_ajax(); |
| 765 | 779 | SetupWizardAjax::catch_lp_ajax(); |
| 780 | + AddonsAjax::catch_lp_ajax(); | |
| 766 | 781 | EditCurriculumAjax::catch_lp_ajax(); |
| 767 | 782 | EditQuizAjax::catch_lp_ajax(); |
| 768 | 783 | EditQuestionAjax::catch_lp_ajax(); |
| 769 | 784 | SendEmailAjax::catch_lp_ajax(); |
| @@ -784,12 +799,9 @@ | ||
| 784 | 799 | |
| 785 | 800 | // Add links setting|document|addon on plugins page. |
| 786 | 801 | add_filter( 'plugin_action_links_' . LP_PLUGIN_BASENAME, array( $this, 'plugin_links' ) ); |
| 787 | 802 | |
| 788 | - register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) ); | |
| 789 | - register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) ); | |
| 790 | - | |
| 791 | - add_action( | |
| 803 | + /*add_action( | |
| 792 | 804 | 'plugin_loaded', |
| 793 | 805 | function ( $plugin ) { |
| 794 | 806 | // For check wp_remote call normally of WP |
| 795 | 807 | if ( ! empty( LP_Request::get_param( 'lp_test_wp_remote' ) ) ) { |
| @@ -796,9 +808,9 @@ | ||
| 796 | 808 | echo '[TEST_REMOTE]'; |
| 797 | 809 | die; |
| 798 | 810 | } |
| 799 | 811 | } |
| 800 | - ); | |
| 812 | + );*/ | |
| 801 | 813 | |
| 802 | 814 | // Check require version thim-core on Backend. |
| 803 | 815 | if ( is_admin() ) { |
| 804 | 816 | add_action( 'before_thim_core_init', array( $this, 'check_thim_core_version_require' ) ); |
| @@ -827,9 +839,9 @@ | ||
| 827 | 839 | return; |
| 828 | 840 | } |
| 829 | 841 | |
| 830 | 842 | // Call active purchase code for site. |
| 831 | - LP_Manager_Addons::instance()->active_site( $addon_slug, $purchase_code_content ); | |
| 843 | + AddonService::instance()->active_site( $addon_slug, $purchase_code_content ); | |
| 832 | 844 | } |
| 833 | 845 | } |
| 834 | 846 | } |
| 835 | 847 | ); |
| @@ -896,9 +908,11 @@ | ||
| 896 | 908 | return $links; |
| 897 | 909 | } |
| 898 | 910 | |
| 899 | 911 | /** |
| 900 | - * Trigger this function while activating Learnpress. | |
| 912 | + * Activation hook callback. | |
| 913 | + * | |
| 914 | + * Including creating database tables, default pages, registering CPTs and flushing rewrite rules. | |
| 901 | 915 | * |
| 902 | 916 | * @since 3.0.0 |
| 903 | 917 | * @version 4.1.4.1 |
| 904 | 918 | */ |