| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
class CJTMetaboxAccessPoint 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 = 'metabox'; |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* put your comment there... |
| 27 |
* |
| 28 |
*/ |
| 29 |
protected function doListen() { |
| 30 |
// Only if permitted! |
| 31 |
if ($this->hasAccess()) { |
| 32 |
// Add CJT Block metabox! |
| 33 |
add_action("add_meta_boxes", array(&$this, 'postsMetabox'), 10, 2); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* put your comment there... |
| 39 |
* |
| 40 |
* @param mixed $postType |
| 41 |
* @param mixed $post |
| 42 |
*/ |
| 43 |
public function postsMetabox($postType, $post) { |
| 44 |
// Initialize. |
| 45 |
$controller = false; |
| 46 |
// Veil access point unless CJT installed! |
| 47 |
if (CJTPlugin::getInstance()->isInstalled()) { |
| 48 |
// Only if permitted! |
| 49 |
if ($this->hasAccess()) { |
| 50 |
// Set as connected object! |
| 51 |
$this->connected(); |
| 52 |
// Load metabox controller! |
| 53 |
$this->controllerName = 'metabox'; |
| 54 |
// Standarize calling the controller with Ajax requests! |
| 55 |
// Ajax uses 'post' parameter as postId! |
| 56 |
$post = $post->ID; |
| 57 |
// Dispatch controller! |
| 58 |
$controller = $this->route(null, compact('postType', 'post')); |
| 59 |
} |
| 60 |
} |
| 61 |
return $controller; |
| 62 |
} |
| 63 |
|
| 64 |
} // End class. |
| 65 |
|
| 66 |
// Hookable! |
| 67 |
CJTMetaboxAccessPoint::define('CJTMetaboxAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |