PluginProbe
LearnPress – Backup & Migration Tool / 4.1.6
LearnPress – Backup & Migration Tool v4.1.6
4.1.6 4.1.5 trunk 0.9 2.0 2.0.1 2.0.2 2.0.3 2.0.4 3.0.0 3.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
learnpress-import-export / learnpress-import-export.php

learnpress-import-export.php in LearnPress – Backup & Migration Tool 4.1.6, at learnpress-import-export.php

191 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: LearnPress – Backup & Migration Tool
4 * Plugin URI: https://thimpress.com/product/learnpress-export-import/
5 * Description: Export and Import your courses with all lesson and quiz in easiest way.
6 * Author: ThimPress
7 * Version: 4.1.6
8 * Author URI: http://thimpress.com
9 * Tags: learnpress, lms, add-on, prerequisites courses
10 * Text Domain: learnpress-import-export
11 * Domain Path: /languages/
12 * Require_LP_Version: 4.4.5
13 * Requires at least: 6.0
14 * Requires PHP: 7.4
15 *
16 * @package learnpress-import-export
17 */
18
19 defined( 'ABSPATH' ) || exit;
20
21 use LPImportExport\LearnDashMigration\LearnDashMigrationController;
22 use LPImportExport\Migration\Controllers\EnqueueScriptsController;
23 use LPImportExport\Migration\Controllers\AdminMenuController;
24 use LPImportExport\Migration\Controllers\MigrationPopupController;
25 use LPImportExport\Migration\Controllers\TutorMigrationController;
26 use LPImportExport\Migration\Controllers\MasterStudyMigrationController;
27 use LPImportExport\Migration\Helpers\Plugin;
28
29 const LP_ADDON_IMPORT_EXPORT_FILE = __FILE__;
30 const LP_ADDON_IMPORT_EXPORT_PATH = __DIR__;
31
32 /**
33 * Class LP_Addon_Import_Export_Preload
34 */
35 class LP_Addon_Import_Export_Preload {
36 /**
37 * @var string[] Addon info
38 */
39 public static $addon_info = array();
40 /**
41 * @var LP_Addon_Import_Export $addon
42 */
43 public static $addon;
44
45 /**
46 * Singleton.
47 *
48 * @return LP_Addon_Import_Export_Preload
49 */
50 public static function instance(): LP_Addon_Import_Export_Preload {
51 static $instance;
52 if ( is_null( $instance ) ) {
53 $instance = new self();
54 }
55
56 return $instance;
57 }
58
59 /**
60 * LP_Addon_Import_Export_Preload constructor.
61 */
62 protected function __construct() {
63 $can_load = true;
64 // Set Base name plugin.
65 define( 'LP_ADDON_IMPORT_EXPORT_BASENAME', plugin_basename( LP_ADDON_IMPORT_EXPORT_FILE ) );
66
67 // Set version addon for LP check .
68 include_once ABSPATH . 'wp-admin/includes/plugin.php';
69 self::$addon_info = get_file_data(
70 LP_ADDON_IMPORT_EXPORT_FILE,
71 array(
72 'Name' => 'Plugin Name',
73 'Require_LP_Version' => 'Require_LP_Version',
74 'Version' => 'Version',
75 )
76 );
77
78 define( 'LP_ADDON_IMPORT_EXPORT_VER', self::$addon_info['Version'] );
79 define( 'LP_ADDON_IMPORT_EXPORT_REQUIRE_VER', self::$addon_info['Require_LP_Version'] );
80 //Dirs and Urls
81 define( 'LP_ADDON_IMPORT_EXPORT_URL', plugin_dir_url( __FILE__ ) );
82 define( 'LP_ADDON_IMPORT_EXPORT_DIR', plugin_dir_path( __FILE__ ) );
83 define( 'LP_ADDON_IMPORT_EXPORT_CONFIG_DIR', LP_ADDON_IMPORT_EXPORT_DIR . 'config/' );
84 define( 'LP_ADDON_IMPORT_EXPORT_VIEWS', LP_ADDON_IMPORT_EXPORT_DIR . 'views/' );
85 define( 'LP_ADDON_IMPORT_EXPORT_ASSETS_URL', LP_ADDON_IMPORT_EXPORT_URL . 'assets/' );
86 define( 'LP_ADDON_IMPORT_EXPORT_INC', LP_ADDON_IMPORT_EXPORT_PATH . '/inc/' );
87 define(
88 'LP_ADDON_IMPORT_EXPORT_FOLDER_ROOT_NAME',
89 str_replace(
90 array( '/', basename( __FILE__ ) ),
91 '',
92 plugin_basename( __FILE__ )
93 )
94 );
95
96 //Pages
97 define( 'LP_ADDON_IMPORT_EXPORT_MIGRATION_PAGE', 'migration_page' );
98
99 //Keys
100 //Tutor
101 define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_COURSE_CPT', 'courses' );
102 define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_COURSE_ENROLLED', 'tutor_enrolled' );
103 define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_TOPIC_CPT', 'topics' );
104 define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_LESSON_CPT', 'lesson' );
105 define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_QUIZ_CPT', 'tutor_quiz' );
106 define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_ASSIGNMENT_CPT', 'tutor_assignments' );
107
108 //Master Study
109 define( 'LP_ADDON_IMPORT_EXPORT_MASTER_STUDY_COURSE_CPT', 'stm-courses' );
110 define( 'LP_ADDON_IMPORT_EXPORT_MASTER_STUDY_COURSE_ENROLLED', 'stm-course-enrolled' );
111
112 define( 'LP_ADDON_IMPORT_EXPORT_MASTER_STUDY_LESSON_CPT', 'stm-lessons' );
113 define( 'LP_ADDON_IMPORT_EXPORT_MASTER_STUDY_QUIZ_CPT', 'stm-quizzes' );
114 define( 'LP_ADDON_IMPORT_EXPORT_MASTER_STUDY_QUESTION_CPT', 'stm-questions' );
115 define( 'LP_ADDON_IMPORT_EXPORT_MASTER_STUDY_ASSIGNMENT_CPT', 'stm-assignments' );
116
117 // Check LP activated .
118 if ( ! is_plugin_active( 'learnpress/learnpress.php' ) ) {
119 $can_load = false;
120 } elseif ( version_compare( LP_ADDON_IMPORT_EXPORT_REQUIRE_VER, get_option( 'learnpress_version', '3.0.0' ), '>' ) ) {
121 $can_load = false;
122 }
123
124 if ( ! $can_load ) {
125 add_action( 'admin_notices', array( $this, 'show_note_errors_require_lp' ) );
126 /*deactivate_plugins( LP_ADDON_IMPORT_EXPORT_BASENAME );
127
128 if ( isset( $_GET['activate'] ) ) {
129 unset( $_GET['activate'] );
130 }*/
131
132 return;
133 }
134
135 require_once LP_ADDON_IMPORT_EXPORT_DIR . '/vendor/autoload.php';
136
137 // Sure LP loaded.
138 add_action( 'learn-press/ready', array( $this, 'load' ) );
139 }
140
141 /**
142 * Load addon
143 */
144 public function load() {
145 include_once LP_ADDON_IMPORT_EXPORT_DIR . '/inc/load.php';
146 self::$addon = LP_Addon_Import_Export::instance();
147
148 include_once LP_PLUGIN_PATH . 'inc/admin/editor/class-lp-admin-editor.php';
149 include_once LP_PLUGIN_PATH . 'inc/curds/class-lp-course-curd.php';
150 include_once LP_PLUGIN_PATH . 'inc/curds/class-lp-section-curd.php';
151 include_once LP_PLUGIN_PATH . 'inc/curds/class-lp-question-curd.php';
152
153 new EnqueueScriptsController();
154 new AdminMenuController();
155
156 if ( Plugin::is_tutor_active() ) {
157 new TutorMigrationController();
158 new MigrationPopupController();
159 }
160
161 if ( Plugin::is_learndash_active() ) {
162 new LearnDashMigrationController();
163 new MigrationPopupController();
164 }
165
166 if ( Plugin::is_master_study_active() ) {
167 new MasterStudyMigrationController();
168 new MigrationPopupController();
169 }
170 }
171
172 public function show_note_errors_require_lp() {
173 ?>
174 <div class="notice notice-error">
175 <p>
176 <?php
177 printf(
178 'Please active <strong>LearnPress version %1$s or later</strong> before active <strong>%2$s</strong>',
179 LP_ADDON_IMPORT_EXPORT_REQUIRE_VER,
180 self::$addon_info['Name']
181 );
182 ?>
183 </p>
184 </div>
185 <?php
186 }
187 }
188
189 LP_Addon_Import_Export_Preload::instance();
190
191