| 1 |
<?php |
| 2 |
|
| 3 |
namespace ElementorOne; |
| 4 |
|
| 5 |
use ElementorOne\Admin\Config; |
| 6 |
use ElementorOne\Connect\Facade; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Class \ElementorOne\Loader |
| 14 |
*/ |
| 15 |
class Loader { |
| 16 |
|
| 17 |
/** |
| 18 |
* Initialize the loader. |
| 19 |
* @return void |
| 20 |
*/ |
| 21 |
public static function init(): void { |
| 22 |
/** |
| 23 |
* Fires in the early stages of Elementor One init hook. |
| 24 |
*/ |
| 25 |
do_action( 'elementor_one/pre_init' ); |
| 26 |
|
| 27 |
self::define_constants(); |
| 28 |
self::initialize_connect(); |
| 29 |
self::initialize_services(); |
| 30 |
self::initialize_components(); |
| 31 |
self::initialize_controllers(); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Initialize the Connect facade with configuration. |
| 36 |
* |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
private static function initialize_connect(): void { |
| 40 |
Facade::make( [ |
| 41 |
'app_name' => Config::APP_NAME, |
| 42 |
'app_prefix' => Config::APP_PREFIX, |
| 43 |
'app_rest_namespace' => Config::APP_REST_NAMESPACE, |
| 44 |
'admin_page' => Config::ADMIN_PAGE, |
| 45 |
'base_url' => Config::BASE_URL, |
| 46 |
'app_type' => Config::APP_TYPE, |
| 47 |
'plugin_slug' => Config::PLUGIN_SLUG, |
| 48 |
'scopes' => Config::SCOPES, |
| 49 |
'connect_mode' => Config::CONNECT_MODE, |
| 50 |
'state_nonce' => Config::STATE_NONCE, |
| 51 |
] ); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Initialize all services. |
| 56 |
* |
| 57 |
* @return void |
| 58 |
*/ |
| 59 |
private static function initialize_services(): void { |
| 60 |
\ElementorOne\Admin\Services\Editor::instance(); |
| 61 |
\ElementorOne\Admin\Services\Migration::instance(); |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Initialize all components. |
| 66 |
* |
| 67 |
* @return void |
| 68 |
*/ |
| 69 |
private static function initialize_components(): void { |
| 70 |
\ElementorOne\Admin\Components\Page::instance(); |
| 71 |
\ElementorOne\Admin\Components\Assets::instance(); |
| 72 |
\ElementorOne\Admin\Components\Fields::instance(); |
| 73 |
\ElementorOne\Admin\Components\Onboarding::instance(); |
| 74 |
\ElementorOne\Admin\Components\EditorUpdateNotification::instance(); |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Initialize all REST controllers. |
| 79 |
* |
| 80 |
* @return void |
| 81 |
*/ |
| 82 |
private static function initialize_controllers(): void { |
| 83 |
new \ElementorOne\Admin\Controllers\TopBar(); |
| 84 |
new \ElementorOne\Admin\Controllers\Themes(); |
| 85 |
new \ElementorOne\Admin\Controllers\Plugins(); |
| 86 |
new \ElementorOne\Admin\Controllers\Settings(); |
| 87 |
} |
| 88 |
|
| 89 |
/** |
| 90 |
* Define constants |
| 91 |
* @return void |
| 92 |
*/ |
| 93 |
public static function define_constants(): void { |
| 94 |
if ( ! defined( 'ELEMENTOR_ONE_ASSETS_URL' ) && function_exists( 'plugin_dir_url' ) ) { |
| 95 |
define( 'ELEMENTOR_ONE_ASSETS_URL', plugin_dir_url( __DIR__ ) . 'assets/build/' ); |
| 96 |
} |
| 97 |
|
| 98 |
if ( ! defined( 'ELEMENTOR_ONE_ASSETS_PATH' ) && function_exists( 'plugin_dir_path' ) ) { |
| 99 |
define( 'ELEMENTOR_ONE_ASSETS_PATH', plugin_dir_path( __DIR__ ) . 'assets/build/' ); |
| 100 |
} |
| 101 |
|
| 102 |
if ( ! defined( 'ELEMENTOR_ONE_UI_ASSETS_ROOT_URL' ) && function_exists( 'plugin_dir_url' ) ) { |
| 103 |
define( 'ELEMENTOR_ONE_UI_ASSETS_ROOT_URL', plugin_dir_url( __DIR__ ) . 'assets/elementor-home/' ); |
| 104 |
} |
| 105 |
|
| 106 |
if ( ! defined( 'ELEMENTOR_ONE_CLIENT_APP_URL' ) ) { |
| 107 |
define( 'ELEMENTOR_ONE_CLIENT_APP_URL', ELEMENTOR_ONE_UI_ASSETS_ROOT_URL . 'client.js' ); |
| 108 |
} |
| 109 |
} |
| 110 |
} |
| 111 |
|