← All changes
|
modules/atomic-widgets/elements/atomic-youtube/atomic-youtube.php
+10
-69
4.3.1
→
3.30.1
View file →
| @@ -3,21 +3,16 @@ | ||
| 3 | 3 | |
| 4 | 4 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 5 | 5 | use Elementor\Modules\AtomicWidgets\Controls\Types\Switch_Control; |
| 6 | 6 | use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 7 | -use Elementor\Modules\AtomicWidgets\DynamicTags\Dynamic_Prop_Type; | |
| 8 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Widget_Base; | |
| 9 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Template; | |
| 10 | -use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 7 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; | |
| 8 | +use Elementor\Modules\AtomicWidgets\Elements\Has_Template; | |
| 11 | 9 | use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; |
| 12 | -use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; | |
| 13 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\Boolean_Prop_Type; |
| 14 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 12 | +use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; | |
| 15 | 13 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 16 | 14 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 17 | -use Elementor\Modules\AtomicWidgets\Elements\Loader\Frontend_Assets_Loader; | |
| 18 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 19 | -use Elementor\Utils; | |
| 20 | 15 | |
| 21 | 16 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | 17 | exit; // Exit if accessed directly. |
| 23 | 18 | } |
| @@ -24,15 +19,8 @@ | ||
| 24 | 19 | |
| 25 | 20 | class Atomic_Youtube extends Atomic_Widget_Base { |
| 26 | 21 | use Has_Template; |
| 27 | 22 | |
| 28 | - protected function get_css_id_control_meta(): array { | |
| 29 | - return [ | |
| 30 | - 'layout' => 'two-columns', | |
| 31 | - 'topDivider' => false, | |
| 32 | - ]; | |
| 33 | - } | |
| 34 | - | |
| 35 | 23 | public static function get_element_type(): string { |
| 36 | 24 | return 'e-youtube'; |
| 37 | 25 | } |
| 38 | 26 | |
| @@ -40,9 +28,9 @@ | ||
| 40 | 28 | return esc_html__( 'YouTube', 'elementor' ); |
| 41 | 29 | } |
| 42 | 30 | |
| 43 | 31 | public function get_keywords() { |
| 44 | - return [ 'ato', 'atom', 'atoms', 'atomic', 'youtube', 'video', 'embed', 'media' ]; | |
| 32 | + return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 45 | 33 | } |
| 46 | 34 | |
| 47 | 35 | public function get_icon() { |
| 48 | 36 | return 'eicon-e-youtube'; |
| @@ -47,12 +35,8 @@ | ||
| 47 | 35 | public function get_icon() { |
| 48 | 36 | return 'eicon-e-youtube'; |
| 49 | 37 | } |
| 50 | 38 | |
| 51 | - public static function get_computed_html_tag( array $settings ): string { | |
| 52 | - return Html_Tag_Computer::compute( $settings, 'div' ); | |
| 53 | - } | |
| 54 | - | |
| 55 | 39 | protected static function define_props_schema(): array { |
| 56 | 40 | return [ |
| 57 | 41 | 'classes' => Classes_Prop_Type::make() |
| 58 | 42 | ->default( [] ), |
| @@ -57,13 +41,12 @@ | ||
| 57 | 41 | 'classes' => Classes_Prop_Type::make() |
| 58 | 42 | ->default( [] ), |
| 59 | 43 | |
| 60 | 44 | 'source' => String_Prop_Type::make() |
| 61 | - ->default( 'https://www.youtube.com/watch?v=XHOmBV4js_E' ) | |
| 62 | - ->alias( 'url', 'video' ), | |
| 45 | + ->default( 'https://www.youtube.com/watch?v=XHOmBV4js_E' ), | |
| 63 | 46 | |
| 64 | - 'start' => String_Prop_Type::make()->meta( Dynamic_Prop_Type::ignore() ), | |
| 65 | - 'end' => String_Prop_Type::make()->meta( Dynamic_Prop_Type::ignore() ), | |
| 47 | + 'start' => String_Prop_Type::make(), | |
| 48 | + 'end' => String_Prop_Type::make(), | |
| 66 | 49 | 'autoplay' => Boolean_Prop_Type::make()->default( false ), |
| 67 | 50 | 'mute' => Boolean_Prop_Type::make()->default( false ), |
| 68 | 51 | 'loop' => Boolean_Prop_Type::make()->default( false ), |
| 69 | 52 | 'lazyload' => Boolean_Prop_Type::make()->default( false ), |
| @@ -70,10 +53,8 @@ | ||
| 70 | 53 | 'player_controls' => Boolean_Prop_Type::make()->default( true ), |
| 71 | 54 | 'captions' => Boolean_Prop_Type::make()->default( false ), |
| 72 | 55 | 'privacy_mode' => Boolean_Prop_Type::make()->default( false ), |
| 73 | 56 | 'rel' => Boolean_Prop_Type::make()->default( true ), |
| 74 | - | |
| 75 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 76 | 57 | ]; |
| 77 | 58 | } |
| 78 | 59 | |
| 79 | 60 | protected function define_atomic_controls(): array { |
| @@ -79,13 +60,12 @@ | ||
| 79 | 60 | protected function define_atomic_controls(): array { |
| 80 | 61 | return [ |
| 81 | 62 | Section::make() |
| 82 | 63 | ->set_label( __( 'Content', 'elementor' ) ) |
| 83 | - ->set_id( 'content' ) | |
| 84 | 64 | ->set_items( [ |
| 85 | 65 | Text_Control::bind_to( 'source' ) |
| 86 | - ->set_placeholder( esc_html__( 'Type or paste your URL', 'elementor' ) ) | |
| 87 | - ->set_label( esc_html__( 'YouTube URL', 'elementor' ) ), | |
| 66 | + ->set_label( esc_html__( 'YouTube URL', 'elementor' ) ) | |
| 67 | + ->set_placeholder( esc_html__( 'Type or paste your URL', 'elementor' ) ), | |
| 88 | 68 | |
| 89 | 69 | Text_Control::bind_to( 'start' )->set_label( esc_html__( 'Start time', 'elementor' ) ), |
| 90 | 70 | Text_Control::bind_to( 'end' )->set_label( esc_html__( 'End time', 'elementor' ) ), |
| 91 | 71 | Switch_Control::bind_to( 'autoplay' )->set_label( esc_html__( 'Autoplay', 'elementor' ) ), |
| @@ -96,23 +76,11 @@ | ||
| 96 | 76 | Switch_Control::bind_to( 'captions' )->set_label( esc_html__( 'Captions', 'elementor' ) ), |
| 97 | 77 | Switch_Control::bind_to( 'privacy_mode' )->set_label( esc_html__( 'Privacy mode', 'elementor' ) ), |
| 98 | 78 | Switch_Control::bind_to( 'rel' )->set_label( esc_html__( 'Related videos', 'elementor' ) ), |
| 99 | 79 | ] ), |
| 100 | - Section::make() | |
| 101 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 102 | - ->set_id( 'settings' ) | |
| 103 | - ->set_items( $this->get_settings_controls() ), | |
| 104 | 80 | ]; |
| 105 | 81 | } |
| 106 | 82 | |
| 107 | - protected function get_settings_controls(): array { | |
| 108 | - return [ | |
| 109 | - Text_Control::bind_to( '_cssid' ) | |
| 110 | - ->set_label( __( 'ID', 'elementor' ) ) | |
| 111 | - ->set_meta( $this->get_css_id_control_meta() ), | |
| 112 | - ]; | |
| 113 | - } | |
| 114 | - | |
| 115 | 83 | protected function define_base_styles(): array { |
| 116 | 84 | return [ |
| 117 | 85 | 'base' => Style_Definition::make() |
| 118 | 86 | ->add_variant( |
| @@ -123,40 +91,13 @@ | ||
| 123 | 91 | ]; |
| 124 | 92 | } |
| 125 | 93 | |
| 126 | 94 | public function get_script_depends() { |
| 127 | - return array_merge( | |
| 128 | - parent::get_script_depends(), | |
| 129 | - [ 'elementor-youtube-handler' ], | |
| 130 | - ); | |
| 95 | + return [ 'elementor-youtube-handler' ]; | |
| 131 | 96 | } |
| 132 | 97 | |
| 133 | - public function register_frontend_handlers() { | |
| 134 | - $assets_url = ELEMENTOR_ASSETS_URL; | |
| 135 | - $min_suffix = ( Utils::is_script_debug() || Utils::is_elementor_tests() ) ? '' : '.min'; | |
| 136 | - | |
| 137 | - wp_register_script( | |
| 138 | - 'elementor-youtube-handler', | |
| 139 | - "{$assets_url}js/youtube-handler{$min_suffix}.js", | |
| 140 | - [ Frontend_Assets_Loader::FRONTEND_HANDLERS_HANDLE ], | |
| 141 | - ELEMENTOR_VERSION, | |
| 142 | - true | |
| 143 | - ); | |
| 144 | - } | |
| 145 | - | |
| 146 | 98 | protected function get_templates(): array { |
| 147 | 99 | return [ |
| 148 | 100 | 'elementor/elements/atomic-youtube' => __DIR__ . '/atomic-youtube.html.twig', |
| 149 | 101 | ]; |
| 150 | - } | |
| 151 | - | |
| 152 | - public function render_markdown(): string { | |
| 153 | - $settings = $this->get_atomic_settings(); | |
| 154 | - $url = $settings['source'] ?? ''; | |
| 155 | - | |
| 156 | - if ( empty( $url ) ) { | |
| 157 | - return ''; | |
| 158 | - } | |
| 159 | - | |
| 160 | - return '[Video](' . esc_url( $url ) . ')'; | |
| 161 | 102 | } |
| 162 | 103 | } |