| @@ -1,15 +1,14 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: LearnPress |
| 4 | - * Plugin URI: http://thimpress.com/learnpress | |
| 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.1.7 | |
| 7 | + * Version: 4.4.7 | |
| 8 | 8 | * Author URI: http://thimpress.com |
| 9 | - * Requires at least: 5.6 | |
| 10 | - * Tested up to: 6.0 | |
| 11 | - * Requires PHP: 7.0 | |
| 9 | + * Requires at least: 6.0 | |
| 10 | + * Requires PHP: 7.4 | |
| 12 | 11 | * Text Domain: learnpress |
| 13 | 12 | * Domain Path: /languages/ |
| 14 | 13 | * |
| 15 | 14 | * @package LearnPress |
| @@ -14,18 +13,96 @@ | ||
| 14 | 13 | * |
| 15 | 14 | * @package LearnPress |
| 16 | 15 | */ |
| 17 | 16 | |
| 18 | -/** | |
| 19 | - * Prevent loading this file directly | |
| 20 | - */ | |
| 17 | +use LearnPress\TemplateHooks\CourseBuilder\Course\BuilderListCoursesTemplate; | |
| 18 | +use LearnPress\TemplateHooks\CourseBuilder\Course\BuilderCourseTemplate; | |
| 19 | +use LearnPress\TemplateHooks\CourseBuilder\Course\BuilderEditCourseTemplate; | |
| 20 | +use LearnPress\Ajax\AI\OpenAiAjax; | |
| 21 | +use LearnPress\Ajax\BuilderDashboardAjax; | |
| 22 | +use LearnPress\Ajax\CourseToolsAjax; | |
| 23 | +use LearnPress\Ajax\CourseBuilder\CourseBuilderAjax; | |
| 24 | +use LearnPress\Ajax\EditCurriculumAjax; | |
| 25 | +use LearnPress\Ajax\EditQuestionAjax; | |
| 26 | +use LearnPress\Ajax\EditQuizAjax; | |
| 27 | +use LearnPress\Ajax\Order\ExportOrderCSVAjax; | |
| 28 | +use LearnPress\Ajax\LessonAjax; | |
| 29 | +use LearnPress\Ajax\LoadContentViaAjax; | |
| 30 | +use LearnPress\Ajax\SampleDataAJAX; | |
| 31 | +use LearnPress\Ajax\SetupWizardAjax; | |
| 32 | +use LearnPress\Ajax\AI\AIAssistantAjax; | |
| 33 | +use LearnPress\Ajax\MCP\McpApiKeysAjax; | |
| 34 | +use LearnPress\Ajax\Webhook\WebhooksAjax; | |
| 35 | +use LearnPress\Ajax\CourseBuilder\CBEditCourseAjax; | |
| 36 | +use LearnPress\Ajax\SendEmailAjax; | |
| 37 | +use LearnPress\Background\LPBackgroundTrigger; | |
| 38 | +use LearnPress\ExternalPlugin\Elementor\LPElementor; | |
| 39 | +use LearnPress\ExternalPlugin\RankMath\LPRankMath; | |
| 40 | +use LearnPress\ExternalPlugin\YoastSeo\LPYoastSeo; | |
| 41 | +use LearnPress\Gutenberg\GutenbergHandleMain; | |
| 42 | +use LearnPress\Ajax\Order\RefundOrderAjax; | |
| 43 | +use LearnPress\MCP\Abilities; | |
| 44 | +use LearnPress\MCP\Auth\ApiKeyAuthenticator; | |
| 45 | +use LearnPress\Models\CourseModel; | |
| 46 | +use LearnPress\Models\UserModel; | |
| 47 | +use LearnPress\Shortcodes\Course\FilterCourseShortcode; | |
| 48 | +use LearnPress\Shortcodes\CourseButtonShortcode; | |
| 49 | +use LearnPress\Shortcodes\CourseMaterialShortcode; | |
| 50 | +use LearnPress\Shortcodes\Courses\ListCoursesShortcode; | |
| 51 | +use LearnPress\Shortcodes\ListInstructorsShortcode; | |
| 52 | +use LearnPress\Shortcodes\SingleInstructorShortcode; | |
| 53 | +use LearnPress\TemplateHooks\Admin\AdminEditQizTemplate; | |
| 54 | +use LearnPress\TemplateHooks\Admin\AdminEditQuestionTemplate; | |
| 55 | +use LearnPress\TemplateHooks\Admin\AdminListStudentsEnrolled; | |
| 56 | +use LearnPress\TemplateHooks\Admin\AdminStatisticsReportTable; | |
| 57 | +use LearnPress\TemplateHooks\Admin\Tools\AdminCourseTools; | |
| 58 | +use LearnPress\Statistics\FilterOptionsProvider; | |
| 59 | +use LearnPress\TemplateHooks\Admin\AI\AdminCreateCourseAITemplate; | |
| 60 | +use LearnPress\TemplateHooks\Admin\AI\AdminEditCourseCurriculumWithAITemplate; | |
| 61 | +use LearnPress\TemplateHooks\Admin\AI\AdminEditWithAITemplate; | |
| 62 | +use LearnPress\TemplateHooks\Course\AdminEditCurriculumTemplate; | |
| 63 | +use LearnPress\TemplateHooks\Course\AdminEditSettingTemplate; | |
| 64 | +use LearnPress\TemplateHooks\Course\CourseMaterialTemplate; | |
| 65 | +use LearnPress\TemplateHooks\Course\FilterCourseTemplate; | |
| 66 | +use LearnPress\TemplateHooks\Course\ListCoursesRelatedTemplate; | |
| 67 | +use LearnPress\TemplateHooks\Course\ListCoursesTemplate; | |
| 68 | +use LearnPress\TemplateHooks\Course\SingleCourseClassicTemplate; | |
| 69 | +use LearnPress\TemplateHooks\Course\SingleCourseModernLayout; | |
| 70 | +use LearnPress\TemplateHooks\Course\SingleCourseOfflineTemplate; | |
| 71 | +use LearnPress\TemplateHooks\Course\SingleCourseTemplate; | |
| 72 | +use LearnPress\TemplateHooks\CourseBuilder\BuilderPopupTemplate; | |
| 73 | +use LearnPress\TemplateHooks\CourseBuilder\CourseBuilderTemplate; | |
| 74 | +use LearnPress\TemplateHooks\CourseBuilder\Dashboard\BuilderDashboardTemplate; | |
| 75 | +use LearnPress\TemplateHooks\CourseBuilder\Lesson\BuilderEditLessonTemplate; | |
| 76 | +use LearnPress\TemplateHooks\CourseBuilder\Lesson\BuilderLessonTemplate; | |
| 77 | +use LearnPress\TemplateHooks\CourseBuilder\Lesson\BuilderListLessonsTemplate; | |
| 78 | +use LearnPress\TemplateHooks\CourseBuilder\Question\BuilderEditQuestionTemplate; | |
| 79 | +use LearnPress\TemplateHooks\CourseBuilder\Question\BuilderListQuestionsTemplate; | |
| 80 | +use LearnPress\TemplateHooks\CourseBuilder\Question\BuilderQuestionTemplate; | |
| 81 | +use LearnPress\TemplateHooks\CourseBuilder\Quiz\BuilderEditQuizTemplate; | |
| 82 | +use LearnPress\TemplateHooks\CourseBuilder\Quiz\BuilderListQuizzesTemplate; | |
| 83 | +use LearnPress\TemplateHooks\CourseBuilder\Quiz\BuilderQuizTemplate; | |
| 84 | +use LearnPress\TemplateHooks\CourseBuilder\Settings\BuilderSettingsTemplate; | |
| 85 | +use LearnPress\TemplateHooks\Instructor\ListInstructorsTemplate; | |
| 86 | +use LearnPress\TemplateHooks\Instructor\SingleInstructorTemplate; | |
| 87 | +use LearnPress\TemplateHooks\Order\AdminOrderItemsTemplate; | |
| 88 | +use LearnPress\TemplateHooks\Order\AdminOrderListTemplate; | |
| 89 | +use LearnPress\TemplateHooks\Profile\ProfileCoursesTemplate; | |
| 90 | +use LearnPress\TemplateHooks\Profile\ProfileGeneralInfoTemplate; | |
| 91 | +use LearnPress\TemplateHooks\Profile\ProfileInstructorStatisticsTemplate; | |
| 92 | +use LearnPress\TemplateHooks\Profile\ProfileOrdersTemplate; | |
| 93 | +use LearnPress\TemplateHooks\Profile\ProfileOrderTemplate; | |
| 94 | +use LearnPress\TemplateHooks\Profile\ProfileQuizzesTemplate; | |
| 95 | +use LearnPress\TemplateHooks\Profile\ProfileStudentEnrolledTemplate; | |
| 96 | +use LearnPress\TemplateHooks\Profile\ProfileStudentStatisticsTemplate; | |
| 97 | +use LearnPress\TemplateHooks\Course\CourseAIAssistantTemplate; | |
| 98 | +use LearnPress\Widgets\LPRegisterWidget; | |
| 99 | +use LearnPress\WPGDPR\ErasePersonalData; | |
| 100 | +use LearnPress\WPGDPR\ExportPersonalData; | |
| 101 | +use LearnPress\Webhook\WebhookDispatcher; | |
| 102 | + | |
| 21 | 103 | defined( 'ABSPATH' ) || exit(); |
| 22 | 104 | |
| 23 | -if ( ! defined( 'LP_PLUGIN_FILE' ) ) { | |
| 24 | - define( 'LP_PLUGIN_FILE', __FILE__ ); | |
| 25 | - require_once 'inc/lp-constants.php'; | |
| 26 | -} | |
| 27 | - | |
| 28 | 105 | if ( ! class_exists( 'LearnPress' ) ) { |
| 29 | 106 | /** |
| 30 | 107 | * Class LearnPress |
| 31 | 108 | * |
| @@ -36,15 +113,15 @@ | ||
| 36 | 113 | * Current version of the plugin |
| 37 | 114 | * |
| 38 | 115 | * @var string |
| 39 | 116 | */ |
| 40 | - public $version = LEARNPRESS_VERSION; | |
| 117 | + public $version = ''; | |
| 41 | 118 | /** |
| 42 | 119 | * Version database require, use for this LP source |
| 43 | 120 | * |
| 44 | 121 | * @var int |
| 45 | 122 | */ |
| 46 | - public $db_version = 4; | |
| 123 | + public $db_version = 5; | |
| 47 | 124 | |
| 48 | 125 | /** |
| 49 | 126 | * The single instance of the class |
| 50 | 127 | * |
| @@ -59,13 +136,8 @@ | ||
| 59 | 136 | */ |
| 60 | 137 | public $session = null; |
| 61 | 138 | |
| 62 | 139 | /** |
| 63 | - * @var LP_Profile | |
| 64 | - */ | |
| 65 | - public $profile = null; | |
| 66 | - | |
| 67 | - /** | |
| 68 | 140 | * @var LP_Cart object |
| 69 | 141 | */ |
| 70 | 142 | public $cart = false; |
| 71 | 143 | |
| @@ -74,32 +146,15 @@ | ||
| 74 | 146 | */ |
| 75 | 147 | public $settings = null; |
| 76 | 148 | |
| 77 | 149 | /** |
| 78 | - * @var null | |
| 79 | - */ | |
| 80 | - public $schedule = null; | |
| 81 | - | |
| 82 | - /** | |
| 83 | 150 | * @var array |
| 84 | 151 | */ |
| 85 | 152 | public $query_vars = array(); |
| 86 | 153 | |
| 87 | 154 | /** |
| 88 | - * Table prefixes | |
| 89 | - * | |
| 90 | 155 | * @var array |
| 91 | 156 | */ |
| 92 | - protected $_table_prefixes = array(); | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * @var null | |
| 96 | - */ | |
| 97 | - public $query = null; | |
| 98 | - | |
| 99 | - /** | |
| 100 | - * @var array | |
| 101 | - */ | |
| 102 | 157 | public $global = array(); |
| 103 | 158 | |
| 104 | 159 | /** |
| 105 | 160 | * @var LP_Template |
| @@ -120,37 +175,72 @@ | ||
| 120 | 175 | * @var string |
| 121 | 176 | */ |
| 122 | 177 | public $thim_core_version_require = '2.0.0'; |
| 123 | 178 | |
| 124 | - /** | |
| 125 | - * | |
| 126 | - */ | |
| 127 | - public $theme_support = null; | |
| 179 | + public static $time_limit_default_of_sever = 0; | |
| 128 | 180 | |
| 129 | - public $gateways = null; | |
| 181 | + public static $doc_link = 'https://learnpresslms.com/docs/'; | |
| 130 | 182 | |
| 131 | 183 | /** |
| 132 | 184 | * LearnPress constructor. |
| 133 | 185 | */ |
| 134 | - protected function __construct() { | |
| 135 | - if ( self::$_instance ) { | |
| 186 | + private function __construct() { | |
| 187 | + /*if ( isset( $_POST['action'] ) && 'heartbeat' === $_POST['action'] ) { | |
| 136 | 188 | return; |
| 189 | + }*/ | |
| 190 | + | |
| 191 | + try { | |
| 192 | + $this->prepare_before_handle(); | |
| 193 | + | |
| 194 | + if ( ! LP_Install::instance()->tables_install_done() ) { | |
| 195 | + return; | |
| 196 | + } | |
| 197 | + | |
| 198 | + // Must handle in hook init of WordPress, when loaded plugins, theme, user. | |
| 199 | + add_action( 'init', [ $this, 'lp_main_handle' ], - 1000 ); | |
| 200 | + | |
| 201 | + // hooks . | |
| 202 | + $this->hooks(); | |
| 203 | + } catch ( Throwable $e ) { | |
| 204 | + error_log( __METHOD__ . ': ' . $e->getMessage() ); | |
| 137 | 205 | } |
| 138 | - self::$_instance = $this; | |
| 206 | + } | |
| 139 | 207 | |
| 140 | - update_option( 'learnpress_version', $this->version ); | |
| 141 | - | |
| 208 | + /** | |
| 209 | + * Prepare before handle. | |
| 210 | + * 1.Load constants and includes files. | |
| 211 | + * 2.Get default time limit of server. | |
| 212 | + * 3.Update version of LP undefined. | |
| 213 | + * | |
| 214 | + * @return void | |
| 215 | + * @since 4.2.7.6 | |
| 216 | + * @version 1.0.0 | |
| 217 | + */ | |
| 218 | + public function prepare_before_handle() { | |
| 142 | 219 | // Define constant . |
| 143 | 220 | $this->plugin_defines(); |
| 144 | 221 | |
| 222 | + self::$time_limit_default_of_sever = ini_get( 'max_execution_time' ); | |
| 223 | + | |
| 224 | + // Update for case compare version of LP if LEARNPRESS_VERSION undefined | |
| 225 | + $this->version = LEARNPRESS_VERSION; | |
| 226 | + if ( is_admin() ) { | |
| 227 | + $learn_press_version = get_option( 'learnpress_version', '' ); | |
| 228 | + if ( $learn_press_version !== $this->version ) { | |
| 229 | + if ( empty( $learn_press_version ) ) { // Case user install new | |
| 230 | + // Set using modern layout for new installation. | |
| 231 | + update_option( 'learn_press_layout_single_course', 'modern' ); | |
| 232 | + } | |
| 233 | + | |
| 234 | + update_option( 'learnpress_version', $this->version ); | |
| 235 | + } | |
| 236 | + } | |
| 237 | + | |
| 145 | 238 | // define table prefixes . |
| 146 | 239 | $this->define_tables(); |
| 147 | 240 | |
| 148 | 241 | // Include files . |
| 149 | 242 | $this->includes(); |
| 150 | - | |
| 151 | - // hooks . | |
| 152 | - $this->init_hooks(); | |
| 153 | 243 | } |
| 154 | 244 | |
| 155 | 245 | /** |
| 156 | 246 | * Define constant. |
| @@ -155,9 +245,12 @@ | ||
| 155 | 245 | /** |
| 156 | 246 | * Define constant. |
| 157 | 247 | */ |
| 158 | 248 | protected function plugin_defines() { |
| 159 | - | |
| 249 | + if ( ! defined( 'LP_PLUGIN_FILE' ) ) { | |
| 250 | + define( 'LP_PLUGIN_FILE', __FILE__ ); | |
| 251 | + include_once 'inc/lp-constants.php'; | |
| 252 | + } | |
| 160 | 253 | } |
| 161 | 254 | |
| 162 | 255 | /** |
| 163 | 256 | * Defines database table names. |
| @@ -176,15 +269,12 @@ | ||
| 176 | 269 | 'order_itemmeta', |
| 177 | 270 | 'quiz_questions', |
| 178 | 271 | 'question_answers', |
| 179 | 272 | 'question_answermeta', |
| 180 | - 'review_logs', | |
| 181 | 273 | ); |
| 182 | 274 | |
| 183 | 275 | foreach ( $tables as $short_name ) { |
| 184 | - $table_name = $wpdb->prefix . LP_TABLE_PREFIX . $short_name; | |
| 185 | - $this->_table_prefixes[ 'tbl_' . $short_name ] = $table_name; | |
| 186 | - | |
| 276 | + $table_name = $wpdb->prefix . LP_TABLE_PREFIX . $short_name; | |
| 187 | 277 | $backward_key = 'learnpress_' . $short_name; |
| 188 | 278 | $wpdb->{$backward_key} = $table_name; |
| 189 | 279 | } |
| 190 | 280 | } |
| @@ -192,8 +282,10 @@ | ||
| 192 | 282 | /** |
| 193 | 283 | * Includes needed files. |
| 194 | 284 | */ |
| 195 | 285 | public function includes() { |
| 286 | + include_once LP_PLUGIN_PATH . 'vendor/autoload.php'; | |
| 287 | + | |
| 196 | 288 | // Include required files load anywhere, both frontend and backend. |
| 197 | 289 | $this->include_files_global(); |
| 198 | 290 | |
| 199 | 291 | // include files when LP ready run - after setup success . |
| @@ -215,194 +307,268 @@ | ||
| 215 | 307 | * |
| 216 | 308 | * @return void |
| 217 | 309 | */ |
| 218 | 310 | private function include_files_global() { |
| 219 | - require_once 'inc/class-lp-multi-language.php'; | |
| 220 | 311 | |
| 221 | 312 | // Filter query . |
| 222 | - require_once 'inc/filters/class-lp-filter.php'; | |
| 223 | - require_once 'inc/filters/class-lp-post-type-filter.php'; | |
| 224 | - require_once 'inc/filters/class-lp-course-filter.php'; | |
| 225 | - require_once 'inc/filters/class-lp-order-filter.php'; | |
| 226 | - require_once 'inc/filters/class-lp-section-filter.php'; | |
| 227 | - require_once 'inc/filters/class-lp-section-items-filter.php'; | |
| 228 | - require_once 'inc/filters/class-lp-question-filter.php'; | |
| 229 | - require_once 'inc/filters/class-lp-user-items-filter.php'; | |
| 230 | - require_once 'inc/filters/class-lp-quiz-questions-filter.php'; | |
| 231 | - require_once 'inc/filters/class-lp-question-answers-filter.php'; | |
| 232 | - require_once 'inc/filters/class-lp-question-answermeta-filter.php'; | |
| 313 | + include_once 'inc/Filters/class-lp-filter.php'; | |
| 314 | + include_once 'inc/Filters/class-lp-post-type-filter.php'; | |
| 315 | + include_once 'inc/Filters/class-lp-post-meta-filter.php'; | |
| 316 | + include_once 'inc/Filters/class-lp-user-filter.php'; | |
| 317 | + include_once 'inc/Filters/class-lp-course-filter.php'; | |
| 318 | + include_once 'inc/Filters/class-lp-course-json-filter.php'; | |
| 319 | + include_once 'inc/Filters/class-lp-order-filter.php'; | |
| 320 | + include_once 'inc/Filters/class-lp-session-filter.php'; | |
| 321 | + include_once 'inc/Filters/class-lp-section-filter.php'; | |
| 322 | + include_once 'inc/Filters/class-lp-section-items-filter.php'; | |
| 323 | + include_once 'inc/Filters/class-lp-question-filter.php'; | |
| 324 | + include_once 'inc/Filters/class-lp-quiz-filter.php'; | |
| 325 | + include_once 'inc/Filters/class-lp-user-items-filter.php'; | |
| 326 | + include_once 'inc/Filters/class-lp-user-item-meta-filter.php'; | |
| 327 | + include_once 'inc/Filters/class-lp-quiz-filter.php'; | |
| 328 | + include_once 'inc/Filters/class-lp-quiz-questions-filter.php'; | |
| 329 | + include_once 'inc/Filters/class-lp-question-answers-filter.php'; | |
| 330 | + include_once 'inc/Filters/class-lp-question-answermeta-filter.php'; | |
| 233 | 331 | |
| 234 | 332 | // Query Database . |
| 235 | - require_once 'inc/databases/class-lp-db.php'; | |
| 236 | - require_once 'inc/databases/class-lp-order-db.php'; | |
| 237 | - require_once 'inc/databases/class-lp-course-db.php'; | |
| 238 | - require_once 'inc/databases/class-lp-lesson-db.php'; | |
| 239 | - require_once 'inc/databases/class-lp-section-db.php'; | |
| 240 | - require_once 'inc/databases/class-lp-section-items-db.php'; | |
| 241 | - require_once 'inc/databases/class-lp-quiz-db.php'; | |
| 242 | - require_once 'inc/databases/class-lp-quiz-questions-db.php'; | |
| 243 | - require_once 'inc/databases/class-lp-question-answers-db.php'; | |
| 244 | - require_once 'inc/databases/class-lp-sessions-db.php'; | |
| 245 | - require_once 'inc/databases/class-lp-question-db.php'; | |
| 246 | - require_once 'inc/databases/class-lp-user-items-db.php'; | |
| 247 | - require_once 'inc/databases/class-lp-user-item-results-db.php'; | |
| 333 | + include_once 'inc/Databases/class-lp-db.php'; | |
| 334 | + include_once 'inc/Databases/class-lp-course-json-db.php'; | |
| 335 | + include_once 'inc/Databases/class-lp-order-db.php'; | |
| 336 | + include_once 'inc/Databases/class-lp-post-db.php'; | |
| 337 | + include_once 'inc/Databases/class-lp-post-meta-db.php'; | |
| 338 | + include_once 'inc/Databases/class-lp-user-db.php'; | |
| 339 | + include_once 'inc/Databases/class-lp-course-db.php'; | |
| 340 | + include_once 'inc/Databases/class-lp-lesson-db.php'; | |
| 341 | + include_once 'inc/Databases/class-lp-section-db.php'; | |
| 342 | + include_once 'inc/Databases/class-lp-section-items-db.php'; | |
| 343 | + include_once 'inc/Databases/class-lp-quiz-db.php'; | |
| 344 | + include_once 'inc/Databases/class-lp-quiz-questions-db.php'; | |
| 345 | + include_once 'inc/Databases/class-lp-question-answers-db.php'; | |
| 346 | + include_once 'inc/Databases/class-lp-sessions-db.php'; | |
| 347 | + include_once 'inc/Databases/class-lp-question-db.php'; | |
| 348 | + include_once 'inc/Databases/class-lp-user-items-db.php'; | |
| 349 | + include_once 'inc/Databases/class-lp-user-item-meta-db.php'; | |
| 350 | + include_once 'inc/Databases/class-lp-user-item-results-db.php'; | |
| 351 | + include_once 'inc/Databases/class-thim-cache-db.php'; | |
| 352 | + include_once 'inc/Databases/class-lp-material-db.php'; | |
| 353 | + include_once 'inc/Databases/class-lp-statistics-db.php'; | |
| 248 | 354 | |
| 249 | - // Read files config on folder config . | |
| 250 | - require_once 'inc/Helper/Config.php'; | |
| 251 | - | |
| 252 | 355 | // File system . |
| 253 | - require_once 'inc/class-lp-file-system.php'; | |
| 356 | + include_once 'inc/class-lp-file-system.php'; | |
| 254 | 357 | |
| 255 | 358 | // File helper |
| 256 | - require_once 'inc/class-lp-helper.php'; | |
| 359 | + include_once 'inc/class-lp-helper.php'; | |
| 257 | 360 | |
| 361 | + // Template Hooks. | |
| 362 | + ListCoursesTemplate::instance(); | |
| 363 | + ListCoursesRelatedTemplate::instance(); | |
| 364 | + ListInstructorsTemplate::instance(); | |
| 365 | + SingleCourseTemplate::instance(); | |
| 366 | + SingleCourseOfflineTemplate::instance(); | |
| 367 | + SingleCourseModernLayout::instance(); | |
| 368 | + SingleCourseClassicTemplate::instance(); | |
| 369 | + SingleInstructorTemplate::instance(); | |
| 370 | + ProfileInstructorStatisticsTemplate::instance(); | |
| 371 | + ProfileStudentStatisticsTemplate::instance(); | |
| 372 | + ProfileOrdersTemplate::instance(); | |
| 373 | + ProfileOrderTemplate::instance(); | |
| 374 | + ProfileGeneralInfoTemplate::instance(); | |
| 375 | + FilterCourseTemplate::instance(); | |
| 376 | + ProfileQuizzesTemplate::instance(); | |
| 377 | + CourseBuilderTemplate::instance(); | |
| 378 | + BuilderCourseTemplate::instance(); | |
| 379 | + BuilderListCoursesTemplate::instance(); | |
| 380 | + BuilderDashboardTemplate::instance(); | |
| 381 | + BuilderSettingsTemplate::instance(); | |
| 382 | + BuilderDashboardAjax::instance(); | |
| 383 | + BuilderEditCourseTemplate::instance(); | |
| 384 | + BuilderLessonTemplate::instance(); | |
| 385 | + BuilderListLessonsTemplate::instance(); | |
| 386 | + BuilderEditLessonTemplate::instance(); | |
| 387 | + BuilderQuizTemplate::instance(); | |
| 388 | + BuilderListQuizzesTemplate::instance(); | |
| 389 | + BuilderEditQuizTemplate::instance(); | |
| 390 | + BuilderQuestionTemplate::instance(); | |
| 391 | + BuilderListQuestionsTemplate::instance(); | |
| 392 | + BuilderEditQuestionTemplate::instance(); | |
| 393 | + BuilderPopupTemplate::instance(); | |
| 394 | + ProfileCoursesTemplate::instance(); | |
| 395 | + ProfileStudentEnrolledTemplate::instance(); | |
| 396 | + | |
| 397 | + // Admin template hooks. | |
| 398 | + AdminEditCurriculumTemplate::instance(); | |
| 399 | + AdminEditSettingTemplate::instance(); | |
| 400 | + AdminEditQizTemplate::instance(); | |
| 401 | + AdminEditQuestionTemplate::instance(); | |
| 402 | + AdminCourseTools::instance(); | |
| 403 | + CourseMaterialTemplate::instance(); | |
| 404 | + CourseAIAssistantTemplate::instance(); | |
| 405 | + AdminOrderItemsTemplate::instance(); | |
| 406 | + AdminOrderListTemplate::instance(); | |
| 407 | + AdminCreateCourseAITemplate::instance(); | |
| 408 | + AdminEditWithAITemplate::instance(); | |
| 409 | + AdminEditCourseCurriculumWithAITemplate::instance(); | |
| 410 | + AdminListStudentsEnrolled::instance(); | |
| 411 | + AdminStatisticsReportTable::instance(); | |
| 412 | + FilterOptionsProvider::register_flush_hooks(); | |
| 413 | + // WP GDPR | |
| 414 | + ErasePersonalData::instance(); | |
| 415 | + ExportPersonalData::instance(); | |
| 416 | + | |
| 258 | 417 | // Models |
| 259 | - require_once 'inc/models/class-lp-rest-response.php'; | |
| 260 | - include_once 'inc/models/steps/class-lp-group-step.php'; | |
| 261 | - include_once 'inc/models/steps/class-lp-step.php'; | |
| 262 | - require_once 'inc/models/class-lp-course-extra-info-fast-query-model.php'; | |
| 418 | + include_once 'inc/Models/class-lp-rest-response.php'; | |
| 419 | + include_once 'inc/Models/steps/class-lp-group-step.php'; | |
| 420 | + include_once 'inc/Models/steps/class-lp-step.php'; | |
| 421 | + include_once 'inc/Models/class-lp-course-extra-info-fast-query-model.php'; | |
| 263 | 422 | |
| 264 | 423 | // Handle steps. |
| 265 | - require_once 'inc/handle-steps/class-lp-handle-steps.php'; | |
| 266 | - require_once 'inc/handle-steps/class-lp-handle-upgrade-db-steps.php'; | |
| 424 | + include_once 'inc/handle-steps/class-lp-handle-steps.php'; | |
| 425 | + include_once 'inc/handle-steps/class-lp-handle-upgrade-db-steps.php'; | |
| 267 | 426 | |
| 268 | 427 | // LP Cache |
| 269 | - require_once 'inc/cache/class-lp-cache.php'; | |
| 270 | - require_once 'inc/cache/class-lp-courses-cache.php'; | |
| 271 | - require_once 'inc/cache/class-lp-course-cache.php'; | |
| 272 | - require_once 'inc/cache/class-lp-quiz-cache.php'; | |
| 428 | + include_once 'inc/cache/class-lp-cache.php'; | |
| 429 | + include_once 'inc/cache/class-lp-courses-cache.php'; | |
| 430 | + include_once 'inc/cache/class-lp-course-cache.php'; | |
| 431 | + include_once 'inc/cache/class-lp-quiz-cache.php'; | |
| 432 | + include_once 'inc/cache/class-lp-question-cache.php'; | |
| 433 | + include_once 'inc/cache/class-lp-session-cache.php'; | |
| 434 | + include_once 'inc/cache/class-lp-settings-cache.php'; | |
| 435 | + include_once 'inc/cache/class-lp-user-items-cache.php'; | |
| 273 | 436 | |
| 274 | 437 | // Background processes. |
| 275 | - require_once 'inc/libraries/wp-background-process/wp-background-processing.php'; | |
| 276 | - require_once 'inc/background-process/abstract-lp-async-request.php'; | |
| 277 | - require_once 'inc/background-process/class-lp-background-single-course.php'; | |
| 278 | - require_once 'inc/background-process/class-lp-background-single-email.php'; | |
| 438 | + LPBackgroundTrigger::instance(); | |
| 439 | + include_once 'inc/libraries/wp-background-process/wp-background-processing.php'; | |
| 440 | + include_once 'inc/background-process/abstract-lp-async-request.php'; | |
| 441 | + //include_once 'inc/background-process/abstract-lp-async-task.php'; | |
| 442 | + include_once 'inc/background-process/class-lp-background-single-course.php'; | |
| 443 | + include_once 'inc/background-process/class-lp-background-single-email.php'; | |
| 279 | 444 | |
| 280 | 445 | // Assets object |
| 281 | - require_once 'inc/class-lp-asset-key.php'; | |
| 282 | - require_once 'inc/abstracts/abstract-assets.php'; | |
| 446 | + include_once 'inc/class-lp-asset-key.php'; | |
| 447 | + include_once 'inc/abstracts/abstract-assets.php'; | |
| 283 | 448 | |
| 284 | 449 | // Debug class |
| 285 | - require_once 'inc/class-lp-debug.php'; | |
| 450 | + include_once 'inc/class-lp-debug.php'; | |
| 286 | 451 | |
| 287 | - require_once 'inc/class-lp-settings.php'; | |
| 288 | - require_once 'inc/abstract-settings.php'; | |
| 289 | - require_once 'inc/settings/abstract-settings-page.php'; | |
| 290 | - require_once 'inc/settings/class-lp-settings-courses.php'; | |
| 291 | - require_once 'inc/class-lp-global.php'; | |
| 292 | - require_once 'inc/class-lp-datetime.php'; | |
| 452 | + include_once 'inc/class-lp-settings.php'; | |
| 453 | + include_once 'inc/abstract-settings.php'; | |
| 454 | + include_once 'inc/settings/abstract-settings-page.php'; | |
| 455 | + include_once 'inc/settings/class-lp-settings-courses.php'; | |
| 456 | + include_once 'inc/class-lp-global.php'; | |
| 457 | + include_once 'inc/class-lp-datetime.php'; | |
| 293 | 458 | |
| 294 | 459 | // Register custom-post-type and taxonomies . |
| 295 | - require_once 'inc/custom-post-types/abstract.php'; | |
| 296 | - require_once 'inc/custom-post-types/course.php'; | |
| 297 | - require_once 'inc/custom-post-types/lesson.php'; | |
| 298 | - require_once 'inc/custom-post-types/quiz.php'; | |
| 299 | - require_once 'inc/custom-post-types/question.php'; | |
| 300 | - require_once 'inc/custom-post-types/order.php'; | |
| 460 | + /*include_once 'inc/custom-post-types/abstract.php'; | |
| 461 | + include_once 'inc/custom-post-types/course.php'; | |
| 462 | + include_once 'inc/custom-post-types/lesson.php'; | |
| 463 | + include_once 'inc/custom-post-types/quiz.php'; | |
| 464 | + include_once 'inc/custom-post-types/question.php'; | |
| 465 | + include_once 'inc/custom-post-types/order.php';*/ | |
| 301 | 466 | |
| 302 | - require_once 'inc/interfaces/interface-curd.php'; | |
| 303 | - require_once 'inc/abstracts/abstract-array-access.php'; | |
| 304 | - require_once 'inc/abstracts/abstract-object-data.php'; | |
| 305 | - require_once 'inc/abstracts/abstract-post-data.php'; | |
| 467 | + include_once 'inc/interfaces/interface-curd.php'; | |
| 468 | + include_once 'inc/abstracts/abstract-array-access.php'; | |
| 469 | + include_once 'inc/abstracts/abstract-object-data.php'; | |
| 470 | + include_once 'inc/abstracts/abstract-post-data.php'; | |
| 306 | 471 | |
| 307 | - require_once 'inc/curds/class-lp-course-curd.php'; | |
| 308 | - require_once 'inc/curds/class-lp-section-curd.php'; | |
| 309 | - require_once 'inc/curds/class-lp-lesson-curd.php'; | |
| 310 | - require_once 'inc/curds/class-lp-quiz-curd.php'; | |
| 311 | - require_once 'inc/curds/class-lp-question-curd.php'; | |
| 312 | - require_once 'inc/curds/class-lp-order-curd.php'; | |
| 313 | - require_once 'inc/curds/class-lp-user-curd.php'; | |
| 314 | - require_once 'inc/curds/class-lp-user-item-curd.php'; | |
| 472 | + include_once 'inc/curds/class-lp-course-curd.php'; | |
| 473 | + include_once 'inc/curds/class-lp-section-curd.php'; | |
| 474 | + include_once 'inc/curds/class-lp-lesson-curd.php'; | |
| 475 | + include_once 'inc/curds/class-lp-quiz-curd.php'; | |
| 476 | + include_once 'inc/curds/class-lp-question-curd.php'; | |
| 477 | + include_once 'inc/curds/class-lp-order-curd.php'; | |
| 478 | + include_once 'inc/curds/class-lp-user-curd.php'; | |
| 479 | + include_once 'inc/curds/class-lp-user-item-curd.php'; | |
| 315 | 480 | |
| 316 | - require_once 'inc/course/class-lp-course-item.php'; | |
| 317 | - require_once 'inc/question/class-lp-question.php'; | |
| 318 | - require_once 'inc/course/class-lp-course-section.php'; | |
| 319 | - require_once 'inc/course/class-lp-course-no-required-enroll.php'; | |
| 320 | - require_once 'inc/user-item/class-lp-user-item.php'; | |
| 321 | - require_once 'inc/user-item/class-lp-user-item-course.php'; | |
| 481 | + include_once 'inc/course/class-lp-course-item.php'; | |
| 482 | + include_once 'inc/question/class-lp-question.php'; | |
| 483 | + include_once 'inc/course/class-lp-course-section.php'; | |
| 484 | + include_once 'inc/course/class-lp-course-no-required-enroll.php'; | |
| 485 | + include_once 'inc/user-item/class-lp-user-item.php'; | |
| 486 | + include_once 'inc/user-item/class-lp-user-item-course.php'; | |
| 322 | 487 | |
| 323 | - require_once 'inc/lp-deprecated.php'; // Will remove if Eduma and guest update all 4.0.0 | |
| 324 | - require_once 'inc/lp-core-functions.php'; | |
| 325 | - require_once 'inc/class-lp-autoloader.php'; | |
| 488 | + include_once 'inc/lp-deprecated.php'; // Will remove if Eduma and guest update all 4.0.0 | |
| 489 | + include_once 'inc/lp-core-functions.php'; | |
| 490 | + include_once 'inc/class-lp-autoloader.php'; | |
| 326 | 491 | |
| 327 | - require_once 'inc/lp-webhooks.php'; | |
| 328 | - require_once 'inc/class-lp-request-handler.php'; | |
| 492 | + 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. | |
| 493 | + include_once 'inc/class-lp-request-handler.php'; | |
| 329 | 494 | |
| 330 | - require_once 'inc/admin/helpers/class-lp-plugins-helper.php'; | |
| 331 | - | |
| 332 | 495 | // Todo: tungnx check those files. |
| 333 | - require_once 'inc/abstracts/abstract-object-query.php'; | |
| 334 | - require_once 'inc/class-lp-course-query.php'; | |
| 335 | - require_once 'inc/abstracts/abstract-addon.php'; | |
| 336 | - require_once 'inc/class-lp-thumbnail-helper.php'; | |
| 337 | - require_once 'inc/cache.php'; | |
| 496 | + include_once 'inc/abstracts/abstract-object-query.php'; | |
| 497 | + include_once 'inc/class-lp-course-query.php'; | |
| 498 | + include_once 'inc/abstracts/abstract-addon.php'; | |
| 499 | + include_once 'inc/class-lp-thumbnail-helper.php'; | |
| 500 | + include_once 'inc/cache.php'; | |
| 338 | 501 | |
| 339 | 502 | // Class handle check db of LP need to upgrade? |
| 340 | - require_once 'inc/admin/class-lp-updater.php'; | |
| 503 | + include_once 'inc/admin/class-lp-updater.php'; | |
| 341 | 504 | |
| 342 | - require_once 'inc/course/lp-course-functions.php'; | |
| 343 | - require_once 'inc/course/abstract-course.php'; | |
| 344 | - require_once 'inc/course/class-lp-course.php'; | |
| 345 | - //require_once 'inc/course/class-lp-course-utils.php'; | |
| 346 | - require_once 'inc/quiz/lp-quiz-functions.php'; | |
| 347 | - require_once 'inc/quiz/class-lp-quiz.php'; | |
| 348 | - require_once 'inc/lesson/lp-lesson-functions.php'; | |
| 349 | - require_once 'inc/order/lp-order-functions.php'; | |
| 350 | - require_once 'inc/order/class-lp-order.php'; | |
| 505 | + include_once 'inc/course/lp-course-functions.php'; | |
| 506 | + include_once 'inc/course/abstract-course.php'; | |
| 507 | + include_once 'inc/course/class-lp-course.php'; | |
| 508 | + include_once 'inc/quiz/lp-quiz-functions.php'; | |
| 509 | + include_once 'inc/quiz/class-lp-quiz.php'; | |
| 510 | + //include_once 'inc/lesson/lp-lesson-functions.php'; | |
| 511 | + include_once 'inc/order/lp-order-functions.php'; | |
| 512 | + include_once 'inc/order/class-lp-order.php'; | |
| 351 | 513 | |
| 352 | - require_once 'inc/user/lp-user-functions.php'; | |
| 353 | - require_once 'inc/user/class-lp-user-factory.php'; | |
| 354 | - require_once 'inc/user/abstract-lp-user.php'; | |
| 355 | - require_once 'inc/user/class-lp-user.php'; | |
| 356 | - require_once 'inc/user/class-lp-profile.php'; | |
| 357 | - require_once 'inc/user-item/class-lp-user-item.php'; | |
| 358 | - require_once 'inc/user-item/class-lp-user-item-course.php'; | |
| 359 | - require_once 'inc/user-item/class-lp-user-item-quiz.php'; | |
| 360 | - require_once 'inc/user-item/class-lp-quiz-results.php'; | |
| 361 | - require_once 'inc/class-lp-session-handler.php'; | |
| 514 | + include_once 'inc/user/lp-user-functions.php'; | |
| 515 | + include_once 'inc/user/class-lp-user-factory.php'; | |
| 516 | + WebhookDispatcher::instance(); | |
| 517 | + include_once 'inc/user/abstract-lp-user.php'; | |
| 518 | + include_once 'inc/user/class-lp-user.php'; | |
| 519 | + include_once 'inc/user/class-lp-profile.php'; | |
| 520 | + include_once 'inc/user-item/class-lp-user-item.php'; | |
| 521 | + include_once 'inc/user-item/class-lp-user-item-course.php'; | |
| 522 | + include_once 'inc/user-item/class-lp-user-item-quiz.php'; | |
| 523 | + include_once 'inc/user-item/class-lp-quiz-results.php'; | |
| 362 | 524 | |
| 363 | - require_once 'inc/class-lp-shortcodes.php'; | |
| 525 | + // Shortcodes. | |
| 526 | + SingleInstructorShortcode::instance(); | |
| 527 | + ListInstructorsShortcode::instance(); | |
| 528 | + CourseMaterialShortcode::instance(); | |
| 529 | + CourseButtonShortcode::instance(); | |
| 530 | + FilterCourseShortcode::instance(); | |
| 531 | + ListCoursesShortcode::instance(); | |
| 532 | + //ListCourseRecentShortcode::instance(); | |
| 533 | + include_once 'inc/class-lp-shortcodes.php'; | |
| 364 | 534 | |
| 365 | 535 | // include template functions . |
| 366 | - require_once 'inc/lp-template-functions.php'; | |
| 367 | - require_once 'inc/templates/abstract-template.php'; | |
| 368 | - //require_once 'inc/class-lp-template.php'; | |
| 536 | + include_once 'inc/lp-template-functions.php'; | |
| 537 | + include_once 'inc/templates/abstract-template.php'; | |
| 538 | + //include_once 'inc/class-lp-template.php'; | |
| 369 | 539 | |
| 370 | 540 | // Cart |
| 371 | - require_once 'inc/cart/class-lp-cart.php'; | |
| 372 | - require_once 'inc/cart/lp-cart-functions.php'; | |
| 541 | + include_once 'inc/cart/class-lp-cart.php'; | |
| 542 | + include_once 'inc/cart/lp-cart-functions.php'; | |
| 373 | 543 | |
| 374 | 544 | // Block Templates |
| 375 | - require_once 'inc/block-template/class-block-until.php'; | |
| 376 | - require_once 'inc/block-template/class-block-controller.php'; | |
| 545 | + //include_once 'inc/block-template/class-abstract-block-template.php'; | |
| 546 | + //include_once 'inc/block-template/class-block-template-handle.php'; | |
| 547 | + GutenbergHandleMain::instance(); | |
| 377 | 548 | |
| 378 | 549 | // API |
| 379 | - require_once 'inc/abstracts/abstract-rest-api.php'; | |
| 380 | - require_once 'inc/abstracts/abstract-rest-controller.php'; | |
| 381 | - require_once 'inc/rest-api/class-lp-core-api.php'; | |
| 382 | - require_once 'inc/rest-api/class-lp-admin-core-api.php'; | |
| 550 | + include_once 'inc/abstracts/abstract-rest-api.php'; | |
| 551 | + include_once 'inc/abstracts/abstract-rest-controller.php'; | |
| 552 | + include_once 'inc/rest-api/class-lp-core-api.php'; | |
| 553 | + include_once 'inc/rest-api/class-lp-admin-core-api.php'; | |
| 383 | 554 | |
| 384 | - // include_once 'inc/theme-support/class-theme-support-base.php'; | |
| 385 | - // include_once 'inc/class-lp-theme-support.php'; | |
| 386 | - | |
| 387 | 555 | /** Jwt */ |
| 388 | 556 | include_once 'inc/jwt/class-jwt-auth.php'; |
| 389 | 557 | |
| 390 | - require_once 'inc/class-lp-widget.php'; | |
| 391 | - require_once 'inc/lp-widget-functions.php'; | |
| 558 | + LPRegisterWidget::instance(); | |
| 559 | + include_once 'inc/class-lp-widget.php'; | |
| 560 | + include_once 'inc/lp-widget-functions.php'; | |
| 392 | 561 | |
| 393 | - // For plugin Elementor | |
| 394 | - if ( defined( 'ELEMENTOR_VERSION' ) ) { | |
| 395 | - require_once 'inc/external-plugin/elementor/class-lp-elementor.php'; | |
| 396 | - } | |
| 397 | - | |
| 398 | 562 | // TODO: update frontend editor before move to function include_files_admin. |
| 399 | - require_once 'inc/admin/views/meta-boxes/class-lp-meta-box.php'; | |
| 563 | + include_once 'inc/admin/views/meta-boxes/class-lp-meta-box.php'; | |
| 400 | 564 | |
| 401 | - require_once 'inc/class-lp-page-controller.php'; | |
| 565 | + include_once 'inc/class-lp-page-controller.php'; | |
| 566 | + LP_Page_Controller::instance(); | |
| 402 | 567 | |
| 403 | - require_once 'inc/gateways/class-lp-gateway-abstract.php'; | |
| 404 | - require_once 'inc/gateways/class-lp-gateways.php'; | |
| 568 | + include_once 'inc/gateways/class-lp-gateway-abstract.php'; | |
| 569 | + include_once 'inc/gateways/subscriptions/class-lp-subscription-manager.php'; | |
| 570 | + include_once 'inc/gateways/class-lp-gateways.php'; | |
| 405 | 571 | } |
| 406 | 572 | |
| 407 | 573 | /** |
| 408 | 574 | * Include file run on backend |
| @@ -411,20 +577,20 @@ | ||
| 411 | 577 | if ( ! is_admin() ) { |
| 412 | 578 | return; |
| 413 | 579 | } |
| 414 | 580 | |
| 415 | - require_once 'inc/admin/class-lp-admin-notice.php'; | |
| 581 | + include_once 'inc/admin/class-lp-admin-ajax.php'; | |
| 416 | 582 | |
| 583 | + include_once 'inc/admin/class-lp-admin-notice.php'; | |
| 584 | + | |
| 417 | 585 | // File handle install LP |
| 418 | - require_once 'inc/class-lp-install.php'; | |
| 586 | + include_once 'inc/class-lp-install.php'; | |
| 419 | 587 | |
| 420 | 588 | // Meta box helper |
| 421 | - require_once 'inc/admin/meta-box/class-lp-meta-box-helper.php'; | |
| 589 | + include_once 'inc/admin/meta-box/class-lp-meta-box-helper.php'; | |
| 422 | 590 | |
| 423 | - require_once 'inc/admin/class-lp-admin.php'; | |
| 424 | - // require_once 'inc/admin/settings/abstract-settings-page.php'; | |
| 425 | - | |
| 426 | - require_once 'inc/admin/class-lp-admin-ajax.php'; | |
| 591 | + // include_once 'inc/admin/class-lp-admin.php'; | |
| 592 | + // include_once 'inc/admin/settings/abstract-settings-page.php'; | |
| 427 | 593 | } |
| 428 | 594 | |
| 429 | 595 | /** |
| 430 | 596 | * Include file run on frontend |
| @@ -433,113 +599,305 @@ | ||
| 433 | 599 | if ( is_admin() ) { |
| 434 | 600 | return; |
| 435 | 601 | } |
| 436 | 602 | |
| 437 | - require_once 'inc/class-lp-assets.php'; | |
| 603 | + include_once 'inc/class-lp-assets.php'; | |
| 438 | 604 | |
| 439 | - require_once 'inc/course/class-model-user-can-view-course-item.php'; | |
| 605 | + include_once 'inc/course/class-model-user-can-view-course-item.php'; | |
| 440 | 606 | |
| 441 | - require_once 'inc/class-lp-ajax.php'; | |
| 607 | + include_once 'inc/class-lp-ajax.php'; | |
| 608 | + | |
| 609 | + include_once 'inc/class-lp-session-handler.php'; | |
| 442 | 610 | } |
| 443 | 611 | |
| 444 | 612 | /** |
| 613 | + * Main instance of LearnPress. | |
| 614 | + * Must load on "init" hook of WordPress. | |
| 615 | + * 1. Load text domain. | |
| 616 | + * 2. Handle lp ajax. | |
| 617 | + * | |
| 618 | + * @return void | |
| 619 | + * @version 4.2.7.6 | |
| 620 | + * @version 1.0.2 | |
| 621 | + */ | |
| 622 | + public function lp_main_handle() { | |
| 623 | + try { | |
| 624 | + // Load text domain. | |
| 625 | + $this->load_plugin_text_domain(); | |
| 626 | + | |
| 627 | + // Register custom post type and taxonomies . | |
| 628 | + include_once 'inc/custom-post-types/abstract.php'; | |
| 629 | + include_once 'inc/custom-post-types/course.php'; | |
| 630 | + include_once 'inc/custom-post-types/lesson.php'; | |
| 631 | + include_once 'inc/custom-post-types/quiz.php'; | |
| 632 | + include_once 'inc/custom-post-types/question.php'; | |
| 633 | + include_once 'inc/custom-post-types/order.php'; | |
| 634 | + | |
| 635 | + // Polylang | |
| 636 | + if ( defined( 'POLYLANG_VERSION' ) ) { | |
| 637 | + include_once 'inc/ExternalPlugin/Polylang/class-lp-polylang.php'; | |
| 638 | + LP_Polylang::instance(); | |
| 639 | + } | |
| 640 | + | |
| 641 | + // For plugin Elementor | |
| 642 | + if ( defined( 'ELEMENTOR_VERSION' ) ) { | |
| 643 | + LPElementor::instance(); | |
| 644 | + } | |
| 645 | + | |
| 646 | + // For plugin WPSEO | |
| 647 | + if ( defined( 'WPSEO_FILE' ) ) { | |
| 648 | + LPYoastSeo::instance(); | |
| 649 | + } | |
| 650 | + | |
| 651 | + // For plugin RankMath | |
| 652 | + if ( defined( 'RANK_MATH_VERSION' ) ) { | |
| 653 | + LPRankMath::instance(); | |
| 654 | + } | |
| 655 | + | |
| 656 | + $this->api = new LP_Core_API(); | |
| 657 | + $this->admin_api = new LP_Admin_Core_API(); | |
| 658 | + $this->get_session(); | |
| 659 | + $this->settings = $this->settings(); | |
| 660 | + $this->get_cart(); | |
| 661 | + | |
| 662 | + // Init emails | |
| 663 | + LP_Emails::instance(); | |
| 664 | + // Email hook notify | |
| 665 | + include_once 'inc/emails/class-lp-email-hooks.php'; | |
| 666 | + | |
| 667 | + if ( is_admin() ) { | |
| 668 | + $this->check_addons_version_valid(); | |
| 669 | + | |
| 670 | + include_once 'inc/admin/class-lp-admin.php'; | |
| 671 | + } | |
| 672 | + | |
| 673 | + // let third parties know that we're ready . | |
| 674 | + do_action( 'learn-press/ready' ); | |
| 675 | + | |
| 676 | + // For addon sorting choice old <= v4.0.1 | |
| 677 | + /*if ( class_exists( 'LP_Addon_Sorting_Choice_Preload' ) ) { | |
| 678 | + if ( version_compare( LP_ADDON_SORTING_CHOICE_VER, '4.0.1', '<=' ) ) { | |
| 679 | + $lp_addon_sorting_choice = new LP_Addon_Sorting_Choice(); | |
| 680 | + $lp_addon_sorting_choice->init(); | |
| 681 | + } | |
| 682 | + }*/ | |
| 683 | + | |
| 684 | + /** | |
| 685 | + * Init gateways, to load all payment gateways, catch callback. | |
| 686 | + * Must be call after learn-press/ready to register hook of addon. | |
| 687 | + */ | |
| 688 | + LP_Gateways::instance(); | |
| 689 | + | |
| 690 | + /** | |
| 691 | + * Fixed temporary for emails of Announcement v4.0.6, Assignment v4.1.1 addons. | |
| 692 | + * @since 4.2.7.4 | |
| 693 | + * When 2 addons update to new version, will remove this code. | |
| 694 | + */ | |
| 695 | + /*if ( class_exists( 'LP_Addon_Announcements_Preload' ) ) { | |
| 696 | + if ( version_compare( LP_ADDON_ANNOUNCEMENTS_VER, '4.0.6', '<=' ) ) { | |
| 697 | + $addon_announcement = LP_Addon_Announcements_Preload::$addon; | |
| 698 | + $addon_announcement->emails_setting(); | |
| 699 | + } | |
| 700 | + }*/ | |
| 701 | + /*if ( class_exists( 'LP_Addon_Assignment_Preload' ) ) { | |
| 702 | + if ( version_compare( LP_ADDON_ASSIGNMENT_VER, '4.1.1', '<=' ) ) { | |
| 703 | + $addon_assignment = LP_Addon_Assignment_Preload::$addon; | |
| 704 | + $addon_assignment->emails_setting(); | |
| 705 | + } | |
| 706 | + }*/ | |
| 707 | + } catch ( Throwable $e ) { | |
| 708 | + LP_Debug::error_log( $e ); | |
| 709 | + } | |
| 710 | + } | |
| 711 | + | |
| 712 | + /** | |
| 713 | + * Check version addons valid version require. | |
| 714 | + * If not valid will be to deactivate. | |
| 715 | + * Reload page, so not affect to hook "learn-press/ready" | |
| 716 | + */ | |
| 717 | + public function check_addons_version_valid() { | |
| 718 | + $addons_valid = true; | |
| 719 | + $plugins = get_option( 'active_plugins' ); | |
| 720 | + | |
| 721 | + $list_lp_addon_activated = preg_grep( '/^learnpress-.*/i', $plugins ); | |
| 722 | + foreach ( $list_lp_addon_activated as $lp_addon ) { | |
| 723 | + $lp_addon_info = get_file_data( | |
| 724 | + WP_PLUGIN_DIR . '/' . $lp_addon, | |
| 725 | + array( | |
| 726 | + 'Require_LP_Version' => 'Require_LP_Version', | |
| 727 | + 'Version' => 'Version', | |
| 728 | + ) | |
| 729 | + ); | |
| 730 | + | |
| 731 | + $lp_addon_version = $lp_addon_info['Version']; | |
| 732 | + | |
| 733 | + $addon = new LP_Addon(); | |
| 734 | + $addon->version = $lp_addon_version; | |
| 735 | + $addon->plugin_base = $lp_addon; | |
| 736 | + $addon->require_version = $lp_addon_info['Require_LP_Version']; | |
| 737 | + $addon_valid = $addon->check_require_version_addon(); | |
| 738 | + | |
| 739 | + if ( $addons_valid ) { | |
| 740 | + //$addon_valid = $addon->check_require_version_lp(); | |
| 741 | + } | |
| 742 | + | |
| 743 | + if ( ! $addon_valid ) { | |
| 744 | + $addons_valid = false; | |
| 745 | + } | |
| 746 | + } | |
| 747 | + } | |
| 748 | + | |
| 749 | + /** | |
| 445 | 750 | * Initial common hooks |
| 446 | 751 | */ |
| 447 | - public function init_hooks() { | |
| 448 | - if ( 0 !== strcmp( LP_PLUGIN_BASENAME, 'learnpress/learnpress.php' ) ) { | |
| 449 | - add_action( 'admin_notices', array( $this, 'error' ) ); | |
| 450 | - } | |
| 752 | + public function hooks() { | |
| 753 | + add_action( 'init', array( $this, 'maybe_init_mcp_abilities' ), 20 ); | |
| 451 | 754 | |
| 755 | + /** | |
| 756 | + * Handle lp ajax. | |
| 757 | + * Set priority after register_post_type to register capabilities for post type of LP. | |
| 758 | + */ | |
| 759 | + add_action( | |
| 760 | + 'init', | |
| 761 | + function () { | |
| 762 | + LoadContentViaAjax::catch_lp_ajax(); | |
| 763 | + LessonAjax::catch_lp_ajax(); | |
| 764 | + SampleDataAJAX::catch_lp_ajax(); | |
| 765 | + SetupWizardAjax::catch_lp_ajax(); | |
| 766 | + EditCurriculumAjax::catch_lp_ajax(); | |
| 767 | + EditQuizAjax::catch_lp_ajax(); | |
| 768 | + EditQuestionAjax::catch_lp_ajax(); | |
| 769 | + SendEmailAjax::catch_lp_ajax(); | |
| 770 | + RefundOrderAjax::catch_lp_ajax(); | |
| 771 | + CourseBuilderAjax::catch_lp_ajax(); | |
| 772 | + OpenAiAjax::catch_lp_ajax(); | |
| 773 | + AIAssistantAjax::catch_lp_ajax(); | |
| 774 | + ExportOrderCSVAjax::catch_lp_ajax(); | |
| 775 | + McpApiKeysAjax::catch_lp_ajax(); | |
| 776 | + WebhooksAjax::catch_lp_ajax(); | |
| 777 | + CBEditCourseAjax::catch_lp_ajax(); | |
| 778 | + CourseToolsAjax::catch_lp_ajax(); | |
| 779 | + | |
| 780 | + do_action( 'learn-press/register-ajax-handlers' ); | |
| 781 | + }, | |
| 782 | + 11 | |
| 783 | + ); | |
| 784 | + | |
| 452 | 785 | // Add links setting|document|addon on plugins page. |
| 453 | 786 | add_filter( 'plugin_action_links_' . LP_PLUGIN_BASENAME, array( $this, 'plugin_links' ) ); |
| 454 | 787 | |
| 455 | 788 | register_activation_hook( LP_PLUGIN_FILE, array( $this, 'on_activate' ) ); |
| 456 | 789 | register_deactivation_hook( LP_PLUGIN_FILE, array( $this, 'on_deactivate' ) ); |
| 457 | - // add_action( 'deactivate_' . LP_PLUGIN_BASENAME, array( $this, 'on_deactivate' ) ); | |
| 458 | 790 | |
| 459 | - if ( ! LP_Install::instance()->tables_install_done() ) { | |
| 460 | - return; | |
| 791 | + add_action( | |
| 792 | + 'plugin_loaded', | |
| 793 | + function ( $plugin ) { | |
| 794 | + // For check wp_remote call normally of WP | |
| 795 | + if ( ! empty( LP_Request::get_param( 'lp_test_wp_remote' ) ) ) { | |
| 796 | + echo '[TEST_REMOTE]'; | |
| 797 | + die; | |
| 798 | + } | |
| 799 | + } | |
| 800 | + ); | |
| 801 | + | |
| 802 | + // Check require version thim-core on Backend. | |
| 803 | + if ( is_admin() ) { | |
| 804 | + add_action( 'before_thim_core_init', array( $this, 'check_thim_core_version_require' ) ); | |
| 461 | 805 | } |
| 462 | 806 | |
| 463 | - add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 20 ); | |
| 464 | - add_action( 'after_setup_theme', array( $this, 'setup_theme' ) ); | |
| 465 | - add_action( 'plugins_loaded', array( $this, 'plugin_loaded' ), - 10 ); | |
| 466 | - // add_action( 'init', array( $this, 'wp_init' ), 10 ); | |
| 807 | + // Save key purchase addon when install via file download from Thimpress. | |
| 808 | + add_action( | |
| 809 | + 'upgrader_process_complete', | |
| 810 | + function ( $plugin_upgrader ) { | |
| 811 | + if ( ! empty( $plugin_upgrader->result ) ) { | |
| 812 | + $res = $plugin_upgrader->result; | |
| 813 | + $path_source = $res['destination'] ?? ''; | |
| 814 | + if ( empty( $path_source ) ) { | |
| 815 | + return; | |
| 816 | + } | |
| 467 | 817 | |
| 468 | - // Check require version thim-core. | |
| 469 | - add_action( 'before_thim_core_init', array( $this, 'check_thim_core_version_require' ) ); | |
| 818 | + $key_purchase_path = realpath( $path_source . '/purchase-code.txt' ); | |
| 819 | + if ( file_exists( $key_purchase_path ) ) { | |
| 820 | + $purchase_code_content = file_get_contents( $key_purchase_path ); | |
| 821 | + if ( empty( $purchase_code_content ) ) { | |
| 822 | + return; | |
| 823 | + } | |
| 824 | + | |
| 825 | + $addon_slug = $res['destination_name'] ?? ''; | |
| 826 | + if ( empty( $addon_slug ) ) { | |
| 827 | + return; | |
| 828 | + } | |
| 829 | + | |
| 830 | + // Call active purchase code for site. | |
| 831 | + LP_Manager_Addons::instance()->active_site( $addon_slug, $purchase_code_content ); | |
| 832 | + } | |
| 833 | + } | |
| 834 | + } | |
| 835 | + ); | |
| 836 | + | |
| 837 | + // Clear cache UserModel when save user. | |
| 838 | + add_action( | |
| 839 | + 'wp_update_user', | |
| 840 | + function ( $user_id ) { | |
| 841 | + $user = UserModel::find( $user_id, true ); | |
| 842 | + $user->clean_caches(); | |
| 843 | + } | |
| 844 | + ); | |
| 845 | + | |
| 846 | + // For temporary fix issue security of wp comments. Is it error of WP, not LP, LP only call to comments_template function. | |
| 847 | + add_filter( | |
| 848 | + 'comments_array', | |
| 849 | + function ( $comments_flat, $post_id ) { | |
| 850 | + // Check if post type is course or item's course (lesson, quiz...) | |
| 851 | + $post_type = get_post_type( $post_id ); | |
| 852 | + $course_item_types = CourseModel::item_types_support(); | |
| 853 | + $course_item_types[] = LP_COURSE_CPT; | |
| 854 | + if ( ! in_array( $post_type, $course_item_types ) ) { | |
| 855 | + return $comments_flat; | |
| 856 | + } | |
| 857 | + | |
| 858 | + foreach ( $comments_flat as $key => $comment ) { | |
| 859 | + $comment->comment_content = wp_kses_post( $comment->comment_content ); | |
| 860 | + $comments_flat[ $key ] = $comment; | |
| 861 | + } | |
| 862 | + | |
| 863 | + return $comments_flat; | |
| 864 | + }, | |
| 865 | + 10, | |
| 866 | + 2 | |
| 867 | + ); | |
| 470 | 868 | } |
| 471 | 869 | |
| 472 | 870 | /** |
| 473 | 871 | * Add links to Documentation and Extensions in plugin's list of action links |
| 474 | 872 | * |
| 475 | - * @since 4.3.11 | |
| 476 | - * | |
| 477 | 873 | * @param array $links Array of action links |
| 478 | 874 | * |
| 479 | 875 | * @return array |
| 876 | + * @since 4.3.11 | |
| 877 | + * @version 1.0.1 | |
| 480 | 878 | */ |
| 481 | 879 | public function plugin_links( array $links ): array { |
| 482 | - $links[] = sprintf( '<a href="%s">%s</a>', admin_url( 'admin.php?page=learn-press-settings' ), __( 'Settings', 'learnpress' ) ); | |
| 483 | - $links[] = sprintf( '<a href="%s" target="_blank">%s</a>', 'https://docspress.thimpress.com/learnpress-4-0/', __( 'Documentation', 'learnpress' ) ); | |
| 484 | - $links[] = sprintf( '<a href="%s" target="_blank">%s</a>', get_admin_url() . '/admin.php?page=learn-press-addons', __( 'Add-ons', 'learnpress' ) ); | |
| 880 | + $links[] = sprintf( | |
| 881 | + '<a href="%s">%s</a>', | |
| 882 | + esc_url_raw( admin_url( 'admin.php?page=learn-press-settings' ) ), | |
| 883 | + esc_html__( 'Settings', 'learnpress' ) | |
| 884 | + ); | |
| 885 | + $links[] = sprintf( | |
| 886 | + '<a href="%s" target="_blank">%s</a>', | |
| 887 | + esc_url_raw( LearnPress::$doc_link ), | |
| 888 | + esc_html__( 'Documentation', 'learnpress' ) | |
| 889 | + ); | |
| 890 | + $links[] = sprintf( | |
| 891 | + '<a href="%s" target="_blank">%s</a>', | |
| 892 | + esc_url_raw( admin_url( 'admin.php?page=learn-press-addons' ) ), | |
| 893 | + esc_html__( 'Add-ons', 'learnpress' ) | |
| 894 | + ); | |
| 485 | 895 | |
| 486 | 896 | return $links; |
| 487 | 897 | } |
| 488 | 898 | |
| 489 | - public function error() { | |
| 490 | - ?> | |
| 491 | - <div class="error"> | |
| 492 | - <p> | |
| 493 | - <?php | |
| 494 | - printf( | |
| 495 | - __( | |
| 496 | - 'LearnPress plugin base directory must be <strong>learnpress/learnpres.php</strong> (case sensitive) to ensure all functions work properly and fully operational (currently <strong>%s</strong>)', | |
| 497 | - 'learnpress' | |
| 498 | - ), | |
| 499 | - LP_PLUGIN_BASENAME | |
| 500 | - ); | |
| 501 | - ?> | |
| 502 | - </p> | |
| 503 | - </div> | |
| 504 | - <?php | |
| 505 | - } | |
| 506 | - | |
| 507 | 899 | /** |
| 508 | - * Maybe flush rewrite rules | |
| 509 | - */ | |
| 510 | - public function wp_init() { | |
| 511 | - /*if ( LP()->session->flush_rewrite_rules ) { | |
| 512 | - flush_rewrite_rules(); | |
| 513 | - unset( LP()->session->flush_rewrite_rules ); | |
| 514 | - }*/ | |
| 515 | - } | |
| 516 | - | |
| 517 | - /** | |
| 518 | - * Get base name of plugin from file. | |
| 519 | - * | |
| 520 | - * @return string | |
| 521 | - */ | |
| 522 | - // private function plugin_basename() { | |
| 523 | - // return learn_press_plugin_basename( __FILE__ ); | |
| 524 | - // } | |
| 525 | - | |
| 526 | - /** | |
| 527 | - * Magic function to get Learnpress data. | |
| 528 | - * | |
| 529 | - * @param $key | |
| 530 | - * | |
| 531 | - * @return bool|LP_Checkout|LP_Course|LP_Emails|LP_User|LP_User_Guest|mixed | |
| 532 | - * @deprecated since 3.0.0 | |
| 533 | - * @editor tungnx | |
| 534 | - * @modify 4.1.3.1 - comment | |
| 535 | - */ | |
| 536 | - /* | |
| 537 | - public function __get( $key ) { | |
| 538 | - return false; | |
| 539 | - }*/ | |
| 540 | - | |
| 541 | - /** | |
| 542 | 900 | * Trigger this function while activating Learnpress. |
| 543 | 901 | * |
| 544 | 902 | * @since 3.0.0 |
| 545 | 903 | * @version 4.1.4.1 |
| @@ -545,9 +903,8 @@ | ||
| 545 | 903 | * @version 4.1.4.1 |
| 546 | 904 | */ |
| 547 | 905 | public function on_activate() { |
| 548 | 906 | LP_Install::instance()->on_activate(); |
| 549 | - // do_action( 'learn-press/activate', $this ); | |
| 550 | 907 | } |
| 551 | 908 | |
| 552 | 909 | /** |
| 553 | 910 | * Trigger this function while deactivating Learnpress. |
| @@ -560,127 +917,43 @@ | ||
| 560 | 917 | do_action( 'learn-press/deactivate', $this ); |
| 561 | 918 | } |
| 562 | 919 | |
| 563 | 920 | /** |
| 564 | - * Trigger WP loaded actions. | |
| 921 | + * Conditionally bootstrap MCP abilities. | |
| 565 | 922 | * |
| 566 | - * @since 3.0.0 | |
| 923 | + * @return void | |
| 567 | 924 | */ |
| 568 | - public function wp_loaded() { | |
| 569 | - if ( $this->is_request( 'frontend' ) ) { | |
| 570 | - $this->gateways = LP_Gateways::instance()->get_available_payment_gateways(); | |
| 925 | + public function maybe_init_mcp_abilities() { | |
| 926 | + if ( LP_Settings::get_option( 'enable_mcp_integration', 'no' ) !== 'yes' ) { | |
| 927 | + return; | |
| 571 | 928 | } |
| 572 | - } | |
| 573 | 929 | |
| 574 | - /** | |
| 575 | - * Setup courses thumbnail. | |
| 576 | - * | |
| 577 | - * @since 3.0.0 | |
| 578 | - */ | |
| 579 | - public function setup_theme() { | |
| 580 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { | |
| 581 | - add_theme_support( 'post-thumbnails' ); | |
| 582 | - } | |
| 583 | - add_post_type_support( LP_COURSE_CPT, 'thumbnail' ); | |
| 584 | - | |
| 585 | - $size = LP_Settings::get_option( | |
| 586 | - 'course_thumbnail_dimensions', | |
| 587 | - array( | |
| 588 | - 500, | |
| 589 | - 300, | |
| 590 | - ) | |
| 591 | - ); | |
| 592 | - | |
| 593 | - $size = array_values( (array) $size ); | |
| 594 | - | |
| 595 | - add_image_size( 'course_thumbnail', $size[0], $size[1], true ); | |
| 930 | + ApiKeyAuthenticator::init(); | |
| 931 | + Abilities::init(); | |
| 596 | 932 | } |
| 597 | 933 | |
| 598 | 934 | /** |
| 599 | - * Trigger Learnpress loaded actions. | |
| 935 | + * Handle load text domain for LearnPress. | |
| 600 | 936 | * |
| 601 | - * @since 3.0.0 | |
| 602 | - * @version 1.0.2 | |
| 603 | - * @editor tungnx | |
| 937 | + * @since 4.2.7.4 | |
| 938 | + * @version 1.0.1 | |
| 604 | 939 | */ |
| 605 | - public function plugin_loaded() { | |
| 606 | - do_action( 'learnpress/hook/before-addons-call-hook-learnpress-ready' ); | |
| 940 | + public function load_plugin_text_domain() { | |
| 941 | + /*$locale = determine_locale(); | |
| 942 | + $locale = apply_filters( 'plugin_locale', $locale, 'learnpress' ); | |
| 607 | 943 | |
| 608 | - // Polylang | |
| 609 | - if ( defined( 'POLYLANG_VERSION' ) ) { | |
| 610 | - require_once 'inc/external-plugin/polylang/class-lp-polylang.php'; | |
| 611 | - LP_Polylang::instance(); | |
| 612 | - } | |
| 944 | + $plugin_translation_path = WP_LANG_DIR . '/plugins/learnpress-' . $locale . '.mo'; | |
| 945 | + $custom_translation_path = WP_LANG_DIR . '/learnpress/learnpress-' . $locale . '.mo'; | |
| 946 | + if ( is_readable( $custom_translation_path ) ) { | |
| 947 | + unload_textdomain( LP_TEXT_DOMAIN ); | |
| 948 | + load_textdomain( LP_TEXT_DOMAIN, $custom_translation_path ); | |
| 949 | + load_textdomain( LP_TEXT_DOMAIN, $plugin_translation_path ); | |
| 950 | + }*/ | |
| 613 | 951 | |
| 614 | - $this->init(); | |
| 615 | - | |
| 616 | - // Todo: tungnx - remove this code after handle ajax on page learn-press-addons | |
| 617 | - // require_once 'inc/background-process/class-lp-background-query-items.php'; | |
| 618 | - // require_once 'inc/background-process/class-lp-background-installer.php'; | |
| 619 | - | |
| 620 | - require_once 'inc/lp-template-hooks.php'; | |
| 621 | - | |
| 622 | - /** | |
| 623 | - * Check version addons valid version require. | |
| 624 | - * If not valid will be to deactivate. | |
| 625 | - * Reload page, so not affect to hook "learn-press/ready" | |
| 626 | - */ | |
| 627 | - $addons_valid = true; | |
| 628 | - $plugins = get_option( 'active_plugins' ); | |
| 629 | - | |
| 630 | - $list_lp_addon_activated = preg_grep( '/^learnpress-.*/i', $plugins ); | |
| 631 | - | |
| 632 | - // Remove hook deactivate addon assignments v3. | |
| 633 | - add_action( | |
| 634 | - 'deactivate_learnpress-assignments/learnpress-assignments.php', | |
| 635 | - array( $this, 'lp_assignment_install' ), | |
| 636 | - - 10 | |
| 637 | - ); | |
| 638 | - | |
| 639 | - foreach ( $list_lp_addon_activated as $lp_addon ) { | |
| 640 | - $lp_addon_info = get_file_data( | |
| 641 | - WP_PLUGIN_DIR . '/' . $lp_addon, | |
| 642 | - array( | |
| 643 | - 'Require_LP_Version' => 'Require_LP_Version', | |
| 644 | - 'Version' => 'Version', | |
| 645 | - ) | |
| 646 | - ); | |
| 647 | - | |
| 648 | - // $lp_addon_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $lp_addon ); | |
| 649 | - $lp_addon_version = $lp_addon_info['Version']; | |
| 650 | - | |
| 651 | - $addon = new Lp_Addon(); | |
| 652 | - $addon->version = $lp_addon_version; | |
| 653 | - $addon->plugin_base = $lp_addon; | |
| 654 | - $addon->require_version = $lp_addon_info['Require_LP_Version']; | |
| 655 | - $addon_valid = $addon->check_require_version_addon(); | |
| 656 | - | |
| 657 | - if ( $addons_valid ) { | |
| 658 | - $addon_valid = $addon->check_require_version_lp(); | |
| 659 | - } | |
| 660 | - | |
| 661 | - if ( ! $addon_valid ) { | |
| 662 | - $addons_valid = false; | |
| 663 | - } | |
| 664 | - } | |
| 665 | - // End check addons valid. | |
| 666 | - | |
| 667 | - if ( ! $addons_valid ) { | |
| 668 | - return; | |
| 669 | - } | |
| 670 | - | |
| 671 | - // let third parties know that we're ready . | |
| 672 | - do_action( 'learn-press/ready' ); | |
| 952 | + load_plugin_textdomain( LP_TEXT_DOMAIN, false, LP_PLUGIN_FOLDER_NAME . '/languages' ); | |
| 673 | 953 | } |
| 674 | 954 | |
| 675 | 955 | /** |
| 676 | - * Remove hook deactivate addon assignments v3. | |
| 677 | - */ | |
| 678 | - public function lp_assignment_install() { | |
| 679 | - remove_action( 'deactivate_learnpress-assignments/learnpress-assignments.php', 'lp_assignment_remove' ); | |
| 680 | - } | |
| 681 | - | |
| 682 | - /** | |
| 683 | 956 | * Get instance of class LP_Template. |
| 684 | 957 | * |
| 685 | 958 | * @param string $type |
| 686 | 959 | * |
| @@ -689,40 +962,15 @@ | ||
| 689 | 962 | * @throws Exception |
| 690 | 963 | * @since 3.3.0 |
| 691 | 964 | */ |
| 692 | 965 | public function template( $type = '' ) { |
| 693 | - if ( ! $this->template ) { | |
| 694 | - $this->template = LP_Template::instance(); | |
| 695 | - } | |
| 966 | + $this->template = LP_Template::instance(); | |
| 967 | + $templates = (array) $this->template->get_templates(); | |
| 696 | 968 | |
| 697 | - return isset( $this->template[ $type ] ) ? $this->template[ $type ] : $this->template; | |
| 969 | + return $templates[ $type ] ?? $this->template; | |
| 698 | 970 | } |
| 699 | 971 | |
| 700 | 972 | /** |
| 701 | - * Init LearnPress when WP initialises | |
| 702 | - */ | |
| 703 | - public function init() { | |
| 704 | - $this->api = new LP_Core_API(); | |
| 705 | - $this->admin_api = new LP_Admin_Core_API(); | |
| 706 | - // $this->theme_support = LP_Theme_Support::instance(); | |
| 707 | - | |
| 708 | - // $this->view_log(); | |
| 709 | - | |
| 710 | - $this->get_session(); | |
| 711 | - | |
| 712 | - $this->settings = $this->settings(); | |
| 713 | - | |
| 714 | - if ( $this->is_request( 'frontend' ) ) { | |
| 715 | - $this->get_cart(); | |
| 716 | - } | |
| 717 | - | |
| 718 | - // Email hook notify | |
| 719 | - include_once 'inc/emails/class-lp-email-hooks.php'; | |
| 720 | - // Init emails | |
| 721 | - LP_Emails::instance(); | |
| 722 | - } | |
| 723 | - | |
| 724 | - /** | |
| 725 | 973 | * Get session object instance. |
| 726 | 974 | * |
| 727 | 975 | * @return mixed |
| 728 | 976 | */ |
| @@ -747,9 +995,9 @@ | ||
| 747 | 995 | * Get cart object instance for online learning market. |
| 748 | 996 | * |
| 749 | 997 | * @return LP_Cart |
| 750 | 998 | */ |
| 751 | - public function get_cart() : LP_Cart { | |
| 999 | + public function get_cart(): LP_Cart { | |
| 752 | 1000 | if ( ! $this->cart ) { |
| 753 | 1001 | $this->cart = LP_Cart::instance(); |
| 754 | 1002 | } |
| 755 | 1003 | |
| @@ -756,30 +1004,8 @@ | ||
| 756 | 1004 | return $this->cart; |
| 757 | 1005 | } |
| 758 | 1006 | |
| 759 | 1007 | /** |
| 760 | - * Check type of request. | |
| 761 | - * | |
| 762 | - * @param string $type ajax, frontend or admin. | |
| 763 | - * | |
| 764 | - * @return bool | |
| 765 | - */ | |
| 766 | - public function is_request( $type ) { | |
| 767 | - switch ( $type ) { | |
| 768 | - case 'admin': | |
| 769 | - return is_admin(); | |
| 770 | - case 'ajax': | |
| 771 | - return defined( 'LP_DOING_AJAX' ); | |
| 772 | - case 'cron': | |
| 773 | - return defined( 'DOING_CRON' ); | |
| 774 | - case 'frontend': | |
| 775 | - return ( ! is_admin() || defined( 'LP_DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ); | |
| 776 | - default: | |
| 777 | - return strtolower( $_SERVER['REQUEST_METHOD'] ) == $type; | |
| 778 | - } | |
| 779 | - } | |
| 780 | - | |
| 781 | - /** | |
| 782 | 1008 | * Get the plugin url. |
| 783 | 1009 | * |
| 784 | 1010 | * @param string $sub_dir |
| 785 | 1011 | * |
| @@ -873,16 +1099,8 @@ | ||
| 873 | 1099 | } |
| 874 | 1100 | |
| 875 | 1101 | return self::$_instance; |
| 876 | 1102 | } |
| 877 | - | |
| 878 | - public function admin_notice_require_addon_version() { | |
| 879 | - ?> | |
| 880 | - <div class="notice notice-error"> | |
| 881 | - <p><?php echo( '<strong>LearnPress version ' . LEARNPRESS_VERSION . ' require Addon</strong> version 4.0.0 or higher' ); ?></p> | |
| 882 | - </div> | |
| 883 | - <?php | |
| 884 | - } | |
| 885 | 1103 | } |
| 886 | 1104 | } |
| 887 | 1105 | |
| 888 | 1106 | /** |
| @@ -899,5 +1117,9 @@ | ||
| 899 | 1117 | /** |
| 900 | 1118 | * Done! entry point of the plugin |
| 901 | 1119 | * Create new instance of LearnPress and put it to global |
| 902 | 1120 | */ |
| 903 | -$GLOBALS['LearnPress'] = LP(); | |
| 1121 | +$GLOBALS['LearnPress'] = LearnPress::instance(); | |
| 1122 | + | |
| 1123 | +// Load template hooks here, before theme add hooks remove. | |
| 1124 | +// Load here because this file call LearnPress::instance(), loop call. | |
| 1125 | +require_once 'inc/lp-template-hooks.php'; | |