use Elementor\Modules\DynamicTags\Module as TagsModule;
use Elementor\Modules\Promotions\Controls\Promotion_Control;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
* Elementor video widget.
* Elementor widget that displays a video player.
class Widget_Video extends Widget_Base {
* Retrieve video widget name.
* @return string Widget name.
public function get_name() {
* Retrieve video widget title.
* @return string Widget title.
public function get_title() {
return esc_html__( 'Video', 'elementor' );
* Retrieve video widget icon.
* @return string Widget icon.
public function get_icon() {
* Retrieve the list of categories the video widget belongs to.
* Used to determine where to display the widget in the editor.
* @return array Widget categories.
public function get_categories() {
* Retrieve the list of keywords the widget belongs to.
* @return array Widget keywords.
public function get_keywords() {
return [ 'video', 'player', 'embed', 'youtube', 'vimeo', 'dailymotion', 'videopress' ];
protected function is_dynamic_content(): bool {
* Get style dependencies.
* Retrieve the list of style dependencies the widget requires.
* @return array Widget style dependencies.
public function get_style_depends(): array {
return [ 'widget-video' ];
public function has_widget_inner_wrapper(): bool {
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
* Register video widget controls.
* Adds different input fields to allow the user to change and customize the widget settings.
* @return array Widget promotion data.
protected function get_upsale_data() {
'condition' => ! Utils::has_pro(),
'image' => esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ),
'image_alt' => esc_attr__( 'Upgrade', 'elementor' ),
'title' => esc_html__( "Grab your visitors' attention", 'elementor' ),
'description' => esc_html__( 'Get the Video Playlist widget and grow your toolbox with Elementor Pro.', 'elementor' ),
'upgrade_url' => esc_url( 'https://go.elementor.com/go-pro-video-widget/' ),
'upgrade_text' => esc_html__( 'Upgrade Now', 'elementor' ),
* Register video widget controls.
* Adds different input fields to allow the user to change and customize the widget settings.
protected function register_controls() {
$this->start_controls_section(
'label' => esc_html__( 'Video', 'elementor' ),
'label' => esc_html__( 'Source', 'elementor' ),
'type' => Controls_Manager::SELECT,
'youtube' => esc_html__( 'YouTube', 'elementor' ),
'vimeo' => esc_html__( 'Vimeo', 'elementor' ),
'dailymotion' => esc_html__( 'Dailymotion', 'elementor' ),
'videopress' => esc_html__( 'VideoPress', 'elementor' ),
'hosted' => esc_html__( 'Self Hosted', 'elementor' ),
'frontend_available' => true,
'label' => esc_html__( 'Link', 'elementor' ),
'type' => Controls_Manager::TEXT,
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
'placeholder' => esc_html__( 'Enter your URL', 'elementor' ) . ' (YouTube)',
'default' => 'https://www.youtube.com/watch?v=XHOmBV4js_E',
'video_type' => 'youtube',
'frontend_available' => true,
'label' => esc_html__( 'Link', 'elementor' ),
'type' => Controls_Manager::TEXT,
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
'placeholder' => esc_html__( 'Enter your URL', 'elementor' ) . ' (Vimeo)',
'default' => 'https://vimeo.com/235215203',
'label' => esc_html__( 'Link', 'elementor' ),
'type' => Controls_Manager::TEXT,
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
'placeholder' => esc_html__( 'Enter your URL', 'elementor' ) . ' (Dailymotion)',
'default' => 'https://www.dailymotion.com/video/x6tqhqb',
'video_type' => 'dailymotion',
'label' => esc_html__( 'External URL', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'video_type' => [ 'hosted', 'videopress' ],
'label' => esc_html__( 'Choose Video File', 'elementor' ),
'type' => Controls_Manager::MEDIA,
TagsModule::MEDIA_CATEGORY,
'video_type' => [ 'hosted', 'videopress' ],
'label' => esc_html__( 'URL', 'elementor' ),
'type' => Controls_Manager::URL,
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
'placeholder' => esc_html__( 'Enter your URL', 'elementor' ),
'video_type' => 'hosted',
'label' => esc_html__( 'URL', 'elementor' ),
'type' => Controls_Manager::TEXT,
'default' => 'https://videopress.com/v/ZCAOzTNk',
TagsModule::POST_META_CATEGORY,
TagsModule::URL_CATEGORY,
'placeholder' => esc_html__( 'VideoPress URL', 'elementor' ),
'video_type' => 'videopress',
'label' => esc_html__( 'Start Time', 'elementor' ),
'type' => Controls_Manager::NUMBER,
'description' => esc_html__( 'Specify a start time (in seconds)', 'elementor' ),
'frontend_available' => true,
'label' => esc_html__( 'End Time', 'elementor' ),
'type' => Controls_Manager::NUMBER,
'description' => esc_html__( 'Specify an end time (in seconds)', 'elementor' ),
'video_type' => [ 'youtube', 'hosted' ],
'frontend_available' => true,
'label' => esc_html__( 'Video Options', 'elementor' ),
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Autoplay', 'elementor' ),
'description' => sprintf(
/* translators: 1: `<a>` opening tag, 2: `</a>` closing tag. */
esc_html__( 'Note: Autoplay is affected by %1$s Google’s Autoplay policy %2$s on Chrome browsers.', 'elementor' ),
'<a href="https://developers.google.com/web/updates/2017/09/autoplay-policy-changes" target="_blank">',
'type' => Controls_Manager::SWITCHER,
'frontend_available' => true,
'label' => esc_html__( 'Play On Mobile', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'frontend_available' => true,
'label' => esc_html__( 'Mute', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'frontend_available' => true,
'label' => esc_html__( 'Loop', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'video_type!' => 'dailymotion',
'frontend_available' => true,
'label' => esc_html__( 'Player Controls', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => esc_html__( 'Hide', 'elementor' ),
'label_on' => esc_html__( 'Show', 'elementor' ),
'video_type!' => 'vimeo',
'frontend_available' => true,
'label' => esc_html__( 'Video Info', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => esc_html__( 'Hide', 'elementor' ),
'label_on' => esc_html__( 'Show', 'elementor' ),
'video_type' => [ 'dailymotion' ],
'label' => esc_html__( 'Captions', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'video_type' => [ 'youtube' ],
'frontend_available' => true,
'label' => esc_html__( 'Logo', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_off' => esc_html__( 'Hide', 'elementor' ),
'label_on' => esc_html__( 'Show', 'elementor' ),
'video_type' => [ 'dailymotion' ],
'label' => esc_html__( 'Privacy Mode', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'description' => esc_html__( 'When you turn on privacy mode, YouTube/Vimeo won\'t store information about visitors on your website unless they play the video.', 'elementor' ),
'video_type' => [ 'youtube', 'vimeo' ],
'frontend_available' => true,
'label' => esc_html__( 'Lazy Load', 'elementor' ),
'type' => Controls_Manager::SWITCHER,
'name' => 'show_image_overlay',