PluginProbe
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager / 1.2.1
FluentSnippets – High-Performance Code Snippets, Header & Footer Code, Custom CSS & PHP Code Manager v1.2.1
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 1.2.1, at Plugin.class.php

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