PluginProbe
Elementor Website Builder – more than just a page builder / 3.33.0-beta1
Elementor Website Builder – more than just a page builder v3.33.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 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 All 457 releases
elementor / modules / atomic-widgets / elements / atomic-tabs / atomic-tab.php

atomic-tab.php in Elementor Website Builder – more than just a page builder 3.33.0-beta1, at modules/atomic-widgets/elements/atomic-tabs/atomic-tab.php

128 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_Tabs;
3
4 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base;
5 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
6 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
7 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
8 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
9 use Elementor\Modules\AtomicWidgets\Controls\Section;
10 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
11 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
12 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Heading\Atomic_Heading;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 class Atomic_Tab extends Atomic_Element_Base {
20 const BASE_STYLE_KEY = 'base';
21
22 public static function get_type() {
23 return 'e-tab';
24 }
25
26 public static function get_element_type(): string {
27 return 'e-tab';
28 }
29
30 public function get_title() {
31 return esc_html__( 'Atomic Tab', 'elementor' );
32 }
33
34 public function get_keywords() {
35 return [ 'ato', 'atom', 'atoms', 'atomic' ];
36 }
37
38 public function get_icon() {
39 return 'eicon-tabs';
40 }
41
42 public function should_show_in_panel() {
43 return false;
44 }
45
46 protected static function define_props_schema(): array {
47 return [
48 'classes' => Classes_Prop_Type::make()
49 ->default( [] ),
50 'tab-panel-id' => String_Prop_Type::make(),
51 'attributes' => Attributes_Prop_Type::make(),
52 ];
53 }
54
55 protected function define_atomic_controls(): array {
56 return [
57 Section::make()
58 ->set_label( __( 'Settings', 'elementor' ) )
59 ->set_id( 'settings' )
60 ->set_items( [] ),
61 ];
62 }
63
64 protected function define_base_styles(): array {
65 $display = String_Prop_Type::generate( 'block' );
66 $padding = Size_Prop_Type::generate( [
67 'size' => 4,
68 'unit' => 'px',
69 ] );
70
71 return [
72 static::BASE_STYLE_KEY => Style_Definition::make()
73 ->add_variant(
74 Style_Variant::make()
75 ->add_prop( 'display', $display )
76 ->add_prop( 'padding', $padding )
77 ),
78 ];
79 }
80
81 protected function define_initial_attributes() {
82 return [
83 'role' => 'tab',
84 'tabindex' => '-1',
85 ];
86 }
87
88 protected function define_default_html_tag() {
89 return 'button';
90 }
91
92 protected function define_default_children() {
93 return [
94 Atomic_Heading::generate()
95 ->settings( [
96 'title' => String_Prop_Type::generate( 'Tab' ),
97 ] )
98 ->build(),
99 ];
100 }
101
102 protected function add_render_attributes() {
103 parent::add_render_attributes();
104 $settings = $this->get_atomic_settings();
105 $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ];
106 $initial_attributes = $this->define_initial_attributes();
107
108 $attributes = [
109 'class' => [
110 'e-con',
111 'e-atomic-element',
112 $base_style_class,
113 ...( $settings['classes'] ?? [] ),
114 ],
115 ];
116
117 if ( ! empty( $settings['tab-panel-id'] ) ) {
118 $attributes['aria-controls'] = esc_attr( $settings['tab-panel-id'] );
119 }
120
121 if ( ! empty( $settings['_cssid'] ) ) {
122 $attributes['id'] = esc_attr( $settings['_cssid'] );
123 }
124
125 $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) );
126 }
127 }
128