PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / addons / DiviBuilder / EverestFormsModule.php
everest-forms / addons / DiviBuilder Last commit date
DiviBuilder.php 1 year ago EverestFormsModule.php 1 year ago Helper.php 4 months ago
EverestFormsModule.php
175 lines
1 <?php
2 /**
3 * Everest Forms Divi Module File.
4 *
5 * @package EverestForms\Divi
6 * @since 3.0.5
7 */
8 namespace EverestForms\Addons\DiviBuilder;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Everest Forms Divi module class.
14 *
15 * @since 3.0.5
16 */
17 class EverestFormsModule extends \ET_Builder_Module {
18 /**
19 * Module slug.
20 *
21 * @since 3.0.5
22 * @var string
23 */
24 public $slug = 'everest_forms_divi_builder';
25
26 /**
27 * Whether module support visual builder. e.g `on` or `off`.
28 *
29 * @since 3.0.5
30 * @var string
31 */
32 public $vb_support = 'on';
33
34 /**
35 * List of controls to allow module customization.
36 *
37 * @since 1.6.13
38 * @var array
39 */
40 protected $setting_controls = array();
41
42 /**
43 * Divi builder init function.
44 *
45 * @since 3.0.5
46 */
47 public function init() {
48 $this->name = esc_html__( 'Everest Forms', 'everest-forms' );
49
50 $this->settings_modal_toggles = array(
51 'general' => array(
52 'toggles' => array(
53 'main_content' => esc_html__( 'Forms', 'everest-forms' ),
54 ),
55 ),
56 );
57
58 add_action( 'wp_enqueue_scripts', array( $this, 'load_divi_builder_scripts' ) );
59 }
60
61 /**
62 * Displays the Module setting fields.
63 *
64 * @since 3.0.5
65 * @return array $fields Array of settings fields.
66 */
67 public function get_fields() {
68
69 $forms = evf_get_all_forms();
70 $default_form = array( esc_html__( 'Select Form', 'everest-forms' ) );
71 $forms = $default_form + $forms;
72
73 $fields = array(
74 'form_id' => array(
75 'label' => esc_html__( 'Select Form', 'everest-forms' ),
76 'type' => 'select',
77 'option_category' => 'basic_option',
78 'toggle_slug' => 'main_content',
79 'options' => $forms,
80 'default' => '5',
81 'computed_affects' => array(
82 '__rendered_evf_forms',
83 ),
84 ),
85 '__rendered_evf_forms' => array(
86 'type' => 'computed',
87 'computed_callback' => 'EverestForms\Addons\DiviBuilder\EverestFormsModule::rendered_evf_forms',
88 'computed_depends_on' => array(
89 'form_id',
90 ),
91 'computed_minimum' => array(
92 'form_id',
93 ),
94 ),
95
96 );
97 return $fields;
98 }
99
100 /**
101 * Advanced Fields Settings.
102 *
103 * @since 3.0.5
104 */
105 public function get_advanced_fields_config() {
106 return array(
107 'link_options' => false,
108 'text' => false,
109 'borders' => false,
110 'box_shadow' => false,
111 'button' => false,
112 'filters' => false,
113 'fonts' => false,
114 );
115 }
116
117 /**
118 * Renders the Everest Form in Visual Builder and Frontend.
119 *
120 * @since 3.0.5
121 * @param array $props Module properties.
122 * @return string HTML output.
123 */
124 public static function rendered_evf_forms( $props = array() ) {
125 $form_id = isset( $props['form_id'] ) ? $props['form_id'] : '0';
126
127 // Check if we are in the Divi Visual Builder
128 if ( et_fb_enabled() ) {
129 return "<div class='everest-forms-divi-preview'>" . esc_html__( 'Everest Forms Preview', 'everest-forms' ) . '</div>';
130 }
131
132 if ( '0' === $form_id ) {
133 return "<div class='everest-forms-divi-empty-form' style='text-align:center'><img src='" . plugin_dir_url( EVF_PLUGIN_FILE ) . 'assets/images/icons/Everest-forms-Logo.png' . "'/></div>";
134 }
135
136 // Render the form via shortcode in the frontend.
137 $divi_shortcode = sprintf( "[everest_form id='%s']", $form_id );
138 $output = "<div class='everest-forms-divi-builder'>";
139 $output .= do_shortcode( $divi_shortcode );
140 $output .= '</div>';
141
142 return $output;
143 }
144
145 /**
146 * Render the module on frontend.
147 *
148 * @since 3.0.5
149 * @param array $unprocessed_props Array of unprocessed Properties.
150 * @param string $content Contents being processed from the prop.
151 * @param string $render_slug The slug of rendering module for rendering output.
152 * @return string HTML content for rendering.
153 */
154 public function render( $unprocessed_props, $content, $render_slug ) {
155 return $this->_render_module_wrapper( static::rendered_evf_forms( $this->props ), $render_slug );
156 }
157
158 /**
159 * Enqueue Divi Builder JavaScript.
160 *
161 * @since 3.0.5
162 */
163 public function load_divi_builder_scripts() {
164 $enqueue_script = array( 'wp-element', 'react', 'react-dom' );
165 wp_register_script(
166 'everest-forms-divi-builder',
167 evf()->plugin_url() . '/dist/divibuilder.min.js',
168 $enqueue_script,
169 evf()->version,
170 true
171 );
172 wp_enqueue_script( 'everest-forms-divi-builder' );
173 }
174 }
175