/**
  * 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);
 }
Exemple #2
0
 public function renderedContent()
 {
     return RenderedContent::get();
 }
Exemple #3
0
 public function includeTemplate($original_template)
 {
     if (RenderedContent::hasRendered()) {
         if (RenderedContent::endIt()) {
             RenderedContent::endFlush();
             return '';
         } else {
             return $this->getTemplate($original_template);
         }
     } else {
         return $original_template;
     }
 }