PluginProbe
Elementor Website Builder – more than just a page builder / 3.30.0-beta1
Elementor Website Builder – more than just a page builder v3.30.0-beta1
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 4.1.0-beta1 4.1.0-dev1 All 452 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.30.0-beta1, at modules/atomic-widgets/elements/atomic-heading/atomic-heading.php

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