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

388 lines 9.5 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 // CODE ADDED BY RBJ -- START
183 // Checks if the version stored in DB matches current version
184 // of the plugin.
185 if ( !$this->installed ) {
186 update_option( self::DB_VERSION_OPTION_NAME, self::DB_VERSION );
187 }
188 // CODE ADDED BY RBJ -- END
189
190 // Load plugin and all installed extensions!.
191 $this->load();
192 $this->loadExtensions();
193
194 // Run MAIN access point!
195 $this->main();
196 }
197
198 /**
199 * put your comment there...
200 *
201 */
202 public function & extensions()
203 {
204 return $this->extensions;
205 }
206
207 /**
208 * put your comment there...
209 *
210 */
211 public function getAccessPoint( $name )
212 {
213 return $this->accessPoints[ $name ];
214 }
215
216 /**
217 * put your comment there...
218 *
219 */
220 public static function getInstance()
221 {
222
223 if ( ! self::$instance )
224 {
225 self::$instance = new CJTPlugin();
226 }
227
228 return self::$instance;
229 }
230
231 /**
232 * put your comment there...
233 *
234 */
235 public static function isCompatibleEnvironment()
236 {
237
238 if ( version_compare( PHP_VERSION, self::ENV_PHP_MIN_VERSION, '<' ) )
239 {
240
241 // In all cases that we'll process the request load the localization file.
242 load_plugin_textdomain( CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES );
243
244 $importHTMLFileCode = 'require "includes" . DIRECTORY_SEPARATOR . "html" . DIRECTORY_SEPARATOR . "incompatible_environment_message.html.php";';
245
246 add_action( 'admin_notices', create_function( '', $importHTMLFileCode ) );
247 add_action( 'network_admin_notices', create_function( '', $importHTMLFileCode ) );
248
249 return false;
250 }
251
252 return true;
253 }
254 /**
255 * put your comment there...
256 *
257 */
258 public function isInstalled()
259 {
260
261 $installed = apply_filters(CJTPluggableHelper::FILTER_INSTALLER_STATUS, $this->installed);
262
263 return $installed;
264 }
265
266 /**
267 * put your comment there...
268 *
269 */
270 public function listen()
271 {
272 // For now we've only admin access points! Future versions might has something changed!
273 if ( is_admin() )
274 {
275
276 $accessPoints = array
277 (
278 'ajax' => new CJTAjaxAccessPoint(),
279 'autoupgrade' => new CJTAutoUpgradeAccessPoint(),
280 'dashboardmetabox' => new CJTDashboardMetaboxAccessPoint(),
281 'extensions' => new CJTExtensionsAccessPoint(),
282 'installer' => new CJTInstallerAccessPoint(),
283 'manage' => new CJTManageAccessPoint(),
284 );
285
286 $accessPoints = apply_filters(CJTPluggableHelper::FILTER_ACCESS_POINTS, $accessPoints);
287
288 // For every access point create instance and LISTEN to the request!
289 foreach ( $accessPoints as $name => $accessPoint )
290 {
291 /**
292 * @var CJTAccessPoint
293 */
294 $this->accessPoints[ $name ] = $accessPoint->listen();
295
296 // We need to do some work when any access point is connected
297 $accessPoint->onconnected = array( & $this, 'onconnected' );
298
299 }
300
301 }
302
303 return $this;
304 }
305
306 /**
307 * put your comment there...
308 *
309 */
310 protected function load()
311 {
312 // Bootstrap the Plugin!
313 cssJSToolbox::getInstance();
314
315 // Load MVC framework core!
316 require_once $this->onimportmodel( CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php' );
317 require_once $this->onimportcontroller( CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php' );
318
319 return $this;
320 }
321
322 /**
323 * put your comment there...
324 *
325 */
326 protected function loadExtensions()
327 {
328 // Load extensions lib!
329 require_once CJTOOLBOX_INCLUDE_PATH . '/extensions/extensions.class.php';
330
331 $this->extensions = new CJTExtensions();
332 $this->extensions->load();
333
334 return $this;
335 }
336
337 /**
338 * Run MAIN access point!
339 *
340 * @return $this
341 */
342 protected function main()
343 {
344 // Fire laod event
345 $this->onload( $this );
346
347 // Access point base class is a dependency!
348 require_once CJTOOLBOX_INCLUDE_PATH . '/access-points/access-point.class.php';
349
350 // Run Main Acces Point!
351 include_once __DIR__ . DIRECTORY_SEPARATOR . 'access.points/main.accesspoint.php';
352
353 $this->mainAC = new CJTMainAccessPoint();
354 $this->mainAC->listen();
355 }
356
357 /**
358 * Called When any In-Listen-State (ILS) Access point is
359 * connected (called by Wordpress hooking system).
360 *
361 * @return boolean TRUE.
362 */
363 public function onconnected( $observer, $state )
364 {
365
366 // In all cases that we'll process the request load the localization file.
367 load_plugin_textdomain( CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES );
368
369 do_action( CJTPluggableHelper::ACTION_CJT_TEXT_DOMAIN_LOADED );
370
371 // Always connet the access point!
372 return $state;
373
374 }
375
376 }// End Class
377
378 // Dont run if environment (e.g PHP version) is incomaptible
379 if ( ! CJTPlugin::isCompatibleEnvironment() )
380 {
381 return;
382 }
383
384 // Initialize events!
385 CJTPlugin::define( 'CJTPlugin', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );
386
387 // Let's Go!
388 CJTPlugin::getInstance();