Skip to content

Commit da57497

Browse files
committed
Optimize: Manully include removed, using classmap for loading classes
1 parent fe82f76 commit da57497

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

classes/TutorLMSMigrationTool.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public function __construct() {
5454
add_filter( 'plugin_action_links_' . plugin_basename( TLMT_FILE ), array( $this, 'plugin_action_links' ) );
5555

5656
if ( $this->check_installed() ) {
57-
$this->includes();
5857
$this->used_classes();
5958
$this->classes_initialize();
6059
} else {
@@ -213,21 +212,6 @@ public function install_tutor_plugin() {
213212
die();
214213
}
215214

216-
/**
217-
* Includes.
218-
*
219-
* @return void
220-
*/
221-
public function includes() {
222-
include TLMT_PATH . 'classes/LPtoTutorMigration.php';
223-
include TLMT_PATH . 'classes/LDtoTutorMigration.php';
224-
if ( is_plugin_active( 'lifterlms/lifterlms.php' ) ) {
225-
include TLMT_PATH . 'classes/LIFtoTutorMigration.php';
226-
}
227-
include TLMT_PATH . 'classes/LDtoTutorExport.php';
228-
include TLMT_PATH . 'classes/Utils.php';
229-
}
230-
231215
/**
232216
* Used classed.
233217
*
@@ -239,7 +223,6 @@ public function used_classes() {
239223
if ( is_plugin_active( 'lifterlms/lifterlms.php' ) ) {
240224
$this->classes[] = 'LIFtoTutorMigration';
241225
}
242-
243226
}
244227

245228
/**

tutor-lms-migration-tool.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
require_once __DIR__ . '/vendor/autoload.php';
2323

24-
require 'classes/Dependency.php';
25-
2624
use TutorLMSMigrationTool\TLMT\Dependency;
2725

2826
/**
@@ -82,17 +80,18 @@ function tutor_migration_tool_deleted() {
8280

8381
register_uninstall_hook( __FILE__, 'tutor_migration_tool_deleted' );
8482

85-
if ( ! class_exists( 'TutorLMSMigrationTool' ) ) {
83+
TutorLMSMigrationTool::instance();
8684

87-
$dependency = new Dependency();
88-
if ( ! $dependency->is_tutor_core_has_req_verion() ) {
89-
add_action( 'admin_notices', array( $dependency, 'show_admin_notice' ) );
90-
return;
85+
add_action(
86+
'plugins_loaded',
87+
function() {
88+
$dependency = new Dependency();
89+
if ( ! $dependency->is_tutor_core_has_req_verion() ) {
90+
add_action( 'admin_notices', array( $dependency, 'show_admin_notice' ) );
91+
return;
92+
}
9193
}
92-
93-
include_once 'classes/TutorLMSMigrationTool.php';
94-
TutorLMSMigrationTool::instance();
95-
}
94+
);
9695

9796
if ( is_plugin_active( 'tutor/tutor.php' ) ) {
9897

0 commit comments

Comments
 (0)