PluginProbe
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder / 1.13.7
Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder v1.13.7
1.15.47 1.15.46 1.15.45 1.15.44 1.15.43 1.13.45 1.13.46 1.13.47 1.13.48 1.13.49 1.13.5 1.13.50 1.13.51 1.13.52 1.13.53 1.13.54 1.13.55 1.13.56 1.13.57 1.13.58 1.13.59 1.13.60 1.13.7 1.13.8 1.13.9 All 351 releases
form-maker / admin / controllers / Widget.php

Widget.php in Form Maker by 10Web – Mobile-Friendly Drag & Drop Contact Form Builder 1.13.7, at admin/controllers/Widget.php

92 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class FMControllerWidget
5 */
6 class FMControllerWidget extends WP_Widget {
7 /**
8 * PLUGIN = 2 points to Contact Form Maker
9 */
10 const PLUGIN = 1;
11
12 private $view;
13 private $model;
14
15 public function __construct() {
16 $widget_ops = array(
17 'classname' => 'form_maker_widget',
18 'description' => sprintf(__('Add %s widget.', WDFMInstance(self::PLUGIN)->prefix), WDFMInstance(self::PLUGIN)->nicename),
19 );
20 // Widget Control Settings.
21 $control_ops = array( 'id_base' => 'form_maker_widget' );
22 // Create the widget.
23 parent::__construct('form_maker_widget', WDFMInstance(self::PLUGIN)->nicename, $widget_ops, $control_ops);
24 require_once WDFMInstance(self::PLUGIN)->plugin_dir . "/admin/models/Widget.php";
25 $this->model = new FMModelWidget();
26 require_once WDFMInstance(self::PLUGIN)->plugin_dir . "/admin/views/Widget.php";
27 $this->view = new FMViewWidget($this->model);
28 }
29
30 /**
31 * Widget.
32 *
33 * @param array $args
34 * @param array $instance
35 */
36 public function widget( $args = array(), $instance = array() ) {
37 if( get_the_title() == 'Preview' && get_post_type() == 'form-maker' . WDFMInstance(self::PLUGIN)->plugin_postfix ) {
38 return;
39 }
40 $contact_form_forms = explode(',', get_option('contact_form_forms'));
41
42 $instance['title'] = isset($instance['title']) ? $instance['title'] : '';
43 $instance['form_id'] = isset($instance['form_id']) ? $instance['form_id'] : 0;
44
45 if ( !WDFMInstance(self::PLUGIN)->is_free || !in_array($instance['form_id'], $contact_form_forms) ) {
46 if ( class_exists('WDFM') ) {
47 require_once(WDFMInstance(self::PLUGIN)->plugin_dir . '/frontend/controllers/form_maker.php');
48 $controller_class = 'FMControllerForm_maker';
49 }
50 else {
51 return;
52 }
53 }
54 else {
55 if ( class_exists('WDCFM') ) {
56 require_once(WDFMInstance(2)->plugin_dir . '/frontend/controllers/form_maker.php');
57 $controller_class = 'FMControllerForm_maker_fmc';
58 }
59 else {
60 return;
61 }
62 }
63 $controller = new $controller_class();
64 $execute = $controller->execute($instance['form_id']);
65 $this->view->widget($args, $instance, $execute);
66 }
67
68 /**
69 * Form.
70 *
71 * @param array $instance
72 */
73 public function form( $instance = array() ) {
74 $ids_FM = $this->model->get_gallery_rows_data(); // ids_Form_Maker
75 $this->view->form($instance, $ids_FM, parent::get_field_id('title'), parent::get_field_name('title'), parent::get_field_id('form_id'), parent::get_field_name('form_id'));
76 }
77
78 /**
79 * Update.
80 *
81 * @param $new_instance
82 * @param $old_instance
83 * @return mixed
84 */
85 public function update( $new_instance = array(), $old_instance = array() ) {
86 $instance['title'] = isset($new_instance['title']) ? $new_instance['title'] : '';
87 $instance['form_id'] = isset($new_instance['form_id']) ? $new_instance['form_id'] : 0;
88
89 return $instance;
90 }
91 }
92