PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.4
Elementor Website Builder – more than just a page builder v4.0.4
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-tabs / atomic-tab-content / atomic-tab-content.php

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

131 lines 3.6 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\Atomic_Tab_Content;
3
4 use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base;
5 use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Element_Template;
6 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
7 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
8 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
9 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
10 use Elementor\Modules\AtomicWidgets\Styles\Style_States;
11 use Elementor\Modules\AtomicWidgets\Controls\Section;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\Elements\Base\Render_Context;
15 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Tabs\Atomic_Tabs\Atomic_Tabs;
16 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
17
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 exit; // Exit if accessed directly.
21 }
22
23 class Atomic_Tab_Content extends Atomic_Element_Base {
24 use Has_Element_Template;
25
26 const BASE_STYLE_KEY = 'base';
27
28 public function __construct( $data = [], $args = null ) {
29 parent::__construct( $data, $args );
30 $this->meta( 'llm_support', false );
31 }
32
33 public static function get_type() {
34 return 'e-tab-content';
35 }
36
37 public static function get_element_type(): string {
38 return 'e-tab-content';
39 }
40
41 public function get_title() {
42 return esc_html__( 'Tab content', 'elementor' );
43 }
44
45 public function get_keywords() {
46 return [ 'ato', 'atom', 'atoms', 'atomic', 'tab', 'content', 'tabs' ];
47 }
48
49 public function get_icon() {
50 return 'eicon-layout';
51 }
52
53 public function should_show_in_panel() {
54 return false;
55 }
56
57 protected static function define_props_schema(): array {
58 return [
59 'classes' => Classes_Prop_Type::make()
60 ->default( [] ),
61 'tab-id' => String_Prop_Type::make(),
62 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
63 ];
64 }
65
66 protected function define_atomic_controls(): array {
67 return [
68 Section::make()
69 ->set_label( __( 'Settings', 'elementor' ) )
70 ->set_id( 'settings' )
71 ->set_items( [] ),
72 ];
73 }
74
75 protected function define_atomic_style_states(): array {
76 $selected_state = Style_States::get_class_states_map()['selected'];
77
78 return [ $selected_state ];
79 }
80
81 protected function define_base_styles(): array {
82 $styles = [
83 'display' => String_Prop_Type::generate( 'block' ),
84 'padding' => Size_Prop_Type::generate( [
85 'size' => 10,
86 'unit' => 'px',
87 ] ),
88 'min-width' => Size_Prop_Type::generate( [
89 'size' => 30,
90 'unit' => 'px',
91 ] ),
92 ];
93
94 return [
95 static::BASE_STYLE_KEY => Style_Definition::make()
96 ->add_variant(
97 Style_Variant::make()
98 ->add_props( $styles )
99 ),
100 ];
101 }
102
103 protected function define_initial_attributes() {
104 return [
105 'role' => 'tabpanel',
106 ];
107 }
108
109 protected function get_templates(): array {
110 return [
111 'elementor/elements/atomic-tab-content' => __DIR__ . '/atomic-tab-content.html.twig',
112 ];
113 }
114
115 protected function build_template_context(): array {
116 $tabs_context = Render_Context::get( Atomic_Tabs::class );
117 $default_active_tab = $tabs_context['default-active-tab'];
118 $get_tab_content_index = $tabs_context['get-tab-content-index'];
119 $tabs_id = $tabs_context['tabs-id'];
120
121 $index = $get_tab_content_index( $this->get_id() );
122 $is_active = $default_active_tab === $index;
123
124 return array_merge( $this->build_base_template_context(), [
125 'is_active' => $is_active,
126 'tab_id' => Atomic_Tabs::get_tab_id( $tabs_id, $index ),
127 'tab_content_id' => Atomic_Tabs::get_tab_content_id( $tabs_id, $index ),
128 ] );
129 }
130 }
131