File: /home/f/r/e/frenchy/refonte2023/wordpress/wp-content/themes/gimont/elementor/widgets/video.php
<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Utils;
use Elementor\Group_Control_Border;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Gimont_Elementor_Video extends Widget_Base {
public function get_name() {
return 'gimont_elementor_video';
}
public function get_title() {
return esc_html__( 'Ova Video', 'gimont' );
}
public function get_icon() {
return 'eicon-video-playlist';
}
public function get_categories() {
return [ 'gimont' ];
}
public function get_script_depends() {
return [ 'gimont-elementor-video' ];
}
// Add Your Controll In This Function
protected function register_controls() {
$this->start_controls_section(
'section_video',
[
'label' => esc_html__( 'Video', 'gimont' ),
]
);
$this->add_control(
'icon',
[
'label' => esc_html__( 'Icon', 'gimont' ),
'type' => \Elementor\Controls_Manager::ICONS,
'default' => [
'value' => 'fas fa-play',
'library' => 'all',
],
]
);
$this->add_control(
'icon_url_video',
[
'label' => esc_html__( 'URL Video', 'gimont' ),
'type' => Controls_Manager::TEXT,
'placeholder' => esc_html__( 'Enter your URL', 'gimont' ) . ' (YouTube)',
'default' => 'https://www.youtube.com/watch?v=XHOmBV4js_E',
]
);
$this->add_control(
'icon_text',
[
'label' => esc_html__( 'Text', 'gimont' ),
'type' => Controls_Manager::TEXT,
'default' => esc_html__( 'Watch the Trailer', 'gimont' ),
]
);
$this->add_control(
'link',
[
'label' => esc_html__( 'Link', 'gimont' ),
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'condition' => [
'icon_url_video' => '',
],
]
);
$this->add_control(
'icon_animation',
[
'label' => esc_html__( 'Animation', 'gimont' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'On', 'gimont' ),
'label_off' => esc_html__( 'Off', 'gimont' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'video_options',
[
'label' => esc_html__( 'Video Options', 'gimont' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'icon_url_video!' => '',
],
]
);
$this->add_control(
'autoplay_video',
[
'label' => esc_html__( 'Autoplay', 'gimont' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'gimont' ),
'label_off' => esc_html__( 'No', 'gimont' ),
'default' => 'yes',
'condition' => [
'icon_url_video!' => '',
],
]
);
$this->add_control(
'mute_video',
[
'label' => esc_html__( 'Mute', 'gimont' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'gimont' ),
'label_off' => esc_html__( 'No', 'gimont' ),
'default' => 'no',
'condition' => [
'icon_url_video!' => '',
],
]
);
$this->add_control(
'loop_video',
[
'label' => esc_html__( 'Loop', 'gimont' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'gimont' ),
'label_off' => esc_html__( 'No', 'gimont' ),
'default' => 'yes',
'condition' => [
'icon_url_video!' => '',
],
]
);
$this->add_control(
'player_controls_video',
[
'label' => esc_html__( 'Player Controls', 'gimont' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'gimont' ),
'label_off' => esc_html__( 'No', 'gimont' ),
'default' => 'yes',
'condition' => [
'icon_url_video!' => '',
],
]
);
$this->add_control(
'modest_branding_video',
[
'label' => esc_html__( 'Modest Branding', 'gimont' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'gimont' ),
'label_off' => esc_html__( 'No', 'gimont' ),
'default' => 'yes',
'condition' => [
'icon_url_video!' => '',
],
]
);
$this->add_control(
'show_info_video',
[
'label' => esc_html__( 'Show Info', 'gimont' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Yes', 'gimont' ),
'label_off' => esc_html__( 'No', 'gimont' ),
'default' => 'no',
'condition' => [
'icon_url_video!' => '',
],
]
);
$this->add_responsive_control(
'alignment',
[
'label' => esc_html__( 'Alignment', 'gimont' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'gimont' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'gimont' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'gimont' ),
'icon' => 'eicon-text-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .ova-video' => 'text-align: {{VALUE}}',
],
]
);
$this->end_controls_section();
/* Begin section icon style */
$this->start_controls_section(
'section_icon_style',
[
'label' => esc_html__( 'Icon', 'gimont' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'icon_font_size',
[
'label' => esc_html__( 'Size', 'gimont' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => 0,
'max' => 200,
],
],
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content i' => 'font-size: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'icon_bgsize',
[
'label' => esc_html__( 'Background Size', 'gimont' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 400,
],
],
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'icon_border_radius',
[
'label' => esc_html__( 'Border Radius', 'gimont' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .ova-video .icon-content-view .content:before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .ova-video .icon-content-view .content:after' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(), [
'name' => 'icon_before_border',
'selector' => '{{WRAPPER}} .ova-video .icon-content-view .content:before',
]
);
$this->add_responsive_control(
'margin',
[
'label' => esc_html__( 'Margin', 'gimont' ),
'type' => \Elementor\Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em', 'rem'],
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->start_controls_tabs( 'tabs_icon_style' );
$this->start_controls_tab(
'tab_icon_normal',
[
'label' => esc_html__( 'Normal', 'gimont' ),
]
);
$this->add_control(
'icon_color_normal',
[
'label' => esc_html__( 'Color', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content i' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'icon_primary_background_normal',
[
'label' => esc_html__( 'Primary Background Color', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content:before' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'icon_secondary_background_normal',
[
'label' => esc_html__( 'Secondary Background Color', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content:after' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_icon_hover',
[
'label' => esc_html__( 'Hover', 'gimont' ),
]
);
$this->add_control(
'icon_color_hover',
[
'label' => esc_html__( 'Color', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content:hover i' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'icon_primary_background_hover',
[
'label' => esc_html__( 'Primary Background Color', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content:hover:before' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'icon_secondary_background_hover',
[
'label' => esc_html__( 'Secondary Background Color', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .icon-content-view .content:hover:after' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
/* Begin text Style */
$this->start_controls_section(
'text_style',
[
'label' => esc_html__( 'Text', 'gimont' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'text_alignment',
[
'label' => esc_html__( 'Alignment', 'gimont' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'gimont' ),
'icon' => 'eicon-h-align-left',
],
'right' => [
'title' => esc_html__( 'Right', 'gimont' ),
'icon' => 'eicon-h-align-right',
],
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'text_typography',
'selector' => '{{WRAPPER}} .ova-video .text',
]
);
$this->add_control(
'text_color',
[
'label' => esc_html__( 'Color', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .text, {{WRAPPER}} .ova-video .text a' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'text_color_hover',
[
'label' => esc_html__( 'Color Hover', 'gimont' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-video .text:hover a, {{WRAPPER}} .ova-video .text:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'text_margin',
[
'label' => esc_html__( 'Margin', 'gimont' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .ova-video .text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
/* End text style */
}
// Render Template Here
protected function render() {
$settings = $this->get_settings();
$icon = $settings['icon'];
$url_video = $settings['icon_url_video'];
$icon_text = $settings['icon_text'];
$link = $settings['link']['url'];
$tg_blank = '';
if ( $settings['link']['is_external'] == 'on' ) {
$tg_blank = 'target="_blank"';
}
$text_alignment = $settings['text_alignment'];
$icon_animation = $settings['icon_animation'];
// video options
$autoplay = $settings['autoplay_video'];
$mute = $settings['mute_video'];
$loop = $settings['loop_video'];
$controls = $settings['player_controls_video'];
$modest = $settings['modest_branding_video'];
$show_info = $settings['show_info_video'];
?>
<div class="ova-video">
<?php if ( $icon_text && $text_alignment != 'right' ): ?>
<div class="text">
<?php if ( $link ): ?>
<a href="<?php echo esc_url( $link ); ?>" <?php echo esc_html( $tg_blank ); ?>>
<?php echo esc_html( $icon_text ); ?>
</a>
<?php else: ?>
<?php echo esc_html( $icon_text ); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="icon-content-view video_active <?php if( $icon_animation != 'yes') { echo esc_attr('no-animation'); } ?>">
<?php if ( ! empty( $url_video ) ) : ?>
<div class="content video-btn"
data-src="<?php echo esc_url( $url_video ); ?>"
data-autoplay="<?php echo esc_attr( $autoplay ); ?>"
data-mute="<?php echo esc_attr( $mute ); ?>"
data-loop="<?php echo esc_attr( $loop ); ?>"
data-controls="<?php echo esc_attr( $controls ); ?>"
data-modest="<?php echo esc_attr( $modest ); ?>"
data-show_info="<?php echo esc_attr( $show_info ); ?>
">
<?php \Elementor\Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] ); ?>
</div>
<?php endif; ?>
</div>
<?php if ( $icon_text && $text_alignment == 'right' ): ?>
<div class="text">
<?php if ( $link ): ?>
<a href="<?php echo esc_url( $link ); ?>" <?php echo esc_html( $tg_blank ); ?>>
<?php echo esc_html( $icon_text ); ?>
</a>
<?php else: ?>
<?php echo esc_html( $icon_text ); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="ova-modal-container">
<div class="modal">
<i class="modal-close ovaicon-cancel"></i>
<iframe class="modal-video" allow="autoplay" allowFullScreen="allowFullScreen" frameBorder="0"></iframe>
</div>
</div>
</div>
<?php
}
}
$widgets_manager->register( new Gimont_Elementor_Video() );