Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-elements   php

Repository URL to install this package:

Version: 2.5.6 

/ addons / jet-elements-video.php

<?php
/**
 * Class: Jet_Elements_Video
 * Name: Video Player
 * Slug: jet-video
 */

namespace Elementor;

use Elementor\Controls_Manager;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Scheme_Typography;
use Elementor\Widget_Base;
use Elementor\Modules\DynamicTags\Module as TagsModule;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

class Jet_Elements_Video extends Jet_Elements_Base {

	public function get_name() {
		return 'jet-video';
	}

	public function get_title() {
		return esc_html__( 'Video Player', 'jet-elements' );
	}

	public function get_icon() {
		return 'jet-elements-icon-video';
	}

	public function get_jet_help_url() {
		return 'https://crocoblock.com/knowledge-base/articles/jetelements-video-player-widget-how-to-add-video-content-to-pages/';
	}

	public function get_categories() {
		return array( 'cherry' );
	}

	public function get_script_depends() {
		if ( isset( $_GET['elementor-preview'] ) && 'wp_enqueue_scripts' === current_filter() ) {
			return array( 'mediaelement' );
		}

		if ( 'mejs' === $this->get_settings( 'self_hosted_player' ) ) {
			return array( 'mediaelement' );
		}

		return array();
	}

	public function get_style_depends() {
		if ( isset( $_GET['elementor-preview'] ) && 'wp_enqueue_scripts' === current_filter() ) {
			return array( 'mediaelement' );
		}

		if ( 'mejs' === $this->get_settings( 'self_hosted_player' ) ) {
			return array( 'mediaelement' );
		}

		return array();
	}

	protected function _register_controls() {
		$css_scheme = apply_filters(
			'jet-elements/video/css-scheme',
			array(
				'wrapper'        => '.jet-video',
				'overlay'        => '.jet-video__overlay',
				'play_btn'       => '.jet-video__play-button',
				'play_btn_icon'  => '.jet-video__play-button-icon',
				'play_btn_image' => '.jet-video__play-button-image',

				'mejs_controls'            => '.jet-video .mejs-controls',
				'mejs_play_pause_btn_wrap' => '.jet-video .mejs-playpause-button',
				'mejs_play_pause_btn'      => '.jet-video .mejs-playpause-button > button',
				'mejs_time'                => '.jet-video .mejs-time',
				'mejs_current_time'        => '.jet-video .mejs-currenttime',
				'mejs_duration_time'       => '.jet-video .mejs-duration',
				'mejs_rail_progress'       => '.jet-video .mejs-time-rail',
				'mejs_total_progress'      => '.jet-video .mejs-time-total',
				'mejs_current_progress'    => '.jet-video .mejs-time-current',
				'mejs_volume_btn_wrap'     => '.jet-video .mejs-volume-button',
				'mejs_volume_btn'          => '.jet-video .mejs-volume-button > button',
				'mejs_volume_slider_hor'   => '.jet-video .mejs-horizontal-volume-slider',
				'mejs_total_volume_hor'    => '.jet-video .mejs-horizontal-volume-total',
				'mejs_current_volume_hor'  => '.jet-video .mejs-horizontal-volume-current',
				'mejs_fullscreen_btn_wrap' => '.jet-video .mejs-fullscreen-button',
				'mejs_fullscreen_btn'      => '.jet-video .mejs-fullscreen-button > button',
			)
		);

		/**
		 * `Video` Section
		 */
		$this->start_controls_section(
			'section_video',
			array(
				'label' => esc_html__( 'Video', 'jet-elements' ),
			)
		);

		$this->add_control(
			'video_type',
			array(
				'label'   => esc_html__( 'Video Type', 'jet-elements' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'youtube',
				'options' => array(
					'youtube'     => esc_html__( 'YouTube', 'jet-elements' ),
					'vimeo'       => esc_html__( 'Vimeo', 'jet-elements' ),
					'self_hosted' => esc_html__( 'Self Hosted', 'jet-elements' ),
				),
			)
		);

		$this->add_control(
			'youtube_url',
			array(
				'label'       => esc_html__( 'YouTube URL', 'jet-elements' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'Enter your URL', 'jet-elements' ),
				'default'     => 'https://www.youtube.com/watch?v=CJO0u_HrWE8',
				'condition' => array(
					'video_type' => 'youtube',
				),
				'dynamic' => array(
					'active' => true,
					'categories' => array(
						TagsModule::POST_META_CATEGORY,
						TagsModule::URL_CATEGORY,
					),
				),
			)
		);

		$this->add_control(
			'vimeo_url',
			array(
				'label'       => esc_html__( 'Vimeo URL', 'jet-elements' ),
				'label_block' => true,
				'type'        => Controls_Manager::TEXT,
				'placeholder' => esc_html__( 'Enter your URL', 'jet-elements' ),
				'default'     => 'https://vimeo.com/235215203',
				'condition' => array(
					'video_type' => 'vimeo',
				),
				'dynamic' => array(
					'active' => true,
					'categories' => array(
						TagsModule::POST_META_CATEGORY,
						TagsModule::URL_CATEGORY,
					),
				),
			)
		);

		$this->add_control(
			'self_hosted_player',
			array(
				'label'   => esc_html__( 'Player', 'jet-elements' ),
				'type'    => Controls_Manager::SELECT,
				'default' => 'html5',
				'options' => array(
					'html5' => esc_html__( 'Default HTML5', 'jet-elements' ),
					'mejs'  => esc_html__( 'MediaElement Player', 'jet-elements' ),
				),
				'condition' => array(
					'video_type' => 'self_hosted',
				),
			)
		);

		$this->add_control(
			'mejs_player_desc',
			array(
				'type' => Controls_Manager::RAW_HTML,
				'raw'  => esc_html__( 'MediaElement Player support MP4 and WebM video formats', 'jet-elements' ),
				'content_classes' => 'elementor-descriptor',
				'condition' => array(
					'video_type'         => 'self_hosted',
					'self_hosted_player' => 'mejs',
				),
			)
		);

		$this->add_control(
			'self_hosted_url',
			array(
				'label'      => esc_html__( 'Self Hosted URL', 'jet-elements' ),
				'type'       => Controls_Manager::MEDIA,
				'media_type' => 'video',
				'condition' => array(
					'video_type' => 'self_hosted',
				),
				'dynamic' => array(
					'active' => true,
					'categories' => array(
						TagsModule::POST_META_CATEGORY,
						TagsModule::MEDIA_CATEGORY,
					),
				),
			)
		);

		$this->add_control(
			'start_time',
			array(
				'label'     => esc_html__( 'Start Time (in seconds)', 'jet-elements' ),
				'type'      => Controls_Manager::NUMBER,
				'condition' => array(
					'loop' => '',
				),
			)
		);

		$this->add_control(
			'end_time',
			array(
				'label'     => esc_html__( 'End Time (in seconds)', 'jet-elements' ),
				'type'      => Controls_Manager::NUMBER,
				'condition' => array(
					'loop'       => '',
					'video_type' => array( 'youtube', 'self_hosted' ),
				),
			)
		);

		$this->add_control(
			'aspect_ratio',
			array(
				'label'   => esc_html__( 'Aspect Ratio', 'jet-elements' ),
				'type'    => Controls_Manager::SELECT,
				'default' => '16-9',
				'options' => array(
					'16-9' => '16:9',
					'21-9' => '21:9',
					'9-16' => '9:16',
					'4-3'  => '4:3',
					'3-2'  => '3:2',
					'1-1'  => '1:1',
				),
				'condition' => array(
					'video_type' => array( 'youtube', 'vimeo' ),
				),
			)
		);
		
		$this->add_control(
			'video_options_heading',
			array(
				'label'     => esc_html__( 'Video Options', 'jet-elements' ),
				'type'      => Controls_Manager::HEADING,
				'separator' => 'before',
			)
		);

		$this->add_control(
			'autoplay',
			array(
				'label'   => esc_html__( 'Autoplay', 'jet-elements' ),
				'type'    => Controls_Manager::SWITCHER,
				'default' => '',
			)
		);

		$this->add_control(
			'mute',
			array(
				'label'   => esc_html__( 'Mute', 'jet-elements' ),
				'type'    => Controls_Manager::SWITCHER,
				'default' => '',
			)
		);

		$this->add_control(
			'loop',
			array(
				'label'   => esc_html__( 'Loop', 'jet-elements' ),
				'type'    => Controls_Manager::SWITCHER,
				'default' => '',
			)
		);

		$this->add_control(
			'controls',
			array(
				'label'     => esc_html__( 'Player Controls', 'jet-elements' ),
				'type'      => Controls_Manager::SWITCHER,
				'label_on'  => esc_html__( 'Show', 'jet-elements' ),
				'label_off' => esc_html__( 'Hide', 'jet-elements' ),
				'default'   => 'yes',
				'condition' => array(
					'video_type!' => 'vimeo',
				),
			)
		);

		$this->add_control(
			'yt_modestbranding',
			array(
				'label'     => esc_html__( 'Modest Branding', 'jet-elements' ),
				'type'      => Controls_Manager::SWITCHER,
				'default'   => '',
				'condition' => array(
					'video_type' => 'youtube',
					'controls'   => 'yes',
				),
			)
		);

		$this->add_control(
			'yt_suggested_videos',
			array(
				'label'   => esc_html__( 'Suggested Videos', 'jet-elements' ),
				'type'    => Controls_Manager::SELECT,
				'default' => '',
				'options' => array(
					''    => esc_html__( 'Current Video Channel', 'jet-elements' ),
					'yes' => esc_html__( 'Any Video', 'jet-elements' ),
				),
				'condition' => array(
					'video_type' => 'youtube',
				),
			)
		);

		$this->add_control(
			'yt_privacy_mode',
			array(
				'label'       => esc_html__( 'Privacy Mode', 'jet-elements' ),
				'type'        => Controls_Manager::SWITCHER,
				'description' => esc_html__( 'When you turn on privacy mode, YouTube won\'t store information about visitors on your website unless they play the video.', 'jet-elements' ),
				'default'     => '',
				'condition'   => array(
					'video_type' => 'youtube',
				),
			)
		);
Loading ...