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 / easy-code-manager.class.php

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

371 lines 7.7 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 // Disallow direct access.
7 defined( 'ABSPATH' ) or die( 'Access denied' );
8
9
10
11 /** Change active profile to development state */
12 define( 'CJTOOLBOX_PROFILE_DEVELOPMENT', 'development' );
13
14 /** Change active profile to production state */
15 define( 'CJTOOLBOX_PROFILE_PRODUCTION', 'production' );
16
17 /** Set development state */
18 define(
19 'CJTOOLBOX_ACTIVE_PROFILE',
20 getenv('ecm-active-profile') ?
21 getenv('ecm-active-profile') :
22 CJTOOLBOX_PROFILE_PRODUCTION
23 );
24
25 define(
26 'CJTOOLBOX_ACTIVE_SERVICES_API_PROFILE',
27 getenv('ecm-active-services-api-profile') ?
28 getenv('ecm-active-services-api-profile') :
29 CJTOOLBOX_PROFILE_PRODUCTION
30 );
31
32 /** MVC library framework */
33 define( 'CJTOOLBOX_MVC_FRAMEWOK', CJTOOLBOX_INCLUDE_PATH . '/mvc' );
34
35 /** Models dir path */
36 define( 'CJTOOLBOX_MODELS_PATH', CJTOOLBOX_PATH . '/models' );
37
38 /** Tables dir path */
39 define( 'CJTOOLBOX_TABLES_PATH', CJTOOLBOX_PATH . '/tables' );
40
41 /** Models views path */
42 define( 'CJTOOLBOX_VIEWS_PATH', CJTOOLBOX_PATH . '/views' );
43
44 /** Views controllers path */
45 define( 'CJTOOLBOX_CONTROLLERS_PATH', CJTOOLBOX_PATH . '/controllers' );
46
47 /** URI to CJT Plugin dir */
48 define( 'CJTOOLBOX_URL', WP_PLUGIN_URL . '/' . CJTOOLBOX_NAME );
49
50 /** URI to CJT Views directory */
51 define( 'CJTOOLBOX_VIEWS_URL', CJTOOLBOX_URL . '/views' );
52
53 /** HTML Components URI */
54 define( 'CJTOOLBOX_HTML_CONPONENTS_URL', CJTOOLBOX_URL . '/framework/html/components' );
55
56 /**
57 * CJT Core class.
58 *
59 * @package CJT
60 * @author Original Developer
61 * @version 0.3
62 */
63 class cssJSToolbox extends CJTHookableClass
64 {
65
66 /**
67 *
68 */
69 const CJT_WEB_SITE_DOMAIN = 'easy-code-manager.com';
70
71 /**
72 * put your comment there...
73 *
74 * @todo remove this and use configuration instead
75 *
76 * @var mixed
77 */
78 public static $config = null;
79
80 /**
81 * put your comment there...
82 *
83 * @var mixed
84 */
85 private $dbDriver;
86
87 /**
88 * Reference of CJT Plugin object.
89 *
90 * @var cssJSToolbox
91 */
92 public static $instance = null;
93
94 /**
95 * put your comment there...
96 *
97 * @var mixed
98 */
99 protected static $ongettext = array( 'parameters' => array( 'text' ) );
100
101 /**
102 * put your comment there...
103 *
104 * @var mixed
105 */
106 protected static $onimport = array( 'parameters' => array( 'vpaths' ) );
107
108 /**
109 * put your comment there...
110 *
111 * @var mixed
112 */
113 protected static $oninstantiate = array( 'parameters' => array( 'instance' ) );
114
115 /**
116 * put your comment there...
117 *
118 * @var mixed
119 */
120 protected $onloadconfiguration = array( 'parameters' => array( 'configuration' ) );
121
122 /**
123 * put your comment there...
124 *
125 * @var mixed
126 */
127 protected $onloaddbdriver = array( 'parameters' => array( 'dbdriver' ) );
128
129 /**
130 * put your comment there...
131 *
132 * @var mixed
133 */
134 protected static $onresolvepath = array( 'parameters' => array( 'path', 'vpath' ) );
135
136 /**
137 * put your comment there...
138 *
139 * @param mixed $text
140 */
141 public static function __( $text )
142 {
143
144 // Get formats as single args
145 $args = func_get_args();
146 array_shift($args);
147
148 $localTxt = self::getText($text);
149
150 // Return formatted text
151 if (!empty($args))
152 {
153
154 // Shift localized text into first array items
155 array_unshift($args, $localTxt);
156
157 // Replacements
158 $localTxt = call_user_func_array('sprintf', $args);
159 }
160
161 return $localTxt;
162 }
163
164 /**
165 * Initialize Plugin.
166 *
167 * @return void
168 */
169 protected function __construct()
170 {
171
172 parent::__construct();
173
174 // When in development stage display everything
175 if ((CJTOOLBOX_ACTIVE_PROFILE == CJTOOLBOX_PROFILE_DEVELOPMENT) &&
176 defined('WP_DEBUG') &&
177 WP_DEBUG)
178 {
179 ini_set('error_reporting', E_ALL);
180 ini_set('display_errors', 'On');
181 }
182
183 // Load configuration.
184 self::$config = $this->onloadconfiguration( require( self::resolvePath( 'configuration.inc.php' ) ) );
185
186 self::import( 'framework:db:mysql:queue-driver.inc.php' );
187
188 $this->dbDriver = $this->onloaddbdriver( new CJTMYSQLQueueDriver( $GLOBALS[ 'wpdb' ] ) );
189 }
190
191 /**
192 * put your comment there...
193 *
194 */
195 public static function getCJTWebSiteURL( $path = null )
196 {
197 $domain = self::CJT_WEB_SITE_DOMAIN;
198
199 return "https://{$domain}/{$path}";
200 }
201
202 /**
203 * put your comment there...
204 *
205 * @returns CJTMYSQLQueueDriver
206 */
207 public function & getDBDriver()
208 {
209 return $this->dbDriver;
210 }
211
212 /**
213 * put your comment there...
214 *
215 */
216 public function getPluginTitles()
217 {
218
219 static $pluginTitles;
220
221 if (!$pluginTitles)
222 {
223 $pluginTitles = array
224 (
225 cssJSToolbox::__('Easy Code Manager'),
226 cssJSToolbox::__('ECM')
227 );
228 }
229
230 return $pluginTitles;
231 }
232
233 /**
234 * Get CJT Plugin object.
235 *
236 * @return cssJSToolbox
237 */
238 public static function & getInstance()
239 {
240
241 if ( ! self::$instance )
242 {
243 self::$instance = self::trigger( 'cssJSToolbox.instantiate', ( new cssJSToolbox() ) );
244 }
245
246 return self::$instance;
247 }
248
249 /**
250 * put your comment there...
251 *
252 */
253 public static function getSecurityToken()
254 {
255 return wp_create_nonce( CJTController::NONCE_ACTION );
256 }
257
258 /**
259 * put your comment there...
260 *
261 */
262 public function getServiesClientAPI()
263 {
264 // Services API Address would be Local in Development
265 // ,and CJT Web Site on Production
266 $apiUrl = ( CJTOOLBOX_ACTIVE_SERVICES_API_PROFILE == CJTOOLBOX_PROFILE_PRODUCTION) ?
267 self::getCJTWebSiteURL() :
268 home_url();
269
270 return CJTServicesClient::getInstance($apiUrl);
271 }
272
273 /**
274 * put your comment there...
275 *
276 * @param mixed $text
277 */
278 private static function getText( $text )
279 {
280 // Make sure to don't use $this while calling!
281 // $this might be an object other than CssJSToolbox!
282 return self::__callStatic( 'cssJSToolbox.ongettext', array( __( $text, CJTOOLBOX_TEXT_DOMAIN ) ) );
283 }
284
285 /**
286 * put your comment there...
287 *
288 * @param mixed $path
289 */
290 public static function getURI( $vPath, $uriBase = null )
291 {
292 // PHP wrapper however its not imlpemented as wrapper yet
293 // because this is not the point right now!
294 if ( strpos( $vPath, 'extension://' ) === 0)
295 {
296 // Expression for getting plugin/extension name!
297 $exp = '/^extension\:\/\/([^\/]+)/';
298 preg_match( $exp, $vPath, $extensionPath );
299
300 // Get base URI + removing extension:// wrapper!
301 $uriBase = plugins_url( $extensionPath[ 1 ] );
302
303 $uri = self::getURI( preg_replace( $exp, '', $vPath ), $uriBase );
304
305 }
306 else
307 {
308 // Translate Virtual path to real path.
309 $path = str_replace( ':', '/', $vPath );
310
311 // Get full URI.
312 if ( ! isset( $uriBase ) )
313 {
314
315 $uriBase = plugin_dir_url( __FILE__ );
316
317 }
318
319 $uri = "{$uriBase}{$path}";
320 }
321
322 return $uri;
323 }
324
325 /**
326 * put your comment there...
327 *
328 */
329 public static function import()
330 {
331
332 $params = func_get_args();
333
334 // Allow vriables list parameters.
335 $vPaths = self::trigger( 'cssJSToolbox.import', $params );
336 foreach ( $vPaths as $vPath )
337 {
338 require_once self::resolvePath( $vPath );
339 }
340
341 }
342
343 /**
344 * put your comment there...
345 *
346 * @param mixed $vPath
347 * @param mixed $base
348 */
349 public static function resolvePath( $vPath, $base = CJTOOLBOX_PATH )
350 {
351 // Resolve CJT extensions path
352 if ( strpos( $vPath, 'extension://' ) === 0 )
353 {
354 // Remove extension wrapper
355 $vPath = str_replace( 'extension://', '', $vPath );
356
357 // Point to plugin directory
358 $base = WP_PLUGIN_DIR;
359
360 }
361 // Replace all :'s with /'s.
362 $path = str_replace( ':', '/', $vPath );
363 $path = "{$base}/{$path}";
364
365 return self::trigger( 'cssJSToolbox.resolvepath', $path, $vPath );
366 }
367
368 }// End Class
369
370 // Hookable!
371 cssJSToolbox::define( 'cssJSToolbox', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );