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