| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTAjaxAccessPoint extends CJTAccessPoint { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
*/ |
| 18 |
public function __construct() { |
| 19 |
// Initialize Access Point base! |
| 20 |
parent::__construct(); |
| 21 |
// Set access point name! |
| 22 |
$this->name = 'ajax'; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
*/ |
| 29 |
protected function doListen() { |
| 30 |
// Define CJT AJAX access point! |
| 31 |
add_action("wp_ajax_{$this->pageId}_api", array(&$this, 'route')); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* put your comment there... |
| 36 |
* |
| 37 |
*/ |
| 38 |
public function route() { |
| 39 |
// Initializing! |
| 40 |
$controller = false; |
| 41 |
// Controllers allowed to be Loaded if not installed |
| 42 |
$notInstalledAllowedControllers = array('installer', 'setup'); |
| 43 |
// Veil access point unless CJT installed or the controller is installer (to allow instalaltion throught AJAX)! |
| 44 |
if (CJTPlugin::getInstance()->isInstalled() || in_array($this->controllerName, $notInstalledAllowedControllers)) { |
| 45 |
// Connected! |
| 46 |
$this->connected(); |
| 47 |
// Instantiate controller. |
| 48 |
$controller = parent::route(); |
| 49 |
// Dispatch the call as its originally requested from ajax action! |
| 50 |
$action = "wp_ajax_{$this->pageId}_{$_REQUEST['CJTAjaxAction']}"; |
| 51 |
// Fire Ajax action. |
| 52 |
do_action($action); |
| 53 |
} |
| 54 |
return $controller; |
| 55 |
} |
| 56 |
|
| 57 |
} // End class. |
| 58 |
|
| 59 |
// Hookable! |
| 60 |
CJTAjaxAccessPoint::define('CJTAjaxAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |
| 61 |
|