PluginProbe
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager / 10
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager v10
10.56 1.2.1 10 10.1 10.2 10.3 10.31 10.32 10.33 10.34 10.50 10.51 10.52 10.53 10.55 9.0 9.0.1 9.4 trunk 1.0.0 1.1 1.2
easy-code-manager / Plugin.class.php

Plugin.class.php in FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager 10, at Plugin.class.php

382 lines 9.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 *
4 */
5
6 defined('ABSPATH') or die(-1);
7
8 /** * */
9 define( 'CJTOOLBOX_PLUGIN_BASE', basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) );
10
11 /** * */
12 define( 'CJTOOLBOX_PLUGIN_FILE', ECMCI::FILE );
13
14 /** CJT Name */
15 define( 'CJTOOLBOX_NAME', plugin_basename( dirname( __FILE__ ) ) );
16
17 /** CJT Text Domain used for localize texts */
18 define( 'CJTOOLBOX_TEXT_DOMAIN', CJTOOLBOX_NAME );
19
20 /** */
21 define( 'CJTOOLBOX_LANGUAGES', CJTOOLBOX_NAME . '/locals/languages/' );
22
23 /** CJT Absoulte path */
24 define( 'CJTOOLBOX_PATH', dirname( __FILE__ ) );
25
26 /** Dont use!! @deprecated */
27 define( 'CJTOOLBOX_INCLUDE_PATH', CJTOOLBOX_PATH . '/framework' );
28
29 /** Access Points path */
30 define( 'CJTOOLBOX_ACCESS_POINTS', CJTOOLBOX_PATH . '/access.points' );
31
32 /** Frmaework path */
33 define('CJTOOLBOX_FRAMEWORK', CJTOOLBOX_INCLUDE_PATH); // Alias to include path!
34
35 define( 'ECM_MEDIA_URL', plugin_dir_url( __FILE__ ) . 'media/' );
36
37 // Import dependencies
38 require_once CJTOOLBOX_FRAMEWORK . '/php/includes.class.php';
39 require_once CJTOOLBOX_FRAMEWORK . '/events/definition.class.php';
40 require_once CJTOOLBOX_FRAMEWORK . '/events/events.class.php';
41 require_once CJTOOLBOX_FRAMEWORK . '/events/wordpress.class.php';
42 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.interface.php';
43 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.class.php';
44
45 // Initialize events engine/system!
46 CJTWordpressEvents::__init( array( 'hookType' => CJTWordpressEvents::HOOK_ACTION ) );
47 CJTWordpressEvents::$paths[ 'subjects' ][ 'core' ] = CJTOOLBOX_FRAMEWORK . '/events/subjects';
48 CJTWordpressEvents::$paths[ 'observers' ][ 'core' ] = CJTOOLBOX_FRAMEWORK . '/events/observers';
49
50 /**
51 * CJT Plugin interface.
52 *
53 * The CJT Plugin is maximum deferred.
54 * All functionality here is just to detect if the request should be processed!
55 *
56 * The main class is located css-js-toolbox.class.php cssJSToolbox class
57 * The plugin is fully developed using Model-View-Controller design pattern.
58 *
59 * access.points directory has all the entry points that processed by the Plugin.
60 *
61 * @package CJT
62 * @author Ahmed Said
63 * @version 6
64 */
65 class CJTPlugin extends CJTHookableClass
66 {
67
68 /**
69 *
70 */
71 const DB_VERSION = ECMCI::VERSION;
72
73 /**
74 * put your comment there...
75 *
76 * @var mixed
77 */
78 CONST ENV_PHP_MIN_VERSION = '5.3';
79
80 /**
81 *
82 */
83 const FW_Version = '4.0';
84
85 /**
86 *
87 */
88 const VERSION = '10';
89
90 /**
91 *
92 */
93 const DB_VERSION_OPTION_NAME = ECMCI::DB_VERSION_OPTION_NAME;
94
95 /**
96 *
97 */
98 const PLUGIN_REQUEST_ID = 'ecm';
99
100 /**
101 * put your comment there...
102 *
103 * @var mixed
104 */
105 protected $accessPoints;
106
107 /**
108 * put your comment there...
109 *
110 * @var mixed
111 */
112 protected $extensions;
113
114 /**
115 * put your comment there...
116 *
117 * @var mixed
118 */
119 protected $installed;
120
121 /**
122 * put your comment there...
123 *
124 * @var CJTPlugin
125 */
126 protected static $instance;
127
128 /**
129 * put your comment there...
130 *
131 * @var mixed
132 */
133 protected $mainAC;
134
135 /**
136 * put your comment there...
137 *
138 * @var mixed
139 */
140 protected $onloaddbversion = array( 'parameters' => array( 'dbVersion' ) );
141
142 /**
143 * put your comment there...
144 *
145 * @var mixed
146 */
147 protected $onimportcontroller = array( 'parameters' => array( 'file' ) );
148
149 /**
150 * put your comment there...
151 *
152 * @var mixed
153 */
154 protected $onimportmodel = array( 'parameters' => array( 'file' ) );
155
156 /**
157 * put your comment there...
158 *
159 * @var mixed
160 */
161 protected $onload = array( 'parameters' => array( 'instance' ) );
162
163 /**
164 * put your comment there...
165 *
166 */
167 protected function __construct()
168 {
169
170 // Class Autoload Added @since 6.2.
171 require __DIR__ . DIRECTORY_SEPARATOR . 'autoload.inc.php';
172
173 // Hookable!
174 parent::__construct();
175
176 // Allow access points to utilize from CJTPlugin functionality
177 // even if the call is recursive inside getInstance/construct methods!!!
178 self::$instance = $this;
179
180 // Installation version
181 $dbVersion = $this->onloaddbversion( get_option( self::DB_VERSION_OPTION_NAME ) );
182 $this->installed = ( ( $dbVersion ) == self::DB_VERSION );
183
184 // Load plugin and all installed extensions!.
185 $this->load();
186 $this->loadExtensions();
187
188 // Run MAIN access point!
189 $this->main();
190 }
191
192 /**
193 * put your comment there...
194 *
195 */
196 public function & extensions()
197 {
198 return $this->extensions;
199 }
200
201 /**
202 * put your comment there...
203 *
204 */
205 public function getAccessPoint( $name )
206 {
207 return $this->accessPoints[ $name ];
208 }
209
210 /**
211 * put your comment there...
212 *
213 */
214 public static function getInstance()
215 {
216
217 if ( ! self::$instance )
218 {
219 self::$instance = new CJTPlugin();
220 }
221
222 return self::$instance;
223 }
224
225 /**
226 * put your comment there...
227 *
228 */
229 public static function isCompatibleEnvironment()
230 {
231
232 if ( version_compare( PHP_VERSION, self::ENV_PHP_MIN_VERSION, '<' ) )
233 {
234
235 // In all cases that we'll process the request load the localization file.
236 load_plugin_textdomain( CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES );
237
238 $importHTMLFileCode = 'require "includes" . DIRECTORY_SEPARATOR . "html" . DIRECTORY_SEPARATOR . "incompatible_environment_message.html.php";';
239
240 add_action( 'admin_notices', create_function( '', $importHTMLFileCode ) );
241 add_action( 'network_admin_notices', create_function( '', $importHTMLFileCode ) );
242
243 return false;
244 }
245
246 return true;
247 }
248 /**
249 * put your comment there...
250 *
251 */
252 public function isInstalled()
253 {
254
255 $installed = apply_filters(CJTPluggableHelper::FILTER_INSTALLER_STATUS, $this->installed);
256
257 return $installed;
258 }
259
260 /**
261 * put your comment there...
262 *
263 */
264 public function listen()
265 {
266 // For now we've only admin access points! Future versions might has something changed!
267 if ( is_admin() )
268 {
269
270 $accessPoints = array
271 (
272 'ajax' => new CJTAjaxAccessPoint(),
273 'autoupgrade' => new CJTAutoUpgradeAccessPoint(),
274 'dashboardmetabox' => new CJTDashboardMetaboxAccessPoint(),
275 'extensions' => new CJTExtensionsAccessPoint(),
276 'installer' => new CJTInstallerAccessPoint(),
277 'manage' => new CJTManageAccessPoint(),
278 );
279
280 $accessPoints = apply_filters(CJTPluggableHelper::FILTER_ACCESS_POINTS, $accessPoints);
281
282 // For every access point create instance and LISTEN to the request!
283 foreach ( $accessPoints as $name => $accessPoint )
284 {
285 /**
286 * @var CJTAccessPoint
287 */
288 $this->accessPoints[ $name ] = $accessPoint->listen();
289
290 // We need to do some work when any access point is connected
291 $accessPoint->onconnected = array( & $this, 'onconnected' );
292
293 }
294
295 }
296
297 return $this;
298 }
299
300 /**
301 * put your comment there...
302 *
303 */
304 protected function load()
305 {
306 // Bootstrap the Plugin!
307 cssJSToolbox::getInstance();
308
309 // Load MVC framework core!
310 require_once $this->onimportmodel( CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php' );
311 require_once $this->onimportcontroller( CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php' );
312
313 return $this;
314 }
315
316 /**
317 * put your comment there...
318 *
319 */
320 protected function loadExtensions()
321 {
322 // Load extensions lib!
323 require_once CJTOOLBOX_INCLUDE_PATH . '/extensions/extensions.class.php';
324
325 $this->extensions = new CJTExtensions();
326 $this->extensions->load();
327
328 return $this;
329 }
330
331 /**
332 * Run MAIN access point!
333 *
334 * @return $this
335 */
336 protected function main()
337 {
338 // Fire laod event
339 $this->onload( $this );
340
341 // Access point base class is a dependency!
342 require_once CJTOOLBOX_INCLUDE_PATH . '/access-points/access-point.class.php';
343
344 // Run Main Acces Point!
345 include_once __DIR__ . DIRECTORY_SEPARATOR . 'access.points/main.accesspoint.php';
346
347 $this->mainAC = new CJTMainAccessPoint();
348 $this->mainAC->listen();
349 }
350
351 /**
352 * Called When any In-Listen-State (ILS) Access point is
353 * connected (called by Wordpress hooking system).
354 *
355 * @return boolean TRUE.
356 */
357 public function onconnected( $observer, $state )
358 {
359
360 // In all cases that we'll process the request load the localization file.
361 load_plugin_textdomain( CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES );
362
363 do_action( CJTPluggableHelper::ACTION_CJT_TEXT_DOMAIN_LOADED );
364
365 // Always connet the access point!
366 return $state;
367
368 }
369
370 }// End Class
371
372 // Dont run if environment (e.g PHP version) is incomaptible
373 if ( ! CJTPlugin::isCompatibleEnvironment() )
374 {
375 return;
376 }
377
378 // Initialize events!
379 CJTPlugin::define( 'CJTPlugin', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );
380
381 // Let's Go!
382 CJTPlugin::getInstance();