| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: LearnPress - Export/Import Courses |
| 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.2 |
| 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.3.2.7 |
| 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\Helpers\Plugin; |
| 27 |
|
| 28 |
const LP_ADDON_IMPORT_EXPORT_FILE = __FILE__; |
| 29 |
|
| 30 |
/** |
| 31 |
* Class LP_Addon_Import_Export_Preload |
| 32 |
*/ |
| 33 |
class LP_Addon_Import_Export_Preload { |
| 34 |
/** |
| 35 |
* @var string[] Addon info |
| 36 |
*/ |
| 37 |
public static $addon_info = array(); |
| 38 |
/** |
| 39 |
* @var LP_Addon_Import_Export $addon |
| 40 |
*/ |
| 41 |
public static $addon; |
| 42 |
|
| 43 |
/** |
| 44 |
* Singleton. |
| 45 |
* |
| 46 |
* @return LP_Addon_Import_Export_Preload |
| 47 |
*/ |
| 48 |
public static function instance(): LP_Addon_Import_Export_Preload { |
| 49 |
static $instance; |
| 50 |
if ( is_null( $instance ) ) { |
| 51 |
$instance = new self(); |
| 52 |
} |
| 53 |
|
| 54 |
return $instance; |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* LP_Addon_Import_Export_Preload constructor. |
| 59 |
*/ |
| 60 |
protected function __construct() { |
| 61 |
$can_load = true; |
| 62 |
// Set Base name plugin. |
| 63 |
define( 'LP_ADDON_IMPORT_EXPORT_BASENAME', plugin_basename( LP_ADDON_IMPORT_EXPORT_FILE ) ); |
| 64 |
|
| 65 |
// Set version addon for LP check . |
| 66 |
include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 67 |
self::$addon_info = get_file_data( |
| 68 |
LP_ADDON_IMPORT_EXPORT_FILE, |
| 69 |
array( |
| 70 |
'Name' => 'Plugin Name', |
| 71 |
'Require_LP_Version' => 'Require_LP_Version', |
| 72 |
'Version' => 'Version', |
| 73 |
) |
| 74 |
); |
| 75 |
|
| 76 |
define( 'LP_ADDON_IMPORT_EXPORT_VER', self::$addon_info['Version'] ); |
| 77 |
define( 'LP_ADDON_IMPORT_EXPORT_REQUIRE_VER', self::$addon_info['Require_LP_Version'] ); |
| 78 |
//Dirs and Urls |
| 79 |
define( 'LP_ADDON_IMPORT_EXPORT_URL', plugin_dir_url( __FILE__ ) ); |
| 80 |
define( 'LP_ADDON_IMPORT_EXPORT_DIR', plugin_dir_path( __FILE__ ) ); |
| 81 |
define( 'LP_ADDON_IMPORT_EXPORT_CONFIG_DIR', LP_ADDON_IMPORT_EXPORT_DIR . 'config/' ); |
| 82 |
define( 'LP_ADDON_IMPORT_EXPORT_VIEWS', LP_ADDON_IMPORT_EXPORT_DIR . 'views/' ); |
| 83 |
define( 'LP_ADDON_IMPORT_EXPORT_ASSETS_URL', LP_ADDON_IMPORT_EXPORT_URL . 'assets/' ); |
| 84 |
define( 'LP_ADDON_IMPORT_EXPORT_PATH', dirname( LP_ADDON_IMPORT_EXPORT_FILE ) ); |
| 85 |
define( 'LP_ADDON_IMPORT_EXPORT_INC', LP_ADDON_IMPORT_EXPORT_PATH . '/inc/' ); |
| 86 |
define( |
| 87 |
'LP_ADDON_IMPORT_EXPORT_FOLDER_ROOT_NAME', |
| 88 |
str_replace( |
| 89 |
array( '/', basename( __FILE__ ) ), |
| 90 |
'', |
| 91 |
plugin_basename( __FILE__ ) |
| 92 |
) |
| 93 |
); |
| 94 |
|
| 95 |
//Pages |
| 96 |
define( 'LP_ADDON_IMPORT_EXPORT_MIGRATION_PAGE', 'migration_page' ); |
| 97 |
|
| 98 |
//Keys |
| 99 |
define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_COURSE_CPT', 'courses' ); |
| 100 |
define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_COURSE_ENROLLED', 'tutor_enrolled' ); |
| 101 |
define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_TOPIC_CPT', 'topics' ); |
| 102 |
define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_LESSON_CPT', 'lesson' ); |
| 103 |
define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_QUIZ_CPT', 'tutor_quiz' ); |
| 104 |
define( 'LP_ADDON_IMPORT_EXPORT_TUTOR_ASSIGNMENT_CPT', 'tutor_assignments' ); |
| 105 |
|
| 106 |
// Check LP activated . |
| 107 |
if ( ! is_plugin_active( 'learnpress/learnpress.php' ) ) { |
| 108 |
$can_load = false; |
| 109 |
} elseif ( version_compare( LP_ADDON_IMPORT_EXPORT_REQUIRE_VER, get_option( 'learnpress_version', '3.0.0' ), '>' ) ) { |
| 110 |
$can_load = false; |
| 111 |
} |
| 112 |
|
| 113 |
if ( ! $can_load ) { |
| 114 |
add_action( 'admin_notices', array( $this, 'show_note_errors_require_lp' ) ); |
| 115 |
deactivate_plugins( LP_ADDON_IMPORT_EXPORT_BASENAME ); |
| 116 |
|
| 117 |
if ( isset( $_GET['activate'] ) ) { |
| 118 |
unset( $_GET['activate'] ); |
| 119 |
} |
| 120 |
|
| 121 |
return; |
| 122 |
} |
| 123 |
|
| 124 |
// Sure LP loaded. |
| 125 |
add_action( 'learn-press/ready', array( $this, 'load' ) ); |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* Load addon |
| 130 |
*/ |
| 131 |
public function load() { |
| 132 |
include_once 'inc/load.php'; |
| 133 |
self::$addon = LP_Addon_Import_Export::instance(); |
| 134 |
|
| 135 |
require_once 'vendor/autoload.php'; |
| 136 |
|
| 137 |
include_once LP_PLUGIN_PATH . 'inc/admin/editor/class-lp-admin-editor.php'; |
| 138 |
include_once LP_PLUGIN_PATH . 'inc/curds/class-lp-course-curd.php'; |
| 139 |
include_once LP_PLUGIN_PATH . 'inc/curds/class-lp-section-curd.php'; |
| 140 |
include_once LP_PLUGIN_PATH . 'inc/curds/class-lp-question-curd.php'; |
| 141 |
|
| 142 |
new EnqueueScriptsController(); |
| 143 |
new AdminMenuController(); |
| 144 |
|
| 145 |
if ( Plugin::is_tutor_active() ) { |
| 146 |
new TutorMigrationController(); |
| 147 |
new MigrationPopupController(); |
| 148 |
} |
| 149 |
|
| 150 |
if ( Plugin::is_learndash_active() ) { |
| 151 |
new LearnDashMigrationController(); |
| 152 |
new MigrationPopupController(); |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
public function show_note_errors_require_lp() { |
| 157 |
?> |
| 158 |
<div class="notice notice-error"> |
| 159 |
<p> |
| 160 |
<?php |
| 161 |
printf( |
| 162 |
'Please active <strong>LearnPress version %1$s or later</strong> before active <strong>%2$s</strong>', |
| 163 |
LP_ADDON_IMPORT_EXPORT_REQUIRE_VER, |
| 164 |
self::$addon_info['Name'] |
| 165 |
); |
| 166 |
?> |
| 167 |
</p> |
| 168 |
</div> |
| 169 |
<?php |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
LP_Addon_Import_Export_Preload::instance(); |
| 174 |
|
| 175 |
|