PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Modules / Widgets / SidebarWidgets.php

SidebarWidgets.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.14, at app/Modules/Widgets/SidebarWidgets.php

100 lines 3.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\Widgets;
4
5 use FluentForm\App\Models\Form;
6
7 class SidebarWidgets extends \WP_Widget
8 {
9 public function __construct()
10 {
11 parent::__construct(
12 'fluentform_widget',
13 esc_html__('Fluent Forms Widget', 'fluentform'),
14 ['description' => esc_html__('Add your form by Fluent Forms', 'fluentform'), ]
15 );
16 }
17
18 public function widget($args, $instance)
19 {
20 $selectedForm = empty($instance['allforms']) ? '' : intval($instance['allforms']);
21
22 if (!$selectedForm) {
23 return;
24 }
25
26 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $args['before_widget'] is provided by WordPress core
27 echo $args['before_widget'];
28
29 if (!empty($instance['title'])) {
30 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $args['before_title'], $args['after_title'] are provided by WordPress core, widget_title filter is expected to return safe HTML
31 echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
32 }
33
34 if ('' != $selectedForm) {
35 $shortcode = "[fluentform id='$selectedForm']";
36 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- do_shortcode() output is safe
37 echo do_shortcode($shortcode);
38 }
39
40 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $args['after_widget'] is provided by WordPress core
41 echo $args['after_widget'];
42 }
43
44 public function form($instance)
45 {
46 $selectedForm = empty($instance['allforms']) ? '' : $instance['allforms'];
47
48 if (isset($instance['title'])) {
49 $title = $instance['title'];
50 } else {
51 $title = '';
52 }
53 // Widget admin form
54 ?>
55 <p>
56 <label
57 for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php esc_html_e('Title (optional):', 'fluentform'); ?></label>
58 <input class="widefat"
59 id="<?php echo esc_attr($this->get_field_id('title')); ?>"
60 name="<?php echo esc_attr($this->get_field_name('title')); ?>"
61 type="text" value="<?php echo esc_attr($title); ?>" />
62 </p>
63 <?php
64 $forms = Form::select(['id', 'title'])
65 ->orderBy('id', 'DESC')
66 ->get();
67 ?>
68
69 <label
70 for="<?php echo esc_attr($this->get_field_id('allforms')); ?>">Select
71 a form:
72 <select style="margin-bottom: 12px;" class='widefat'
73 id="<?php echo esc_attr($this->get_field_id('allforms')); ?>"
74 name="<?php echo esc_attr($this->get_field_name('allforms')); ?>"
75 type="text">
76 <?php
77 foreach ($forms as $item) {
78 ?>
79 <option <?php if ($item->id == $selectedForm) {
80 echo 'selected';
81 } ?> value='<?php echo esc_attr($item->id); ?>'>
82 <?php echo esc_html($item->title); ?> (<?php echo esc_attr($item->id); ?>)
83 </option>
84 <?php
85 }
86 ?>
87 </select>
88 </label>
89 <?php
90 }
91
92 public function update($new_instance, $old_instance)
93 {
94 $instance = [];
95 $instance['title'] = (!empty($new_instance['title'])) ? wp_strip_all_tags($new_instance['title']) : '';
96 $instance['allforms'] = intval($new_instance['allforms']);
97 return $instance;
98 }
99 }
100