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

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