/** * Overrides global $post and $wp_query with the rendered content from CloudLess. * Its done if is_main_query and CloudLess detected a correct and matching route. */ public function override() { global $wp_query; if ($wp_query->is_main_query() && !$this->routes->isRouted() || !$wp_query->is_main_query() && !$this->routes->isRouted() || !$wp_query->is_main_query() && $this->routes->isRouted()) { return; } $bag = Container::instance()->fetch('Bag'); $args = ['post_content' => RenderedContent::get(), 'post_title' => $bag->title, 'is_page' => true, 'guid' => $this->routes->getCurrentRoute()->getRoutePath()]; $dummy = new DummyPost($args); $dummy->overrideWpQuery(); remove_filter('the_content', 'wpautop'); unset($dummy); }
/** * @param $handle * @return bool */ public function disable404handling($handle) { if ($this->routes->isRouted()) { return false; } return $handle; }
public function setupContainer() { $container = Container::instance(); $container->add('CLMVC\\Interfaces\\IScriptInclude', new WpScriptIncludes()); $container->add('CLMVC\\Interfaces\\IStyleInclude', new WpStyleIncludes()); $container->add('CLMVC\\Interfaces\\IOptions', 'CLMVC\\ViewEngines\\WordPress\\WpOptions', 'class'); $container->add('CLMVC\\Interfaces\\IPost', 'CLMVC\\ViewEngines\\WordPress\\WpPost', 'class'); $container->add('Routes', Routes::instance()); $container->add(Routes::class, Routes::instance()); $container->add('Bag', new BaggedValues()); }