/** * @param string $controller * @param string $action * @param string $template * * @return string Empty string if path is not found. */ public function findView($controller, $action, $template = 'php') { $viewPath = $this->controller->getViewPath(); if (!is_array($viewPath)) { $viewPath = [$viewPath]; } $viewPath = Filter::run('cl-view-path', [$viewPath, $this->controller, $controller, $action]); $viewPath = Filter::run("cl-view-path-{$controller}", [$viewPath, $this->controller, $controller, $action]); if ($viewPath) { if ($path = $this->viewPaths($viewPath, strtolower($controller) . DIRECTORY_SEPARATOR . strtolower($action) . '.' . $template)) { return $path; } if ($path = $this->viewPaths($viewPath, $controller . DIRECTORY_SEPARATOR . $action . '.' . $template)) { return $path; } if ($path = $this->viewPaths($viewPath, $controller . '-' . $action . '.' . $template)) { return $path; } } $apps = AoiSoraSettings::getApplications(); $lc_controller = strtolower($controller); $lc_action = strtolower($action); foreach ($apps as $app) { $path = $app['path']; if (file_exists($path . VIEWS . $controller . '/' . $action . '.php')) { return $path . VIEWS . $controller . '/' . $action . '.php'; } if (file_exists($path . VIEWS . $lc_controller . '/' . $lc_action . '.php')) { return $path . VIEWS . $lc_controller . '/' . $lc_action . '.php'; } } return ''; }
public function templateRendering() { if (!current_theme_supports('cloudless')) { Container::instance()->make(ThemeCompatibility::class); } else { Filter::register('template_include', [$this, 'includeTemplate']); } }
/** * @param array $tags * @param BaseController $controller * * @return array */ function clmvc_setup_default_tags($tags, $controller) { $bag = $controller->getBag(); $tags['title'] = Filter::run('title', array($bag['title'])); $tags['stylesheets'] = implode("\n", Filter::run('stylesheets-frontend', array(array()))); $tags['javascript_footer'] = implode("\n", Filter::run('javascripts-footer-frontend', array(array()))); $tags['javascript_head'] = implode("\n", Filter::run('javascripts-head-frontend', array(array()))); return $tags; }
private function filters() { foreach ($this->filters as $key => $filter) { if (is_numeric($key)) { Filter::registerHandler($filter, [$this, 'wp_filter_handler']); } else { Filter::registerHandler($key, [$this, 'wp_filter_handler']); } } }
public function init() { RenderingEngines::registerEngine('php', 'CLMVC\\Controllers\\Render\\Engines\\PhpRenderingEngine'); (new WpActionOverrides())->init(); $this->setupConstants(); $this->setupContainer(); $this->setupWpContainer(); if (is_admin()) { Filter::register('after_plugin_row', [$this, 'loadCloudlessFirst'], 10); } Filter::register('status_header', [$this, 'addHeader']); }
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); }
public function __construct() { parent::__construct(); Filter::register('stylesheets-frontend', array($this, 'render')); }