PluginProbe
CSS & JavaScript Toolbox / 12.0.4
CSS & JavaScript Toolbox v12.0.4
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
← All changes | css-js-toolbox.class.php +162 -101 6.012.0.4 View file →
@@ -1,78 +1,81 @@
1 1 <?php
2 2 /**
3 -*
3 +*
4 4 */
5 5
6 6 // Disallow direct access.
7 -defined('ABSPATH') or die("Access denied");
7 +defined( 'ABSPATH' ) or die( 'Access denied' );
8 8
9 +
10 +
9 11 /** Change active profile to development state */
10 -define('CJTOOLBOX_PROFILE_DEVELOPMENT', 'development');
12 +define( 'CJTOOLBOX_PROFILE_DEVELOPMENT', 'development' );
11 13
12 14 /** Change active profile to production state */
13 -define('CJTOOLBOX_PROFILE_PRODUCTION', 'production');
15 +define( 'CJTOOLBOX_PROFILE_PRODUCTION', 'production' );
14 16
15 17 /** Set development state */
16 -define('CJTOOLBOX_ACTIVE_PROFILE', CJTOOLBOX_PROFILE_DEVELOPMENT);
18 +define( 'CJTOOLBOX_ACTIVE_PROFILE', CJTOOLBOX_PROFILE_DEVELOPMENT );
17 19
18 20 /** MVC library framework */
19 -define('CJTOOLBOX_MVC_FRAMEWOK', CJTOOLBOX_INCLUDE_PATH . '/mvc');
21 +define( 'CJTOOLBOX_MVC_FRAMEWOK', CJTOOLBOX_INCLUDE_PATH . '/mvc' );
20 22
21 23 /** Models dir path */
22 -define('CJTOOLBOX_MODELS_PATH', CJTOOLBOX_PATH . '/models');
24 +define( 'CJTOOLBOX_MODELS_PATH', CJTOOLBOX_PATH . '/models' );
23 25
24 26 /** Tables dir path */
25 -define('CJTOOLBOX_TABLES_PATH', CJTOOLBOX_PATH . '/tables');
27 +define( 'CJTOOLBOX_TABLES_PATH', CJTOOLBOX_PATH . '/tables' );
26 28
27 29 /** Models views path */
28 -define('CJTOOLBOX_VIEWS_PATH', CJTOOLBOX_PATH . '/views');
30 +define( 'CJTOOLBOX_VIEWS_PATH', CJTOOLBOX_PATH . '/views' );
29 31
30 32 /** Views controllers path */
31 -define('CJTOOLBOX_CONTROLLERS_PATH', CJTOOLBOX_PATH . '/controllers');
33 +define( 'CJTOOLBOX_CONTROLLERS_PATH', CJTOOLBOX_PATH . '/controllers' );
32 34
33 35 /** URI to CJT Plugin dir */
34 -define('CJTOOLBOX_URL', WP_PLUGIN_URL . '/' . CJTOOLBOX_NAME );
36 +define( 'CJTOOLBOX_URL', WP_PLUGIN_URL . '/' . CJTOOLBOX_NAME );
35 37
36 38 /** URI to CJT Views directory */
37 -define('CJTOOLBOX_VIEWS_URL', CJTOOLBOX_URL . '/views');
39 +define( 'CJTOOLBOX_VIEWS_URL', CJTOOLBOX_URL . '/views' );
38 40
39 41 /** HTML Components URI */
40 -define('CJTOOLBOX_HTML_CONPONENTS_URL', CJTOOLBOX_URL . '/framework/html/components');
42 +define( 'CJTOOLBOX_HTML_CONPONENTS_URL', CJTOOLBOX_URL . '/framework/html/components' );
41 43
42 44 /**
43 45 * CJT Core class.
44 -*
46 +*
45 47 * @package CJT
46 48 * @author Original Developer
47 49 * @version 0.3
48 50 */
49 -class cssJSToolbox extends CJTHookableClass {
50 -
51 +class cssJSToolbox extends CJTHookableClass
52 +{
53 +
51 54 /**
52 - *
55 + *
53 56 */
54 57 const CJT_WEB_SITE_DOMAIN = 'css-javascript-toolbox.com';
55 -
58 +
56 59 /**
57 60 * put your comment there...
58 - *
61 + *
59 62 * @todo remove this and use configuration instead
60 - *
63 + *
61 64 * @var mixed
62 65 */
63 66 public static $config = null;
64 -
67 +
65 68 /**
66 69 * put your comment there...
67 - *
70 + *
68 71 * @var mixed
69 72 */
70 73 private $dbDriver;
71 -
74 +
72 75 /**
73 76 * Reference of CJT Plugin object.
74 - *
77 + *
75 78 * @var cssJSToolbox
76 79 */
77 80 public static $instance = null;
78 81
@@ -77,167 +80,225 @@
77 80 public static $instance = null;
78 81
79 82 /**
80 83 * put your comment there...
81 - *
84 + *
82 85 * @var mixed
83 86 */
84 - protected static $ongettext = array('parameters' => array('text'));
85 -
87 + protected static $ongettext = [ 'parameters' => [ 'text' ] ];
88 +
86 89 /**
87 90 * put your comment there...
88 - *
91 + *
89 92 * @var mixed
90 93 */
91 - protected static $onimport = array('parameters' => array('vpaths'));
92 -
94 + protected static $onimport = [ 'parameters' => [ 'vpaths' ] ];
95 +
93 96 /**
94 97 * put your comment there...
95 - *
98 + *
96 99 * @var mixed
97 100 */
98 - protected static $oninstantiate = array('parameters' => array('instance'));
99 -
101 + protected static $oninstantiate = [ 'parameters' => [ 'instance' ] ];
102 +
100 103 /**
101 104 * put your comment there...
102 - *
105 + *
103 106 * @var mixed
104 107 */
105 - protected $onloadconfiguration = array('parameters' => array('configuration'));
106 -
108 + protected $onloadconfiguration = [ 'parameters' => [ 'configuration' ] ];
109 +
107 110 /**
108 111 * put your comment there...
109 - *
112 + *
110 113 * @var mixed
111 114 */
112 - protected $onloaddbdriver = array('parameters' => array('dbdriver'));
115 + protected $onloaddbdriver = [ 'parameters' => [ 'dbdriver' ] ];
113 116
114 117 /**
115 118 * put your comment there...
116 - *
119 + *
117 120 * @var mixed
118 121 */
119 - protected static $onresolvepath = array('parameters' => array('path', 'vpath'));
120 -
122 + protected static $onresolvepath = [ 'parameters' => [ 'path', 'vpath' ] ];
123 +
124 + /**
125 + * put your comment there...
126 + *
127 + * @param mixed $text
128 + */
129 + public static function _( $formattedText )
130 + {
131 +
132 + // Get formats as single args
133 + $args = func_get_args();
134 + array_shift( $args );
135 +
136 + // Shift localized text into first array items
137 + array_unshift( $args, self::getText( $formattedText ) );
138 +
139 + // Return formatted text
140 + return call_user_func_array( 'sprintf', $args );
141 + }
142 +
121 143 /**
122 - * Initialize Plugin.
123 - *
144 + * Initialize Plugin.
145 + *
124 146 * @return void
125 147 */
126 - protected function __construct() {
127 - // Initialize hookable!
148 + protected function __construct()
149 + {
150 +
128 151 parent::__construct();
152 +
129 153 // Load configuration.
130 - self::$config = $this->onloadconfiguration(require(self::resolvePath('configuration.inc.php')));
131 - // Initialize vars!
132 - self::import('framework:db:mysql:queue-driver.inc.php');
133 - $this->dbDriver = $this->onloaddbdriver(new CJTMYSQLQueueDriver($GLOBALS['wpdb']));
154 + self::$config = $this->onloadconfiguration( require( self::resolvePath( 'configuration.inc.php' ) ) );
155 +
156 +
157 + self::import( 'framework:db:mysql:queue-driver.inc.php' );
158 +
159 + $this->dbDriver = $this->onloaddbdriver( new CJTMYSQLQueueDriver( $GLOBALS[ 'wpdb' ] ) );
134 160 }
135 -
161 +
136 162 /**
137 163 * put your comment there...
138 - *
164 + *
139 165 */
140 - public function getCJTWebSiteURL($path = null) {
141 - $domain = self::CJT_WEB_SITE_DOMAIN;
142 - return "http://{$domain}/{$path}";
166 + public static function getCJTWebSiteURL( $path = null )
167 + {
168 + $domain = self::CJT_WEB_SITE_DOMAIN;
169 +
170 + return "https://{$domain}/{$path}";
143 171 }
144 -
172 +
145 173 /**
146 174 * put your comment there...
147 - *
175 + *
148 176 */
149 - public function getDBDriver() {
150 - return $this->dbDriver;
177 + public function & getDBDriver()
178 + {
179 + return $this->dbDriver;
151 180 }
152 -
181 +
153 182 /**
154 183 * Get CJT Plugin object.
155 - *
184 + *
156 185 * @return cssJSToolbox
157 186 */
158 - public static function getInstance() {
159 - if (!self::$instance) {
160 - self::$instance = self::trigger('cssJSToolbox.instantiate', (new cssJSToolbox()));
187 + public static function & getInstance()
188 + {
189 +
190 + if ( ! self::$instance )
191 + {
192 + self::$instance = self::trigger( 'cssJSToolbox.instantiate', ( new cssJSToolbox() ) );
161 193 }
194 +
162 195 return self::$instance;
163 196 }
164 -
197 +
165 198 /**
166 199 * put your comment there...
167 - *
200 + *
168 201 */
169 - public function getSecurityToken() {
170 - return wp_create_nonce(CJTController::NONCE_ACTION);
202 + public static function getSecurityToken()
203 + {
204 + return wp_create_nonce( CJTController::NONCE_ACTION );
171 205 }
172 -
206 +
173 207 /**
174 208 * put your comment there...
175 - *
209 + *
176 210 * @param mixed $text
177 211 */
178 - public function getText($text) {
179 - // Make sure to don't use $this while calling!
180 - // $this might be an object other than CssJSToolbox!
181 - return self::__callStatic('cssJSToolbox.ongettext', array(__($text, CJTOOLBOX_TEXT_DOMAIN)));
212 + public static function getText( $text )
213 + {
214 + // Simply return text without any translation attempts
215 + return $text;
182 216 }
183 -
217 +
184 218 /**
185 219 * put your comment there...
186 - *
220 + *
187 221 * @param mixed $path
188 222 */
189 - public static function getURI($vPath, $uriBase = null) {
223 + public static function getURI( $vPath, $uriBase = null )
224 + {
190 225 // PHP wrapper however its not imlpemented as wrapper yet
191 226 // because this is not the point right now!
192 - if (strpos($vPath, 'extension://') === 0) {
227 + if ( strpos( $vPath, 'extension://' ) === 0)
228 + {
193 229 // Expression for getting plugin/extension name!
194 230 $exp = '/^extension\:\/\/([^\/]+)/';
195 - preg_match($exp, $vPath, $extensionPath);
231 + preg_match( $exp, $vPath, $extensionPath );
232 +
196 233 // Get base URI + removing extension:// wrapper!
197 - $uriBase = plugins_url($extensionPath[1]);
198 - $uri = self::getURI(preg_replace($exp, '', $vPath), $uriBase);
199 - }
200 - else {
234 + $uriBase = plugins_url( $extensionPath[ 1 ] );
235 +
236 + $uri = self::getURI( preg_replace( $exp, '', $vPath ), $uriBase );
237 +
238 + }
239 + else
240 + {
201 241 // Translate Virtual path to real path.
202 - $path = str_replace(':', '/', $vPath);
242 + $path = str_replace( ':', '/', $vPath );
243 +
203 244 // Get full URI.
204 - if (!isset($uriBase)) {
205 - $uriBase = plugin_dir_url(__FILE__);
245 + if ( ! isset( $uriBase ) )
246 + {
247 +
248 + $uriBase = plugin_dir_url( __FILE__ );
249 +
206 250 }
207 - $uri = "{$uriBase}{$path}";
251 +
252 + $uri = "{$uriBase}{$path}";
208 253 }
254 +
209 255 return $uri;
210 256 }
211 -
257 +
212 258 /**
213 259 * put your comment there...
214 - *
260 + *
215 261 */
216 - public static function import() {
217 - // Initialize!
262 + public static function import()
263 + {
264 +
218 265 $params = func_get_args();
266 +
219 267 // Allow vriables list parameters.
220 - $vPaths = self::trigger('cssJSToolbox.import', $params);
221 - foreach ($vPaths as $vPath) {
222 - // Import file.
223 - require_once self::resolvePath($vPath);
268 + $vPaths = self::trigger( 'cssJSToolbox.import', $params );
269 + foreach ( $vPaths as $vPath )
270 + {
271 + require_once self::resolvePath( $vPath );
224 272 }
273 +
225 274 }
226 -
275 +
227 276 /**
228 277 * put your comment there...
229 - *
278 + *
230 279 * @param mixed $vPath
231 280 * @param mixed $base
232 281 */
233 - public static function resolvePath($vPath, $base = CJTOOLBOX_PATH) {
282 + public static function resolvePath( $vPath, $base = CJTOOLBOX_PATH )
283 + {
284 + // Resolve CJT extensions path
285 + if ( strpos( $vPath, 'extension://' ) === 0 )
286 + {
287 + // Remove extension wrapper
288 + $vPath = str_replace( 'extension://', '', $vPath );
289 +
290 + // Point to plugin directory
291 + $base = WP_PLUGIN_DIR;
292 +
293 + }
234 294 // Replace all :'s with /'s.
235 - $path = str_replace(':', '/', $vPath);
295 + $path = str_replace( ':', '/', $vPath );
236 296 $path = "{$base}/{$path}";
237 - return self::trigger('cssJSToolbox.resolvepath', $path, $vPath);
297 +
298 + return self::trigger( 'cssJSToolbox.resolvepath', $path, $vPath );
238 299 }
239 -
300 +
240 301 }// End Class
241 302
242 303 // Hookable!
243 -cssJSToolbox::define('cssJSToolbox', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
304 +cssJSToolbox::define( 'cssJSToolbox', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );