PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0
Elementor Website Builder – more than just a page builder v4.3.0
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 4.1.0-beta2 4.1.0-dev2 All 455 releases
elementor / modules / atomic-widgets / elements / atomic-background-video / atomic-background-video-pause / atomic-background-video-pause.php

atomic-background-video-pause.php in Elementor Website Builder – more than just a page builder 4.3.0, at modules/atomic-widgets/elements/atomic-background-video/atomic-background-video-pause/atomic-background-video-pause.php

163 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\AtomicWidgets\Elements\Atomic_Background_Video\Atomic_Background_Video_Pause;
4
5 use Elementor\Modules\AtomicWidgets\Controls\Section;
6 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Paragraph\Atomic_Paragraph;
7 use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base;
8 use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Element_Template;
9 use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer;
10 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
11 use Elementor\Modules\AtomicWidgets\PropTypes\Background_Prop_Type;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type;
14 use Elementor\Modules\AtomicWidgets\PropTypes\Escaped_Html_Prop_Type;
15 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
16 use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type;
17 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
18 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
19 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
20
21 if ( ! defined( 'ABSPATH' ) ) {
22 exit;
23 }
24
25 class Atomic_Background_Video_Pause extends Atomic_Element_Base {
26 use Has_Element_Template;
27
28 const BASE_STYLE_KEY = 'base';
29
30 public static $widget_description = 'Pause button for the Background Video element. REQUIRED child: e-paragraph with the button label text (e.g. "Pause"). Drop any element inside to replace the default label.';
31
32 public function __construct( $data = [], $args = null ) {
33 parent::__construct( $data, $args );
34 $this->meta( 'permanently_locked', true );
35 }
36
37 public static function get_type() {
38 return 'e-background-video-pause';
39 }
40
41 public static function get_element_type(): string {
42 return 'e-background-video-pause';
43 }
44
45 public function get_title() {
46 return esc_html__( 'Pause Button', 'elementor' );
47 }
48
49 public function get_keywords() {
50 return [ 'ato', 'atom', 'atoms', 'atomic', 'background', 'video', 'pause' ];
51 }
52
53 public function get_icon() {
54 // No Structure/Navigator icon: this locked control is identified by its title alone.
55 return '';
56 }
57
58 public function should_show_in_panel() {
59 return false;
60 }
61
62 public static function get_computed_html_tag( array $settings ): string {
63 return Html_Tag_Computer::compute( $settings, 'button' );
64 }
65
66 protected static function define_props_schema(): array {
67 return [
68 'classes' => Classes_Prop_Type::make()->default( [] ),
69 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ),
70 ];
71 }
72
73 public static function get_props_schema(): array {
74 $schema = parent::get_props_schema();
75
76 // Locked sub-element: Display Conditions belong on the Background Video root only.
77 unset( $schema['display-conditions'] );
78
79 return $schema;
80 }
81
82 protected function define_atomic_controls(): array {
83 return [
84 Section::make()
85 ->set_label( __( 'Settings', 'elementor' ) )
86 ->set_id( 'settings' )
87 ->set_items( [] ),
88 ];
89 }
90
91 protected function define_initial_attributes() {
92 return [
93 'type' => 'button',
94 'aria-label' => esc_attr__( 'Pause video', 'elementor' ),
95 ];
96 }
97
98 protected function define_base_styles(): array {
99 return [
100 static::BASE_STYLE_KEY => Style_Definition::make()
101 ->add_variant(
102 Style_Variant::make()
103 ->add_props( [
104 'display' => String_Prop_Type::generate( 'inline-flex' ),
105 'align-items' => String_Prop_Type::generate( 'center' ),
106 'justify-content' => String_Prop_Type::generate( 'center' ),
107 'cursor' => String_Prop_Type::generate( 'pointer' ),
108 'border-style' => String_Prop_Type::generate( 'none' ),
109 'background' => Background_Prop_Type::generate( [
110 'color' => Color_Prop_Type::generate( 'transparent' ),
111 ] ),
112 'padding' => Size_Prop_Type::generate( [
113 'size' => 8,
114 'unit' => 'px',
115 ] ),
116 ] )
117 ),
118 ];
119 }
120
121 public static function build_default_element( bool $mark_required = false ): array {
122 $builder = static::generate()
123 ->children( [ static::build_label_paragraph() ] )
124 ->editor_settings( [
125 'title' => esc_html__( 'Pause Button', 'elementor' ),
126 ] );
127
128 if ( $mark_required ) {
129 $builder->meta( [ 'required' => true ] );
130 }
131
132 return $builder->build();
133 }
134
135 private static function build_label_paragraph(): array {
136 return Atomic_Paragraph::generate()
137 ->meta( [ 'required' => true ] )
138 ->settings( [
139 'paragraph' => Escaped_Html_Prop_Type::generate( esc_html__( 'Pause', 'elementor' ) ),
140 'tag' => String_Prop_Type::generate( 'span' ),
141 ] )
142 ->build();
143 }
144
145 protected function define_default_children() {
146 return [
147 static::build_label_paragraph(),
148 ];
149 }
150
151 protected function get_templates(): array {
152 return [
153 'elementor/elements/atomic-background-video-pause' => __DIR__ . '/atomic-background-video-pause.html.twig',
154 ];
155 }
156
157 protected function build_template_context(): array {
158 return array_merge( $this->build_base_template_context(), [
159 'initial_attributes' => $this->define_initial_attributes(),
160 ] );
161 }
162 }
163