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

167 lines 4.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\Controls\Types\Inline_Editing_Control;
9 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base;
10 use Elementor\Modules\AtomicWidgets\Elements\Has_Template;
11 use Elementor\Modules\AtomicWidgets\Module as Atomic_Widgets_Module;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Html_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
17 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
18 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
19 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
20 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
21 use Elementor\Plugin;
22
23 if ( ! defined( 'ABSPATH' ) ) {
24 exit; // Exit if accessed directly.
25 }
26
27 class Atomic_Heading extends Atomic_Widget_Base {
28 use Has_Template;
29
30 const LINK_BASE_STYLE_KEY = 'link-base';
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 $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING );
50
51 $title_prop = $is_feature_active
52 ? Html_Prop_Type::make()->default( __( 'This is a title', 'elementor' ) )
53 : String_Prop_Type::make()->default( __( 'This is a title', 'elementor' ) );
54
55 $props = [
56 'classes' => Classes_Prop_Type::make()
57 ->default( [] ),
58
59 'tag' => String_Prop_Type::make()
60 ->enum( [ 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] )
61 ->default( 'h2' )
62 ->description( 'The HTML tag for the heading element. Could be h1, h2, up to h6' ),
63
64 'title' => $title_prop
65 ->description( 'The text content of the heading.' ),
66
67 'link' => Link_Prop_Type::make(),
68
69 'attributes' => Attributes_Prop_Type::make(),
70 ];
71
72 return $props;
73 }
74
75 protected function define_atomic_controls(): array {
76 $is_feature_active = Plugin::$instance->experiments->is_feature_active( Atomic_Widgets_Module::EXPERIMENT_INLINE_EDITING );
77
78 $control = $is_feature_active
79 ? Inline_Editing_Control::bind_to( 'title' )
80 ->set_placeholder( __( 'Type your title here', 'elementor' ) )
81 ->set_label( __( 'Title', 'elementor' ) )
82 : Textarea_Control::bind_to( 'title' )
83 ->set_placeholder( __( 'Type your title here', 'elementor' ) )
84 ->set_label( __( 'Title', 'elementor' ) );
85
86 $content_section = Section::make()
87 ->set_label( __( 'Content', 'elementor' ) )
88 ->set_items( [ $control ] );
89 return [
90 $content_section,
91 Section::make()
92 ->set_label( __( 'Settings', 'elementor' ) )
93 ->set_id( 'settings' )
94 ->set_items( $this->get_settings_controls() ),
95 ];
96 }
97
98 protected function get_settings_controls(): array {
99 return [
100 Select_Control::bind_to( 'tag' )
101 ->set_options([
102 [
103 'value' => 'h1',
104 'label' => 'H1',
105 ],
106 [
107 'value' => 'h2',
108 'label' => 'H2',
109 ],
110 [
111 'value' => 'h3',
112 'label' => 'H3',
113 ],
114 [
115 'value' => 'h4',
116 'label' => 'H4',
117 ],
118 [
119 'value' => 'h5',
120 'label' => 'H5',
121 ],
122 [
123 'value' => 'h6',
124 'label' => 'H6',
125 ],
126 ])
127 ->set_label( __( 'Tag', 'elementor' ) ),
128 Link_Control::bind_to( 'link' )
129 ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) )
130 ->set_label( __( 'Link', 'elementor' ) )
131 ->set_meta( [
132 'topDivider' => true,
133 ] ),
134 Text_Control::bind_to( '_cssid' )
135 ->set_label( __( 'ID', 'elementor' ) )
136 ->set_meta( $this->get_css_id_control_meta() ),
137 ];
138 }
139
140 protected function define_base_styles(): array {
141 $margin_value = Size_Prop_Type::generate( [
142 'unit' => 'px',
143 'size' => 0 ,
144 ] );
145
146 return [
147 'base' => Style_Definition::make()
148 ->add_variant(
149 Style_Variant::make()
150 ->add_prop( 'margin', $margin_value )
151 ),
152 self::LINK_BASE_STYLE_KEY => Style_Definition::make()
153 ->add_variant(
154 Style_Variant::make()
155 ->add_prop( 'all', 'unset' )
156 ->add_prop( 'cursor', 'pointer' )
157 ),
158 ];
159 }
160
161 protected function get_templates(): array {
162 return [
163 'elementor/elements/atomic-heading' => __DIR__ . '/atomic-heading.html.twig',
164 ];
165 }
166 }
167