PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.31
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.31
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 3.6.31, at app/Modules/Widgets/SidebarWidgets.php

91 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 namespace FluentForm\App\Modules\Widgets;
4
5 class SidebarWidgets extends \WP_Widget
6 {
7 function __construct()
8 {
9 parent::__construct(
10 'fluentform_widget',
11 esc_html__('WP Fluent Forms Widget', 'fluentform'),
12 array('description' => esc_html__('Add your form by WP Fluent Forms', 'fluentform'),)
13 );
14 }
15
16 public function widget($args, $instance)
17 {
18 $selectedForm = empty($instance['allforms']) ? '' : intval($instance['allforms']);
19
20 if(!$selectedForm) {
21 return;
22 }
23
24 echo $args['before_widget'];
25
26 if ( ! empty( $instance['title'] ) ) {
27 echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ) . $args['after_title'];
28 }
29
30 if ($selectedForm != '') {
31 $shortcode = "[fluentform id='$selectedForm']";
32 echo do_shortcode($shortcode);
33 }
34
35 echo $args['after_widget'];
36
37 }
38
39 public function form($instance)
40 {
41 $selectedForm = empty($instance['allforms']) ? '' : $instance['allforms'];
42
43 if (isset($instance['title'])) {
44 $title = $instance['title'];
45 } else {
46 $title = __('', 'fluentform');
47 }
48 // Widget admin form
49 ?>
50 <p>
51 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title (optional):'); ?></label>
52 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>"
53 name="<?php echo $this->get_field_name('title'); ?>" type="text"
54 value="<?php echo esc_attr($title); ?>"/>
55 </p>
56 <?php
57 $forms = wpFluent()->table('fluentform_forms')
58 ->select(array('id', 'title'))
59 ->orderBy('id', 'DESC')
60 ->get();
61 ?>
62
63 <label for="<?php echo $this->get_field_id('allforms'); ?>">Select a form:
64 <select style="margin-bottom: 12px;" class='widefat' id="<?php echo $this->get_field_id('allforms'); ?>"
65 name="<?php echo $this->get_field_name('allforms'); ?>" type="text"
66 >
67 <?php
68 foreach ($forms as $item) {
69 ?>
70 <option <?php if ($item->id == $selectedForm) {
71 echo 'selected';
72 } ?> value='<?php echo $item->id; ?>'>
73 <?php echo $item->title; ?> (<?php echo $item->id; ?>)
74 </option>
75 <?php
76 }
77 ?>
78 </select>
79 </label>
80 <?php
81 }
82
83 public function update($new_instance, $old_instance)
84 {
85 $instance = array();
86 $instance['title'] = (!empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
87 $instance['allforms'] = intval($new_instance['allforms']);
88 return $instance;
89 }
90 }
91