PluginProbe
Elementor Website Builder – more than just a page builder / 3.29.0-beta4
Elementor Website Builder – more than just a page builder v3.29.0-beta4
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/div-block/div-block.php +85 -83 4.0.9 → 3.29.0-beta4 View file →
@@ -1,21 +1,21 @@
1 1 <?php
2 2 namespace Elementor\Modules\AtomicWidgets\Elements\Div_Block;
3 3
4 -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base;
4 +use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
5 +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base;
6 +use Elementor\Modules\AtomicWidgets\Controls\Section;
7 +use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control;
8 +use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
9 +use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type;
10 +use Elementor\Modules\AtomicWidgets\PropTypes\Dimensions_Prop_Type;
11 +use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
5 12 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
6 13 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
7 14 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
8 -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
9 15 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
10 -use Elementor\Modules\AtomicWidgets\Controls\Section;
11 -use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
12 -use Elementor\Modules\AtomicWidgets\Controls\Types\Html_Tag_Control;
13 -use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
14 -use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager;
15 -use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
16 -use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
17 -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
16 +use Elementor\Plugin;
17 +use Elementor\Utils;
18 18
19 19 if ( ! defined( 'ABSPATH' ) ) {
20 20 exit; // Exit if accessed directly.
21 21 }
@@ -22,13 +22,8 @@
22 22
23 23 class Div_Block extends Atomic_Element_Base {
24 24 const BASE_STYLE_KEY = 'base';
25 25
26 - public function __construct( $data = [], $args = null ) {
27 - parent::__construct( $data, $args );
28 - $this->meta( 'is_container', true );
29 - }
30 -
31 26 public static function get_type() {
32 27 return 'e-div-block';
33 28 }
34 29
@@ -36,9 +31,9 @@
36 31 return 'e-div-block';
37 32 }
38 33
39 34 public function get_title() {
40 - return esc_html__( 'Div block', 'elementor' );
35 + return esc_html__( 'Div Block', 'elementor' );
41 36 }
42 37
43 38 public function get_keywords() {
44 39 return [ 'ato', 'atom', 'atoms', 'atomic' ];
@@ -48,36 +43,17 @@
48 43 return 'eicon-div-block';
49 44 }
50 45
51 46 protected static function define_props_schema(): array {
52 - $tag_dependencies = Dependency_Manager::make( Dependency_Manager::RELATION_AND )
53 - ->where( [
54 - 'operator' => 'ne',
55 - 'path' => [ 'link', 'destination' ],
56 - 'nestedPath' => [ 'group' ],
57 - 'value' => 'action',
58 - 'newValue' => [
59 - '$$type' => 'string',
60 - 'value' => 'button',
61 - ],
62 - ] )->where( [
63 - 'operator' => 'not_exist',
64 - 'path' => [ 'link', 'destination' ],
65 - 'newValue' => [
66 - '$$type' => 'string',
67 - 'value' => 'a',
68 - ],
69 - ] )->get();
70 -
71 47 return [
72 48 'classes' => Classes_Prop_Type::make()
73 49 ->default( [] ),
50 +
74 51 'tag' => String_Prop_Type::make()
75 - ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button' ] )
76 - ->default( 'div' )
77 - ->set_dependencies( $tag_dependencies ),
52 + ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer' ] )
53 + ->default( 'div' ),
54 +
78 55 'link' => Link_Prop_Type::make(),
79 - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
80 56 ];
81 57 }
82 58
83 59 protected function define_atomic_controls(): array {
@@ -83,11 +59,11 @@
83 59 protected function define_atomic_controls(): array {
84 60 return [
85 61 Section::make()
86 62 ->set_label( __( 'Settings', 'elementor' ) )
87 - ->set_id( 'settings' )
88 63 ->set_items( [
89 - Html_Tag_Control::bind_to( 'tag' )
64 + Select_Control::bind_to( 'tag' )
65 + ->set_label( esc_html__( 'HTML Tag', 'elementor' ) )
90 66 ->set_options( [
91 67 [
92 68 'value' => 'div',
93 69 'label' => 'Div',
@@ -111,26 +87,79 @@
111 87 [
112 88 'value' => 'footer',
113 89 'label' => 'Footer',
114 90 ],
115 - ])
116 - ->set_fallback_labels( [
117 - 'a' => 'a (link)',
118 - ] )
119 - ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ),
120 - Link_Control::bind_to( 'link' )
121 - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) )
122 - ->set_label( __( 'Link', 'elementor' ) )
123 - ->set_meta( [
124 - 'topDivider' => true,
125 - ] ),
126 - Text_Control::bind_to( '_cssid' )
127 - ->set_label( __( 'ID', 'elementor' ) )
128 - ->set_meta( $this->get_css_id_control_meta() ),
129 - ] ),
91 + ]),
92 +
93 + Link_Control::bind_to( 'link' ),
94 +
95 + ]),
130 96 ];
131 97 }
132 98
99 + protected function _get_default_child_type( array $element_data ) {
100 + $el_types = array_keys( Plugin::$instance->elements_manager->get_element_types() );
101 +
102 + if ( in_array( $element_data['elType'], $el_types, true ) ) {
103 + return Plugin::$instance->elements_manager->get_element_types( $element_data['elType'] );
104 + }
105 +
106 + return Plugin::$instance->widgets_manager->get_widget_types( $element_data['widgetType'] );
107 + }
108 +
109 + protected function content_template() {
110 + ?>
111 + <?php
112 + }
113 +
114 + protected function add_render_attributes() {
115 + parent::add_render_attributes();
116 + $settings = $this->get_atomic_settings();
117 + $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ];
118 +
119 + $attributes = [
120 + 'class' => [
121 + 'e-con',
122 + $base_style_class,
123 + ...( $settings['classes'] ?? [] ),
124 + ],
125 + ];
126 +
127 + if ( ! empty( $settings['link']['href'] ) ) {
128 + $attributes = array_merge( $attributes, $settings['link'] );
129 + }
130 +
131 + $this->add_render_attribute( '_wrapper', $attributes );
132 + }
133 +
134 + public function before_render() {
135 + ?>
136 + <<?php $this->print_html_tag(); ?> <?php $this->print_render_attribute_string( '_wrapper' ); ?>>
137 + <?php
138 + }
139 +
140 + public function after_render() {
141 + ?>
142 + </<?php $this->print_html_tag(); ?>>
143 + <?php
144 + }
145 +
146 + /**
147 + * Print safe HTML tag for the element based on the element settings.
148 + *
149 + * @return void
150 + */
151 + protected function print_html_tag() {
152 + $html_tag = $this->get_html_tag();
153 + Utils::print_validated_html_tag( $html_tag );
154 + }
155 +
156 + protected function get_html_tag(): string {
157 + $settings = $this->get_atomic_settings();
158 +
159 + return ! empty( $settings['link']['href'] ) ? 'a' : ( $settings['tag'] ?? 'div' );
160 + }
161 +
133 162 protected function define_base_styles(): array {
134 163 $display = String_Prop_Type::generate( 'block' );
135 164
136 165 return [
@@ -155,33 +184,6 @@
155 184 return Size_Prop_Type::generate( [
156 185 'size' => 30,
157 186 'unit' => 'px',
158 187 ] );
159 - }
160 -
161 - protected function add_render_attributes() {
162 - parent::add_render_attributes();
163 - $settings = $this->get_atomic_settings();
164 - $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ];
165 - $initial_attributes = $this->define_initial_attributes();
166 -
167 - $attributes = [
168 - 'class' => [
169 - 'e-con',
170 - 'e-atomic-element',
171 - $base_style_class,
172 - ...( $settings['classes'] ?? [] ),
173 - ],
174 - ];
175 -
176 - if ( ! empty( $settings['_cssid'] ) ) {
177 - $attributes['id'] = esc_attr( $settings['_cssid'] );
178 - }
179 -
180 - if ( ! empty( $settings['link']['href'] ) ) {
181 - $link_attributes = $this->get_link_attributes( $settings['link'] );
182 - $attributes = array_merge( $attributes, $link_attributes );
183 - }
184 -
185 - $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) );
186 188 }
187 189 }