← All changes
|
modules/atomic-widgets/elements/atomic-youtube/atomic-youtube.php
+12
-58
4.3.0-beta3
→
3.31.4
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; | |
| 10 | +use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Array_Prop_Type; | |
| 13 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\Boolean_Prop_Type; |
| 14 | 12 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_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 | } |
| @@ -40,9 +35,9 @@ | ||
| 40 | 35 | return esc_html__( 'YouTube', 'elementor' ); |
| 41 | 36 | } |
| 42 | 37 | |
| 43 | 38 | public function get_keywords() { |
| 44 | - return [ 'ato', 'atom', 'atoms', 'atomic', 'youtube', 'video', 'embed', 'media' ]; | |
| 39 | + return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 45 | 40 | } |
| 46 | 41 | |
| 47 | 42 | public function get_icon() { |
| 48 | 43 | return 'eicon-e-youtube'; |
| @@ -47,12 +42,8 @@ | ||
| 47 | 42 | public function get_icon() { |
| 48 | 43 | return 'eicon-e-youtube'; |
| 49 | 44 | } |
| 50 | 45 | |
| 51 | - public static function get_computed_html_tag( array $settings ): string { | |
| 52 | - return Html_Tag_Computer::compute( $settings, 'div' ); | |
| 53 | - } | |
| 54 | - | |
| 55 | 46 | protected static function define_props_schema(): array { |
| 56 | 47 | return [ |
| 57 | 48 | 'classes' => Classes_Prop_Type::make() |
| 58 | 49 | ->default( [] ), |
| @@ -57,13 +48,12 @@ | ||
| 57 | 48 | 'classes' => Classes_Prop_Type::make() |
| 58 | 49 | ->default( [] ), |
| 59 | 50 | |
| 60 | 51 | 'source' => String_Prop_Type::make() |
| 61 | - ->default( 'https://www.youtube.com/watch?v=XHOmBV4js_E' ) | |
| 62 | - ->alias( 'url', 'video' ), | |
| 52 | + ->default( 'https://www.youtube.com/watch?v=XHOmBV4js_E' ), | |
| 63 | 53 | |
| 64 | - 'start' => String_Prop_Type::make()->meta( Dynamic_Prop_Type::ignore() ), | |
| 65 | - 'end' => String_Prop_Type::make()->meta( Dynamic_Prop_Type::ignore() ), | |
| 54 | + 'start' => String_Prop_Type::make(), | |
| 55 | + 'end' => String_Prop_Type::make(), | |
| 66 | 56 | 'autoplay' => Boolean_Prop_Type::make()->default( false ), |
| 67 | 57 | 'mute' => Boolean_Prop_Type::make()->default( false ), |
| 68 | 58 | 'loop' => Boolean_Prop_Type::make()->default( false ), |
| 69 | 59 | 'lazyload' => Boolean_Prop_Type::make()->default( false ), |
| @@ -71,9 +61,9 @@ | ||
| 71 | 61 | 'captions' => Boolean_Prop_Type::make()->default( false ), |
| 72 | 62 | 'privacy_mode' => Boolean_Prop_Type::make()->default( false ), |
| 73 | 63 | 'rel' => Boolean_Prop_Type::make()->default( true ), |
| 74 | 64 | |
| 75 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 65 | + 'attributes' => Key_Value_Array_Prop_Type::make(), | |
| 76 | 66 | ]; |
| 77 | 67 | } |
| 78 | 68 | |
| 79 | 69 | protected function define_atomic_controls(): array { |
| @@ -79,13 +69,12 @@ | ||
| 79 | 69 | protected function define_atomic_controls(): array { |
| 80 | 70 | return [ |
| 81 | 71 | Section::make() |
| 82 | 72 | ->set_label( __( 'Content', 'elementor' ) ) |
| 83 | - ->set_id( 'content' ) | |
| 84 | 73 | ->set_items( [ |
| 85 | 74 | Text_Control::bind_to( 'source' ) |
| 86 | - ->set_placeholder( esc_html__( 'Type or paste your URL', 'elementor' ) ) | |
| 87 | - ->set_label( esc_html__( 'YouTube URL', 'elementor' ) ), | |
| 75 | + ->set_label( esc_html__( 'YouTube URL', 'elementor' ) ) | |
| 76 | + ->set_placeholder( esc_html__( 'Type or paste your URL', 'elementor' ) ), | |
| 88 | 77 | |
| 89 | 78 | Text_Control::bind_to( 'start' )->set_label( esc_html__( 'Start time', 'elementor' ) ), |
| 90 | 79 | Text_Control::bind_to( 'end' )->set_label( esc_html__( 'End time', 'elementor' ) ), |
| 91 | 80 | Switch_Control::bind_to( 'autoplay' )->set_label( esc_html__( 'Autoplay', 'elementor' ) ), |
| @@ -96,21 +85,13 @@ | ||
| 96 | 85 | Switch_Control::bind_to( 'captions' )->set_label( esc_html__( 'Captions', 'elementor' ) ), |
| 97 | 86 | Switch_Control::bind_to( 'privacy_mode' )->set_label( esc_html__( 'Privacy mode', 'elementor' ) ), |
| 98 | 87 | Switch_Control::bind_to( 'rel' )->set_label( esc_html__( 'Related videos', 'elementor' ) ), |
| 99 | 88 | ] ), |
| 100 | - Section::make() | |
| 101 | - ->set_label( __( 'Settings', 'elementor' ) ) | |
| 102 | - ->set_id( 'settings' ) | |
| 103 | - ->set_items( $this->get_settings_controls() ), | |
| 104 | 89 | ]; |
| 105 | 90 | } |
| 106 | 91 | |
| 107 | 92 | 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 | - ]; | |
| 93 | + return []; | |
| 113 | 94 | } |
| 114 | 95 | |
| 115 | 96 | protected function define_base_styles(): array { |
| 116 | 97 | return [ |
| @@ -123,40 +104,13 @@ | ||
| 123 | 104 | ]; |
| 124 | 105 | } |
| 125 | 106 | |
| 126 | 107 | public function get_script_depends() { |
| 127 | - return array_merge( | |
| 128 | - parent::get_script_depends(), | |
| 129 | - [ 'elementor-youtube-handler' ], | |
| 130 | - ); | |
| 108 | + return [ 'elementor-youtube-handler' ]; | |
| 131 | 109 | } |
| 132 | 110 | |
| 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 | 111 | protected function get_templates(): array { |
| 147 | 112 | return [ |
| 148 | 113 | 'elementor/elements/atomic-youtube' => __DIR__ . '/atomic-youtube.html.twig', |
| 149 | 114 | ]; |
| 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 | 115 | } |
| 162 | 116 | } |