PluginProbe
Media Cloud Sync / 1.2.13
Media Cloud Sync v1.2.13
1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 All 34 releases
media-cloud-sync / includes / main.php

main.php in Media Cloud Sync 1.2.13, at includes/main.php

171 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS;
4
5
6 defined('ABSPATH') || exit;
7
8 /**
9 * Media Cloud Sync Plugin by Dudlewebs
10 *
11 * The main plugin handler class is responsible for initializing Plugin.
12 *
13 * @since 1.0.0
14 */
15 class Main {
16 /**
17 * Instance.
18 *
19 * Holds the plugin instance.
20 *
21 * @since 1.0.0
22 * @access public
23 * @static
24 *
25 * @var Plugin
26 */
27 public static $instance = null;
28
29 /**
30 * Plugin constructor.+
31 *
32 * Initializing plugin.
33 *
34 * @since 1.0.0
35 * @access private
36 */
37 private function __construct(){
38 $this->register_autoloader();
39 add_action('init', [$this, 'init'], 0);
40 add_action('rest_api_init', [$this, 'on_rest_api_init'], 9);
41
42 $adminInstance = Admin::instance();
43 // reg activation hook.
44 register_activation_hook(WPMCS_FILE, [$adminInstance, 'install']);
45 // reg deactivation hook.
46 register_deactivation_hook(WPMCS_FILE, [$adminInstance, 'deactivation']);
47 }
48
49 /**
50 * Register autoloader.
51 *
52 * Elementor autoloader loads all the classes needed to run the plugin.
53 *
54 * @since 1.6.0
55 * @access private
56 */
57 private function register_autoloader(){
58 require_once WPMCS_INCLUDES_PATH.'autoloader.php';
59
60 Autoloader::run();
61 }
62
63
64 /**
65 * Instance.
66 *
67 * Ensures only one instance of the plugin class is loaded or can be loaded.
68 *
69 * @return Plugin An instance of the class.
70 * @since 1.0.0
71 * @access public
72 * @static
73 *
74 */
75 public static function instance(){
76 if (is_null(self::$instance)) {
77 self::$instance = new self();
78 }
79
80 return self::$instance;
81 }
82
83 /**
84 * Init.
85 *
86 * Initialize Plugin. Register support for all the
87 * supported post types and initialize components.
88 *
89 * @since 1.0.0
90 * @access public
91 */
92 public function init(){
93 $this->init_components();
94 $this->init_services();
95 }
96
97 /**
98 * Init components.
99 *
100 * @since 1.0.0
101 * @access private
102 */
103 private function init_components(){
104 /**
105 * All backend API has to initiallize outside is_admin(), as REST URL is not part of wp_admin
106 */
107 Schema::init();
108 Api::instance();
109
110 Front::instance();
111
112 if (is_admin()) {
113 Admin::instance();
114 }
115 }
116
117 /**
118 * Init Services.
119 *
120 * @since 1.0.0
121 * @access private
122 */
123 public function init_services(){
124 Cdn::instance();
125 Cache::instance();
126 Compatibility::instance();
127
128 // Integrations
129 Integration::instance();
130 FilterContent::instance();
131 }
132
133
134 /**
135 * @since 1.0.0
136 * @access public
137 */
138 public function on_rest_api_init(){
139 }
140
141 /**
142 * Clone.
143 *
144 * Disable class cloning and throw an error on object clone.
145 *
146 * The whole idea of the singleton design pattern is that there is a single
147 * object. Therefore, we don't want the object to be cloned.
148 *
149 * @access public
150 * @since 1.0.0
151 */
152 public function __clone(){
153 // Cloning instances of the class is forbidden.
154 _doing_it_wrong(__FUNCTION__, esc_html__('Something went wrong.', 'media-cloud-sync'), '1.0.0');
155 }
156
157 /**
158 * Wakeup.
159 *
160 * Disable unserializing of the class.
161 *
162 * @access public
163 * @since 1.0.0
164 */
165 public function __wakeup(){
166 // Unserializing instances of the class is forbidden.
167 _doing_it_wrong(__FUNCTION__, esc_html__('Something went wrong.', 'media-cloud-sync'), '1.0.0');
168 }
169 }
170
171 Main::instance();