PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.0-beta1
Elementor Website Builder – more than just a page builder v3.30.0-beta1
4.3.4 4.3.3 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 All 457 releases
← All changes | modules/atomic-widgets/elements/atomic-heading/atomic-heading.php +41 -73 4.1.5 → 3.30.0-beta1 View file →
@@ -1,23 +1,22 @@
1 1 <?php
2 2 namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Heading;
3 3
4 4 use Elementor\Modules\AtomicWidgets\Controls\Section;
5 -use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control;
6 5 use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
7 6 use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control;
8 7 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
9 -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base;
10 -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template;
11 -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
8 +use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control;
9 +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base;
10 +use Elementor\Modules\AtomicWidgets\Elements\Has_Template;
11 +use Elementor\Modules\AtomicWidgets\Module;
12 12 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
13 -use Elementor\Modules\AtomicWidgets\PropTypes\Html_V3_Prop_Type;
14 13 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
15 14 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
16 15 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
17 16 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
18 17 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
19 -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
18 +use Elementor\Plugin;
20 19
21 20 if ( ! defined( 'ABSPATH' ) ) {
22 21 exit; // Exit if accessed directly.
23 22 }
@@ -26,10 +25,8 @@
26 25 use Has_Template;
27 26
28 27 const LINK_BASE_STYLE_KEY = 'link-base';
29 28
30 - public static $widget_description = 'Display a heading with customizable tag, styles, and link options.';
31 -
32 29 public static function get_element_type(): string {
33 30 return 'e-heading';
34 31 }
35 32
@@ -45,28 +42,27 @@
45 42 return 'eicon-e-heading';
46 43 }
47 44
48 45 protected static function define_props_schema(): array {
49 - return [
46 + $props = [
50 47 'classes' => Classes_Prop_Type::make()
51 48 ->default( [] ),
52 49
53 50 'tag' => String_Prop_Type::make()
54 51 ->enum( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] )
55 - ->default( 'h2' )
56 - ->description( 'The HTML tag for the heading element. Could be h1, h2, up to h6' ),
52 + ->default( 'h2' ),
57 53
58 - 'title' => Html_V3_Prop_Type::make()
59 - ->default( [
60 - 'content' => String_Prop_Type::generate( __( 'This is a title', 'elementor' ) ),
61 - 'children' => [],
62 - ] )
63 - ->description( 'The text content of the heading.' ),
54 + 'title' => String_Prop_Type::make()
55 + ->default( __( 'This is a title', 'elementor' ) ),
64 56
65 57 'link' => Link_Prop_Type::make(),
58 + ];
66 59
67 - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
68 - ];
60 + if ( Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_VERSION_3_30 ) ) {
61 + $props['_cssid'] = String_Prop_Type::make();
62 + }
63 +
64 + return $props;
69 65 }
70 66
71 67 protected function define_atomic_controls(): array {
72 68 $content_section = Section::make()
@@ -71,26 +67,17 @@
71 67 protected function define_atomic_controls(): array {
72 68 $content_section = Section::make()
73 69 ->set_label( __( 'Content', 'elementor' ) )
74 70 ->set_items( [
75 - Inline_Editing_Control::bind_to( 'title' )
76 - ->set_placeholder( __( 'Type your title here', 'elementor' ) )
77 - ->set_label( __( 'Title', 'elementor' ) ),
71 + Textarea_Control::bind_to( 'title' )
72 + ->set_label( __( 'Title', 'elementor' ) )
73 + ->set_placeholder( __( 'Type your title here', 'elementor' ) ),
78 74 ] );
79 75
80 - return [
81 - $content_section,
82 - Section::make()
83 - ->set_label( __( 'Settings', 'elementor' ) )
84 - ->set_id( 'settings' )
85 - ->set_items( $this->get_settings_controls() ),
86 - ];
87 - }
88 -
89 - protected function get_settings_controls(): array {
90 - return [
76 + $settings_section_items = [
91 77 Select_Control::bind_to( 'tag' )
92 - ->set_options([
78 + ->set_label( esc_html__( 'Tag', 'elementor' ) )
79 + ->set_options( [
93 80 [
94 81 'value' => 'h1',
95 82 'label' => 'H1',
96 83 ],
@@ -113,20 +100,29 @@
113 100 [
114 101 'value' => 'h6',
115 102 'label' => 'H6',
116 103 ],
117 - ])
118 - ->set_label( __( 'Tag', 'elementor' ) ),
119 - Link_Control::bind_to( 'link' )
120 - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) )
121 - ->set_label( __( 'Link', 'elementor' ) )
122 - ->set_meta( [
123 - 'topDivider' => true,
124 - ] ),
125 - Text_Control::bind_to( '_cssid' )
126 - ->set_label( __( 'ID', 'elementor' ) )
127 - ->set_meta( $this->get_css_id_control_meta() ),
104 + ]),
105 + Link_Control::bind_to( 'link' )->set_meta( [
106 + 'topDivider' => true,
107 + ] ),
128 108 ];
109 +
110 + if ( Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_VERSION_3_30 ) ) {
111 + $settings_section_items[] = Text_Control::bind_to( '_cssid' )->set_label( __( 'ID', 'elementor' ) )->set_meta( [
112 + 'layout' => 'two-columns',
113 + 'topDivider' => true,
114 + ] );
115 + }
116 +
117 + $settings_section = Section::make()
118 + ->set_label( __( 'Settings', 'elementor' ) )
119 + ->set_items( $settings_section_items );
120 +
121 + return [
122 + $content_section,
123 + $settings_section,
124 + ];
129 125 }
130 126
131 127 protected function define_base_styles(): array {
132 128 $margin_value = Size_Prop_Type::generate( [
@@ -152,34 +148,6 @@
152 148 protected function get_templates(): array {
153 149 return [
154 150 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig',
155 151 ];
156 - }
157 -
158 - public function render_markdown(): string {
159 - $settings = $this->get_atomic_settings();
160 - $title = wp_strip_all_tags( $settings['title'] ?? '' );
161 -
162 - if ( empty( $title ) ) {
163 - return '';
164 - }
165 -
166 - $tag = $settings['tag'] ?? 'h2';
167 - $level_map = [
168 - 'h1' => 1,
169 - 'h2' => 2,
170 - 'h3' => 3,
171 - 'h4' => 4,
172 - 'h5' => 5,
173 - 'h6' => 6,
174 - ];
175 - $level = $level_map[ $tag ] ?? 2;
176 -
177 - $md = str_repeat( '#', $level ) . ' ' . $title;
178 -
179 - if ( ! empty( $settings['link']['href'] ) ) {
180 - $md = str_repeat( '#', $level ) . ' [' . $title . '](' . esc_url( $settings['link']['href'] ) . ')';
181 - }
182 -
183 - return $md;
184 152 }
185 153 }