PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.26
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.26
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / widgets / FrmElementorWidget.php

FrmElementorWidget.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.26, at classes/widgets/FrmElementorWidget.php

130 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 if ( class_exists( '\Elementor\Widget_Base' ) ) {
7 class FrmElementorWidget extends \Elementor\Widget_Base {
8
9 /**
10 * @return string
11 */
12 public function get_name() {
13 return 'formidable';
14 }
15
16 /**
17 * @return string
18 */
19 public function get_title() {
20 return FrmAppHelper::get_menu_name() . ' ' . __( 'Forms', 'formidable' );
21 }
22
23 /**
24 * @return string
25 */
26 public function get_icon() {
27 return FrmAppHelper::get_menu_icon_class();
28 }
29
30 /**
31 * @return array
32 */
33 public function get_categories() {
34 return array( 'general' );
35 }
36
37 /**
38 * @return void
39 */
40 protected function register_controls() {
41 $this->start_controls_section(
42 'section_form_dropdown',
43 array(
44 'label' => __( 'Select Form', 'formidable' ),
45 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
46 )
47 );
48
49 $this->add_control(
50 'form_id',
51 array(
52 'label' => __( 'Form', 'formidable' ),
53 'type' => \Elementor\Controls_Manager::SELECT2,
54 'options' => $this->get_form_options(),
55 )
56 );
57
58 $this->end_controls_section();
59
60 $this->start_controls_section(
61 'section_options',
62 array(
63 'label' => __( 'Options', 'formidable' ),
64 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
65 )
66 );
67
68 $this->add_basic_switcher_control( 'title', __( 'Show Form Title', 'formidable' ) );
69 $this->add_basic_switcher_control( 'description', __( 'Show Form Description', 'formidable' ) );
70 $this->add_basic_switcher_control( 'minimize', __( 'Minimize HTML', 'formidable' ) );
71
72 $this->end_controls_section();
73 }
74
75 /**
76 * @param string $key
77 * @param string $title
78 *
79 * @return void
80 */
81 private function add_basic_switcher_control( $key, $title ) {
82 $this->add_control(
83 $key,
84 array(
85 'label' => $title,
86 'type' => \Elementor\Controls_Manager::SWITCHER,
87 )
88 );
89 }
90
91 /**
92 * @return array
93 */
94 private function get_form_options() {
95 $query = array();
96 $where = apply_filters( 'frm_forms_dropdown', $query, 'form' );
97 $forms = FrmForm::get_published_forms( $where, 999, 'exclude' );
98 $options = array( '' => '' );
99
100 foreach ( $forms as $form ) {
101 $form_title = '' === $form->name ? FrmFormsHelper::get_no_title_text() : FrmAppHelper::truncate( $form->name, 50 );
102 $options[ $form->id ] = esc_html( $form_title );
103 }
104
105 return $options;
106 }
107
108 /**
109 * @return void
110 */
111 protected function render() {
112 $settings = $this->get_settings_for_display();
113 $form_id = isset( $settings['form_id'] ) ? absint( $settings['form_id'] ) : 0;
114 $title = isset( $settings['title'] ) && 'yes' === $settings['title'];
115 $description = isset( $settings['description'] ) && 'yes' === $settings['description'];
116 $minimize = isset( $settings['minimize'] ) && 'yes' === $settings['minimize'];
117
118 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
119 echo FrmFormsController::get_form_shortcode(
120 array(
121 'id' => $form_id, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
122 'title' => $title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
123 'description' => $description, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
124 'minimize' => $minimize, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
125 )
126 );
127 }
128 }
129 }//end if
130