PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0
Elementor Website Builder – more than just a page builder v4.0.0
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 4.0.0, at modules/atomic-widgets/elements/atomic-heading/atomic-heading.php

158 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_V3_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_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
65 'link' => Link_Prop_Type::make(),
66
67 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
68 ];
69 }
70
71 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 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 [
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,
124 ] ),
125 Text_Control::bind_to( '_cssid' )
126 ->set_label( __( 'ID', 'elementor' ) )
127 ->set_meta( $this->get_css_id_control_meta() ),
128 ];
129 }
130
131 protected function define_base_styles(): array {
132 $margin_value = Size_Prop_Type::generate( [
133 'unit' => 'px',
134 'size' => 0 ,
135 ] );
136
137 return [
138 'base' => Style_Definition::make()
139 ->add_variant(
140 Style_Variant::make()
141 ->add_prop( 'margin', $margin_value )
142 ),
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 ];
150 }
151
152 protected function get_templates(): array {
153 return [
154 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig',
155 ];
156 }
157 }
158