| @@ -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.4 | |
| 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 |
| @@ -18,15 +18,20 @@ | ||
| 18 | 18 | use LearnPress\TemplateHooks\CourseBuilder\Course\BuilderCourseTemplate; |
| 19 | 19 | use LearnPress\TemplateHooks\CourseBuilder\Course\BuilderEditCourseTemplate; |
| 20 | 20 | use LearnPress\Ajax\AI\OpenAiAjax; |
| 21 | 21 | use LearnPress\Ajax\BuilderDashboardAjax; |
| 22 | +use LearnPress\Ajax\CourseToolsAjax; | |
| 22 | 23 | use LearnPress\Ajax\CourseBuilder\CourseBuilderAjax; |
| 23 | 24 | use LearnPress\Ajax\EditCurriculumAjax; |
| 25 | +use LearnPress\Ajax\AddonsAjax; | |
| 26 | +use LearnPress\Services\AddonService; | |
| 24 | 27 | use LearnPress\Ajax\EditQuestionAjax; |
| 25 | 28 | use LearnPress\Ajax\EditQuizAjax; |
| 26 | 29 | use LearnPress\Ajax\Order\ExportOrderCSVAjax; |
| 27 | 30 | use LearnPress\Ajax\LessonAjax; |
| 28 | 31 | use LearnPress\Ajax\LoadContentViaAjax; |
| 32 | +use LearnPress\Ajax\SampleDataAJAX; | |
| 33 | +use LearnPress\Ajax\SetupWizardAjax; | |
| 29 | 34 | use LearnPress\Ajax\AI\AIAssistantAjax; |
| 30 | 35 | use LearnPress\Ajax\MCP\McpApiKeysAjax; |
| 31 | 36 | use LearnPress\Ajax\Webhook\WebhooksAjax; |
| 32 | 37 | use LearnPress\Ajax\CourseBuilder\CBEditCourseAjax; |
| @@ -46,12 +51,15 @@ | ||
| 46 | 51 | use LearnPress\Shortcodes\CourseMaterialShortcode; |
| 47 | 52 | use LearnPress\Shortcodes\Courses\ListCoursesShortcode; |
| 48 | 53 | use LearnPress\Shortcodes\ListInstructorsShortcode; |
| 49 | 54 | use LearnPress\Shortcodes\SingleInstructorShortcode; |
| 55 | +use LearnPress\TemplateHooks\Admin\AdminAddonsPage; | |
| 50 | 56 | use LearnPress\TemplateHooks\Admin\AdminEditQizTemplate; |
| 51 | 57 | use LearnPress\TemplateHooks\Admin\AdminEditQuestionTemplate; |
| 52 | 58 | use LearnPress\TemplateHooks\Admin\AdminListStudentsEnrolled; |
| 53 | 59 | use LearnPress\TemplateHooks\Admin\AdminStatisticsReportTable; |
| 60 | +use LearnPress\TemplateHooks\Admin\Notices\AdminNotesTemplate; | |
| 61 | +use LearnPress\TemplateHooks\Admin\Tools\AdminCourseTools; | |
| 54 | 62 | use LearnPress\Statistics\FilterOptionsProvider; |
| 55 | 63 | use LearnPress\TemplateHooks\Admin\AI\AdminCreateCourseAITemplate; |
| 56 | 64 | use LearnPress\TemplateHooks\Admin\AI\AdminEditCourseCurriculumWithAITemplate; |
| 57 | 65 | use LearnPress\TemplateHooks\Admin\AI\AdminEditWithAITemplate; |
| @@ -177,8 +185,15 @@ | ||
| 177 | 185 | public static $doc_link = 'https://learnpresslms.com/docs/'; |
| 178 | 186 | |
| 179 | 187 | /** |
| 180 | 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. | |
| 181 | 196 | */ |
| 182 | 197 | private function __construct() { |
| 183 | 198 | /*if ( isset( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) { |
| 184 | 199 | return; |
| @@ -186,19 +201,22 @@ | ||
| 186 | 201 | |
| 187 | 202 | try { |
| 188 | 203 | $this->prepare_before_handle(); |
| 189 | 204 | |
| 205 | + register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) ); | |
| 206 | + register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) ); | |
| 207 | + | |
| 190 | 208 | if ( ! LP_Install::instance()->tables_install_done() ) { |
| 191 | 209 | return; |
| 192 | 210 | } |
| 193 | 211 | |
| 194 | - // Must handle in hook init of WordPress, when loaded plugins, theme, user. | |
| 212 | + // init runs after WordPress core, plugins, theme and user are loaded. | |
| 195 | 213 | add_action( 'init', [ $this, 'lp_main_handle' ], - 1000 ); |
| 196 | 214 | |
| 197 | - // hooks . | |
| 215 | + // Register remaining plugin hooks. | |
| 198 | 216 | $this->hooks(); |
| 199 | 217 | } catch ( Throwable $e ) { |
| 200 | - error_log( __METHOD__ . ': ' . $e->getMessage() ); | |
| 218 | + LP_Debug::error_log( $e ); | |
| 201 | 219 | } |
| 202 | 220 | } |
| 203 | 221 | |
| 204 | 222 | /** |
| @@ -394,8 +412,10 @@ | ||
| 394 | 412 | AdminEditCurriculumTemplate::instance(); |
| 395 | 413 | AdminEditSettingTemplate::instance(); |
| 396 | 414 | AdminEditQizTemplate::instance(); |
| 397 | 415 | AdminEditQuestionTemplate::instance(); |
| 416 | + AdminNotesTemplate::instance(); | |
| 417 | + AdminCourseTools::instance(); | |
| 398 | 418 | CourseMaterialTemplate::instance(); |
| 399 | 419 | CourseAIAssistantTemplate::instance(); |
| 400 | 420 | AdminOrderItemsTemplate::instance(); |
| 401 | 421 | AdminOrderListTemplate::instance(); |
| @@ -404,8 +424,9 @@ | ||
| 404 | 424 | AdminEditCourseCurriculumWithAITemplate::instance(); |
| 405 | 425 | AdminListStudentsEnrolled::instance(); |
| 406 | 426 | AdminStatisticsReportTable::instance(); |
| 407 | 427 | FilterOptionsProvider::register_flush_hooks(); |
| 428 | + AdminAddonsPage::instance(); | |
| 408 | 429 | // WP GDPR |
| 409 | 430 | ErasePersonalData::instance(); |
| 410 | 431 | ExportPersonalData::instance(); |
| 411 | 432 | |
| @@ -486,10 +507,8 @@ | ||
| 486 | 507 | |
| 487 | 508 | include_once 'inc/lp-webhooks.php'; // Addon learnpress-2checkout-payment v4.0.1 is using, when update v4.0.2 don't need load it. |
| 488 | 509 | include_once 'inc/class-lp-request-handler.php'; |
| 489 | 510 | |
| 490 | - include_once 'inc/admin/helpers/class-lp-plugins-helper.php'; | |
| 491 | - | |
| 492 | 511 | // Todo: tungnx check those files. |
| 493 | 512 | include_once 'inc/abstracts/abstract-object-query.php'; |
| 494 | 513 | include_once 'inc/class-lp-course-query.php'; |
| 495 | 514 | include_once 'inc/abstracts/abstract-addon.php'; |
| @@ -576,10 +595,8 @@ | ||
| 576 | 595 | } |
| 577 | 596 | |
| 578 | 597 | include_once 'inc/admin/class-lp-admin-ajax.php'; |
| 579 | 598 | |
| 580 | - include_once 'inc/admin/class-lp-admin-notice.php'; | |
| 581 | - | |
| 582 | 599 | // File handle install LP |
| 583 | 600 | include_once 'inc/class-lp-install.php'; |
| 584 | 601 | |
| 585 | 602 | // Meta box helper |
| @@ -757,8 +774,11 @@ | ||
| 757 | 774 | 'init', |
| 758 | 775 | function () { |
| 759 | 776 | LoadContentViaAjax::catch_lp_ajax(); |
| 760 | 777 | LessonAjax::catch_lp_ajax(); |
| 778 | + SampleDataAJAX::catch_lp_ajax(); | |
| 779 | + SetupWizardAjax::catch_lp_ajax(); | |
| 780 | + AddonsAjax::catch_lp_ajax(); | |
| 761 | 781 | EditCurriculumAjax::catch_lp_ajax(); |
| 762 | 782 | EditQuizAjax::catch_lp_ajax(); |
| 763 | 783 | EditQuestionAjax::catch_lp_ajax(); |
| 764 | 784 | SendEmailAjax::catch_lp_ajax(); |
| @@ -769,8 +789,9 @@ | ||
| 769 | 789 | ExportOrderCSVAjax::catch_lp_ajax(); |
| 770 | 790 | McpApiKeysAjax::catch_lp_ajax(); |
| 771 | 791 | WebhooksAjax::catch_lp_ajax(); |
| 772 | 792 | CBEditCourseAjax::catch_lp_ajax(); |
| 793 | + CourseToolsAjax::catch_lp_ajax(); | |
| 773 | 794 | |
| 774 | 795 | do_action( 'learn-press/register-ajax-handlers' ); |
| 775 | 796 | }, |
| 776 | 797 | 11 |
| @@ -778,12 +799,9 @@ | ||
| 778 | 799 | |
| 779 | 800 | // Add links setting|document|addon on plugins page. |
| 780 | 801 | add_filter( 'plugin_action_links_' . LP_PLUGIN_BASENAME, array( $this, 'plugin_links' ) ); |
| 781 | 802 | |
| 782 | - register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) ); | |
| 783 | - register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) ); | |
| 784 | - | |
| 785 | - add_action( | |
| 803 | + /*add_action( | |
| 786 | 804 | 'plugin_loaded', |
| 787 | 805 | function ( $plugin ) { |
| 788 | 806 | // For check wp_remote call normally of WP |
| 789 | 807 | if ( ! empty( LP_Request::get_param( 'lp_test_wp_remote' ) ) ) { |
| @@ -790,9 +808,9 @@ | ||
| 790 | 808 | echo '[TEST_REMOTE]'; |
| 791 | 809 | die; |
| 792 | 810 | } |
| 793 | 811 | } |
| 794 | - ); | |
| 812 | + );*/ | |
| 795 | 813 | |
| 796 | 814 | // Check require version thim-core on Backend. |
| 797 | 815 | if ( is_admin() ) { |
| 798 | 816 | add_action( 'before_thim_core_init', array( $this, 'check_thim_core_version_require' ) ); |
| @@ -821,9 +839,9 @@ | ||
| 821 | 839 | return; |
| 822 | 840 | } |
| 823 | 841 | |
| 824 | 842 | // Call active purchase code for site. |
| 825 | - LP_Manager_Addons::instance()->active_site( $addon_slug, $purchase_code_content ); | |
| 843 | + AddonService::instance()->active_site( $addon_slug, $purchase_code_content ); | |
| 826 | 844 | } |
| 827 | 845 | } |
| 828 | 846 | } |
| 829 | 847 | ); |
| @@ -867,20 +885,34 @@ | ||
| 867 | 885 | * @param array $links Array of action links |
| 868 | 886 | * |
| 869 | 887 | * @return array |
| 870 | 888 | * @since 4.3.11 |
| 871 | - * | |
| 889 | + * @version 1.0.1 | |
| 872 | 890 | */ |
| 873 | 891 | public function plugin_links( array $links ): array { |
| 874 | - $links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=learn-press-settings' ), __( 'Settings', 'learnpress' ) ); | |
| 875 | - $links[] = sprintf( '<a href="%s" target="_blank">%s</a>', LearnPress::$doc_link, __( 'Documentation', 'learnpress' ) ); | |
| 876 | - $links[] = sprintf( '<a href="%s" target="_blank">%s</a>', get_admin_url() . '/admin.php?page=learn-press-addons', __( 'Add-ons', 'learnpress' ) ); | |
| 892 | + $links[] = sprintf( | |
| 893 | + '<a href="%s">%s</a>', | |
| 894 | + esc_url_raw( admin_url( 'admin.php?page=learn-press-settings' ) ), | |
| 895 | + esc_html__( 'Settings', 'learnpress' ) | |
| 896 | + ); | |
| 897 | + $links[] = sprintf( | |
| 898 | + '<a href="%s" target="_blank">%s</a>', | |
| 899 | + esc_url_raw( LearnPress::$doc_link ), | |
| 900 | + esc_html__( 'Documentation', 'learnpress' ) | |
| 901 | + ); | |
| 902 | + $links[] = sprintf( | |
| 903 | + '<a href="%s" target="_blank">%s</a>', | |
| 904 | + esc_url_raw( admin_url( 'admin.php?page=learn-press-addons' ) ), | |
| 905 | + esc_html__( 'Add-ons', 'learnpress' ) | |
| 906 | + ); | |
| 877 | 907 | |
| 878 | 908 | return $links; |
| 879 | 909 | } |
| 880 | 910 | |
| 881 | 911 | /** |
| 882 | - * Trigger this function while activating Learnpress. | |
| 912 | + * Activation hook callback. | |
| 913 | + * | |
| 914 | + * Including creating database tables, default pages, registering CPTs and flushing rewrite rules. | |
| 883 | 915 | * |
| 884 | 916 | * @since 3.0.0 |
| 885 | 917 | * @version 4.1.4.1 |
| 886 | 918 | */ |