PluginProbe
Elementor Website Builder – more than just a page builder / 3.31.1
Elementor Website Builder – more than just a page builder v3.31.1
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-youtube / atomic-youtube.php

atomic-youtube.php in Elementor Website Builder – more than just a page builder 3.31.1, at modules/atomic-widgets/elements/atomic-youtube/atomic-youtube.php

117 lines 4.1 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_Youtube;
3
4 use Elementor\Modules\AtomicWidgets\Controls\Section;
5 use Elementor\Modules\AtomicWidgets\Controls\Types\Switch_Control;
6 use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control;
7 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base;
8 use Elementor\Modules\AtomicWidgets\Elements\Has_Template;
9 use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type;
10 use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Array_Prop_Type;
11 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\Boolean_Prop_Type;
12 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
13 use Elementor\Modules\AtomicWidgets\Styles\Style_Definition;
14 use Elementor\Modules\AtomicWidgets\Styles\Style_Variant;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit if accessed directly.
18 }
19
20 class Atomic_Youtube extends Atomic_Widget_Base {
21 use Has_Template;
22
23 protected function get_css_id_control_meta(): array {
24 return [
25 'layout' => 'two-columns',
26 'topDivider' => false,
27 ];
28 }
29
30 public static function get_element_type(): string {
31 return 'e-youtube';
32 }
33
34 public function get_title() {
35 return esc_html__( 'YouTube', 'elementor' );
36 }
37
38 public function get_keywords() {
39 return [ 'ato', 'atom', 'atoms', 'atomic' ];
40 }
41
42 public function get_icon() {
43 return 'eicon-e-youtube';
44 }
45
46 protected static function define_props_schema(): array {
47 return [
48 'classes' => Classes_Prop_Type::make()
49 ->default( [] ),
50
51 'source' => String_Prop_Type::make()
52 ->default( 'https://www.youtube.com/watch?v=XHOmBV4js_E' ),
53
54 'start' => String_Prop_Type::make(),
55 'end' => String_Prop_Type::make(),
56 'autoplay' => Boolean_Prop_Type::make()->default( false ),
57 'mute' => Boolean_Prop_Type::make()->default( false ),
58 'loop' => Boolean_Prop_Type::make()->default( false ),
59 'lazyload' => Boolean_Prop_Type::make()->default( false ),
60 'player_controls' => Boolean_Prop_Type::make()->default( true ),
61 'captions' => Boolean_Prop_Type::make()->default( false ),
62 'privacy_mode' => Boolean_Prop_Type::make()->default( false ),
63 'rel' => Boolean_Prop_Type::make()->default( true ),
64
65 'attributes' => Key_Value_Array_Prop_Type::make(),
66 ];
67 }
68
69 protected function define_atomic_controls(): array {
70 return [
71 Section::make()
72 ->set_label( __( 'Content', 'elementor' ) )
73 ->set_items( [
74 Text_Control::bind_to( 'source' )
75 ->set_label( esc_html__( 'YouTube URL', 'elementor' ) )
76 ->set_placeholder( esc_html__( 'Type or paste your URL', 'elementor' ) ),
77
78 Text_Control::bind_to( 'start' )->set_label( esc_html__( 'Start time', 'elementor' ) ),
79 Text_Control::bind_to( 'end' )->set_label( esc_html__( 'End time', 'elementor' ) ),
80 Switch_Control::bind_to( 'autoplay' )->set_label( esc_html__( 'Autoplay', 'elementor' ) ),
81 Switch_Control::bind_to( 'mute' )->set_label( esc_html__( 'Mute', 'elementor' ) ),
82 Switch_Control::bind_to( 'loop' )->set_label( esc_html__( 'Loop', 'elementor' ) ),
83 Switch_Control::bind_to( 'lazyload' )->set_label( esc_html__( 'Lazy load', 'elementor' ) ),
84 Switch_Control::bind_to( 'player_controls' )->set_label( esc_html__( 'Player controls', 'elementor' ) ),
85 Switch_Control::bind_to( 'captions' )->set_label( esc_html__( 'Captions', 'elementor' ) ),
86 Switch_Control::bind_to( 'privacy_mode' )->set_label( esc_html__( 'Privacy mode', 'elementor' ) ),
87 Switch_Control::bind_to( 'rel' )->set_label( esc_html__( 'Related videos', 'elementor' ) ),
88 ] ),
89 ];
90 }
91
92 protected function get_settings_controls(): array {
93 return [];
94 }
95
96 protected function define_base_styles(): array {
97 return [
98 'base' => Style_Definition::make()
99 ->add_variant(
100 Style_Variant::make()
101 ->add_prop( 'aspect-ratio', String_Prop_Type::generate( '16/9' ) )
102 ->add_prop( 'overflow', String_Prop_Type::generate( 'hidden' ) )
103 ),
104 ];
105 }
106
107 public function get_script_depends() {
108 return [ 'elementor-youtube-handler' ];
109 }
110
111 protected function get_templates(): array {
112 return [
113 'elementor/elements/atomic-youtube' => __DIR__ . '/atomic-youtube.html.twig',
114 ];
115 }
116 }
117