# fluentform/1.2.4/app/Modules/ProcessExteriorModule.php

Fluent Forms – Customizable Contact Forms, Survey, Quiz, &amp; Conversational Form Builder, version 1.2.4. 70 lines.

- Page: https://pluginprobe.com/plugins/fluentform/1.2.4/code/app/Modules/ProcessExteriorModule.php
- Raw: https://pluginprobe.com/plugins/fluentform/1.2.4/raw/app/Modules/ProcessExteriorModule.php
- Modified: 2018-01-04T13:51:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/fluentform/1.2.4/code/app/Modules/ProcessExteriorModule.php#L10-L20`.

```php
<?php namespace FluentForm\App\Modules;

use FluentForm\App;
use FluentForm\Config;
use FluentForm\Request;
use FluentForm\View;

class ProcessExteriorModule
{
	public function handleExteriorPages()
	{
		if(isset($_GET['fluentform_pages']) && $_GET['fluentform_pages'] == 1) {
			if(isset($_GET['preview_id']) && $_GET['preview_id']) {
				$form_id = intval($_GET['preview_id']);
				$this->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 );
		}
	}
	
}
```
