PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.5
Elementor Website Builder – more than just a page builder v3.32.5
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 4.0.7 All 451 releases
elementor / modules / atomic-widgets / elements / flexbox / flexbox.php

flexbox.php in Elementor Website Builder – more than just a page builder 3.32.5, at modules/atomic-widgets/elements/flexbox/flexbox.php

158 lines 4.2 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\Flexbox;
3
4 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base;
5 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
6 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
7 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
8 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
9 use Elementor\Modules\AtomicWidgets\Controls\Section;
10 use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
11 use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control;
12 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
13 use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
17
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit; // Exit if accessed directly.
20 }
21
22 class Flexbox extends Atomic_Element_Base {
23 const BASE_STYLE_KEY = 'base';
24
25 public static function get_type() {
26 return 'e-flexbox';
27 }
28
29 public static function get_element_type(): string {
30 return 'e-flexbox';
31 }
32
33 public function get_title() {
34 return esc_html__( 'Flexbox', 'elementor' );
35 }
36
37 public function get_keywords() {
38 return [ 'ato', 'atom', 'atoms', 'atomic' ];
39 }
40
41 public function get_icon() {
42 return 'eicon-flexbox';
43 }
44
45 protected static function define_props_schema(): array {
46 $tag_dependencies = Dependency_Manager::make()
47 ->where( [
48 'operator' => 'not_exist',
49 'path' => [ 'link', 'destination' ],
50 ] )
51 ->get();
52
53 return [
54 'classes' => Classes_Prop_Type::make()
55 ->default( [] ),
56 'tag' => String_Prop_Type::make()
57 ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer' ] )
58 ->default( 'div' )
59 ->set_dependencies( $tag_dependencies ),
60 'link' => Link_Prop_Type::make(),
61 'attributes' => Attributes_Prop_Type::make(),
62 ];
63 }
64
65 protected function define_atomic_controls(): array {
66 return [
67 Section::make()
68 ->set_label( __( 'Settings', 'elementor' ) )
69 ->set_id( 'settings' )
70 ->set_items( [
71 Select_Control::bind_to( 'tag' )
72 ->set_options( [
73 [
74 'value' => 'div',
75 'label' => 'Div',
76 ],
77 [
78 'value' => 'header',
79 'label' => 'Header',
80 ],
81 [
82 'value' => 'section',
83 'label' => 'Section',
84 ],
85 [
86 'value' => 'article',
87 'label' => 'Article',
88 ],
89 [
90 'value' => 'aside',
91 'label' => 'Aside',
92 ],
93 [
94 'value' => 'footer',
95 'label' => 'Footer',
96 ],
97 ])
98 ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ),
99 Link_Control::bind_to( 'link' )
100 ->set_label( __( 'Link', 'elementor' ) )
101 ->set_meta( [
102 'topDivider' => true,
103 ] ),
104 Text_Control::bind_to( '_cssid' )
105 ->set_label( __( 'ID', 'elementor' ) )
106 ->set_meta( $this->get_css_id_control_meta() ),
107 ] ),
108 ];
109 }
110
111 protected function define_base_styles(): array {
112 $display = String_Prop_Type::generate( 'flex' );
113 $flex_direction = String_Prop_Type::generate( 'row' );
114
115 return [
116 static::BASE_STYLE_KEY => Style_Definition::make()
117 ->add_variant(
118 Style_Variant::make()
119 ->add_prop( 'display', $display )
120 ->add_prop( 'flex-direction', $flex_direction )
121 ->add_prop( 'padding', $this->get_base_padding() )
122 ),
123 ];
124 }
125
126 protected function get_base_padding(): array {
127 return Size_Prop_Type::generate( [
128 'size' => 10,
129 'unit' => 'px',
130 ] );
131 }
132
133 protected function add_render_attributes() {
134 parent::add_render_attributes();
135 $settings = $this->get_atomic_settings();
136 $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ];
137
138 $attributes = [
139 'class' => [
140 'e-con',
141 'e-atomic-element',
142 $base_style_class,
143 ...( $settings['classes'] ?? [] ),
144 ],
145 ];
146
147 if ( ! empty( $settings['_cssid'] ) ) {
148 $attributes['id'] = esc_attr( $settings['_cssid'] );
149 }
150
151 if ( ! empty( $settings['link']['href'] ) ) {
152 $attributes = array_merge( $attributes, $settings['link'] );
153 }
154
155 $this->add_render_attribute( '_wrapper', $attributes );
156 }
157 }
158