CSS & JavaScript Toolbox - Version 6.0.6

Version Description

  • Fix: Conflict with other Plugins!
  • Fix: Javascript exception throwed when dismissing the install/upgrade notice.
  • Enhancement: Disallow (with user notice) upgrade/downgrade if the target version is not being supported, therefor saving user data!
  • Enhancement: Don't break down the site if manual upgrade/downgrage process is incompleted! Allow user to revert back manually or disable the Plugin.
  • Enhancement: E_ALL complain! Suppress all notices when WP_DEBUG set to true, allow better development, fast performance and error handling.
Download this release

Release Info

Developer wipeoutmedia
Plugin Icon 128x128 CSS & JavaScript Toolbox
Version 6.0.6
Comparing to
See all releases

Code changes from version 6.0 to 6.0.6

Files changed (44) hide show
  1. access.points/autoupgrade.accesspoint.php +1 -1
  2. access.points/extensions.accesspoint.php +1 -3
  3. access.points/installer.accesspoint.php +2 -6
  4. access.points/main.accesspoint.php +6 -4
  5. access.points/tinymce.accesspoint.php +1 -1
  6. controllers/blocks-ajax.php +2 -2
  7. controllers/blocks-coupling.php +4 -8
  8. css-js-toolbox.php +2 -2
  9. framework/access-points/access-point.class.php +3 -3
  10. framework/access-points/directory-spider.class.php +17 -29
  11. framework/db/mysql/table.inc.php +0 -1
  12. framework/db/mysql/xtable.inc.php +6 -4
  13. framework/events/definition.class.php +6 -3
  14. framework/events/events.class.php +1 -1
  15. framework/events/observers/observer.observer.php +4 -0
  16. framework/events/subjects/subject.subject.php +1 -1
  17. framework/html/components/checkbox-list/checkbox-list.class.php +0 -2
  18. framework/html/list.php +2 -2
  19. framework/mvc/controller.inc.php +9 -2
  20. framework/mvc/model.inc.php +1 -1
  21. framework/mvc/view.inc.php +8 -6
  22. includes/installer/upgrade/block.class.php +2 -2
  23. index.php +1 -1
  24. models/block.php +6 -3
  25. models/blocks-backups.php +1 -1
  26. models/blocks.php +1 -1
  27. models/extensions.php +1 -1
  28. models/installer.php +23 -17
  29. models/setup.php +5 -1
  30. readme.txt +23 -14
  31. screenshot-1.jpg +0 -0
  32. screenshot-2.jpg +0 -0
  33. tables/blocks.php +3 -3
  34. views/blocks/block/tmpl/edit.html.tmpl +1 -19
  35. views/blocks/cjt-block/helpers/wppageslist.inc.php +1 -2
  36. views/blocks/manager/tmpl/help/intro.html.tmpl +2 -14
  37. views/installer/install/public/css/default.css +2 -1
  38. views/installer/install/tmpl/default.html.tmpl +5 -0
  39. views/installer/install/tmpl/default_operation.html.tmpl +3 -3
  40. views/installer/install/tmpl/upgrades/02.operations +12 -0
  41. views/installer/install/tmpl/upgrades/03.operations +1 -0
  42. views/installer/install/tmpl/upgrades/upgrade.html.tmpl +2 -6
  43. views/installer/install/view.php +17 -5
  44. views/installer/notice/public/js/default/default.js +1 -1
access.points/autoupgrade.accesspoint.php CHANGED
@@ -57,7 +57,7 @@ class CJTAutoUpgradeAccessPoint extends CJTAccessPoint {
57
  public function route() {
58
  // Load Auto Upgrade controller!
59
  $this->controllerName = 'auto-upgrade';
60
- parent::route()
61
  // Set action name to autoUpgrade
62
  ->setAction('enable')
63
  // fire action to enable automatic upgrade!
57
  public function route() {
58
  // Load Auto Upgrade controller!
59
  $this->controllerName = 'auto-upgrade';
60
+ parent::route(false)
61
  // Set action name to autoUpgrade
62
  ->setAction('enable')
63
  // fire action to enable automatic upgrade!
access.points/extensions.accesspoint.php CHANGED
@@ -65,9 +65,7 @@ class CJTExtensionsAccessPoint extends CJTAccessPoint {
65
  // Set as connected object!
66
  $this->connected();
67
  // Load extensions view throughjt the default controller!
68
- $_REQUEST['view'] ='extensions/plugins-list';
69
- // Create controller!
70
- parent::route()
71
  // Set Action name!
72
  ->setAction('extensions')
73
  // Dispatch the call!
65
  // Set as connected object!
66
  $this->connected();
67
  // Load extensions view throughjt the default controller!
68
+ parent::route(null, array('view' => 'extensions/plugins-list'))
 
 
69
  // Set Action name!
70
  ->setAction('extensions')
71
  // Dispatch the call!
access.points/installer.accesspoint.php CHANGED
@@ -48,9 +48,7 @@ class CJTInstallerAccessPoint extends CJTAccessPoint {
48
  // Set as connected object!
49
  $this->connected();
50
  // Set controller internal parameters.
51
- $_REQUEST['view'] = 'installer/install';
52
- // create controller.
53
- return $this->route()
54
  // Set Action
55
  ->setAction('install');
56
  }
@@ -65,9 +63,7 @@ class CJTInstallerAccessPoint extends CJTAccessPoint {
65
  // if there is no access point processed/connected the request
66
  if (!$this->stopNotices) {
67
  // Set MVC request parameters.
68
- $_REQUEST['view'] = 'installer/notice';
69
- // Instantiate installer cotroller and fire notice action!
70
- $this->route()
71
  // Set action name.
72
  ->setAction('notInstalledNotice')
73
  // Fire action!
48
  // Set as connected object!
49
  $this->connected();
50
  // Set controller internal parameters.
51
+ return $this->route(null, array('view' => 'installer/install'))
 
 
52
  // Set Action
53
  ->setAction('install');
54
  }
63
  // if there is no access point processed/connected the request
64
  if (!$this->stopNotices) {
65
  // Set MVC request parameters.
66
+ $this->route(null , array('view' => 'installer/notice'))
 
 
67
  // Set action name.
68
  ->setAction('notInstalledNotice')
69
  // Fire action!
access.points/main.accesspoint.php CHANGED
@@ -51,9 +51,11 @@ class CJTMainAccessPoint extends CJTAccessPoint {
51
  *
52
  */
53
  public function main() {
54
- // Run the coupling!
55
- $this->controllerName = 'blocks-coupling';
56
- $this->route();
 
 
57
  // Run all the aother access points!
58
  CJTPlugin::getInstance()->listen();
59
  }
@@ -67,7 +69,7 @@ class CJTMainAccessPoint extends CJTAccessPoint {
67
  $mainAccessPointObject = self::$instance;
68
  // Load default controller!
69
  $mainAccessPointObject->controllerName = 'default';
70
- $controller = $mainAccessPointObject->route()
71
  // Fire uninstall action!
72
  ->setAction('uninstall')
73
  ->_doAction();
51
  *
52
  */
53
  public function main() {
54
+ // Run the coupling only if installed!
55
+ if (CJTPlugin::getInstance()->isInstalled()) {
56
+ $this->controllerName = 'blocks-coupling';
57
+ $this->route(false);
58
+ }
59
  // Run all the aother access points!
60
  CJTPlugin::getInstance()->listen();
61
  }
69
  $mainAccessPointObject = self::$instance;
70
  // Load default controller!
71
  $mainAccessPointObject->controllerName = 'default';
72
+ $controller = $mainAccessPointObject->route(false)
73
  // Fire uninstall action!
74
  ->setAction('uninstall')
75
  ->_doAction();
access.points/tinymce.accesspoint.php CHANGED
@@ -41,7 +41,7 @@ class CJTTinymceAccessPoint extends CJTAccessPoint {
41
  public function route($plugins) {
42
  // Load tinymce/shortcodes view through default controller!
43
  $this->controllerName = 'default';
44
- parent::route(array('view' => 'tinymce/shortcodes'))
45
  // Display
46
  ->setAction('display')
47
  ->_doAction();
41
  public function route($plugins) {
42
  // Load tinymce/shortcodes view through default controller!
43
  $this->controllerName = 'default';
44
+ parent::route(null, array('view' => 'tinymce/shortcodes'))
45
  // Display
46
  ->setAction('display')
47
  ->_doAction();
controllers/blocks-ajax.php CHANGED
@@ -112,7 +112,7 @@ class CJTBlocksAjaxController extends CJTAjaxController {
112
  $blockView->setBlock($block);
113
  $response['view'] = $blockView->getTemplate('new');
114
  }
115
- $response['id'] = $id;
116
  // Set response object.
117
  $this->response = $response;
118
  }
@@ -149,7 +149,7 @@ class CJTBlocksAjaxController extends CJTAjaxController {
149
  // Get view object.
150
  $view = CJTController::getView($viewName);
151
  // Push view variables.
152
- foreach ((array) $viewInfo['vars'] as $var) {
153
  $view->$var = $_GET["view.{$var}"];
154
  }
155
  // Some views required custom pushing, this is can
112
  $blockView->setBlock($block);
113
  $response['view'] = $blockView->getTemplate('new');
114
  }
115
+ $response['id'] = $blockId;
116
  // Set response object.
117
  $this->response = $response;
118
  }
149
  // Get view object.
150
  $view = CJTController::getView($viewName);
151
  // Push view variables.
152
+ foreach ((isset($viewInfo['vars']) ? $viewInfo['vars'] : array()) as $var) {
153
  $view->$var = $_GET["view.{$var}"];
154
  }
155
  // Some views required custom pushing, this is can
controllers/blocks-coupling.php CHANGED
@@ -236,10 +236,6 @@ class CJTBlocksCouplingController extends CJTController {
236
  if($matchedExpression = @preg_match("/{$expression}/", $expressionsRequestURL)) {
237
  break;
238
  }
239
- else if ($matchedExpression === false) { // Error
240
- $message .= "<div style='background-color:red;font-size:20px;'>There are expression error in '{$block->name}' Block!! Expr=({$expression})</div>";
241
- echo($message);
242
- }
243
  }
244
  }
245
  /**
@@ -458,13 +454,13 @@ class CJTBlocksCouplingController extends CJTController {
458
  // Initialize vars.
459
  $replacement = '';
460
  // Default Class.
461
- if (!$attributes['class']) {
462
  $class = 'block';
463
  }
464
  switch ($class) {
465
  case 'block':
466
  // Get is the default "operation"!
467
- if (!$attributes['op']) {
468
  $attributes['op'] = 'get';
469
  }
470
  switch ($attributes['op']) {
@@ -472,9 +468,9 @@ class CJTBlocksCouplingController extends CJTController {
472
  // Import dependecies.
473
  cssJSToolbox::import('framework:db:mysql:xtable.inc.php');
474
  // Output block if 'force="true" or only if it wasn't already in the header/footer!
475
- if ((($attributes['force'] == "true") || !in_array($attributes['id'], $this->onActionIds))) {
476
  // Id is being used!
477
- if ($attributes['force'] != 'true') {
478
  $this->onActionIds[] = (int) $attributes['id'];
479
  }
480
  // Get block code.
236
  if($matchedExpression = @preg_match("/{$expression}/", $expressionsRequestURL)) {
237
  break;
238
  }
 
 
 
 
239
  }
240
  }
241
  /**
454
  // Initialize vars.
455
  $replacement = '';
456
  // Default Class.
457
+ if (!isset($attributes['class'])) {
458
  $class = 'block';
459
  }
460
  switch ($class) {
461
  case 'block':
462
  // Get is the default "operation"!
463
+ if (!isset($attributes['op'])) {
464
  $attributes['op'] = 'get';
465
  }
466
  switch ($attributes['op']) {
468
  // Import dependecies.
469
  cssJSToolbox::import('framework:db:mysql:xtable.inc.php');
470
  // Output block if 'force="true" or only if it wasn't already in the header/footer!
471
+ if ((((isset($attributes['force'])) && ($attributes['force'] == "true")) || !in_array($attributes['id'], $this->onActionIds))) {
472
  // Id is being used!
473
+ if ((isset($attributes['force'])) && ($attributes['force'] != 'true')) {
474
  $this->onActionIds[] = (int) $attributes['id'];
475
  }
476
  // Get block code.
css-js-toolbox.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: CSS & JavaScript Toolbox
4
  Plugin URI: http://css-javascript-toolbox.com/css-javascript-toolbox-free
5
  Description: CJT Plugin for WordPress to easily add custom CSS and JavaScript to individual pages
6
- Version: 6.0
7
  Author: Wipeout Media
8
  Author URI: http://css-javascript-toolbox.com/
9
 
@@ -285,7 +285,7 @@ class CJTPlugin extends CJTHookableClass {
285
  // Access point base class is a dependency!
286
  require_once 'framework/access-points/access-point.class.php';
287
  // Run Main Acces Point!
288
- require_once 'access.points/main.accesspoint.php';
289
  $this->mainAC = new CJTMainAccessPoint();
290
  $this->mainAC->listen();
291
  }
3
  Plugin Name: CSS & JavaScript Toolbox
4
  Plugin URI: http://css-javascript-toolbox.com/css-javascript-toolbox-free
5
  Description: CJT Plugin for WordPress to easily add custom CSS and JavaScript to individual pages
6
+ Version: 6.0.6
7
  Author: Wipeout Media
8
  Author URI: http://css-javascript-toolbox.com/
9
 
285
  // Access point base class is a dependency!
286
  require_once 'framework/access-points/access-point.class.php';
287
  // Run Main Acces Point!
288
+ include_once 'access.points/main.accesspoint.php';
289
  $this->mainAC = new CJTMainAccessPoint();
290
  $this->mainAC->listen();
291
  }
framework/access-points/access-point.class.php CHANGED
@@ -95,7 +95,7 @@ abstract class CJTAccessPoint extends CJTHookableClass implements CJTIAccessPoin
95
  // Initialize Hookable.
96
  parent::__construct();
97
  // Initialize!
98
- $this->controllerName = $this->ongetdefaultcontrollername($_REQUEST['controller'] ? $_REQUEST['controller'] : $defaultController);
99
  }
100
 
101
  /**
@@ -177,13 +177,13 @@ abstract class CJTAccessPoint extends CJTHookableClass implements CJTIAccessPoin
177
  *
178
  * @param mixed $request
179
  */
180
- public function route($request = null) {
181
  // Only loading one controller is allowed.
182
  if (!$this->controller) {
183
  // Import view class.
184
  require_once CJTOOLBOX_MVC_FRAMEWOK . '/view.inc.php';
185
  // Instantiate controller!
186
- $this->controller = $this->onsetcontroller(CJTController::getInstance($this->controllerName, null, $request));
187
  }
188
  return $this->controller;
189
  }
95
  // Initialize Hookable.
96
  parent::__construct();
97
  // Initialize!
98
+ $this->controllerName = $this->ongetdefaultcontrollername(isset($_REQUEST['controller']) ? $_REQUEST['controller'] : $defaultController);
99
  }
100
 
101
  /**
177
  *
178
  * @param mixed $request
179
  */
180
+ public function route($loadView = null, $request = null) {
181
  // Only loading one controller is allowed.
182
  if (!$this->controller) {
183
  // Import view class.
184
  require_once CJTOOLBOX_MVC_FRAMEWOK . '/view.inc.php';
185
  // Instantiate controller!
186
+ $this->controller = $this->onsetcontroller(CJTController::getInstance($this->controllerName, $loadView, $request));
187
  }
188
  return $this->controller;
189
  }
framework/access-points/directory-spider.class.php CHANGED
@@ -11,11 +11,6 @@ defined('ABSPATH') or die("Access denied");
11
  */
12
  class CJTAccessPointsDirectorySpider extends ArrayIterator {
13
 
14
- /**
15
- *
16
- */
17
- const CACHE_POINTER = 'settings.CJTAccessPointsDirectorySpider.cache';
18
-
19
  /**
20
  * put your comment there...
21
  *
@@ -66,30 +61,23 @@ class CJTAccessPointsDirectorySpider extends ArrayIterator {
66
  /**
67
  * put your comment there...
68
  *
69
- * @param mixed $reload
70
- * @return CJTAccessPointsDirectorySpider
71
- * @todo Set realod = false when released!
72
  */
73
- protected function load($reload = false) {
74
- // Get if cached and not force reload!
75
- if (!($this->aPoints = get_option(self::CACHE_POINTER)) || $reload) {
76
- // Reset access points!
77
- $this->aPoints =array();
78
- // Get all defined ap inside the specified directory!
79
- $accessPoints = new DirectoryIterator($this->dir);
80
- foreach ($accessPoints as $file) {
81
- if (!$file->isDir()) {
82
- // Build point info!
83
- $point = array();
84
- $point['file'] = $file->getFilename();
85
- $point['name'] = $file->getBaseName('.accesspoint.php');
86
- $point['class'] = "{$this->prefix}{$point['name']}AccessPoint";
87
- // Add to points list!
88
- $this->aPoints[$point['name']] = $point;
89
- }
90
- }
91
- // Update the cache;
92
- update_option(self::CACHE_POINTER, $this->aPoints);
93
  }
94
  return $this;
95
  }
@@ -104,7 +92,7 @@ class CJTAccessPointsDirectorySpider extends ArrayIterator {
104
  // Full absolulte path to access point file!
105
  $absPath = "{$this->dir}/{$point['file']}";
106
  // Instantiate point class, this will put it in action!
107
- require_once $absPath;
108
  return new $point['class']();
109
  }
110
 
11
  */
12
  class CJTAccessPointsDirectorySpider extends ArrayIterator {
13
 
 
 
 
 
 
14
  /**
15
  * put your comment there...
16
  *
61
  /**
62
  * put your comment there...
63
  *
64
+ * @return CJTAccessPointsDirectorySpider Returns $this.
 
 
65
  */
66
+ protected function load() {
67
+ // Reset access points!
68
+ $this->aPoints =array();
69
+ // Get all defined ap inside the specified directory!
70
+ $accessPoints = new DirectoryIterator($this->dir);
71
+ foreach ($accessPoints as $file) {
72
+ if (!$file->isDir()) {
73
+ // Build point info!
74
+ $point = array();
75
+ $point['file'] = $file->getFilename();
76
+ $point['name'] = $file->getBaseName('.accesspoint.php');
77
+ $point['class'] = "{$this->prefix}{$point['name']}AccessPoint";
78
+ // Add to points list!
79
+ $this->aPoints[$point['name']] = $point;
80
+ }
 
 
 
 
 
81
  }
82
  return $this;
83
  }
92
  // Full absolulte path to access point file!
93
  $absPath = "{$this->dir}/{$point['file']}";
94
  // Instantiate point class, this will put it in action!
95
+ include_once $absPath;
96
  return new $point['class']();
97
  }
98
 
framework/db/mysql/table.inc.php CHANGED
@@ -48,7 +48,6 @@ abstract class CJTTable {
48
  // Set table name.
49
  $this->dbDriver = $dbDriver;
50
  $this->table = $this->dbDriver->getTableName($table);
51
- $this->id = $id;
52
  // Read table fields.
53
  $this->fields = $this->dbDriver->getColumns($this->table);
54
  }
48
  // Set table name.
49
  $this->dbDriver = $dbDriver;
50
  $this->table = $this->dbDriver->getTableName($table);
 
51
  // Read table fields.
52
  $this->fields = $this->dbDriver->getColumns($this->table);
53
  }
framework/db/mysql/xtable.inc.php CHANGED
@@ -171,14 +171,16 @@ abstract class CJTxTable extends CJTHookableClass {
171
  * @param mixed $field
172
  */
173
  public function get($field) {
174
- return $this->ongetfield($this->item->{$field}, $field);
 
 
175
  }
176
 
177
  /**
178
  * put your comment there...
179
  *
180
  */
181
- public function &getData() {
182
  return $this->ongetdata($this->item);
183
  }
184
 
@@ -264,6 +266,7 @@ abstract class CJTxTable extends CJTHookableClass {
264
  * @param mixed
265
  */
266
  public function load($query = null) {
 
267
  $key = null;
268
  // Query might be an array of keys!
269
  if (is_array($query)) {
@@ -337,12 +340,11 @@ abstract class CJTxTable extends CJTHookableClass {
337
  */
338
  public function save($forceInsert = false) {
339
  $keyFieldName = $this->key[0];
340
- $id = $this->item->{$keyFieldName};
341
  $item = (array) $this->item;
342
  // Don't update id field.
343
  $fieldsList = array_diff_key($item, array_flip($this->key));
344
  $fieldsList = implode(',', $this->prepareQueryParameters($fieldsList));
345
- if (!$forceInsert && $id) { // Update
346
  // Where clause.
347
  $condition = implode(' AND ', $this->prepareQueryParameters($this->getKey()));
348
  $query = "UPDATE {$this->table()} SET {$fieldsList} WHERE {$condition}";
171
  * @param mixed $field
172
  */
173
  public function get($field) {
174
+ // Get the value of the field with E_ALL complain!
175
+ $value = (is_object($this->item) && property_exists($this->item, $field)) ? $this->item->{$field} : null;
176
+ return $this->ongetfield($value, $field);
177
  }
178
 
179
  /**
180
  * put your comment there...
181
  *
182
  */
183
+ public function getData() {
184
  return $this->ongetdata($this->item);
185
  }
186
 
266
  * @param mixed
267
  */
268
  public function load($query = null) {
269
+ $tableKey = null;
270
  $key = null;
271
  // Query might be an array of keys!
272
  if (is_array($query)) {
340
  */
341
  public function save($forceInsert = false) {
342
  $keyFieldName = $this->key[0];
 
343
  $item = (array) $this->item;
344
  // Don't update id field.
345
  $fieldsList = array_diff_key($item, array_flip($this->key));
346
  $fieldsList = implode(',', $this->prepareQueryParameters($fieldsList));
347
+ if (!$forceInsert && $this->get($keyFieldName)) { // Update
348
  // Where clause.
349
  $condition = implode(' AND ', $this->prepareQueryParameters($this->getKey()));
350
  $query = "UPDATE {$this->table()} SET {$fieldsList} WHERE {$condition}";
framework/events/definition.class.php CHANGED
@@ -86,9 +86,12 @@ class CJTEventsDefinition {
86
  // Extend events from all base classes!
87
  foreach ($this->bases as $baseClassName => $options) {
88
  $baseClass = $this->get($baseClassName);
89
- foreach (((array) $baseClass['events']) as $name => $event) {
90
- $event['type'] = array_merge($event['type'], $options);
91
- $definition['events'][$name] = $event;
 
 
 
92
  }
93
  }
94
  return $definition;
86
  // Extend events from all base classes!
87
  foreach ($this->bases as $baseClassName => $options) {
88
  $baseClass = $this->get($baseClassName);
89
+ // E_ALL complain!
90
+ if (isset($baseClass['events'])) {
91
+ foreach ($baseClass['events'] as $name => $event) {
92
+ $event['type'] = array_merge($event['type'], $options);
93
+ $definition['events'][$name] = $event;
94
+ }
95
  }
96
  }
97
  return $definition;
framework/events/events.class.php CHANGED
@@ -216,7 +216,7 @@ abstract class CJTEvents {
216
  // Create subject object! and bind live events!
217
  $subject = $this->subjects[$event['id']] = $this->createSubject($event);
218
  // Live events!
219
- $lives = (array) self::$live[$this->targetClass][$event['id']];
220
  foreach ($lives as $live) {
221
  $subject[] = $live['observer'];
222
  }
216
  // Create subject object! and bind live events!
217
  $subject = $this->subjects[$event['id']] = $this->createSubject($event);
218
  // Live events!
219
+ $lives = isset(self::$live[$this->targetClass][$event['id']]) ? self::$live[$this->targetClass][$event['id']] : array();
220
  foreach ($lives as $live) {
221
  $subject[] = $live['observer'];
222
  }
framework/events/observers/observer.observer.php CHANGED
@@ -118,6 +118,10 @@ abstract class CJTObserver implements CJTIObserver {
118
  $observer = $callback;
119
  }
120
  else {
 
 
 
 
121
  // Short-hand array structure!
122
  if (is_array($callback) && isset($callback['callback'])) {
123
  // Get all params without callback
118
  $observer = $callback;
119
  }
120
  else {
121
+ // Define vars (E_ALL complain)!.
122
+ $name = null;
123
+ $filter = null;
124
+ $param = null;
125
  // Short-hand array structure!
126
  if (is_array($callback) && isset($callback['callback'])) {
127
  // Get all params without callback
framework/events/subjects/subject.subject.php CHANGED
@@ -67,7 +67,7 @@ abstract class CJTEESubject implements CJTEEISubject, Countable, ArrayAccess {
67
  * @param mixed $name
68
  */
69
  public function getDefinition($name) {
70
- return $this->definition[$name];
71
  }
72
 
73
  /**
67
  * @param mixed $name
68
  */
69
  public function getDefinition($name) {
70
+ return isset($this->definition[$name]) ? $this->definition[$name] : null;
71
  }
72
 
73
  /**
framework/html/components/checkbox-list/checkbox-list.class.php CHANGED
@@ -80,8 +80,6 @@ class HTMLCheckboxList extends HTMLComponent {
80
  $this->id = $id;
81
  $this->className = $className;
82
  $this->title = $title;
83
- $this->itemClassName = $itemClassName;
84
- $this->itemSelectedClassName = $itemClassName;
85
  // Initialize default values.
86
  $this->itemDefaults = (object) array(
87
  'name' => $name,
80
  $this->id = $id;
81
  $this->className = $className;
82
  $this->title = $title;
 
 
83
  // Initialize default values.
84
  $this->itemDefaults = (object) array(
85
  'name' => $name,
framework/html/list.php CHANGED
@@ -94,7 +94,7 @@ class CJTListField extends CJTHTMLField {
94
  '__params__' => (object) array('className' => 'optional')))+ $this->items;
95
  }
96
  // Build HTML select.
97
- $listName = ($this->options['standard'] == true) ? "name='{$this->name}'" : '';
98
  $list = "<select id='{$this->id}' {$listName} class='{$this->classesList}' {$this->moreIntoTag}>";
99
  foreach ($this->items as $key => $item) {
100
  // Standrize the use of object.
@@ -115,7 +115,7 @@ class CJTListField extends CJTHTMLField {
115
  $list .= '</select>';
116
  // If this is the first instance to be outputed for the current form output the control field.
117
  $fieldKey = "{$this->form}-{$this->name}";
118
- if (!$this->options['standard'] && !in_array($fieldKey, self::$instances)) {
119
  // Output control fields.
120
  $list .= "<input type='hidden' name='{$this->name}' value='{$this->value}' />";
121
  // Mark form as instantiated!
94
  '__params__' => (object) array('className' => 'optional')))+ $this->items;
95
  }
96
  // Build HTML select.
97
+ $listName = (isset($this->options['standard']) && ($this->options['standard'] == true)) ? "name='{$this->name}'" : '';
98
  $list = "<select id='{$this->id}' {$listName} class='{$this->classesList}' {$this->moreIntoTag}>";
99
  foreach ($this->items as $key => $item) {
100
  // Standrize the use of object.
115
  $list .= '</select>';
116
  // If this is the first instance to be outputed for the current form output the control field.
117
  $fieldKey = "{$this->form}-{$this->name}";
118
+ if ((!isset($this->options['standard'])) && (!in_array($fieldKey, self::$instances))) {
119
  // Output control fields.
120
  $list .= "<input type='hidden' name='{$this->name}' value='{$this->value}' />";
121
  // Mark form as instantiated!
framework/mvc/controller.inc.php CHANGED
@@ -104,14 +104,21 @@ abstract class CJTController extends CJTHookableClass {
104
  // Initialize hookable!
105
  parent::__construct();
106
  // Read request parameters.
107
- $this->request = $request ? $request : $_REQUEST;
108
  // Create default model.
109
  if (isset($this->controllerInfo['model'])) {
 
 
 
 
110
  $this->model = CJTModel::create($this->controllerInfo['model'], array(), $this->controllerInfo['model_file']);
111
  }
112
  // Create default view.
113
  if ($hasView === null) { // Default value for $hasView = true
114
- $view = $this->ongetviewname($this->request['view'] ? $this->request['view'] : $this->controllerInfo['view']);
 
 
 
115
  if ($view) {
116
  $this->view = self::getView($view)
117
  // Push data into view.
104
  // Initialize hookable!
105
  parent::__construct();
106
  // Read request parameters.
107
+ $this->request = array_merge(((array) $_REQUEST), ((array) $request));
108
  // Create default model.
109
  if (isset($this->controllerInfo['model'])) {
110
+ // E_ALL complain!
111
+ if (!isset($this->controllerInfo['model_file'])) {
112
+ $this->controllerInfo['model_file'] = null;
113
+ }
114
  $this->model = CJTModel::create($this->controllerInfo['model'], array(), $this->controllerInfo['model_file']);
115
  }
116
  // Create default view.
117
  if ($hasView === null) { // Default value for $hasView = true
118
+ // Request/passed parameters has priority over controller default view!
119
+ $view = $this->ongetviewname(isset($this->request['view']) ? $this->request['view'] :
120
+ (isset($this->controllerInfo['view']) ? $this->controllerInfo['view'] : null)
121
+ );
122
  if ($view) {
123
  $this->view = self::getView($view)
124
  // Push data into view.
framework/mvc/model.inc.php CHANGED
@@ -46,7 +46,7 @@ abstract class CJTModel {
46
  * @param mixed $params
47
  * @param mixed $file
48
  */
49
- public static function & getInstance($model, $params = array(), $file = null) {
50
  return CJTController::getModel($model, $params, $file);
51
  }
52
 
46
  * @param mixed $params
47
  * @param mixed $file
48
  */
49
+ public static function getInstance($model, $params = array(), $file = null) {
50
  return CJTController::getModel($model, $params, $file);
51
  }
52
 
framework/mvc/view.inc.php CHANGED
@@ -342,7 +342,9 @@ abstract class CJTView extends CJTHookableClass {
342
  preg_match($nameExp, $script, $scriptObject);
343
  // [[2]Prefix], [4] name. Prefix may be not presented.
344
  $name = "{$scriptObject[2]}{$scriptObject[4]}";
345
- if (!$stack[$name]) {
 
 
346
  // Any JS lib file should named the same as the parent folder with the extension added.
347
  $libPath = ":{$scriptObject[4]}:{$scriptObject[4]}";
348
  // Pass virtual path to getURI and resolvePath to
@@ -350,9 +352,9 @@ abstract class CJTView extends CJTHookableClass {
350
  $jsFile = cssJSToolbox::getURI(preg_replace($nameExp, "{$libPath}.js", $script));
351
  $localizationFile = cssJSToolbox::resolvePath(preg_replace($nameExp, "{$libPath}.localization.php", $script));
352
  // Enqueue script file.
353
- wp_enqueue_script($name, $jsFile, null, null, $scriptObject[7]);
354
  // Set script parameters.
355
- if (preg_match_all('/(\w+)=(\w+)/', $scriptObject[5], $params, PREG_SET_ORDER) ) {
356
  // Set parameters.
357
  foreach ($params as $param) {
358
  $stack[$name]->cjt[$param[1]] = $param[2];
@@ -376,7 +378,7 @@ abstract class CJTView extends CJTHookableClass {
376
  }
377
  // Enqueue already registered scripts!
378
  else {
379
- wp_enqueue_script($name, $jsFile, null, null, $scriptObject[7]);
380
  }
381
  }
382
  }
@@ -405,7 +407,7 @@ abstract class CJTView extends CJTHookableClass {
405
  preg_match($nameExp, $style, $styleObject);
406
  // [[2]Prefix], [4] name. Prefix may be not presented.
407
  $name = "{$styleObject[2]}{$styleObject[4]}";
408
- if (!$GLOBALS['wp_styles']->registered[$name]) {
409
  // Make all enqueued styles names unique from enqueued scripts.
410
  // This is useful when merging styles & scripts is required.
411
  $name = "CSS-{$name}";
@@ -418,7 +420,7 @@ abstract class CJTView extends CJTHookableClass {
418
  }
419
  else {
420
  // Enqueue already registered styles.
421
- wp_enqueue_style($name, $cssFile);
422
  }
423
  }
424
  }
342
  preg_match($nameExp, $script, $scriptObject);
343
  // [[2]Prefix], [4] name. Prefix may be not presented.
344
  $name = "{$scriptObject[2]}{$scriptObject[4]}";
345
+ $location = isset($scriptObject[7]) ? $scriptObject[7] : null;
346
+ $scriptParameters = isset($scriptObject[5]) ? $scriptObject[5] : '';
347
+ if (!isset($stack[$name])) {
348
  // Any JS lib file should named the same as the parent folder with the extension added.
349
  $libPath = ":{$scriptObject[4]}:{$scriptObject[4]}";
350
  // Pass virtual path to getURI and resolvePath to
352
  $jsFile = cssJSToolbox::getURI(preg_replace($nameExp, "{$libPath}.js", $script));
353
  $localizationFile = cssJSToolbox::resolvePath(preg_replace($nameExp, "{$libPath}.localization.php", $script));
354
  // Enqueue script file.
355
+ wp_enqueue_script($name, $jsFile, null, null, $location);
356
  // Set script parameters.
357
+ if (preg_match_all('/(\w+)=(\w+)/', $scriptParameters, $params, PREG_SET_ORDER) ) {
358
  // Set parameters.
359
  foreach ($params as $param) {
360
  $stack[$name]->cjt[$param[1]] = $param[2];
378
  }
379
  // Enqueue already registered scripts!
380
  else {
381
+ wp_enqueue_script($name, null, null, null, $location);
382
  }
383
  }
384
  }
407
  preg_match($nameExp, $style, $styleObject);
408
  // [[2]Prefix], [4] name. Prefix may be not presented.
409
  $name = "{$styleObject[2]}{$styleObject[4]}";
410
+ if (!isset($GLOBALS['wp_styles']->registered[$name])) {
411
  // Make all enqueued styles names unique from enqueued scripts.
412
  // This is useful when merging styles & scripts is required.
413
  $name = "CSS-{$name}";
420
  }
421
  else {
422
  // Enqueue already registered styles.
423
+ wp_enqueue_style($name);
424
  }
425
  }
426
  }
includes/installer/upgrade/block.class.php CHANGED
@@ -54,7 +54,7 @@ abstract class CJTInstallerBlock extends ArrayIterator {
54
  $block['created'] = $block['lastModified'] = current_time('mysql');
55
  $block['owner'] = get_current_user_id();
56
  // Translate old assignment panel to use the new structure!
57
- if ($srcBlock['category']) {
58
  $pins['categories'] = $srcBlock['category'];
59
  }
60
  // Translate named map from last versions to the value used in the new versions!
@@ -64,7 +64,7 @@ abstract class CJTInstallerBlock extends ArrayIterator {
64
  'allposts' => CJTBlockModel::PINS_POSTS_ALL_POSTS,
65
  'frontpage' => CJTBlockModel::PINS_PAGES_FRONT_PAGE,
66
  );
67
- foreach (((array) $srcBlock['page']) as $assignedObject) {
68
  // Translate named pin to flag!
69
  if (isset($namedPins[$assignedObject])) {
70
  // Set pinPoint flags!
54
  $block['created'] = $block['lastModified'] = current_time('mysql');
55
  $block['owner'] = get_current_user_id();
56
  // Translate old assignment panel to use the new structure!
57
+ if (isset($srcBlock['category'])) {
58
  $pins['categories'] = $srcBlock['category'];
59
  }
60
  // Translate named map from last versions to the value used in the new versions!
64
  'allposts' => CJTBlockModel::PINS_POSTS_ALL_POSTS,
65
  'frontpage' => CJTBlockModel::PINS_PAGES_FRONT_PAGE,
66
  );
67
+ foreach ((isset($srcBlock['page']) ? $srcBlock['page'] : array()) as $assignedObject) {
68
  // Translate named pin to flag!
69
  if (isset($namedPins[$assignedObject])) {
70
  // Set pinPoint flags!
index.php CHANGED
@@ -1,2 +1,2 @@
1
  <?php
2
- // index.php just to prevent indexing of plugin folder
1
  <?php
2
+ // index.php just to prevent indexing of plugin folder
models/block.php CHANGED
@@ -143,9 +143,9 @@ class CJTBlockModel extends CJTModel {
143
  *
144
  * @deprecated Use calculatePinpoint
145
  */
146
- public static function calculateBlockPinPoint(&$block) {
147
  // Generate PinPoint Value.
148
- if (is_array($block->pinPoint)) {
149
  $pinPoint = 0;
150
  // Each item is a bit flag.
151
  foreach ($block->pinPoint as $pin) {
@@ -153,7 +153,10 @@ class CJTBlockModel extends CJTModel {
153
  }
154
  }
155
  else {
156
- // If provided as integer.
 
 
 
157
  $pinPoint = (int) $block->pinPoint;
158
  }
159
  // Pin should be set only for not empty properties.
143
  *
144
  * @deprecated Use calculatePinpoint
145
  */
146
+ public static function calculateBlockPinPoint(& $block) {
147
  // Generate PinPoint Value.
148
+ if (isset($block->pinPoint) && is_array($block->pinPoint)) {
149
  $pinPoint = 0;
150
  // Each item is a bit flag.
151
  foreach ($block->pinPoint as $pin) {
153
  }
154
  }
155
  else {
156
+ // Provided as integer or not even provided!
157
+ if (!isset($block->pinPoint)) {
158
+ $block->pinPoint = 0;
159
+ }
160
  $pinPoint = (int) $block->pinPoint;
161
  }
162
  // Pin should be set only for not empty properties.
models/blocks-backups.php CHANGED
@@ -62,7 +62,7 @@ class CJTBlocksBackupsModel {
62
  $blocks['filters']['types'] = array('block', 'revision');
63
  // Its important to get revision blocks at the end
64
  // to create blocks id map.
65
- $blocks['orderBy'] = array('type');
66
  $blocks = $blocksModel->getBlocks(null, $blocks['filters'], $blocks['fields'], OBJECT_K, $blocks['orderby']);
67
  // Prepare vars before copying.
68
  $desBlockId = $blocksTable->getNextId();
62
  $blocks['filters']['types'] = array('block', 'revision');
63
  // Its important to get revision blocks at the end
64
  // to create blocks id map.
65
+ $blocks['orderby'] = array('type');
66
  $blocks = $blocksModel->getBlocks(null, $blocks['filters'], $blocks['fields'], OBJECT_K, $blocks['orderby']);
67
  // Prepare vars before copying.
68
  $desBlockId = $blocksTable->getNextId();
models/blocks.php CHANGED
@@ -81,7 +81,7 @@ class CJTBlocksModel {
81
  $this->delete(array_shift($revisions)->id);
82
  }
83
  // Get block data.
84
- $block['fields'] = array('lastModified', 'pinPoint', 'code', 'links', 'expressions');
85
  // get() developed to return multiple blocks, fetch the first.
86
  $block = array_shift($blocks->get($blockId, $block['fields']));
87
  // Set other fields.
81
  $this->delete(array_shift($revisions)->id);
82
  }
83
  // Get block data.
84
+ $block['fields'] = array('id', 'lastModified', 'pinPoint', 'code', 'links', 'expressions');
85
  // get() developed to return multiple blocks, fetch the first.
86
  $block = array_shift($blocks->get($blockId, $block['fields']));
87
  // Set other fields.
models/extensions.php CHANGED
@@ -17,7 +17,7 @@ class CJTExtensionsModel {
17
  */
18
  public function getListTypeName() {
19
  // if the search term is for CJT extensions return 'extensions' otherwise return 'plugins'
20
- $type = ($_REQUEST['s'] == CJTExtensionsAccessPoint::PLUGINS_PAGE_SEARCH_TERM) ? 'extensions' : 'plugins';
21
  return $type;
22
  }
23
 
17
  */
18
  public function getListTypeName() {
19
  // if the search term is for CJT extensions return 'extensions' otherwise return 'plugins'
20
+ $type = (isset($_REQUEST['s']) == CJTExtensionsAccessPoint::PLUGINS_PAGE_SEARCH_TERM) ? 'extensions' : 'plugins';
21
  return $type;
22
  }
23
 
models/installer.php CHANGED
@@ -76,33 +76,38 @@ class CJTInstallerModel {
76
  *
77
  */
78
  public function getInternalVersionName() {
79
- return str_replace('.', '', $this->installedDbVersion);
80
  }
81
-
82
  /**
83
- * put your comment there...
84
  *
 
85
  */
86
  public function getOperations() {
87
- // If installation is didn't never run before thise would be unset!
88
- if (!($operations = get_option(self::INSTALLATION_STATE))) {
89
  // Import installer reflection!
90
  cssJSToolbox::import('framework:installer:reflection.class.php');
91
  // Get Installer operations.
92
  cssJSToolbox::import('includes:installer:installer:installer.class.php');
93
- $operations['operations']['install'] = CJTInstallerReflection::getInstance('CJTInstaller', 'CJTInstaller')->getOperations();
94
  if ($this->isUpgrade()) {
95
  // Get upgrade operations , Also cache upgrader info for later use!
96
- $operations['upgrader'] = $upgrader = $this->getUpgrader();
 
 
 
 
 
97
  cssJSToolbox::import($upgrader['file']);
98
- $operations['operations']['upgrade'] = CJTInstallerReflection::getInstance($upgrader['class'], 'CJTUpgradeNonTabledVersions')->getOperations();
99
  }
100
- // Cache operations!
101
- update_option(self::INSTALLATION_STATE, $operations);
102
  }
103
- return $operations;
104
  }
105
-
106
  /**
107
  * put your comment there...
108
  *
@@ -126,16 +131,17 @@ class CJTInstallerModel {
126
  // Read input!
127
  $rOperation = $this->input['operation'];
128
  $type = $rOperation['type'];
129
- // Get allowed operations with thier state!
130
  $operations = (array) get_option(self::INSTALLATION_STATE);
 
131
  // Invalid operation!
132
- if (!isset($operations['operations'][$type][$rOperation['name']])) {
133
  throw new Exception('Invalid operation');
134
  }
135
  else {
136
  // Install only if not installed!
137
- $operation =& $operations['operations'][$type][$rOperation['name']];
138
- if ($operation['state'] != self::OPERATION_STATE_INSTALLED) {
139
  // Import installer and get installer object!
140
  switch ($type) {
141
  case 'install':
@@ -143,7 +149,7 @@ class CJTInstallerModel {
143
  $installer = CJTInstaller::getInstance();
144
  break;
145
  case 'upgrade':
146
- $upgrader = $operations['upgrader'];
147
  cssJSToolbox::import($upgrader['file']);
148
  $installer = new $upgrader['class']();
149
  break;
76
  *
77
  */
78
  public function getInternalVersionName() {
79
+ return str_replace(array('.', '-'), '', $this->installedDbVersion);
80
  }
81
+
82
  /**
83
+ * Get installer operations for current CJT version!
84
  *
85
+ * @return array Operations list metadata.
86
  */
87
  public function getOperations() {
88
+ // Check if cached: Use only installer cache for 'current' CJT version.
89
+ if (!isset($operations[CJTPlugin::DB_VERSION])) {
90
  // Import installer reflection!
91
  cssJSToolbox::import('framework:installer:reflection.class.php');
92
  // Get Installer operations.
93
  cssJSToolbox::import('includes:installer:installer:installer.class.php');
94
+ $operations[CJTPlugin::DB_VERSION]['operations']['install'] = CJTInstallerReflection::getInstance('CJTInstaller', 'CJTInstaller')->getOperations();
95
  if ($this->isUpgrade()) {
96
  // Get upgrade operations , Also cache upgrader info for later use!
97
+ $operations[CJTPlugin::DB_VERSION]['upgrader'] = $upgrader = $this->getUpgrader();
98
+ // Check if upgrader exists!
99
+ if (!file_exists(cssJSToolbox::resolvePath($upgrader['file']))) {
100
+ throw new Exception("Could not find upgrade/downgrade agent for installer '{$this->installedDbVersion}'! Incompatible version numbers! Upgrader/Downgrwader is no being supported by current versions!!");
101
+ }
102
+ // Import upgrader + reflect its operations!
103
  cssJSToolbox::import($upgrader['file']);
104
+ $operations[CJTPlugin::DB_VERSION]['operations']['upgrade'] = CJTInstallerReflection::getInstance($upgrader['class'], 'CJTUpgradeNonTabledVersions')->getOperations();
105
  }
106
+ update_option(self::INSTALLATION_STATE, $operations);
 
107
  }
108
+ return $operations[CJTPlugin::DB_VERSION];
109
  }
110
+
111
  /**
112
  * put your comment there...
113
  *
131
  // Read input!
132
  $rOperation = $this->input['operation'];
133
  $type = $rOperation['type'];
134
+ // Get allowed operations with their state!
135
  $operations = (array) get_option(self::INSTALLATION_STATE);
136
+ $vOperations =& $operations[CJTPlugin::DB_VERSION];
137
  // Invalid operation!
138
+ if (!isset($vOperations['operations'][$type][$rOperation['name']])) {
139
  throw new Exception('Invalid operation');
140
  }
141
  else {
142
  // Install only if not installed!
143
+ $operation =& $vOperations['operations'][$type][$rOperation['name']];
144
+ if ((!isset($operation['state'])) || ($operation['state'] != self::OPERATION_STATE_INSTALLED)) {
145
  // Import installer and get installer object!
146
  switch ($type) {
147
  case 'install':
149
  $installer = CJTInstaller::getInstance();
150
  break;
151
  case 'upgrade':
152
+ $upgrader = $vOperations['upgrader'];
153
  cssJSToolbox::import($upgrader['file']);
154
  $installer = new $upgrader['class']();
155
  break;
models/setup.php CHANGED
@@ -35,6 +35,10 @@ class CJTSetupModel {
35
  public function __construct() {
36
  // Read all cached licenses!
37
  $this->licenses = get_option(self::LICENSES_CACHE);
 
 
 
 
38
  }
39
 
40
  /**
@@ -103,7 +107,7 @@ class CJTSetupModel {
103
  *
104
  */
105
  public function & getLicenses() {
106
- return $this->licenses ? $this->licenses : array();
107
  }
108
 
109
  /**
35
  public function __construct() {
36
  // Read all cached licenses!
37
  $this->licenses = get_option(self::LICENSES_CACHE);
38
+ // Make sure its array!
39
+ if (!is_array($this->licenses)) {
40
+ $this->licenses = array();
41
+ }
42
  }
43
 
44
  /**
107
  *
108
  */
109
  public function & getLicenses() {
110
+ return $this->licenses;
111
  }
112
 
113
  /**
readme.txt CHANGED
@@ -7,7 +7,7 @@ License: GPLv2 or later
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Requires at least: 3.3
9
  Tested up to: 3.5.1
10
- Stable tag: 6.0
11
 
12
  Easily add custom CSS, JavaScript, HTML and PHP code to unique CJT code blocks and assign them wherever you want.
13
 
@@ -62,10 +62,10 @@ Regards,
62
  Team CJT
63
 
64
  == Installation ==
65
-
66
- 1. Upload the 'css-js-toolbox' folder to the '/wp-content/plugins/' directory
67
- 2. Activate the plugin through the 'Plugins' menu in WordPress
68
- 3. Click 'CSS & JavaScript Toolbox' link in the main navigation (left side of your Dashboard).
69
 
70
  == Frequently Asked Questions ==
71
  = Why was the CJT plugin developed and what is it used for? =
@@ -114,16 +114,22 @@ Make sure you have copied and pasted the Page, Post, or Category URL exactly as
114
  Hook location feature gives you control over the location of outputting the CSS/JS code. This is useful in case overriding another plugins' CSS is required. Also sometimes its better to put your JS code in the footer to avoid slowing down your page load.
115
 
116
  = I received a weird error, what do I do now? =
117
- Sometimes a bug decides to rear its ugly head and when this happens, this is when we need your help. If you receive an error, if it be a PHP error, or some functionality that isn't working for whatever reason, please visit our: [CSS & JavaScript Toolbox website and let us know](http://css-javascript-toolbox.com/support/plugin/css-javascript-toolbox-forum)
118
 
119
  == Screenshots ==
120
 
121
  1. Main CJT V6 CE code block screen
122
  2. CJT Shortcode button
123
 
124
-
125
  == Changelog ==
126
 
 
 
 
 
 
 
 
127
  = 6.0 =
128
  * Core code is 100% re-written for optimum performance and future enhancements, and is 100% based on MVC (Model–view–controller) design.
129
  * 100% Using Web 2.0
@@ -185,15 +191,18 @@ Sometimes a bug decides to rear its ugly head and when this happens, this is whe
185
  == Upgrade Notice ==
186
 
187
  = 0.8 =
188
- - Templates feature/system is not available anymore! Please backup your templates data manually before upgrading. You can do this by copying and pasting CSS and JS template data into a text editor and saving your text file.
189
- - If you have any other third-party plugin or software integrated with the CJT plugin database, please note that the database structure has been completely changed in CJT V6 CE.
190
- - Linked scripts are now obsolete! If you've linked scripts with any code blocks, then those blocks might stop working.
 
 
191
 
192
  = 0.3 =
193
- - Templates feature/system is not available anymore! Please backup your templates data manually before upgrading. You can do this by copying and pasting CSS and JS template data into a text editor and saving your text file.
194
- - If you have any other third-party plugin or software integrated with the CJT plugin database, please note that the database structure has been completely changed in CJT V6 CE.
195
- - Code block names will get changed as 'CSS & Javascript Block' phrase will be removed and replaced by 'Block' word.
196
- - The double-slashes fix modules is now obsolete! If you have extra slashes (double slashes) in your code block you have to clean it manually yourself or upgrade to version 0.8 to fix them first!
 
197
 
198
  == Credits ==
199
 
7
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  Requires at least: 3.3
9
  Tested up to: 3.5.1
10
+ Stable tag: 6.0.6
11
 
12
  Easily add custom CSS, JavaScript, HTML and PHP code to unique CJT code blocks and assign them wherever you want.
13
 
62
  Team CJT
63
 
64
  == Installation ==
65
+ 1. If you're upgrading from older versions its highly recommended to backup your database before upgrading.
66
+ 2. Upload the 'css-js-toolbox' folder to the '/wp-content/plugins/' directory
67
+ 3. Activate the plugin through the 'Plugins' menu in WordPress
68
+ 4. Click 'CSS & JavaScript Toolbox' link in the main navigation (left side of your Dashboard).
69
 
70
  == Frequently Asked Questions ==
71
  = Why was the CJT plugin developed and what is it used for? =
114
  Hook location feature gives you control over the location of outputting the CSS/JS code. This is useful in case overriding another plugins' CSS is required. Also sometimes its better to put your JS code in the footer to avoid slowing down your page load.
115
 
116
  = I received a weird error, what do I do now? =
117
+ Sometimes a bug decides to rear its ugly head and when this happens, this is when we need your help. If you receive an error, if it be a PHP error, or some functionality that isn't working for whatever reason, please visit our: [CSS & JavaScript Toolbox website and let us know](http://wordpress.org/support/plugin/css-javascript-toolbox)
118
 
119
  == Screenshots ==
120
 
121
  1. Main CJT V6 CE code block screen
122
  2. CJT Shortcode button
123
 
 
124
  == Changelog ==
125
 
126
+ = 6.0.6 =
127
+ * Fix: Conflict with other Plugins!
128
+ * Fix: Javascript exception throwed when dismissing the install/upgrade notice.
129
+ * Enhancement: Disallow (with user notice) upgrade/downgrade if the target version is not being supported, therefor saving user data!
130
+ * Enhancement: Don't break down the site if manual upgrade/downgrage process is incompleted! Allow user to revert back manually or disable the Plugin.
131
+ * Enhancement: E_ALL complain! Suppress all notices when WP_DEBUG set to true, allow better development, fast performance and error handling.
132
+
133
  = 6.0 =
134
  * Core code is 100% re-written for optimum performance and future enhancements, and is 100% based on MVC (Model–view–controller) design.
135
  * 100% Using Web 2.0
191
  == Upgrade Notice ==
192
 
193
  = 0.8 =
194
+ Its recommended to backup your database before upgrading.
195
+ Templates feature/system is not available anymore! Please backup your templates data manually before upgrading.
196
+ You can do this by copying and pasting CSS and JS template data into a text editor and saving your text file.
197
+ If you have any other third-party plugin or software integrated with the CJT plugin database, please note that the database structure has been completely changed in CJT V6 CE.
198
+ Linked scripts are now obsolete! If you've linked scripts with any code blocks, then those blocks might stop working.
199
 
200
  = 0.3 =
201
+ Its recommended to backup your database before upgrading.
202
+ Templates feature/system is not available anymore! Please backup your templates data manually before upgrading.
203
+ You can do this by copying and pasting CSS and JS template data into a text editor and saving your text file. If you have any other third-party plugin or software integrated with the CJT plugin database, please note that the database structure has been completely changed in CJT V6 CE.
204
+ Code block names will get changed as 'CSS & Javascript Block' phrase will be removed and replaced by 'Block' word.
205
+ The double-slashes fix modules is now obsolete! If you have extra slashes (double slashes) in your code block you have to clean it manually yourself or upgrade to version 0.8 to fix them first!
206
 
207
  == Credits ==
208
 
screenshot-1.jpg DELETED
Binary file
screenshot-2.jpg DELETED
Binary file
tables/blocks.php CHANGED
@@ -69,16 +69,16 @@ class CJTBlocksTable extends CJTTable {
69
  $where[] = " `id` IN ({$ids})";
70
  }
71
  // Filter by backup name.
72
- $where[] = (($filters['backupId'] == null) ? ' `backupId` IS NULL' : " `backupId` = {$filters['backupId']}");
73
  unset($filters['backupId']);
74
  // Filter by parent.
75
- if ($filters['parent'] != null) {
76
  $filters['parent'] = implode(',', ((array) $filters['parent']));
77
  $where[] = " `parent` IN ({$filters['parent']})";
78
  unset($filters['parent']);
79
  }
80
  // Types filter.
81
- if ($filters['types']) {
82
  $types = '"' . implode('", "', $filters['types']) . '"';
83
  $where[] = " `type` IN ({$types})";
84
  unset($filters['types']);
69
  $where[] = " `id` IN ({$ids})";
70
  }
71
  // Filter by backup name.
72
+ $where[] = (!isset($filters['backupId']) ? ' `backupId` IS NULL' : " `backupId` = {$filters['backupId']}");
73
  unset($filters['backupId']);
74
  // Filter by parent.
75
+ if (isset($filters['parent'])) {
76
  $filters['parent'] = implode(',', ((array) $filters['parent']));
77
  $where[] = " `parent` IN ({$filters['parent']})";
78
  unset($filters['parent']);
79
  }
80
  // Types filter.
81
+ if (isset($filters['types'])) {
82
  $types = '"' . implode('", "', $filters['types']) . '"';
83
  $where[] = " `type` IN ({$types})";
84
  unset($filters['types']);
views/blocks/block/tmpl/edit.html.tmpl CHANGED
@@ -17,7 +17,7 @@ defined('ABSPATH') or die("Access denied");
17
  <input type="hidden" name="blocks[]" value="<?php echo $this->block->id ?>" />
18
  <?php
19
  // Hidden fields.
20
- $fields = array('name','state','location','scripts');
21
  foreach ($fields as $field) :
22
  ?>
23
  <input type="hidden" name="cjtoolbox[<?php echo $this->block->id; ?>][<?php echo $field ?>]" value="<?php echo $this->block->$field ?>" />
@@ -29,23 +29,5 @@ defined('ABSPATH') or die("Access denied");
29
  <div id="editor-<?php echo $this->block->id ?>" class="code-editor">
30
  </div>
31
  </div>
32
- <?php
33
- // Meta field.
34
- foreach ((array) $this->block->meta as $module => $values) :
35
- foreach ($values as $metaName => $metaValue) :
36
- $isHidden = strpos($metaName, '_');
37
- if (($isHidden !== FALSE) && ($isHidden == 0)) {
38
- // Fields start with underscore is private to the modules.
39
- continue;
40
- }
41
- if (is_array($metaValue)) {
42
- $metaValue = json_encode($metaValue);
43
- }
44
- ?>
45
- <input type="hidden" class="meta-<?php echo $this->block->id ?>-<?php echo $module ?>" name="cjtoolbox[<?php echo $this->block->id ?>][meta][<?php echo $module ?>][<?php echo $metaName ?>]" value='<?php echo $metaValue ?>' />
46
- <?php
47
- endforeach;
48
- endforeach;
49
- ?>
50
  </div>
51
  </div>
17
  <input type="hidden" name="blocks[]" value="<?php echo $this->block->id ?>" />
18
  <?php
19
  // Hidden fields.
20
+ $fields = array('name', 'state','location');
21
  foreach ($fields as $field) :
22
  ?>
23
  <input type="hidden" name="cjtoolbox[<?php echo $this->block->id; ?>][<?php echo $field ?>]" value="<?php echo $this->block->$field ?>" />
29
  <div id="editor-<?php echo $this->block->id ?>" class="code-editor">
30
  </div>
31
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  </div>
33
  </div>
views/blocks/cjt-block/helpers/wppageslist.inc.php CHANGED
@@ -38,7 +38,7 @@ abstract class WPPagesListHelper {
38
  if (is_taxonomy_hierarchical($taxonomy_name)) {
39
  $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
40
  }
41
- $walker = new cj_Walker_Nav_Menu_Checklist($db_fields, $blockId, 'categories', $selectedTaxonomies, $regionMetrics);
42
  $args['walker'] = $walker;
43
  echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args);
44
  }
@@ -71,7 +71,6 @@ abstract class WPPagesListHelper {
71
  $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
72
  }
73
  $walker = new cj_Walker_Nav_Menu_Checklist($db_fields, $blockId, $name, $selectedPages);
74
- $post_type_object = get_post_type_object($post_type_name);
75
  $args['walker'] = $walker;
76
  $checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args);
77
  echo $checkbox_items;
38
  if (is_taxonomy_hierarchical($taxonomy_name)) {
39
  $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' );
40
  }
41
+ $walker = new cj_Walker_Nav_Menu_Checklist($db_fields, $blockId, 'categories', $selectedTaxonomies);
42
  $args['walker'] = $walker;
43
  echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args);
44
  }
71
  $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' );
72
  }
73
  $walker = new cj_Walker_Nav_Menu_Checklist($db_fields, $blockId, $name, $selectedPages);
 
74
  $args['walker'] = $walker;
75
  $checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args);
76
  echo $checkbox_items;
views/blocks/manager/tmpl/help/intro.html.tmpl CHANGED
@@ -8,18 +8,6 @@ defined('ABSPATH') or die("Access denied");
8
  ?>
9
 
10
  <h2><?php echo cssJSToolbox::getText('Welcome to the CSS & JavaScript Toolbox dashboard') ?></h2>
11
- <p><?php echo cssJSToolbox::getText('Since you do not have any code blocks active, you can either: create a new code block or create a new code template.') ?></p>
12
  <h4><?php echo cssJSToolbox::getText('Create a new Code Block') ?></h4>
13
- <p><?php echo cssJSToolbox::getText('You can add a new code block by clicking the New Code Block button. Once your code block has been added, simply choose the editor you wish to work with and write your code. You can then select if you want your code to run in the header or the footer of the webpage. Now it\'s just a matter of selecting the webpage where you want the code to run on, by using the Assignment Panel. This panel lets you assign your code block to Pages, Posts, Categories, URLs, and much more, and you can select as many as you need. Once you have saved your code block by clicking the Save button (or Save All Changes button), you can see it in action by refreshing the assigned webpage.') ?></p>
14
- <h4><?php echo cssJSToolbox::getText('Create a new Code Template') ?></h4>
15
- <p><?php echo cssJSToolbox::getText('You can create code templates when you click into the Code Template Manager. To find this, hover over the icon showing a small cog over pages, and a tooltip should say Code Template Manager. Press this and if you have chosen to install the Template Samples, you will notice them sitting in there ready to be used. If you want to create a code template from scratch, click the Create Template button. Here you can choose a name for your code template, select a code language type (i.e. CSS, JavaScript, HTML, PHP), choose whether the template is in Draft or Published state, and then write your code. You have other tabs that allow you to write a Description, add Keywords and Version number, etc. Once you are happy with your code template, you can click the Save button') ?></p>
16
- <h4><?php echo cssJSToolbox::getText('Embedding or Linking a Code Templates') ?></h4>
17
- <p> <?php echo cssJSToolbox::getText('Code Templates can be either embedded or linked into your code blocks. To see all your code templates, you have to click the Template Lookup icon by hovering over the icon with the open/closed angled brackets. A popup will appear showing you code templates in the form of users and they are:') ?></p>
18
- <ol>
19
- <li><?php echo cssJSToolbox::getText('WordPress: default code templates that are packaged with WordPress') ?></li>
20
- <li><?php echo cssJSToolbox::getText('Sample Templates: CJT Sample Templates (depending if Sample Templates were selected during install)') ?></li>
21
- <li><?php echo cssJSToolbox::getText('Users: code templates created by actual WordPress users and administrators') ?> </li>
22
- </ol>
23
- <p><?php echo cssJSToolbox::getText('You can click on any of the 3 types of users to see all of their code templates, and you can either embed or link these to code blocks.') ?></p>
24
- <p><strong><?php echo cssJSToolbox::getText('Embed') ?></strong>: <?php echo cssJSToolbox::getText('embedding a code template will paste the entire template contents into the code block editor. This can be ideal if you want to do further enhancements and customisations to the code without permanently changing the base template.') ?></p>
25
- <p><strong><?php echo cssJSToolbox::getText('Link') ?></strong>: <?php echo cssJSToolbox::getText('linking the code template does not actually paste the template into the code block editor but instead links to it. This is more ideal if you want to link many code templates to the one code block. There is no need to create individual code blocks for each.') ?></p>
8
  ?>
9
 
10
  <h2><?php echo cssJSToolbox::getText('Welcome to the CSS & JavaScript Toolbox dashboard') ?></h2>
11
+ <p><?php echo cssJSToolbox::getText('Since you do not have any code blocks active, you can create a new code block.') ?></p>
12
  <h4><?php echo cssJSToolbox::getText('Create a new Code Block') ?></h4>
13
+ <p><?php echo cssJSToolbox::getText('You can add a new code block by clicking the New Code Block button. Once your code block has been added, simply choose the editor you wish to work with and write your code. You can then select if you want your code to run in the header or the footer of the webpage. Now it\'s just a matter of selecting the webpage where you want the code to run on, by using the Assignment Panel. This panel lets you assign your code block to Pages, Posts, Categories, URLs, and much more, and you can select as many as you need. Once you have saved your code block by clicking the Save button (or Save All Changes button), you can see it in action by refreshing the assigned webpage.') ?></p>
 
 
 
 
 
 
 
 
 
 
 
 
views/installer/install/public/css/default.css CHANGED
@@ -8,4 +8,5 @@ ul.installation-list li.installed .text{top: -3px; position: relative;}
8
  ul.installation-list li.progress {list-style-image: url('../images/progress.gif');}
9
  ul.installation-list li.installed {margin-left: 34px; list-style-image: url('../images/installed.png');}
10
 
11
- input[name="install"] {width: 79px;}
 
8
  ul.installation-list li.progress {list-style-image: url('../images/progress.gif');}
9
  ul.installation-list li.installed {margin-left: 34px; list-style-image: url('../images/installed.png');}
10
 
11
+ input[name="install"] {width: 79px;}
12
+ .error {font-size: 20px}
views/installer/install/tmpl/default.html.tmpl CHANGED
@@ -16,6 +16,7 @@ else {
16
  }
17
  ?>
18
  <div class="cjt-installer-view">
 
19
  <form name="installation-form" action="">
20
  <input type="hidden" id="cjt-securityToken" value="<?php echo $this->securityToken ?>" />
21
  <h1><?php echo cssJSToolbox::getText($title) ?></h1>
@@ -47,5 +48,9 @@ else {
47
  }
48
  ?>
49
  <input type="button" name="install" value="<?php echo cssJSToolbox::getText($installButtonTitle) ?>" />
 
 
 
 
50
  </form>
51
  </div>
16
  }
17
  ?>
18
  <div class="cjt-installer-view">
19
+ <?php if (!$this->error) : ?>
20
  <form name="installation-form" action="">
21
  <input type="hidden" id="cjt-securityToken" value="<?php echo $this->securityToken ?>" />
22
  <h1><?php echo cssJSToolbox::getText($title) ?></h1>
48
  }
49
  ?>
50
  <input type="button" name="install" value="<?php echo cssJSToolbox::getText($installButtonTitle) ?>" />
51
+ <?php else : ?>
52
+ <div class="error"><p><?php echo $this->error->getMessage() ?></p></div>
53
+ <br>
54
+ <?php endif ?>
55
  </form>
56
  </div>
views/installer/install/tmpl/default_operation.html.tmpl CHANGED
@@ -6,9 +6,9 @@
6
  // Disallow direct access.
7
  defined('ABSPATH') or die("Access denied");
8
  ?>
9
- <li class="<?php echo $operation['name'] ?><?php if ($operation['state']) echo " {$operation['state']}"; ?>">
10
- <?php if ($operation['state'] != CJTInstallerModel::OPERATION_STATE_INSTALLED) : ?>
11
- <input type="checkbox" checked="checked" <?php echo ($operation['attributes']['optional'] ? 'class="optional"' : 'disabled="disabled"') ?> value="1" />
12
  <?php endif; ?>
13
  <span class="text"><?php echo $operation['text'] ?></span>
14
  </li>
6
  // Disallow direct access.
7
  defined('ABSPATH') or die("Access denied");
8
  ?>
9
+ <li class="<?php echo $operation['name'] ?><?php if (isset($operation['state'])) echo " {$operation['state']}"; ?>">
10
+ <?php if (!isset($operation['state']) || ($operation['state'] != CJTInstallerModel::OPERATION_STATE_INSTALLED)) : ?>
11
+ <input type="checkbox" checked="checked" <?php echo (isset($operation['attributes']['optional']) ? 'class="optional"' : 'disabled="disabled"') ?> value="1" />
12
  <?php endif; ?>
13
  <span class="text"><?php echo $operation['text'] ?></span>
14
  </li>
views/installer/install/tmpl/upgrades/02.operations ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ */
5
+
6
+ // Disallow direct access.
7
+ defined('ABSPATH') or die("Access denied");
8
+
9
+ // Return operatrions!
10
+ return array(
11
+ 'blocks' => array('text' => cssJSToolbox::getText('Transfer blocks to the new blocks table. Old versions doesn\'t use a specific blocks table!')),
12
+ );
views/installer/install/tmpl/upgrades/03.operations CHANGED
@@ -8,5 +8,6 @@ defined('ABSPATH') or die("Access denied");
8
 
9
  // Return operatrions!
10
  return array(
 
11
  'backups' => array('text' => cssJSToolbox::getText('Transfer backup blocks.')),
12
  );
8
 
9
  // Return operatrions!
10
  return array(
11
+ 'blocks' => array('text' => cssJSToolbox::getText('Transfer blocks to the new blocks table. Old versions doesn\'t use a specific blocks table!')),
12
  'backups' => array('text' => cssJSToolbox::getText('Transfer backup blocks.')),
13
  );
views/installer/install/tmpl/upgrades/upgrade.html.tmpl CHANGED
@@ -11,13 +11,9 @@ defined('ABSPATH') or die("Access denied");
11
  <p><?php echo cssJSToolbox::getText('Important Note: It is highly recommended to upgrade the plugin using the same administrator or user that was used to manage the code blocks. This allows the upgrade system to obtain the code blocks \'ORDER\' from the current logged in administrators or users\' meta data.') ?></p>
12
  <ul class="installation-list upgrade">
13
  <?php
14
- // Define upgrade-common operations.
15
- $operations = array(
16
- 'blocks' => array('text' => cssJSToolbox::getText('Transfer blocks to the new blocks table. Old versions doesn\'t use a specific blocks table!')),
17
- );
18
  // Get version operations.
19
- $versionOperation = @include ("{$this->installedDbVersionId}.operations");
20
- $operations = array_merge($operations, ($versionOperation ? $versionOperation : array()));
21
  // Add last operations.
22
  $operations['finalize'] = array('text' => cssJSToolbox::getText('Finalize Upgrade.'));
23
  // Print upgrade operations.
11
  <p><?php echo cssJSToolbox::getText('Important Note: It is highly recommended to upgrade the plugin using the same administrator or user that was used to manage the code blocks. This allows the upgrade system to obtain the code blocks \'ORDER\' from the current logged in administrators or users\' meta data.') ?></p>
12
  <ul class="installation-list upgrade">
13
  <?php
 
 
 
 
14
  // Get version operations.
15
+ $operations = @include ("{$this->installedDbVersionId}.operations");
16
+ $operations = $operations ? $operations : array();
17
  // Add last operations.
18
  $operations['finalize'] = array('text' => cssJSToolbox::getText('Finalize Upgrade.'));
19
  // Print upgrade operations.
views/installer/install/view.php CHANGED
@@ -11,6 +11,13 @@ defined('ABSPATH') or die("Access denied");
11
  */
12
  class CJTInstallerInstallView extends CJTView {
13
 
 
 
 
 
 
 
 
14
  /**
15
  * put your comment there...
16
  *
@@ -67,11 +74,16 @@ class CJTInstallerInstallView extends CJTView {
67
  public function display($tpl = null) {
68
  $model = $this->getModel('installer');
69
  // Initialize templates vars!
70
- $this->installedDbVersion = $model->getInstalledDbVersion();
71
- $this->installedDbVersionId = $model->getInternalVersionName();
72
- $this->securityToken = cssJSToolbox::getSecurityToken();
73
- $this->operations = $model->getOperations();
74
- $this->upgrade = $model->isUpgrade();
 
 
 
 
 
75
  // Display view!
76
  echo $this->getTemplate($tpl);
77
  }
11
  */
12
  class CJTInstallerInstallView extends CJTView {
13
 
14
+ /**
15
+ * put your comment there...
16
+ *
17
+ * @var Exception
18
+ */
19
+ protected $error;
20
+
21
  /**
22
  * put your comment there...
23
  *
74
  public function display($tpl = null) {
75
  $model = $this->getModel('installer');
76
  // Initialize templates vars!
77
+ try {
78
+ $this->installedDbVersion = $model->getInstalledDbVersion();
79
+ $this->installedDbVersionId = $model->getInternalVersionName();
80
+ $this->securityToken = cssJSToolbox::getSecurityToken();
81
+ $this->operations = $model->getOperations();
82
+ $this->upgrade = $model->isUpgrade();
83
+ }
84
+ catch (Exception $exception) {
85
+ $this->error = $exception;
86
+ }
87
  // Display view!
88
  echo $this->getTemplate($tpl);
89
  }
views/installer/notice/public/js/default/default.js CHANGED
@@ -28,7 +28,7 @@
28
  CJTServer.send('installer', 'dismissNotice').success($.proxy(
29
  function() {
30
  // Hide notice!
31
- this.notice.fadeOut('slow').done(this.remove());
32
  }, this)
33
  );
34
  }
28
  CJTServer.send('installer', 'dismissNotice').success($.proxy(
29
  function() {
30
  // Hide notice!
31
+ this.notice.fadeOut('slow', function() {this.remove()});
32
  }, this)
33
  );
34
  }