PluginProbe
Elementor Website Builder – more than just a page builder / 3.34.0-beta1
Elementor Website Builder – more than just a page builder v3.34.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 +32 -61 4.3.0-beta2 → 3.34.0-beta1 View file →
@@ -1,24 +1,25 @@
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\Elements\Base\Html_Tag_Computer;
7 +use Elementor\Modules\AtomicWidgets\Controls\Types\Textarea_Control;
8 +use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control;
9 +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base;
10 +use Elementor\Modules\AtomicWidgets\Elements\Has_Template;
11 +use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module;
12 +use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
12 13 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
13 -use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
14 -use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type;
14 +use Elementor\Modules\AtomicWidgets\PropTypes\Html_Prop_Type;
15 15 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
16 16 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
17 17 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
18 18 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
19 19 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
20 -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
20 +use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
21 +use Elementor\Plugin;
21 22
22 23 if ( ! defined( 'ABSPATH' ) ) {
23 24 exit; // Exit if accessed directly.
24 25 }
@@ -27,10 +28,8 @@
27 28 use Has_Template;
28 29
29 30 const LINK_BASE_STYLE_KEY = 'link-base';
30 31
31 - public static $widget_description = 'Display a heading with customizable tag, styles, and link options.';
32 -
33 32 public static function get_element_type(): string {
34 33 return 'e-heading';
35 34 }
36 35
@@ -45,20 +44,16 @@
45 44 public function get_icon() {
46 45 return 'eicon-e-heading';
47 46 }
48 47
49 - public static function html_tag_follows_link(): bool {
50 - return false;
51 - }
48 + protected static function define_props_schema(): array {
49 + $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING );
52 50
53 - public static function get_computed_html_tag( array $settings ): string {
54 - return Html_Tag_Computer::compute( $settings, 'h2', [
55 - Html_Tag_Computer::FOLLOW_LINK_OPTION => static::html_tag_follows_link(),
56 - ] );
57 - }
51 + $title_prop = $is_feature_active
52 + ? Html_Prop_Type::make()->default( __( 'This is a title', 'elementor' ) )
53 + : String_Prop_Type::make()->default( __( 'This is a title', 'elementor' ) );
58 54
59 - protected static function define_props_schema(): array {
60 - return [
55 + $props = [
61 56 'classes' => Classes_Prop_Type::make()
62 57 ->default( [] ),
63 58
64 59 'tag' => String_Prop_Type::make()
@@ -63,31 +58,35 @@
63 58
64 59 'tag' => String_Prop_Type::make()
65 60 ->enum( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] )
66 61 ->default( 'h2' )
67 - ->description( 'The HTML tag for the heading element. One of: h1, h2, h3, h4, h5, or h6. Do not use p, span, or div.' ),
62 + ->description( 'The HTML tag for the heading element. Could be h1, h2, up to h6' ),
68 63
69 - 'title' => Escaped_Html_Prop_Type::make()
70 - ->default( __( 'This is a title', 'elementor' ) )
71 - ->description( 'The text content of the heading.' )
72 - ->alias( 'text', 'content', 'heading' ),
64 + 'title' => $title_prop
65 + ->description( 'The text content of the heading.' ),
73 66
74 67 'link' => Link_Prop_Type::make(),
75 68
76 - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
69 + 'attributes' => Attributes_Prop_Type::make(),
77 70 ];
71 +
72 + return $props;
78 73 }
79 74
80 75 protected function define_atomic_controls(): array {
76 + $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING );
77 +
78 + $control = $is_feature_active
79 + ? Inline_Editing_Control::bind_to( 'title' )
80 + ->set_placeholder( __( 'Type your title here', 'elementor' ) )
81 + ->set_label( __( 'Title', 'elementor' ) )
82 + : Textarea_Control::bind_to( 'title' )
83 + ->set_placeholder( __( 'Type your title here', 'elementor' ) )
84 + ->set_label( __( 'Title', 'elementor' ) );
85 +
81 86 $content_section = Section::make()
82 87 ->set_label( __( 'Content', 'elementor' ) )
83 - ->set_id( 'content' )
84 - ->set_items( [
85 - Inline_Editing_Control::bind_to( 'title' )
86 - ->set_placeholder( __( 'Type your title here', 'elementor' ) )
87 - ->set_label( __( 'Title', 'elementor' ) ),
88 - ] );
89 -
88 + ->set_items( [ $control ] );
90 89 return [
91 90 $content_section,
92 91 Section::make()
93 92 ->set_label( __( 'Settings', 'elementor' ) )
@@ -162,34 +161,6 @@
162 161 protected function get_templates(): array {
163 162 return [
164 163 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig',
165 164 ];
166 - }
167 -
168 - public function render_markdown(): string {
169 - $settings = $this->get_atomic_settings();
170 - $title = wp_strip_all_tags( $settings['title'] ?? '' );
171 -
172 - if ( empty( $title ) ) {
173 - return '';
174 - }
175 -
176 - $tag = $settings['tag'] ?? 'h2';
177 - $level_map = [
178 - 'h1' => 1,
179 - 'h2' => 2,
180 - 'h3' => 3,
181 - 'h4' => 4,
182 - 'h5' => 5,
183 - 'h6' => 6,
184 - ];
185 - $level = $level_map[ $tag ] ?? 2;
186 -
187 - $md = str_repeat( '#', $level ) . ' ' . $title;
188 -
189 - if ( ! empty( $settings['link']['href'] ) ) {
190 - $md = str_repeat( '#', $level ) . ' [' . $title . '](' . esc_url( $settings['link']['href'] ) . ')';
191 - }
192 -
193 - return $md;
194 165 }
195 166 }