PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 All 140 releases
← All changes | learnpress.php +55 -19 4.4.2 → 4.4.9 View file →
@@ -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.2
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,11 +51,16 @@
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;
59 +use LearnPress\TemplateHooks\Admin\AdminStatisticsReportTable;
60 +use LearnPress\TemplateHooks\Admin\Notices\AdminNotesTemplate;
61 +use LearnPress\TemplateHooks\Admin\Tools\AdminCourseTools;
62 +use LearnPress\Statistics\FilterOptionsProvider;
53 63 use LearnPress\TemplateHooks\Admin\AI\AdminCreateCourseAITemplate;
54 64 use LearnPress\TemplateHooks\Admin\AI\AdminEditCourseCurriculumWithAITemplate;
55 65 use LearnPress\TemplateHooks\Admin\AI\AdminEditWithAITemplate;
56 66 use LearnPress\TemplateHooks\Course\AdminEditCurriculumTemplate;
@@ -175,8 +185,15 @@
175 185 public static $doc_link = 'https://learnpresslms.com/docs/';
176 186
177 187 /**
178 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.
179 196 */
180 197 private function __construct() {
181 198 /*if ( isset( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) {
182 199 return;
@@ -184,19 +201,22 @@
184 201
185 202 try {
186 203 $this->prepare_before_handle();
187 204
205 + register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) );
206 + register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) );
207 +
188 208 if ( ! LP_Install::instance()->tables_install_done() ) {
189 209 return;
190 210 }
191 211
192 - // Must handle in hook init of WordPress, when loaded plugins, theme, user.
212 + // init runs after WordPress core, plugins, theme and user are loaded.
193 213 add_action( 'init', [ $this, 'lp_main_handle' ], - 1000 );
194 214
195 - // hooks .
215 + // Register remaining plugin hooks.
196 216 $this->hooks();
197 217 } catch ( Throwable $e ) {
198 - error_log( __METHOD__ . ': ' . $e->getMessage() );
218 + LP_Debug::error_log( $e );
199 219 }
200 220 }
201 221
202 222 /**
@@ -392,8 +412,10 @@
392 412 AdminEditCurriculumTemplate::instance();
393 413 AdminEditSettingTemplate::instance();
394 414 AdminEditQizTemplate::instance();
395 415 AdminEditQuestionTemplate::instance();
416 + AdminNotesTemplate::instance();
417 + AdminCourseTools::instance();
396 418 CourseMaterialTemplate::instance();
397 419 CourseAIAssistantTemplate::instance();
398 420 AdminOrderItemsTemplate::instance();
399 421 AdminOrderListTemplate::instance();
@@ -400,8 +422,11 @@
400 422 AdminCreateCourseAITemplate::instance();
401 423 AdminEditWithAITemplate::instance();
402 424 AdminEditCourseCurriculumWithAITemplate::instance();
403 425 AdminListStudentsEnrolled::instance();
426 + AdminStatisticsReportTable::instance();
427 + FilterOptionsProvider::register_flush_hooks();
428 + AdminAddonsPage::instance();
404 429 // WP GDPR
405 430 ErasePersonalData::instance();
406 431 ExportPersonalData::instance();
407 432
@@ -482,10 +507,8 @@
482 507
483 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.
484 509 include_once 'inc/class-lp-request-handler.php';
485 510
486 - include_once 'inc/admin/helpers/class-lp-plugins-helper.php';
487 -
488 511 // Todo: tungnx check those files.
489 512 include_once 'inc/abstracts/abstract-object-query.php';
490 513 include_once 'inc/class-lp-course-query.php';
491 514 include_once 'inc/abstracts/abstract-addon.php';
@@ -572,10 +595,8 @@
572 595 }
573 596
574 597 include_once 'inc/admin/class-lp-admin-ajax.php';
575 598
576 - include_once 'inc/admin/class-lp-admin-notice.php';
577 -
578 599 // File handle install LP
579 600 include_once 'inc/class-lp-install.php';
580 601
581 602 // Meta box helper
@@ -753,8 +774,11 @@
753 774 'init',
754 775 function () {
755 776 LoadContentViaAjax::catch_lp_ajax();
756 777 LessonAjax::catch_lp_ajax();
778 + SampleDataAJAX::catch_lp_ajax();
779 + SetupWizardAjax::catch_lp_ajax();
780 + AddonsAjax::catch_lp_ajax();
757 781 EditCurriculumAjax::catch_lp_ajax();
758 782 EditQuizAjax::catch_lp_ajax();
759 783 EditQuestionAjax::catch_lp_ajax();
760 784 SendEmailAjax::catch_lp_ajax();
@@ -765,8 +789,9 @@
765 789 ExportOrderCSVAjax::catch_lp_ajax();
766 790 McpApiKeysAjax::catch_lp_ajax();
767 791 WebhooksAjax::catch_lp_ajax();
768 792 CBEditCourseAjax::catch_lp_ajax();
793 + CourseToolsAjax::catch_lp_ajax();
769 794
770 795 do_action( 'learn-press/register-ajax-handlers' );
771 796 },
772 797 11
@@ -774,12 +799,9 @@
774 799
775 800 // Add links setting|document|addon on plugins page.
776 801 add_filter( 'plugin_action_links_' . LP_PLUGIN_BASENAME, array( $this, 'plugin_links' ) );
777 802
778 - register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) );
779 - register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) );
780 -
781 - add_action(
803 + /*add_action(
782 804 'plugin_loaded',
783 805 function ( $plugin ) {
784 806 // For check wp_remote call normally of WP
785 807 if ( ! empty( LP_Request::get_param( 'lp_test_wp_remote' ) ) ) {
@@ -786,9 +808,9 @@
786 808 echo '[TEST_REMOTE]';
787 809 die;
788 810 }
789 811 }
790 - );
812 + );*/
791 813
792 814 // Check require version thim-core on Backend.
793 815 if ( is_admin() ) {
794 816 add_action( 'before_thim_core_init', array( $this, 'check_thim_core_version_require' ) );
@@ -817,9 +839,9 @@
817 839 return;
818 840 }
819 841
820 842 // Call active purchase code for site.
821 - LP_Manager_Addons::instance()->active_site( $addon_slug, $purchase_code_content );
843 + AddonService::instance()->active_site( $addon_slug, $purchase_code_content );
822 844 }
823 845 }
824 846 }
825 847 );
@@ -863,20 +885,34 @@
863 885 * @param array $links Array of action links
864 886 *
865 887 * @return array
866 888 * @since 4.3.11
867 - *
889 + * @version 1.0.1
868 890 */
869 891 public function plugin_links( array $links ): array {
870 - $links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=learn-press-settings' ), __( 'Settings', 'learnpress' ) );
871 - $links[] = sprintf( '<a href="%s" target="_blank">%s</a>', LearnPress::$doc_link, __( 'Documentation', 'learnpress' ) );
872 - $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 + );
873 907
874 908 return $links;
875 909 }
876 910
877 911 /**
878 - * Trigger this function while activating Learnpress.
912 + * Activation hook callback.
913 + *
914 + * Including creating database tables, default pages, registering CPTs and flushing rewrite rules.
879 915 *
880 916 * @since 3.0.0
881 917 * @version 4.1.4.1
882 918 */