PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0-beta1
Elementor Website Builder – more than just a page builder v4.0.0-beta1
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
← All changes | modules/atomic-widgets/elements/atomic-form/atomic-form.php +34 -90 4.1.5 → 4.0.0-beta1 View file →
@@ -25,9 +25,8 @@
25 25 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
26 26 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
27 27 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
28 28 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
29 -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
30 29
31 30 if ( ! defined( 'ABSPATH' ) ) {
32 31 exit; // Exit if accessed directly.
33 32 }
@@ -36,31 +35,17 @@
36 35 use Has_Element_Template;
37 36
38 37 const BASE_STYLE_KEY = 'base';
39 38
40 - public static $widget_description = 'A form container that holds form field widgets (labels, inputs, textareas, checkboxes, submit button) and status messages.';
41 -
42 - public const ACTION_EMAIL = 'email';
43 39 public const ACTION_COLLECT_SUBMISSIONS = 'collect-submissions';
44 - public const ACTION_WEBHOOK = 'webhook';
45 40 public const METADATA_REMOTE_IP = 'remote_ip';
46 41 public const METADATA_USER_AGENT = 'user_agent';
47 42
48 -
49 -
50 43 public function __construct( $data = [], $args = null ) {
51 44 parent::__construct( $data, $args );
52 45 $this->meta( 'is_container', true );
53 46 }
54 47
55 - public static function get_default_recipient_email(): string {
56 - return sanitize_email( (string) get_option( 'admin_email', '' ) );
57 - }
58 -
59 - public static function get_default_sender_email(): string {
60 - return sanitize_email( (string) 'email@' . wp_parse_url( home_url(), PHP_URL_HOST ) );
61 - }
62 -
63 48 public static function get_type() {
64 49 return 'e-form';
65 50 }
66 51
@@ -68,9 +53,9 @@
68 53 return self::get_type();
69 54 }
70 55
71 56 public function get_title() {
72 - return esc_html__( 'Atomic form', 'elementor' );
57 + return esc_html__( 'Atomic Form', 'elementor' );
73 58 }
74 59
75 60 public function get_keywords() {
76 61 return [ 'atomic', 'form' ];
@@ -79,18 +64,14 @@
79 64 public function get_icon() {
80 65 return 'eicon-atomic-form';
81 66 }
82 67
83 - public static function get_base_props_schema(): array {
84 - return self::define_props_schema();
85 - }
86 -
87 68 protected static function define_props_schema(): array {
88 69 $email_dependencies = Dependency_Manager::make()
89 70 ->where( [
90 71 'operator' => 'contains',
91 72 'path' => [ 'actions-after-submit' ],
92 - 'value' => self::ACTION_EMAIL,
73 + 'value' => 'email',
93 74 'effect' => 'hide',
94 75 ] )
95 76 ->get();
96 77
@@ -102,17 +83,8 @@
102 83 'effect' => 'hide',
103 84 ] )
104 85 ->get();
105 86
106 - $webhook_dependencies = Dependency_Manager::make()
107 - ->where( [
108 - 'operator' => 'contains',
109 - 'path' => [ 'actions-after-submit' ],
110 - 'value' => self::ACTION_WEBHOOK,
111 - 'effect' => 'hide',
112 - ] )
113 - ->get();
114 -
115 87 return [
116 88 'classes' => Classes_Prop_Type::make()
117 89 ->default( [] ),
118 90 'form-name' => String_Prop_Type::make()
@@ -121,9 +93,9 @@
121 93 ->enum( [ 'default', 'success', 'error' ] )
122 94 ->default( 'default' )
123 95 ->meta( 'generates_class', 'form-state-{value}' ),
124 96 'actions-after-submit' => String_Array_Prop_Type::make()
125 - ->default( [ String_Prop_Type::generate( self::ACTION_EMAIL ) ] ),
97 + ->default( [ String_Prop_Type::generate( 'email' ) ] ),
126 98 'submissions_metadata' => String_Array_Prop_Type::make()
127 99 ->set_dependencies( $submissions_metadata_dependencies )
128 100 ->default( [
129 101 String_Prop_Type::generate( self::METADATA_REMOTE_IP ),
@@ -130,18 +102,10 @@
130 102 String_Prop_Type::generate( self::METADATA_USER_AGENT ),
131 103 ] ),
132 104 'email' => Email_Prop_Type::make()
133 105 ->set_dependencies( $email_dependencies )
134 - ->meta( Overridable_Prop_Type::ignore() )
135 - ->default( [
136 - 'to' => String_Prop_Type::generate( self::get_default_recipient_email() ),
137 - 'from' => String_Prop_Type::generate( self::get_default_sender_email() ),
138 - ] ),
139 - 'webhook_url' => String_Prop_Type::make()
140 - ->set_dependencies( $webhook_dependencies )
141 - ->meta( Overridable_Prop_Type::ignore() )
142 - ->default( '' ),
143 - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
106 + ->default( [] ),
107 + 'attributes' => Attributes_Prop_Type::make(),
144 108 ];
145 109 }
146 110
147 111 protected function define_atomic_controls(): array {
@@ -172,9 +136,9 @@
172 136 Section::make()
173 137 ->set_label( __( 'Content', 'elementor' ) )
174 138 ->set_items( [
175 139 Text_Control::bind_to( 'form-name' )
176 - ->set_label( __( 'Form name', 'elementor' ) ),
140 + ->set_label( __( 'Form Name', 'elementor' ) ),
177 141 $state_control,
178 142 Chips_Control::bind_to( 'actions-after-submit' )
179 143 ->set_label( __( 'Actions after submit', 'elementor' ) )
180 144 ->set_meta( [ 'topDivider' => true ] )
@@ -179,24 +143,16 @@
179 143 ->set_label( __( 'Actions after submit', 'elementor' ) )
180 144 ->set_meta( [ 'topDivider' => true ] )
181 145 ->set_options( [
182 146 [
183 - 'label' => __( 'Email', 'elementor' ),
184 - 'value' => self::ACTION_EMAIL,
185 - ],
186 - [
187 147 'label' => __( 'Collect submissions', 'elementor' ),
188 148 'value' => self::ACTION_COLLECT_SUBMISSIONS,
189 149 ],
190 150 [
191 - 'label' => __( 'Webhook', 'elementor' ),
192 - 'value' => self::ACTION_WEBHOOK,
151 + 'label' => __( 'Email', 'elementor' ),
152 + 'value' => 'email',
193 153 ],
194 154 ] ),
195 - Email_Form_Action_Control::bind_to( 'email' )
196 - ->set_meta( [
197 - 'topDivider' => true,
198 - ] ),
199 155 Chips_Control::bind_to( 'submissions_metadata' )
200 156 ->set_label( __( 'Include metadata', 'elementor' ) )
201 157 ->set_meta( [ 'topDivider' => true ] )
202 158 ->set_options( [
@@ -208,12 +164,12 @@
208 164 'label' => __( 'User Agent', 'elementor' ),
209 165 'value' => self::METADATA_USER_AGENT,
210 166 ],
211 167 ] ),
212 - Text_Control::bind_to( 'webhook_url' )
213 - ->set_label( __( 'Webhook URL', 'elementor' ) )
214 - ->set_placeholder( __( 'https://your-webhook-url.com', 'elementor' ) )
215 - ->set_meta( [ 'topDivider' => true ] ),
168 + Email_Form_Action_Control::bind_to( 'email' )
169 + ->set_meta( [
170 + 'topDivider' => true,
171 + ] ),
216 172 ] ),
217 173 Section::make()
218 174 ->set_label( __( 'Settings', 'elementor' ) )
219 175 ->set_id( 'settings' )
@@ -234,10 +190,8 @@
234 190 ->add_prop( 'display', String_Prop_Type::generate( 'flex' ) )
235 191 ->add_prop( 'flex', String_Prop_Type::generate( '1' ) )
236 192 ->add_prop( 'flex-direction', String_Prop_Type::generate( 'row' ) )
237 193 ->add_prop( 'flex-wrap', String_Prop_Type::generate( 'wrap' ) )
238 - ->add_prop( 'align-items', String_Prop_Type::generate( 'flex-start' ) )
239 - ->add_prop( 'align-content', String_Prop_Type::generate( 'start' ) )
240 194 ->add_prop( 'gap', Size_Prop_Type::generate( [
241 195 'size' => 10,
242 196 'unit' => 'px',
243 197 ] ) )
@@ -273,9 +227,9 @@
273 227 protected function define_default_children() {
274 228
275 229 $prefix = 'e-form-';
276 230
277 - $children = [
231 + return [
278 232 $this->build_label( __( 'First name', 'elementor' ), $prefix . 'first-name' ),
279 233 $this->build_input( __( 'First name', 'elementor' ), 'text', $prefix . 'first-name' ),
280 234
281 235 $this->build_label( __( 'Last name', 'elementor' ), $prefix . 'last-name' ),
@@ -285,32 +239,30 @@
285 239 $this->build_input( __( '[email protected]', 'elementor' ), 'email', $prefix . 'email' ),
286 240
287 241 $this->build_label( __( 'Message', 'elementor' ), $prefix . 'message' ),
288 242 $this->build_input( __( 'Your message', 'elementor' ), 'textarea', $prefix . 'message' ),
289 - ];
290 243
291 - $children[] = $this->build_checkbox_row( __( 'Checkbox', 'elementor' ), $prefix . 'checkbox' );
244 + $this->build_checkbox_row( __( 'Checkbox', 'elementor' ), $prefix . 'checkbox' ),
292 245
293 - $children[] = Widget_Builder::make( 'e-form-submit-button' )
294 - ->settings( [
295 - 'text' => Html_V3_Prop_Type::generate( [
296 - 'content' => String_Prop_Type::generate( __( 'Submit', 'elementor' ) ),
297 - 'children' => [],
298 - ] ),
299 - ] )
300 - ->build();
301 - $children[] = $this->build_status_message(
302 - __( 'Great! We’ve received your information.', 'elementor' ),
303 - 'success',
304 - __( 'Success message', 'elementor' )
305 - );
306 - $children[] = $this->build_status_message(
307 - __( 'We couldn’t process your submission. Please retry', 'elementor' ),
308 - 'error',
309 - __( 'Error message', 'elementor' )
310 - );
311 -
312 - return $children;
246 + Widget_Builder::make( 'e-form-submit-button' )
247 + ->settings( [
248 + 'text' => Html_V3_Prop_Type::generate( [
249 + 'content' => String_Prop_Type::generate( __( 'Submit', 'elementor' ) ),
250 + 'children' => [],
251 + ] ),
252 + ] )
253 + ->build(),
254 + $this->build_status_message(
255 + __( 'Great! We’ve received your information.', 'elementor' ),
256 + 'success',
257 + __( 'Success message', 'elementor' )
258 + ),
259 + $this->build_status_message(
260 + __( 'We couldn’t process your submission. Please retry', 'elementor' ),
261 + 'error',
262 + __( 'Error message', 'elementor' )
263 + ),
264 + ];
313 265 }
314 266
315 267 private function build_checkbox_row( string $label_text, string $checkbox_id ): array {
316 268 $checkbox = Widget_Builder::make( 'e-form-checkbox' )
@@ -371,9 +323,8 @@
371 323 ? Form_Success_Message::get_element_type()
372 324 : Form_Error_Message::get_element_type();
373 325
374 326 return Element_Builder::make( $element_type )
375 - ->meta( [ 'required' => true ] )
376 327 ->settings( [
377 328 'attributes' => Attributes_Prop_Type::generate( [
378 329 Key_Value_Prop_Type::generate( [] ),
379 330 ] ),
@@ -387,8 +338,9 @@
387 338 'paragraph' => $paragraph_value,
388 339 ] )
389 340 ->build(),
390 341 ] )
342 + ->is_locked( true )
391 343 ->build();
392 344 }
393 345
394 346 protected function get_templates(): array {
@@ -402,14 +354,6 @@
402 354
403 355 $context['form_state'] = 'default';
404 356
405 357 return $context;
406 - }
407 -
408 - public static function is_instance_form( $instance ): bool {
409 - return $instance instanceof Atomic_Form;
410 - }
411 -
412 - public function render_markdown(): string {
413 - return '';
414 358 }
415 359 }