PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4.2
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 5.4.2, at classes/widgets/FrmElementorWidget.php

103 lines 2.8 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 public function get_name() {
10 return 'formidable';
11 }
12
13 public function get_title() {
14 return FrmAppHelper::get_menu_name() . ' ' . __( 'Forms', 'formidable' );
15 }
16
17 public function get_icon() {
18 return FrmAppHelper::get_menu_icon_class();
19 }
20
21 public function get_categories() {
22 return array( 'general' );
23 }
24
25 protected function register_controls() {
26 $this->start_controls_section(
27 'section_form_dropdown',
28 array(
29 'label' => __( 'Select Form', 'formidable' ),
30 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
31 )
32 );
33
34 $this->add_control(
35 'form_id',
36 array(
37 'label' => __( 'Form', 'formidable' ),
38 'type' => \Elementor\Controls_Manager::SELECT2,
39 'options' => $this->get_form_options(),
40 )
41 );
42
43 $this->end_controls_section();
44
45 $this->start_controls_section(
46 'section_options',
47 array(
48 'label' => __( 'Options', 'formidable' ),
49 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
50 )
51 );
52
53 $this->add_basic_switcher_control( 'title', __( 'Show Form Title', 'formidable' ) );
54 $this->add_basic_switcher_control( 'description', __( 'Show Form Description', 'formidable' ) );
55 $this->add_basic_switcher_control( 'minimize', __( 'Minimize HTML', 'formidable' ) );
56
57 $this->end_controls_section();
58 }
59
60 private function add_basic_switcher_control( $key, $title ) {
61 $this->add_control(
62 $key,
63 array(
64 'label' => $title,
65 'type' => \Elementor\Controls_Manager::SWITCHER,
66 )
67 );
68 }
69
70 private function get_form_options() {
71 $query = array();
72 $where = apply_filters( 'frm_forms_dropdown', $query, 'form' );
73 $forms = FrmForm::get_published_forms( $where, 999, 'exclude' );
74 $options = array( '' => '' );
75
76 foreach ( $forms as $form ) {
77 $form_title = '' === $form->name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 50 );
78 $options[ $form->id ] = esc_html( $form_title );
79 }
80
81 return $options;
82 }
83
84 protected function render() {
85 $settings = $this->get_settings_for_display();
86 $form_id = isset( $settings['form_id'] ) ? absint( $settings['form_id'] ) : 0;
87 $title = isset( $settings['title'] ) && 'yes' === $settings['title'];
88 $description = isset( $settings['description'] ) && 'yes' === $settings['description'];
89 $minimize = isset( $settings['minimize'] ) && 'yes' === $settings['minimize'];
90
91 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
92 echo FrmFormsController::get_form_shortcode(
93 array(
94 'id' => $form_id,
95 'title' => $title,
96 'description' => $description,
97 'minimize' => $minimize,
98 )
99 );
100 }
101 }
102 }
103