File: /home/globfdxw/www/wp-content/plugins/bearsthemes-addons/widgets/video-box/widget.php
<?php
namespace BearsthemesAddons\Widgets\Video_Box;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Icons_Manager;
use Elementor\Plugin;
use Elementor\Embed;
use Elementor\Utils;
use Elementor\Modules\DynamicTags\Module as TagsModule;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Be_Video_Box extends Widget_Base {
public function get_name() {
return 'be-video-box';
}
public function get_title() {
return __( 'Be Video Box', 'bearsthemes-addons' );
}
public function get_icon() {
return 'eicon-youtube';
}
public function get_categories() {
return [ 'bearsthemes-addons' ];
}
public function get_script_depends() {
return [ 'jquery-magnific-popup', 'bearsthemes-addons' ];
}
protected function register_skins() {
$this->add_skin( new Skins\Skin_Pumori( $this ) );
$this->add_skin( new Skins\Skin_Baruntse( $this ) );
$this->add_skin( new Skins\Skin_Coropuna( $this ) );
$this->add_skin( new Skins\Skin_Cholatse( $this ) );
}
protected function register_layout_section_controls() {
$this->start_controls_section(
'section_layout',
[
'label' => __( 'Layout', 'bearsthemes-addons' ),
]
);
$this->add_control(
'image',
[
'label' => __( 'Choose Image', 'bearsthemes-addons' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'select_icon',
[
'label' => __( 'Icon', 'bearsthemes-addons' ),
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'icon',
'default' => [
'value' => 'fa fa-play',
'library' => 'fa-solid',
],
]
);
$this->add_control(
'icon_view',
[
'label' => __( 'View', 'bearsthemes-addons' ),
'type' => Controls_Manager::SELECT,
'default' => '',
'options' => [
'' => __( 'Default', 'bearsthemes-addons' ),
'stacked' => __( 'Stacked', 'bearsthemes-addons' ),
'framed' => __( 'Framed', 'bearsthemes-addons' ),
],
'prefix_class' => 'elementor-video-box--icon-view-',
]
);
$this->add_control(
'icon_shape',
[
'label' => __( 'Shape', 'bearsthemes-addons' ),
'type' => Controls_Manager::SELECT,
'default' => 'circle',
'options' => [
'circle' => __( 'Circle', 'bearsthemes-addons' ),
'square' => __( 'Square', 'bearsthemes-addons' ),
],
'condition' => [
'icon_view!' => '',
],
'prefix_class' => 'elementor-video-box--icon-shape-',
]
);
$this->end_controls_section();
}
protected function register_video_section_controls() {
$this->start_controls_section(
'section_video',
[
'label' => __( 'Video', 'elementor' ),
]
);
$this->add_control(
'video_type',
[
'label' => __( 'Source', 'elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'youtube',
'options' => [
'youtube' => __( 'YouTube', 'elementor' ),
'vimeo' => __( 'Vimeo', 'elementor' ),
'dailymotion' => __( 'Dailymotion', 'elementor' ),
'hosted' => __( 'Self Hosted', 'elementor' ),
],
]
);
$this->add_control(
'youtube_url',
[
'label' => __( 'Link', 'elementor' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
],
],
'placeholder' => __( 'Enter your URL', 'elementor' ) . ' (YouTube)',
'default' => 'https://www.youtube.com/watch?v=XHOmBV4js_E',
'label_block' => true,
'condition' => [
'video_type' => 'youtube',
],
]
);
$this->add_control(
'vimeo_url',
[
'label' => __( 'Link', 'elementor' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
],
],
'placeholder' => __( 'Enter your URL', 'elementor' ) . ' (Vimeo)',
'default' => 'https://vimeo.com/235215203',
'label_block' => true,
'condition' => [
'video_type' => 'vimeo',
],
]
);
$this->add_control(
'dailymotion_url',
[
'label' => __( 'Link', 'elementor' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
],
],
'placeholder' => __( 'Enter your URL', 'elementor' ) . ' (Dailymotion)',
'default' => 'https://www.dailymotion.com/video/x6tqhqb',
'label_block' => true,
'condition' => [
'video_type' => 'dailymotion',
],
]
);
$this->add_control(
'insert_url',
[
'label' => __( 'External URL', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'video_type' => 'hosted',
],
]
);
$this->add_control(
'hosted_url',
[
'label' => __( 'Choose File', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::MEDIA_CATEGORY,
],
],
'media_type' => 'video',
'condition' => [
'video_type' => 'hosted',
'insert_url' => '',
],
]
);
$this->add_control(
'external_url',
[
'label' => __( 'URL', 'elementor' ),
'type' => Controls_Manager::URL,
'autocomplete' => false,
'options' => false,
'label_block' => true,
'show_label' => false,
'dynamic' => [
'active' => true,
'categories' => [
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
],
],
'media_type' => 'video',
'placeholder' => __( 'Enter your URL', 'elementor' ),
'condition' => [
'video_type' => 'hosted',
'insert_url' => 'yes',
],
]
);
$this->add_control(
'start',
[
'label' => __( 'Start Time', 'elementor' ),
'type' => Controls_Manager::NUMBER,
'description' => __( 'Specify a start time (in seconds)', 'elementor' ),
'condition' => [
'loop' => '',
],
]
);
$this->add_control(
'end',
[
'label' => __( 'End Time', 'elementor' ),
'type' => Controls_Manager::NUMBER,
'description' => __( 'Specify an end time (in seconds)', 'elementor' ),
'condition' => [
'loop' => '',
'video_type' => [ 'youtube', 'hosted' ],
],
]
);
$this->add_control(
'video_options',
[
'label' => __( 'Video Options', 'elementor' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_control(
'autoplay',
[
'label' => __( 'Autoplay', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
]
);
$this->add_control(
'play_on_mobile',
[
'label' => __( 'Play On Mobile', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'autoplay' => 'yes',
],
]
);
$this->add_control(
'mute',
[
'label' => __( 'Mute', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
]
);
$this->add_control(
'loop',
[
'label' => __( 'Loop', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'video_type!' => 'dailymotion',
],
]
);
$this->add_control(
'controls',
[
'label' => __( 'Player Controls', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => __( 'Hide', 'elementor' ),
'label_on' => __( 'Show', 'elementor' ),
'default' => 'yes',
'condition' => [
'video_type!' => 'vimeo',
],
]
);
$this->add_control(
'showinfo',
[
'label' => __( 'Video Info', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => __( 'Hide', 'elementor' ),
'label_on' => __( 'Show', 'elementor' ),
'default' => 'yes',
'condition' => [
'video_type' => [ 'dailymotion' ],
],
]
);
$this->add_control(
'modestbranding',
[
'label' => __( 'Modest Branding', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'video_type' => [ 'youtube' ],
'controls' => 'yes',
],
]
);
$this->add_control(
'logo',
[
'label' => __( 'Logo', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => __( 'Hide', 'elementor' ),
'label_on' => __( 'Show', 'elementor' ),
'default' => 'yes',
'condition' => [
'video_type' => [ 'dailymotion' ],
],
]
);
// YouTube.
$this->add_control(
'yt_privacy',
[
'label' => __( 'Privacy Mode', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'description' => __( 'When you turn on privacy mode, YouTube won\'t store information about visitors on your website unless they play the video.', 'elementor' ),
'condition' => [
'video_type' => 'youtube',
],
]
);
$this->add_control(
'lazy_load',
[
'label' => __( 'Lazy Load', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'conditions' => [
'relation' => 'or',
'terms' => [
[
'name' => 'video_type',
'operator' => '===',
'value' => 'youtube',
],
[
'relation' => 'and',
'terms' => [
[
'name' => 'video_type',
'operator' => '!==',
'value' => 'hosted',
],
],
],
],
],
'frontend_available' => true,
]
);
$this->add_control(
'rel',
[
'label' => __( 'Suggested Videos', 'elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'' => __( 'Current Video Channel', 'elementor' ),
'yes' => __( 'Any Video', 'elementor' ),
],
'condition' => [
'video_type' => 'youtube',
],
]
);
// Vimeo.
$this->add_control(
'vimeo_title',
[
'label' => __( 'Intro Title', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => __( 'Hide', 'elementor' ),
'label_on' => __( 'Show', 'elementor' ),
'default' => 'yes',
'condition' => [
'video_type' => 'vimeo',
],
]
);
$this->add_control(
'vimeo_portrait',
[
'label' => __( 'Intro Portrait', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => __( 'Hide', 'elementor' ),
'label_on' => __( 'Show', 'elementor' ),
'default' => 'yes',
'condition' => [
'video_type' => 'vimeo',
],
]
);
$this->add_control(
'vimeo_byline',
[
'label' => __( 'Intro Byline', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => __( 'Hide', 'elementor' ),
'label_on' => __( 'Show', 'elementor' ),
'default' => 'yes',
'condition' => [
'video_type' => 'vimeo',
],
]
);
$this->add_control(
'color',
[
'label' => __( 'Controls Color', 'elementor' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'condition' => [
'video_type' => [ 'vimeo', 'dailymotion' ],
],
]
);
$this->add_control(
'download_button',
[
'label' => __( 'Download Button', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => __( 'Hide', 'elementor' ),
'label_on' => __( 'Show', 'elementor' ),
'condition' => [
'video_type' => 'hosted',
],
]
);
$this->add_control(
'preload',
[
'label' => esc_html__( 'Preload', 'elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'metadata' => esc_html__( 'Metadata', 'elementor' ),
'auto' => esc_html__( 'Auto', 'elementor' ),
'none' => esc_html__( 'None', 'elementor' ),
],
'description' => sprintf(
esc_html__( 'Preload attribute lets you specify how the video should be loaded when the page loads. %1$sLearn More%2$s', 'elementor' ),
'<a target="_blank" href="https://go.elementor.com/preload-video/">',
'</a>'
),
'default' => 'metadata',
'condition' => [
'video_type' => 'hosted',
'autoplay' => '',
],
]
);
$this->add_control(
'poster',
[
'label' => __( 'Poster', 'elementor' ),
'type' => Controls_Manager::MEDIA,
'condition' => [
'video_type' => 'hosted',
],
]
);
$this->add_control(
'view',
[
'label' => __( 'View', 'elementor' ),
'type' => Controls_Manager::HIDDEN,
'default' => 'youtube',
]
);
$this->end_controls_section();
}
protected function register_design_layout_section_controls() {
$this->start_controls_section(
'section_design_layout',
[
'label' => __( 'Layout', 'bearsthemes-addons' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'box_height',
[
'label' => __( 'Height', 'bearsthemes-addons' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => '',
],
'range' => [
'px' => [
'min' => 300,
'max' => 1000,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-video-box' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'overlay_color',
[
'label' => __( 'Overlay Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-video-box__overlay' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
}
protected function register_design_icon_section_controls() {
$this->start_controls_section(
'section_design_icon',
[
'label' => __( 'Icon', 'bearsthemes-addons' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'icon_size',
[
'label' => __( 'Icon Size', 'bearsthemes-addons' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => '',
],
'range' => [
'px' => [
'min' => 10,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-video-box__icon i' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .elementor-video-box__icon svg' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'icon_size_wrap',
[
'label' => __( 'Wrap Size', 'bearsthemes-addons' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => '',
],
'range' => [
'px' => [
'min' => 10,
'max' => 200,
],
],
'condition' => [
'icon_view!' => '',
],
'selectors' => [
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon,
{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'icon_border',
[
'label' => __( 'Border Size', 'bearsthemes-addons' ),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => '',
],
'range' => [
'px' => [
'min' => 1,
'max' => 20,
],
],
'condition' => [
'icon_view' => 'framed',
],
'selectors' => [
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon' => 'border-width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'icon_border_radius',
[
'label' => __( 'Border Radius', 'bearsthemes-addons' ),
'type' => Controls_Manager::DIMENSIONS,
'condition' => [
'icon_view!' => '',
],
'selectors' => [
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon,
{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}',
],
]
);
$this->start_controls_tabs( 'tabs_icon' );
$this->start_controls_tab(
'tab_icon_normal',
[
'label' => __( 'Normal', 'bearsthemes-addons' ),
]
);
$this->add_control(
'icon_color',
[
'label' => __( 'Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-video-box__icon i' => 'color: {{VALUE}};',
'{{WRAPPER}} .elementor-video-box__icon svg' => 'fill: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon i' => 'color: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon svg' => 'fill: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon i' => 'color: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'icon_background',
[
'label' => __( 'Background Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'condition' => [
'icon_view!' => '',
],
'selectors' => [
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'icon_border_color',
[
'label' => __( 'Border Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'condition' => [
'icon_view' => 'framed',
],
'selectors' => [
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_icon_hover',
[
'label' => __( 'Hover', 'bearsthemes-addons' ),
]
);
$this->add_control(
'icon_color_hover',
[
'label' => __( 'Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-video-box__icon:hover i' => 'color: {{VALUE}};',
'{{WRAPPER}} .elementor-video-box__icon:hover svg' => 'fill: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon:hover i' => 'color: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon:hover svg' => 'fill: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon:hover i' => 'color: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon:hover svg' => 'fill: {{VALUE}};',
],
]
);
$this->add_control(
'icon_background_hover',
[
'label' => __( 'Background Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'condition' => [
'icon_view!' => '',
],
'selectors' => [
'{{WRAPPER}}.elementor-video-box--icon-view-stacked .elementor-video-box__icon:hover' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'icon_border_color_hover',
[
'label' => __( 'Border Color', 'bearsthemes-addons' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'condition' => [
'icon_view' => 'framed',
],
'selectors' => [
'{{WRAPPER}}.elementor-video-box--icon-view-framed .elementor-video-box__icon:hover' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function register_design_video_section_controls() {
$this->start_controls_section(
'section_design_video',
[
'label' => __( 'Video', 'elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'aspect_ratio',
[
'label' => __( 'Aspect Ratio', 'elementor' ),
'type' => Controls_Manager::SELECT,
'options' => [
'169' => '16:9',
'219' => '21:9',
'43' => '4:3',
'32' => '3:2',
'11' => '1:1',
'916' => '9:16',
],
'default' => '169',
]
);
$this->end_controls_section();
}
protected function register_controls() {
$this->register_layout_section_controls();
$this->register_video_section_controls();
$this->register_design_layout_section_controls();
$this->register_design_icon_section_controls();
$this->register_design_video_section_controls();
}
public function get_embed_params() {
$settings = $this->get_settings_for_display();
$params = [];
if ( $settings['autoplay'] ) {
$params['autoplay'] = '1';
if ( $settings['play_on_mobile'] ) {
$params['playsinline'] = '1';
}
}
$params_dictionary = [];
if ( 'youtube' === $settings['video_type'] ) {
$params_dictionary = [
'loop',
'controls',
'mute',
'rel',
'modestbranding',
];
if ( $settings['loop'] ) {
$video_properties = Embed::get_video_properties( $settings['youtube_url'] );
$params['playlist'] = $video_properties['video_id'];
}
$params['start'] = $settings['start'];
$params['end'] = $settings['end'];
$params['wmode'] = 'opaque';
} elseif ( 'vimeo' === $settings['video_type'] ) {
$params_dictionary = [
'loop',
'mute' => 'muted',
'vimeo_title' => 'title',
'vimeo_portrait' => 'portrait',
'vimeo_byline' => 'byline',
];
$params['color'] = str_replace( '#', '', $settings['color'] );
$params['autopause'] = '0';
} elseif ( 'dailymotion' === $settings['video_type'] ) {
$params_dictionary = [
'controls',
'mute',
'showinfo' => 'ui-start-screen-info',
'logo' => 'ui-logo',
];
$params['ui-highlight'] = str_replace( '#', '', $settings['color'] );
$params['start'] = $settings['start'];
$params['endscreen-enable'] = '0';
}
foreach ( $params_dictionary as $key => $param_name ) {
$setting_name = $param_name;
if ( is_string( $key ) ) {
$setting_name = $key;
}
$setting_value = $settings[ $setting_name ] ? '1' : '0';
$params[ $param_name ] = $setting_value;
}
return $params;
}
public function get_embed_options() {
$settings = $this->get_settings_for_display();
$embed_options = [];
if ( 'youtube' === $settings['video_type'] ) {
$embed_options['privacy'] = $settings['yt_privacy'];
} elseif ( 'vimeo' === $settings['video_type'] ) {
$embed_options['start'] = $settings['start'];
}
$embed_options['lazy_load'] = ! empty( $settings['lazy_load'] );
return $embed_options;
}
public function get_hosted_video_url() {
$settings = $this->get_settings_for_display();
if ( ! empty( $settings['insert_url'] ) ) {
$video_url = $settings['external_url']['url'];
} else {
$video_url = $settings['hosted_url']['url'];
}
if ( empty( $video_url ) ) {
return '';
}
if ( $settings['start'] || $settings['end'] ) {
$video_url .= '#t=';
}
if ( $settings['start'] ) {
$video_url .= $settings['start'];
}
if ( $settings['end'] ) {
$video_url .= ',' . $settings['end'];
}
return $video_url;
}
public function get_hosted_params() {
$settings = $this->get_settings_for_display();
$video_params = [];
foreach ( [ 'autoplay', 'loop', 'controls' ] as $option_name ) {
if ( $settings[ $option_name ] ) {
$video_params[ $option_name ] = '';
}
}
if ( $settings['preload'] ) {
$video_params['preload'] = $settings['preload'];
}
if ( $settings['mute'] ) {
$video_params['muted'] = 'muted';
}
if ( $settings['play_on_mobile'] ) {
$video_params['playsinline'] = '';
}
if ( ! $settings['download_button'] ) {
$video_params['controlsList'] = 'nodownload';
}
if ( $settings['poster']['url'] ) {
$video_params['poster'] = $settings['poster']['url'];
}
return $video_params;
}
public function render_hosted_video() {
$video_url = $this->get_hosted_video_url();
if ( empty( $video_url ) ) {
return;
}
$video_params = $this->get_hosted_params();
?>
<video class="elementor-video" src="<?php echo esc_url( $video_url ); ?>" <?php echo Utils::render_html_attributes( $video_params ); ?>></video>
<?php
}
public function get_instance_value_skin( $key ) {
$settings = $this->get_settings_for_display();
if( !empty( $settings['_skin'] ) && isset( $settings[str_replace( '-', '_', $settings['_skin'] ) . '_' . $key] ) ) {
return $settings[str_replace( '-', '_', $settings['_skin'] ) . '_' . $key];
}
return $settings[$key];
}
public function render_icon() {
$settings = $this->get_settings_for_display();
if ( empty( $settings['icon'] ) && ! Icons_Manager::is_migration_allowed() ) {
// add old default
$settings['icon'] = 'fa fa-play';
}
if ( ! empty( $settings['icon'] ) ) {
$this->add_render_attribute( 'icon', 'class', $settings['icon'] );
$this->add_render_attribute( 'icon', 'aria-hidden', 'true' );
}
$migrated = isset( $settings['__fa4_migrated']['select_icon'] );
$is_new = empty( $settings['icon'] ) && Icons_Manager::is_migration_allowed();
if ( $is_new || $migrated ) {
Icons_Manager::render_icon( $settings['select_icon'], [ 'aria-hidden' => 'true' ] );
} else {
?>
<i <?php $this->print_render_attribute_string( 'icon' ); ?>></i>
<?php
}
}
public function render_element_header() {
$settings = $this->get_settings_for_display();
if( $settings['_skin'] ) {
$this->add_render_attribute( 'wrapper', 'class', 'elementor-video-box elementor-video-box--' . $settings['_skin'] );
} else {
$this->add_render_attribute( 'wrapper', 'class', 'elementor-video-box elementor-video-box--default' );
}
?>
<div <?php echo $this->get_render_attribute_string( 'wrapper' ); ?>>
<?php
}
public function render_element_footer() {
?>
</div>
<?php
}
protected function render() {
$settings = $this->get_settings_for_display();
$video_url = $settings[ $settings['video_type'] . '_url' ];
if ( 'hosted' === $settings['video_type'] ) {
$video_url = $this->get_hosted_video_url();
}
if ( empty( $video_url ) ) {
return;
}
if ( 'hosted' === $settings['video_type'] ) {
ob_start();
$this->render_hosted_video();
$video_html = ob_get_clean();
} else {
$embed_params = $this->get_embed_params();
$embed_options = $this->get_embed_options();
$is_static_render_mode = Plugin::$instance->frontend->is_static_render_mode();
$post_id = get_queried_object_id();
if ( $is_static_render_mode ) {
$video_html = Embed::get_embed_thumbnail_html( $video_url, $post_id );
} else {
$video_html = Embed::get_embed_html( $video_url, $embed_params, $embed_options );
}
}
if ( empty( $video_html ) ) {
echo esc_url( $video_url );
return;
}
$popup_id = 'elementor-video-popup-' . $this->get_id();
$this->render_element_header();
if( '' !== $settings['image']['url'] ) {
echo '<img class="thumb" src="' . esc_url( $settings['image']['url'] ) . '" alt=""/>';
}
?>
<div class="elementor-video-box__overlay"></div>
<div class="elementor-video-box__content">
<a href="<?php echo esc_attr( '#'.$popup_id ); ?>" class="elementor-open-popup-link">
<div class="elementor-video-box__icon">
<?php echo $this->render_icon(); ?>
</div>
</a>
</div>
<div id="<?php echo esc_attr( $popup_id ); ?>" class="elementor-popup__white-popup mfp-hide">
<div class="elementor-popup__video <?php echo 'elementor-popup__aspect-ratio-'.$settings['aspect_ratio'] ?>">
<?php echo $video_html; ?>
</div>
</div>
<?php
$this->render_element_footer();
}
protected function content_template() {
}
}