private function actions() { foreach ($this->hooks as $key => $hook) { if (is_numeric($key)) { Hook::registerHandler($hook, [$this, 'wp_hook_handler']); } else { Hook::registerHandler($key, [$this, 'wp_hook_handler']); } } }
/** * Inject a style handler for includes. * * @param IIncludes $iStyleInclude */ public function __construct(IIncludes $iStyleInclude = null) { if ($iStyleInclude) { $this->styleInclude = $iStyleInclude; } else { $this->styleInclude = Container::instance()->fetch('CLMVC\\Interfaces\\IStyleInclude'); } $this->styleInclude->init(); Hook::register('stylesheets-register', array($this, 'registerIncludes')); }
public function init() { Hook::register('init', [$this, 'routeQuery'], 1); Hook::register('init', [$this, 'renderText'], 99999); add_filter('do_parse_request', [$this, 'disableParseRequest'], 9999999, 3); Filter::register('posts_request', [$this, 'disablePostQuery'], 9999999); Filter::register('pre_handle_404', [$this, 'disable404handling']); Hook::register('rendering-render', function ($controllerName, $action) { global $clmvc_template; $clmvc_template = [$controllerName, $action]; }); Hook::register('init', [$this, 'templateRendering'], 9999); Filter::register('document_title_parts', [$this, 'setTitle']); Filter::register('wp_title', [$this, 'setTitle']); add_filter('pre_get_document_title', [$this, 'override404']); }
public function init() { if (Security::isAdmin()) { Filter::register('set_plugin_has_updates', array($this, 'siteTransientUpdatePlugins')); Hook::register('set_plugin_has_updates', array($this, 'transientUpdatePlugins')); if (isset($_GET['plugin']) && $_GET['plugin'] == $this->application->getName()) { Hook::register('install_plugins_pre_plugin-information', array($this, 'versionInformation')); } $this->application->onInitUpdate(); $oldVersion = AoiSoraSettings::getApplicationVersion($this->application->getName()); if ($this->application->installed() && version_compare($oldVersion, $this->version, '<')) { AoiSoraSettings::addApplication($this->application->getName(), $this->application->getInstallDirectory(), $this->version); $this->application->update(); } if ($this->update_site && isset($_REQUEST['action']) && 'upgrade-plugin' == $_REQUEST['action'] && isset($_REQUEST['plugin']) && urldecode($_REQUEST['plugin']) == $this->application->getInstallName()) { Filter::register('http_request_args', array($this, 'addUpdateUrl'), 10); } } }
/** * Renders a controller and its action. * * @param string $controller * @param string $action * * @throws RenderException */ public function render($controller, $action) { if (!$this->canRender()) { return; } $view_path = $this->views->findView($controller, $action, $this->getTemplate()); if ($view_path) { Hook::run('rendering-render', [$controller, strtolower($action), $this->controller]); $tags = Filter::run('view-tags', array(array(), $this->controller)); $engine = RenderingEngines::getEngine($this->getTemplate(), $this->controller->getViewPath()); $view_content = $engine->render($view_path, array_merge($this->getBag(), $tags, ['bag' => $this->getBag() + $tags])); $layout_path = $this->views->findLayout($this->getTemplate()); if ($layout_path) { $engine = RenderingEngines::getEngine($this->getTemplate(), $view_path); $view_content = $engine->render($layout_path, array_merge($this->getBag(), $tags, ['bag' => $this->getBag() + $tags], Filter::run("{$this->controllerName}-{$action}-blocks", array(array('view' => $view_content))))); } $this->disableRendering(); RenderedContent::set($view_content); return; } $view_content = "Could not find view for {$controller}, {$action} in: " . $view_path; trigger_error($view_content, E_USER_WARNING); }
/** * Executes an action on the controller. * * @param string $action The name of the action to execute. * @param array $getParams values part of routing * * @throws \Exception Thrown if action is not found. */ public function executeAction($action, $getParams = array()) { if (method_exists($this, $action)) { $reflection = new ReflectionMethod($this, $action); if (!$reflection->isPublic()) { trigger_error(sprintf('The action you tried to execute is not public: %s', $action)); if (method_exists($this, 'notFound')) { $this->notFound(); } } $this->action = $action; $perform = true; $action_params = $reflection->getParameters(); $this->params = $getParams; $paramValues = $this->getParameters($getParams, $action_params); $this->performForEvent($this, $this->getValues(), 'beforeAction', $action, $perform); if ($perform) { Hook::run($this->controller . '-pre' . ucfirst($action), $this); call_user_func_array(array($this, $action), $paramValues); $this->actionRan = true; Hook::run($this->controller . '-post' . ucfirst($action), $this); } if ($this->actionHasRun()) { $this->performForEvent($this, $this->getValues(), 'afterActionHasRun', $action); } $this->performForEvent($this, $this->getValues(), 'afterAction', $action); if ($this->renderer->canRender()) { $this->renderer->RenderToAction($action); } $this->setupHeadersAndResponseCode(); } elseif (method_exists($this, 'notFound')) { $this->notFound(); } else { throw new \Exception('There are no action that corresponds to request.'); } }
/** * Called on plugins loaded. runs hooks. aoisora-libraries, aoisora-loaded */ public function loaded() { Events\Hook::run('cloudless-libraries'); Events\Hook::run('cloudless-loaded'); }
function aoisora_loaded() { Hook::run('aoisora-loaded'); }