loadDefaultPageTemplate(); $this->renderFormPreview($form_id); } } } public function renderFormPreview($form_id) { if(App\Modules\Acl\Acl::hasAnyFormPermission($form_id)) { $form = wpFluent()->table('fluentform_forms') ->find($form_id); if($form) { add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ), 100, 1 ); add_filter( 'post_thumbnail_html', '__return_empty_string' ); add_filter( 'get_the_excerpt', function ($content) { return ''; } ); add_filter('the_title', function ($title) use ($form) { if(in_the_loop()) { return $form->title; } return $title; }, 100, 1); add_filter('the_content', function($content) use ($form) { if(in_the_loop()) { return View::make( 'public.preview_form', array( 'form' => $form ) ); } return $content; }); } } } private function loadDefaultPageTemplate() { add_filter( 'template_include', function ($original) { return locate_template( array( 'page.php', 'single.php', 'index.php' ) ); } ); } /** * Set the posts to one * * @param WP_Query $query * * @return void */ public function pre_get_posts( $query ) { if ( $query->is_main_query() ) { $query->set( 'posts_per_page', 1 ); } } }