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

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