-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp-integrator-x.php
More file actions
144 lines (121 loc) · 3.58 KB
/
Copy pathwp-integrator-x.php
File metadata and controls
144 lines (121 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
* Plugin Name: WP Integrator X
* Description: Advanced integrations, background jobs, and APIs for WordPress.
* Requires at least: 6.1
* Requires PHP: 7.4
* Version: 0.1.0
* Author: Mohamed Salah
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-integrator-x
*
* @package create-block
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Support for site-level autoloading.
if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
require_once __DIR__ . '/vendor/autoload.php';
}
// Custom autoloader for plugin services that aren't picked up by composer
spl_autoload_register(
function ( $class_name ) {
// Only handle our plugin's classes
if ( strpos( $class_name, 'WP_Integrator_X\\Services\\' ) === 0 ) {
$class_file = str_replace( 'WP_Integrator_X\\Services\\', '', $class_name );
$class_file = str_replace( '_', '-', strtolower( $class_file ) );
$file_path = __DIR__ . '/app/services/class-' . $class_file . '.php';
if ( file_exists( $file_path ) ) {
require_once $file_path;
}
}
// Handle admin pages
if ( strpos( $class_name, 'WP_Integrator_X\\App\\Admin_Pages\\' ) === 0 ) {
$class_file = str_replace( 'WP_Integrator_X\\App\\Admin_Pages\\', '', $class_name );
$class_file = str_replace( '_', '-', strtolower( $class_file ) );
$file_path = __DIR__ . '/app/admin-pages/class-' . $class_file . '.php';
if ( file_exists( $file_path ) ) {
require_once $file_path;
}
}
// Handle CLI commands
if ( strpos( $class_name, 'WP_Integrator_X\\App\\CLI\\' ) === 0 ) {
$class_file = str_replace( 'WP_Integrator_X\\App\\CLI\\', '', $class_name );
$class_file = str_replace( '_', '-', strtolower( $class_file ) );
$file_path = __DIR__ . '/app/cli/class-' . $class_file . '.php';
if ( file_exists( $file_path ) ) {
require_once $file_path;
}
}
}
);
// Plugin version.
if ( ! defined( 'WP_INTEGRATOR_X_VERSION' ) ) {
define( 'WP_INTEGRATOR_X_VERSION', '1.0.0' );
}
// Define WP_INTEGRATOR_X_PLUGIN_FILE.
if ( ! defined( 'WP_INTEGRATOR_X_PLUGIN_FILE' ) ) {
define( 'WP_INTEGRATOR_X_PLUGIN_FILE', __FILE__ );
}
// Plugin directory.
if ( ! defined( 'WP_INTEGRATOR_X_DIR' ) ) {
define( 'WP_INTEGRATOR_X_DIR', plugin_dir_path( __FILE__ ) );
}
// Plugin url.
if ( ! defined( 'WP_INTEGRATOR_X_URL' ) ) {
define( 'WP_INTEGRATOR_X_URL', plugin_dir_url( __FILE__ ) );
}
// Assets url.
if ( ! defined( 'WP_INTEGRATOR_X_ASSETS_URL' ) ) {
define( 'WP_INTEGRATOR_X_ASSETS_URL', WP_INTEGRATOR_X_URL . '/assets' );
}
// Shared UI Version.
if ( ! defined( 'WP_INTEGRATOR_X_SUI_VERSION' ) ) {
define( 'WP_INTEGRATOR_X_SUI_VERSION', '2.12.23' );
}
/**
* WP_Integrator_X class.
*/
class WP_Integrator_X {
/**
* Holds the class instance.
*
* @var WP_Integrator_X $instance
*/
private static $instance = null;
/**
* Return an instance of the class
*
* Return an instance of the WP_Integrator_X Class.
*
* @return WP_Integrator_X class instance.
* @since 1.0.0
*/
public static function get_instance() {
if ( null === self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Class initializer.
*/
public function load() {
load_plugin_textdomain(
'wp-integrator-x',
false,
dirname( plugin_basename( __FILE__ ) ) . '/languages'
);
WP_Integrator_X\Core\Loader::instance();
}
}
// Init the plugin and load the plugin instance for the first time.
add_action(
'init',
function () {
WP_Integrator_X::get_instance()->load();
},
9
);