public function initializeMetaboxes() { foreach ($this->metaboxes as $metabox) { $callback = isset($metabox['requestAction']) ? $metabox['requestAction'] : array('controller' => 'metaboxes', 'action' => 'edit'); $callback = GummDispatcher::getCallbackToDispatch($callback); if (!$callback) { trigger_error(__('Invalid callback to dispatch for metabox', 'gummfw')); } $metabox['page'] = (array) $metabox['page']; $pages = array(); foreach ($metabox['page'] as $k => $page) { $type = $page; $not = array(); if (is_array($page)) { $type = $k; if (isset($page['NOT'])) { $not = (array) $page['NOT']; } } if ($type === 'single') { $postTypes = $this->Post->getPostTypes(); foreach ($postTypes as $postType) { if (!in_array($postType, $not)) { $this->addMetaBox($metabox, $callback, $postType); $pages[] = $postType; } } } else { $shouldAdd = true; if (isset($_REQUEST['post']) && in_array($_REQUEST['post'], $not)) { $shouldAdd = false; } if ($shouldAdd) { $this->addMetaBox($metabox, $callback, $type); $pages[] = $type; } } } if (isset($metabox['hidden']) && $metabox['hidden']) { $hideOn = $pages; if ($metabox['hidden'] !== true) { $hideOn = array(); $metabox['hidden'] = (array) $metabox['hidden']; foreach ($metabox['hidden'] as $hideOnType) { if ($hideOnType === 'single') { $hideOn = array_merge($hideOn, $this->Post->getPostTypes()); } else { $hideOn[] = $hideOnType; } } } foreach ($hideOn as $page) { if (!isset($this->hiddenMetaboxes[$page])) { $this->hiddenMetaboxes[$page] = array(); } $this->hiddenMetaboxes[$page][] = $metabox['id']; } } } }
/** * @return array|false */ public static function getCallbackToDispatch(array $requestAction = array()) { $_this = GummDispatcher::getInstance(); extract($requestAction, EXTR_SKIP); if (!isset($controller)) { $controller = $_this->RequestHandler->getController(); // Render / Add to Menu the Theme Options Page if (!$controller) { return false; } if (!$controller && is_admin() && !$_this->RequestHandler->isAdminAjax()) { $controller = 'options'; $action = 'admin_index'; } elseif (!$controller) { return false; } } if (!isset($action)) { $action = $_this->RequestHandler->getAction(); } if (!$action) { $action = 'index'; if (is_admin()) { $action = 'admin_' . $action; } } // $ControllerObj = GummRegistry::get('Controller', $controller); // debug($ControllerObj); App::import('Controller', $controller); $controllerClass = Inflector::camelize($controller) . 'Controller'; if (!class_exists($controllerClass)) { trigger_error(sprintf(__('Class %s not defined.', 'gummfw'), $controllerClass), E_USER_ERROR); } $ControllerObj = new $controllerClass(); if (!is_a($ControllerObj, 'Controller')) { trigger_error(sprintf(__('Class %s must be a Controller.', 'gummfw'), $controllerClass), E_USER_ERROR); } $realAction = str_replace(GUMM_FW_PREFIX, '', $action); if (strpos($realAction, 'admin_') === false && (is_admin() || isset($_REQUEST['gummadmin']))) { $realAction = 'admin_' . $realAction; } $ControllerObj->action = $realAction; $callback = array(&$ControllerObj, $realAction); if (!is_callable($callback)) { trigger_error(__('Request is not a valid callback.', 'gummfw'), E_USER_ERROR); } return $callback; }
require_once GUMM_BASE . 'app_controller.php'; require_once GUMM_CONFIGS . 'routes.php'; require_once GUMM_CONFIGS . 'core.php'; require_once GUMM_CONFIGS . 'assets.config'; require_once GUMM_CONFIGS . 'data.config'; require_once GUMM_CONFIGS . 'options.config'; require_once GUMM_CONFIGS . 'metaboxes.config'; require_once GUMM_CONFIGS . 'resolutions.config'; // Register GUMM Helpers to be available in all views App::import('Helper', 'Wp'); App::import('Helper', 'Js'); App::import('Helper', 'Media'); App::import('Helper', 'Text'); App::import('Helper', 'Html'); // App::uses('functions', 'Vendor/EnvatoWordpressToolkit'); $GummDispatcher = new GummDispatcher(); // Called in views to get custom logic for WP specific functions $gummWpHelper = GummRegistry::get('Helper', 'Wp'); $gummJsHelper = GummRegistry::get('Helper', 'Js'); $gummJsHelper->registerScripts(); $gummMediaHelper = GummRegistry::get('Helper', 'Media'); $gummTextHelper = GummRegistry::get('Helper', 'Text'); $gummHtmlHelper = GummRegistry::get('Helper', 'Html'); $gummHtmlHelper->registerStyles(); $gummLayoutHelper = GummRegistry::get('Helper', 'Layout'); if (Configure::read('Data.externalPluginIntegraion')) { App::uses('GummExternalPluginIntegration', 'Plugin/GummExternalPluginIntegration'); $gummExternalPluginIntegration = new GummExternalPluginIntegration(); $gummExternalPluginIntegration->integrate(); } if (GummRegistry::get('Helper', 'Wp')->getOption('enable_image_preload') == 'true' && !GummRegistry::get('Component', 'RequestHandler')->isAjax()) {
/** * @param array $callback * @param mixed $params * @return void */ public function requestAction($requested, $render = true) { if (!isset($requested['controller'])) { if (is_a($this, 'View')) { if (isset($this->controller)) { $requested['controller'] = str_replace('_controller', '', Inflector::underscore(get_class($this->controller))); } } } if (!isset($requested['controller']) || !isset($requested['action'])) { return false; } $callback = GummDispatcher::getCallbackToDispatch($requested); if (!$callback) { return false; } $args = GummRouter::getUrlParams($requested); $params = $args['params']; $controller =& $callback[0]; $controller->startupProcess(); $return = call_user_func_array($callback, $params); if ($render === false) { ob_start(); $controller->shutdownProcess(false); $return = ob_get_clean(); } else { $controller->shutdownProcess(false); } return $return; }