PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / modules / atomic-widgets / elements / atomic-form / form-message / form-message.php

form-message.php in Elementor Website Builder – more than just a page builder 4.3.0-beta3, at modules/atomic-widgets/elements/atomic-form/form-message/form-message.php

121 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Form\Form_Message;
3
4 use Elementor\Modules\AtomicWidgets\Controls\Section;
5 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
6 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph\Atomic_Paragraph;
7 use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base;
8 use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Element_Template;
9 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
10 use Elementor\Modules\AtomicWidgets\PropTypes\Background_Prop_Type;
11 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
17 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
18 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
19
20 if ( ! defined( 'ABSPATH' ) ) {
21 exit;
22 }
23
24 abstract class Form_Message extends Atomic_Element_Base {
25 use Has_Element_Template;
26
27 const BASE_STYLE_KEY = 'base';
28
29 public static $widget_description = 'A container for form status messages (success or error). Hidden by default, shown based on form submission state.';
30
31 abstract protected static function get_background_color(): string;
32
33 abstract protected static function get_text_color(): string;
34
35 abstract protected static function get_default_status_paragraph_text(): string;
36
37 public function __construct( $data = [], $args = null ) {
38 parent::__construct( $data, $args );
39 $this->meta( 'is_container', true );
40 $this->meta( 'permanently_locked', true );
41 }
42
43 public function get_icon() {
44 return 'eicon-div-block';
45 }
46
47 public function should_show_in_panel() {
48 return false;
49 }
50
51 protected static function define_props_schema(): array {
52 return [
53 'classes' => Classes_Prop_Type::make()
54 ->default( [] ),
55 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
56 ];
57 }
58
59 protected function define_allowed_child_types() {
60 return [];
61 }
62
63 protected function define_default_children() {
64 return [
65 Atomic_Paragraph::generate()
66 ->settings( [
67 'paragraph' => Escaped_Html_Prop_Type::generate( static::get_default_status_paragraph_text() ),
68 ] )
69 ->build(),
70 ];
71 }
72
73 protected function define_atomic_controls(): array {
74 return [
75 Section::make()
76 ->set_label( __( 'Settings', 'elementor' ) )
77 ->set_id( 'settings' )
78 ->set_items( [
79 Text_Control::bind_to( '_cssid' )
80 ->set_label( __( 'ID', 'elementor' ) )
81 ->set_meta( $this->get_css_id_control_meta() ),
82 ] ),
83 ];
84 }
85
86 protected function define_base_styles(): array {
87 return [
88 static::BASE_STYLE_KEY => Style_Definition::make()
89 ->add_variant(
90 Style_Variant::make()
91 ->add_props( [
92 'display' => String_Prop_Type::generate( 'none' ),
93 'background' => Background_Prop_Type::generate( [
94 'color' => Color_Prop_Type::generate( static::get_background_color() ),
95 ] ),
96 'color' => Color_Prop_Type::generate( static::get_text_color() ),
97 'padding' => Size_Prop_Type::generate( [
98 'size' => 12,
99 'unit' => 'px',
100 ] ),
101 'text-align' => String_Prop_Type::generate( 'center' ),
102 'font-size' => Size_Prop_Type::generate( [
103 'size' => 12,
104 'unit' => 'px',
105 ] ),
106 ] )
107 ),
108 ];
109 }
110
111 protected function get_templates(): array {
112 return [
113 'elementor/elements/form-message' => __DIR__ . '/form-message.html.twig',
114 ];
115 }
116
117 protected function build_template_context(): array {
118 return $this->build_base_template_context();
119 }
120 }
121