| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
|
| 7 |
//Import dependencies. |
| 8 |
require_once 'observer.observer.php'; |
| 9 |
|
| 10 |
/** |
| 11 |
* |
| 12 |
*/ |
| 13 |
abstract class CJTWordpressHookObserver extends CJTObserver { |
| 14 |
|
| 15 |
/** |
| 16 |
* put your comment there... |
| 17 |
* |
| 18 |
* @var mixed |
| 19 |
*/ |
| 20 |
protected $priority; |
| 21 |
|
| 22 |
/** |
| 23 |
* |
| 24 |
*/ |
| 25 |
const PRIORITY = 10; |
| 26 |
|
| 27 |
/** |
| 28 |
* put your comment there... |
| 29 |
* |
| 30 |
* @param mixed $priority |
| 31 |
* @return CJTWordpressHookObserver |
| 32 |
*/ |
| 33 |
public function __construct($name = null, $filter = null, $priority = self::PRIORITY) { |
| 34 |
// Initialize parent! |
| 35 |
parent::__construct($name, $filter); |
| 36 |
// Initialize vars! |
| 37 |
$this->priority = $priority; |
| 38 |
} |
| 39 |
|
| 40 |
/** |
| 41 |
* put your comment there... |
| 42 |
* |
| 43 |
* @param mixed $subject |
| 44 |
* @param mixed $callback |
| 45 |
* @return CJTObserver |
| 46 |
*/ |
| 47 |
protected function init($subject, $callback, $param) { |
| 48 |
// Initialize parent! |
| 49 |
$return = parent::init($subject, $callback, $param); |
| 50 |
// Cache callback key! |
| 51 |
$this->key = self::getObserverKey($this->subject->getHookName(), $this->callback, $this->priority); |
| 52 |
return $return; |
| 53 |
} |
| 54 |
|
| 55 |
/** |
| 56 |
* put your comment there... |
| 57 |
* |
| 58 |
* @param mixed $name |
| 59 |
* @param mixed $callback |
| 60 |
* @param mixed $priority |
| 61 |
*/ |
| 62 |
public static function getObserverKey($name, $callback, $priority = self::PRIORITY) { |
| 63 |
return _wp_filter_build_unique_id($name, $callback, $priority); |
| 64 |
} |
| 65 |
|
| 66 |
} // End class |