PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.0-dev2
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 +56 -118 4.1.0-beta3 → 3.28.0-dev2 View file →
@@ -1,23 +1,21 @@
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\Color_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;
17 +use Elementor\Modules\WpRest\Classes\WP_Post;
20 18
21 19 if ( ! defined( 'ABSPATH' ) ) {
22 20 exit; // Exit if accessed directly.
23 21 }
@@ -24,24 +22,16 @@
24 22
25 23 class Atomic_Heading extends Atomic_Widget_Base {
26 24 use Has_Template;
27 25
28 - const LINK_BASE_STYLE_KEY = 'link-base';
29 -
30 - public static $widget_description = 'Display a heading with customizable tag, styles, and link options.';
31 -
32 26 public static function get_element_type(): string {
33 - return 'e-heading';
27 + return 'a-heading';
34 28 }
35 29
36 30 public function get_title() {
37 - return esc_html__( 'Heading', 'elementor' );
31 + return esc_html__( 'Atomic Heading', 'elementor' );
38 32 }
39 33
40 - public function get_keywords() {
41 - return [ 'ato', 'atom', 'atoms', 'atomic' ];
42 - }
43 -
44 34 public function get_icon() {
45 35 return 'eicon-e-heading';
46 36 }
47 37
@@ -51,102 +41,78 @@
51 41 ->default( [] ),
52 42
53 43 'tag' => String_Prop_Type::make()
54 44 ->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' ),
45 + ->default( 'h2' ),
57 46
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.' ),
47 + 'title' => String_Prop_Type::make()
48 + ->default( __( 'Your Title Here', 'elementor' ) ),
64 49
65 50 'link' => Link_Prop_Type::make(),
66 -
67 - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
68 51 ];
69 52 }
70 53
71 54 protected function define_atomic_controls(): array {
72 - $content_section = Section::make()
73 - ->set_label( __( 'Content', 'elementor' ) )
74 - ->set_items( [
75 - Inline_Editing_Control::bind_to( 'title' )
76 - ->set_placeholder( __( 'Type your title here', 'elementor' ) )
77 - ->set_label( __( 'Title', 'elementor' ) ),
78 - ] );
79 -
80 55 return [
81 - $content_section,
82 56 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 [
91 - Select_Control::bind_to( 'tag' )
92 - ->set_options([
93 - [
94 - 'value' => 'h1',
95 - 'label' => 'H1',
96 - ],
97 - [
98 - 'value' => 'h2',
99 - 'label' => 'H2',
100 - ],
101 - [
102 - 'value' => 'h3',
103 - 'label' => 'H3',
104 - ],
105 - [
106 - 'value' => 'h4',
107 - 'label' => 'H4',
108 - ],
109 - [
110 - 'value' => 'h5',
111 - 'label' => 'H5',
112 - ],
113 - [
114 - 'value' => 'h6',
115 - 'label' => 'H6',
116 - ],
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,
57 + ->set_label( __( 'Content', 'elementor' ) )
58 + ->set_items( [
59 + Textarea_Control::bind_to( 'title' )
60 + ->set_label( __( 'Title', 'elementor' ) )
61 + ->set_placeholder( __( 'Type your title here', 'elementor' ) ),
62 + Select_Control::bind_to( 'tag' )
63 + ->set_label( esc_html__( 'Tag', 'elementor' ) )
64 + ->set_options( [
65 + [
66 + 'value' => 'h1',
67 + 'label' => 'H1',
68 + ],
69 + [
70 + 'value' => 'h2',
71 + 'label' => 'H2',
72 + ],
73 + [
74 + 'value' => 'h3',
75 + 'label' => 'H3',
76 + ],
77 + [
78 + 'value' => 'h4',
79 + 'label' => 'H4',
80 + ],
81 + [
82 + 'value' => 'h5',
83 + 'label' => 'H5',
84 + ],
85 + [
86 + 'value' => 'h6',
87 + 'label' => 'H6',
88 + ],
89 + ]),
90 + Link_Control::bind_to( 'link' ),
124 91 ] ),
125 - Text_Control::bind_to( '_cssid' )
126 - ->set_label( __( 'ID', 'elementor' ) )
127 - ->set_meta( $this->get_css_id_control_meta() ),
128 92 ];
129 93 }
130 94
131 95 protected function define_base_styles(): array {
132 - $margin_value = Size_Prop_Type::generate( [
133 - 'unit' => 'px',
134 - 'size' => 0 ,
96 + $color_value = Color_Prop_Type::generate( 'black' );
97 + $font_family_value = String_Prop_Type::generate( 'Inter' );
98 + $font_size_value = Size_Prop_Type::generate( [
99 + 'size' => 3,
100 + 'unit' => 'rem',
135 101 ] );
102 + $line_height_value = String_Prop_Type::generate( '1.1' );
103 + $font_weight_value = String_Prop_Type::generate( '600' );
136 104
137 105 return [
138 106 'base' => Style_Definition::make()
139 107 ->add_variant(
140 108 Style_Variant::make()
141 - ->add_prop( 'margin', $margin_value )
109 + ->add_prop( 'color', $color_value )
110 + ->add_prop( 'font-family', $font_family_value )
111 + ->add_prop( 'font-size', $font_size_value )
112 + ->add_prop( 'line-height', $line_height_value )
113 + ->add_prop( 'font-weight', $font_weight_value )
142 114 ),
143 - self::LINK_BASE_STYLE_KEY => Style_Definition::make()
144 - ->add_variant(
145 - Style_Variant::make()
146 - ->add_prop( 'all', 'unset' )
147 - ->add_prop( 'cursor', 'pointer' )
148 - ),
149 115 ];
150 116 }
151 117
152 118 protected function get_templates(): array {
@@ -152,34 +118,6 @@
152 118 protected function get_templates(): array {
153 119 return [
154 120 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig',
155 121 ];
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 122 }
185 123 }