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