PluginProbe
CSS & JavaScript Toolbox / 9.3
CSS & JavaScript Toolbox v9.3
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 | controllers/blocks-coupling.php +18 -60 129.3 View file →
@@ -23,11 +23,11 @@
23 23 * put your comment there...
24 24 *
25 25 * @var mixed
26 26 */
27 - public $blocks = array(
28 - 'code' => array(),
29 - 'scripts' => array(),
27 + protected $blocks = array(
28 + 'code' => array('header' => '', 'footer' => ''),
29 + 'scripts' => array('header' => array(), 'footer' => array()),
30 30 );
31 31
32 32 /**
33 33 * put your comment there...
@@ -42,15 +42,8 @@
42 42 * @var mixed
43 43 */
44 44 protected $filters = null;
45 45
46 - /**
47 - * put your comment there...
48 - *
49 - * @var mixed
50 - */
51 - protected $hookAttacher;
52 -
53 46 /**
54 47 * put your comment there...
55 48 *
56 49 * @var mixed
@@ -238,43 +231,25 @@
238 231 * @see CJTController for more details
239 232 * @return void
240 233 */
241 234 public function __construct() {
242 -
243 235 // Only one instance is allowed.
244 236 if (self::$instance) {
245 237 throw new Exception('Trying to instantiate multiple coupling instances!!');
246 238 }
247 -
248 239 // Hold the single instance we've!
249 240 self::$instance = $this;
250 241 $siteHook = cssJSToolbox::$config->core->siteHook;
251 -
252 242 // Initialize controller.
253 243 parent::__construct(false);
254 -
255 244 // Import related libraries
256 245 CJTModel::import('block');
257 -
258 246 // Not default action needed.
259 247 $this->defaultAction = null;
260 - $this->hookAttacher = new CJTBlocksCouplingHookAttacher(array(&$this, 'outputBlocks'));
261 -
262 - // Initialize Blocks array
263 - foreach ($this->hookAttacher->getFiltersList() as $hooks) {
264 -
265 - foreach ($hooks as $hook) {
266 -
267 - $this->blocks['code'][$hook['locationName']] = '';
268 - $this->blocks['script'][$hook['locationName']] = '';
269 - }
270 - }
271 -
272 248 // Initialize controller.
273 249 $initCouplingCallback = $this->onassigncouplingcallback(array(&$this, 'initCoupling'));
274 250 add_action('admin_init', $initCouplingCallback);
275 251 add_action($siteHook->tag, $initCouplingCallback, $siteHook->priority);
276 -
277 252 // Add Shortcode callbacks.
278 253 add_shortcode('cjtoolbox', array(&$this, 'shortcode'));
279 254 }
280 255
@@ -305,9 +280,9 @@
305 280 $blocksOrder = array();
306 281 $metaBoxesOrder = $this->onblocksorder( $this->model->getOrder() );
307 282
308 283 // Get ORDER-INDEX <TO> BLOCK-ID mapping.
309 - if ( $metaBoxesOrder ) preg_match_all( '/cjtoolbox-(\d+)/', $metaBoxesOrder[ 'normal' ], $blocksOrder, PREG_SET_ORDER );
284 + preg_match_all( '/cjtoolbox-(\d+)/', $metaBoxesOrder[ 'normal' ], $blocksOrder, PREG_SET_ORDER );
310 285
311 286 /**
312 287 * append more to orders produced by CJTBlocksCouplingController::setRequestFilter().
313 288 * More to orders may allow other blocks to bein the output (e.g metaboxe blocks).
@@ -356,9 +331,8 @@
356 331 $this->onprocess();
357 332
358 333 foreach ( $blocksOrder as $blockOrder )
359 334 {
360 -
361 335 $blockId = (int) $blockOrder[1];
362 336
363 337 // As mentioned above. Orders is for all blocks not just those queried from db.
364 338 if ( isset($blocks[ $blockId ] ) )
@@ -443,14 +417,8 @@
443 417 endif;
444 418 // CODE UPDATED BY RBJ -- END
445 419 }
446 420
447 - // Initialize block LOCATION array for the first time
448 - if (!isset($this->blocks[ 'code' ][ $block->location ])) {
449 -
450 - $this->blocks[ 'code' ][ $block->location ] = '';
451 - }
452 -
453 421 $this->blocks[ 'code' ][ $block->location ] .= $this->onappendcode( $evaluatedCode );
454 422
455 423 // Store all used Ids in the CORRECT ORDER.
456 424 $this->addOnActionIds( $blockId );
@@ -493,16 +461,8 @@
493 461 public function getFilters() {
494 462 return $this->ongetfilters($this->filters);
495 463 }
496 464
497 - /**
498 - * put your comment there...
499 - *
500 - */
501 - public function & getHooksAttacher() {
502 - return $this->hookAttacher;
503 - }
504 -
505 465 /**
506 466 * put your comment there...
507 467 *
508 468 */
@@ -522,11 +482,9 @@
522 482 $port = ($_SERVER["SERVER_PORT"] != "80") ? ":{$_SERVER["SERVER_PORT"]}" : '';
523 483 // Request URI.
524 484 $requestURI = $_SERVER['REQUEST_URI'];
525 485 // Final URL.
526 - //$url = "{$protocol}{$host}{$port}{$requestURI}";
527 - // Removing port segment from the URL as it is causing bugs.
528 - $url = "{$protocol}{$host}{$requestURI}";
486 + $url = "{$protocol}{$host}{$port}{$requestURI}";
529 487 return $url;
530 488 }
531 489
532 490 /**
@@ -549,22 +507,19 @@
549 507 return;
550 508 }
551 509 // Get current application hook prefix.
552 510 $actionsPrefix = is_admin() ? 'admin' : 'wp';
553 -
554 511 // Get cache or get blocks if not cached.
555 512 // If there is no cache or no blocks for output
556 513 // do nothing.
557 514 if ($this->getCached() || $this->getBlocks()) {
558 -
559 515 // Output blocks on various locations!
560 - $this->hookAttacher->bind();
561 -
516 + add_action("{$actionsPrefix}_head", array(&$this, 'outputBlocks'), 30);
517 + add_action("{$actionsPrefix}_footer", array(&$this, 'outputBlocks'), 30);
562 518 // Links templates & styloes!
563 519 add_action("{$actionsPrefix}_enqueue_scripts", array(&$this, 'linkTemplates'), 30);
564 520 add_action("{$actionsPrefix}_print_styles", array(&$this, 'linkTemplates'), 30);
565 521 }
566 -
567 522 // Link style sheet in footer required custom implementation.
568 523 add_action("{$actionsPrefix}_print_footer_scripts", array(&$this, 'linkFooterStyleSheets'), 9);
569 524 // Make sure this is executed only once.
570 525 // Sometimes wp hook run on backend and sometimes its not.
@@ -641,16 +596,19 @@
641 596 * put your comment there...
642 597 *
643 598 */
644 599 public function outputBlocks() {
645 -
646 - $hooks = $this->hookAttacher->getHooksByFilterName(current_filter());
647 -
648 - foreach ($hooks as $hook) {
649 -
650 - echo $this->onoutput($this->blocks['code'][$hook['locationName']], $hook['locationName']);
651 - }
652 -
600 + // Derived location name from wordpress filter name.
601 + $currentFilter = current_filter();
602 + // Map "wp hook location" to "block hook location".
603 + $locationsMap = array('head' => 'header', 'footer' => 'footer');
604 + // This hook is used across both ends, front and back ends.
605 + // Remove application prefix (wp_ or admin_).
606 + // Remining is head or footer.
607 + $location = str_replace(array('wp_', 'admin_'), '', $currentFilter);
608 + // Map to block location.
609 + $location = $locationsMap[$location];
610 + echo $this->onoutput($this->blocks['code'][$location], $location);
653 611 }
654 612
655 613 /**
656 614 * put your comment there...