PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.9
Elementor Website Builder – more than just a page builder v3.35.9
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 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / atomic-widgets / elements / atomic-heading / atomic-heading.php

atomic-heading.php in Elementor Website Builder – more than just a page builder 3.35.9, at modules/atomic-widgets/elements/atomic-heading/atomic-heading.php

155 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Heading;
3
4 use Elementor\Modules\AtomicWidgets\Controls\Section;
5 use Elementor\Modules\AtomicWidgets\Controls\Types\Inline_Editing_Control;
6 use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control;
7 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;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Html_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
17 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
18 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
19 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
20
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit; // Exit if accessed directly.
23 }
24
25 class Atomic_Heading extends Atomic_Widget_Base {
26 use Has_Template;
27
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 public static function get_element_type(): string {
33 return 'e-heading';
34 }
35
36 public function get_title() {
37 return esc_html__( 'Heading', 'elementor' );
38 }
39
40 public function get_keywords() {
41 return [ 'ato', 'atom', 'atoms', 'atomic' ];
42 }
43
44 public function get_icon() {
45 return 'eicon-e-heading';
46 }
47
48 protected static function define_props_schema(): array {
49 return [
50 'classes' => Classes_Prop_Type::make()
51 ->default( [] ),
52
53 'tag' => String_Prop_Type::make()
54 ->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' ),
57
58 'title' => Html_Prop_Type::make()
59 ->default( __( 'This is a title', 'elementor' ) )
60 ->description( 'The text content of the heading.' ),
61
62 'link' => Link_Prop_Type::make(),
63
64 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
65 ];
66 }
67
68 protected function define_atomic_controls(): array {
69 $content_section = Section::make()
70 ->set_label( __( 'Content', 'elementor' ) )
71 ->set_items( [
72 Inline_Editing_Control::bind_to( 'title' )
73 ->set_placeholder( __( 'Type your title here', 'elementor' ) )
74 ->set_label( __( 'Title', 'elementor' ) ),
75 ] );
76
77 return [
78 $content_section,
79 Section::make()
80 ->set_label( __( 'Settings', 'elementor' ) )
81 ->set_id( 'settings' )
82 ->set_items( $this->get_settings_controls() ),
83 ];
84 }
85
86 protected function get_settings_controls(): array {
87 return [
88 Select_Control::bind_to( 'tag' )
89 ->set_options([
90 [
91 'value' => 'h1',
92 'label' => 'H1',
93 ],
94 [
95 'value' => 'h2',
96 'label' => 'H2',
97 ],
98 [
99 'value' => 'h3',
100 'label' => 'H3',
101 ],
102 [
103 'value' => 'h4',
104 'label' => 'H4',
105 ],
106 [
107 'value' => 'h5',
108 'label' => 'H5',
109 ],
110 [
111 'value' => 'h6',
112 'label' => 'H6',
113 ],
114 ])
115 ->set_label( __( 'Tag', 'elementor' ) ),
116 Link_Control::bind_to( 'link' )
117 ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) )
118 ->set_label( __( 'Link', 'elementor' ) )
119 ->set_meta( [
120 'topDivider' => true,
121 ] ),
122 Text_Control::bind_to( '_cssid' )
123 ->set_label( __( 'ID', 'elementor' ) )
124 ->set_meta( $this->get_css_id_control_meta() ),
125 ];
126 }
127
128 protected function define_base_styles(): array {
129 $margin_value = Size_Prop_Type::generate( [
130 'unit' => 'px',
131 'size' => 0 ,
132 ] );
133
134 return [
135 'base' => Style_Definition::make()
136 ->add_variant(
137 Style_Variant::make()
138 ->add_prop( 'margin', $margin_value )
139 ),
140 self::LINK_BASE_STYLE_KEY => Style_Definition::make()
141 ->add_variant(
142 Style_Variant::make()
143 ->add_prop( 'all', 'unset' )
144 ->add_prop( 'cursor', 'pointer' )
145 ),
146 ];
147 }
148
149 protected function get_templates(): array {
150 return [
151 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig',
152 ];
153 }
154 }
155