| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
* |
| 12 |
* This is the first class name build for using autoload! |
| 13 |
* Autoload is not being supported yet however this is the first |
| 14 |
* class on the plain!!!! |
| 15 |
*/ |
| 16 |
class CJT_Controllers_Coupling_Shortcode extends CJTHookableClass { |
| 17 |
|
| 18 |
/** |
| 19 |
* put your comment there... |
| 20 |
* |
| 21 |
* @var mixed |
| 22 |
*/ |
| 23 |
protected $attributes; |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
* @var mixed |
| 29 |
*/ |
| 30 |
protected $content = null; |
| 31 |
|
| 32 |
/** |
| 33 |
* put your comment there... |
| 34 |
* |
| 35 |
* @param mixed $attributes |
| 36 |
* @param mixed $content |
| 37 |
* @return CJT_Controllers_Coupling_Shortcode |
| 38 |
*/ |
| 39 |
public function __construct($attributes, $content) { |
| 40 |
// Hookable initialization! |
| 41 |
parent::__construct(); |
| 42 |
// Initialize. |
| 43 |
$this->attributes = $attributes; |
| 44 |
$this->content = $content; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* put your comment there... |
| 49 |
* |
| 50 |
*/ |
| 51 |
public function __toString() { |
| 52 |
// Initialize. |
| 53 |
$attributes =& $this->attributes; |
| 54 |
// Default Class. |
| 55 |
if (!isset($attributes['class'])) { |
| 56 |
$shortcodeClass = 'Block'; |
| 57 |
} |
| 58 |
// Get Shortcode class file, check existance! |
| 59 |
$shortcodeClassFile = cssJSToolbox::resolvePath('controllers:coupling:shortcode:block:block.php'); |
| 60 |
if (!file_exists($shortcodeClassFile)) { |
| 61 |
throw new Exception('Shortcode Type is not supported!! Only (block) type is currently available!!!'); |
| 62 |
} |
| 63 |
// Import shortcodee handler file. |
| 64 |
require_once $shortcodeClassFile; |
| 65 |
|
| 66 |
// Import class. |
| 67 |
$className = "CJT_Controllers_Coupling_Shortcode_{$shortcodeClass}"; |
| 68 |
|
| 69 |
// Load shortcode 'CLASS' handler. |
| 70 |
$shortcode = new $className($this->attributes, $this->content); |
| 71 |
|
| 72 |
// Return Shortcode replacements. |
| 73 |
return ((string) $shortcode); |
| 74 |
} |
| 75 |
|
| 76 |
} // End class |
| 77 |
|
| 78 |
// Hookable! |
| 79 |
CJT_Controllers_Coupling_Shortcode::define('CJT_Controllers_Coupling_Shortcode'); |