| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules; |
| 4 |
|
| 5 |
use FluentForm\App\Models\Form; |
| 6 |
use FluentForm\App\Modules\Acl\Acl; |
| 7 |
|
| 8 |
class ProcessExteriorModule |
| 9 |
{ |
| 10 |
public function handleExteriorPages() |
| 11 |
{ |
| 12 |
if (defined('CT_VERSION')) { |
| 13 |
// oxygen page compatibility |
| 14 |
remove_action('wp_head', 'oxy_print_cached_css', 999999); |
| 15 |
} |
| 16 |
wp_register_script( |
| 17 |
'fluentform_editor_helper', |
| 18 |
fluentFormMix('js/fluent_forms_editor_helper.js'), |
| 19 |
array('jquery'), |
| 20 |
FLUENTFORM_VERSION, |
| 21 |
true |
| 22 |
); |
| 23 |
$this->renderFormPreview(intval(wpFluentForm('request')->get('preview_id'))); |
| 24 |
} |
| 25 |
|
| 26 |
public function renderFormPreview($form_id) |
| 27 |
{ |
| 28 |
if (Acl::hasAnyFormPermission($form_id)) { |
| 29 |
add_filter('fluentform/is_form_renderable', function ($renderable) { |
| 30 |
$renderable['status'] = true; |
| 31 |
return $renderable; |
| 32 |
}); |
| 33 |
|
| 34 |
$form = Form::find($form_id); |
| 35 |
if ($form) { |
| 36 |
wp_enqueue_script('fluentform_editor_helper'); |
| 37 |
wpFluentForm('view')->render('frameless.show_preview', [ |
| 38 |
'form_id' => $form_id, |
| 39 |
'form' => $form, |
| 40 |
]); |
| 41 |
exit(); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
private function loadDefaultPageTemplate() |
| 47 |
{ |
| 48 |
add_filter('template_include', function ($original) { |
| 49 |
return locate_template(['page.php', 'single.php', 'index.php']); |
| 50 |
}); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Set the posts to one |
| 55 |
* |
| 56 |
* @param WP_Query $query |
| 57 |
* |
| 58 |
* @return void |
| 59 |
*/ |
| 60 |
public function pre_get_posts($query) |
| 61 |
{ |
| 62 |
if ($query->is_main_query()) { |
| 63 |
$query->set('posts_per_page', 1); |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
|