File "video-info-widget.php"
Full Path: /home/leadltht/fastlinkinternet.com/img/video-info/video-info-widget.php
File size: 28.6 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace BdevsElement\Widget;
Use \Elementor\Core\Schemes\Typography;
use \Elementor\Utils;
use \Elementor\Repeater;
use \Elementor\Control_Media;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Box_Shadow;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Typography;
use \Elementor\Icons_Manager;
defined( 'ABSPATH' ) || die();
class Video_Info extends BDevs_El_Widget {
/**
* Get widget name.
*
* Retrieve Bdevs Element widget name.
*
* @since 1.0.0
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'video_info';
}
/**
* Get widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Video Info', 'bdevselement' );
}
/**
* Get widget icon.
*
* @since 1.0.0
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-video-camera';
}
public function get_keywords() {
return [ 'info', 'video', 'box', 'text', 'content' ];
}
/**
* Register content related controls
*/
protected function register_content_controls() {
$this->start_controls_section(
'_section_design_title',
[
'label' => __('Design Style', 'bdevselement'),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'design_style',
[
'label' => __('Design Style', 'bdevselement'),
'type' => Controls_Manager::SELECT,
'options' => [
'style_1' => __('Style 1', 'bdevselement'),
// 'style_2' => __('Style 2', 'bdevselement'),
],
'default' => 'style_1',
'frontend_available' => true,
'style_transfer' => true,
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_media',
[
'label' => __( 'Icon / Image', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
'condition' => [
'design_style' => ['style_10']
]
]
);
$this->add_control(
'type',
[
'label' => __( 'Media Type', 'bdevselement' ),
'type' => Controls_Manager::CHOOSE,
'label_block' => false,
'options' => [
'icon' => [
'title' => __( 'Icon', 'bdevselement' ),
'icon' => 'fa fa-smile-o',
],
'image' => [
'title' => __( 'Image', 'bdevselement' ),
'icon' => 'fa fa-image',
],
],
'default' => 'icon',
'toggle' => false,
'style_transfer' => true,
]
);
$this->add_control(
'image',
[
'label' => __( 'Image', 'bdevselement' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'condition' => [
'type' => 'image'
],
'dynamic' => [
'active' => true,
]
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'thumbnail',
'default' => 'medium_large',
'separator' => 'none',
'exclude' => [
'full',
'custom',
'large',
'shop_catalog',
'shop_single',
'shop_thumbnail'
],
'condition' => [
'type' => 'image'
]
]
);
if ( bdevs_element_is_elementor_version( '<', '2.6.0' ) ) {
$this->add_control(
'icon',
[
'label' => __( 'Icon', 'bdevselement' ),
'label_block' => true,
'type' => Controls_Manager::ICON,
'options' => bdevs_element_get_bdevs_element_icons(),
'default' => 'fa fa-smile-o',
'condition' => [
'type' => 'icon'
]
]
);
}
else {
$this->add_control(
'selected_icon',
[
'type' => Controls_Manager::ICONS,
'fa4compatibility' => 'icon',
'label_block' => true,
'default' => [
'value' => 'fas fa-smile-wink',
'library' => 'fa-solid',
],
'condition' => [
'type' => 'icon'
]
]
);
}
$this->end_controls_section();
$this->start_controls_section(
'_section_features_list',
[
'label' => __( 'Shape Images', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
'condition' => [
'design_style' => ['style_10']
]
]
);
$repeater = new Repeater();
$repeater->add_control(
'shape_image',
[
'type' => Controls_Manager::MEDIA,
'label' => __( 'Image', 'bdevselement' ),
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'dynamic' => [
'active' => true,
]
]
);
$repeater->add_control(
'title',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __( 'Title', 'bdevselement' ),
'placeholder' => __( 'Type title here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'slides',
[
'show_label' => false,
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '<# print(title || "Carousel Item"); #>',
'default' => [
[
'shape_image' => [
'url' => Utils::get_placeholder_image_src(),
],
],
[
'shape_image' => [
'url' => Utils::get_placeholder_image_src(),
],
]
]
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'shape',
'default' => 'medium_large',
'separator' => 'before',
'exclude' => [
'custom'
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_video_info',
[
'label' => __( 'Video Info', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'bg_image',
[
'label' => __('Video BG Image', 'bdevselement'),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'video_link',
[
'label' => __( 'Video Link', 'bdevselement' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => __( '#', 'bdevselement' ),
'placeholder' => __( 'Type Video Link', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_title',
[
'label' => __( 'Title & Description', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
'condition' => [
'design_style' => ['style_10']
]
]
);
$this->add_control(
'title',
[
'label' => __( 'Title', 'bdevselement' ),
'label_block' => true,
'type' => Controls_Manager::TEXT,
'default' => __( 'bdevs Info Box Title', 'bdevselement' ),
'placeholder' => __( 'Type Info Box Title', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'description',
[
'label' => __( 'Description', 'bdevselement' ),
'description' => bdevs_element_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXTAREA,
'default' => __( 'bdevs info box description goes here', 'bdevselement' ),
'placeholder' => __( 'Type info box description', 'bdevselement' ),
'rows' => 5,
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'video_url',
[
'label' => __( 'Video URL', 'bdevselement' ),
'description' => bdevs_element_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'bdevs video url goes here', 'bdevselement' ),
'placeholder' => __( 'Set Video URL', 'bdevselement' ),
'label_block' => true,
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'title_tag',
[
'label' => __( 'Title HTML Tag', 'bdevselement' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'h1' => [
'title' => __( 'H1', 'bdevselement' ),
'icon' => 'eicon-editor-h1'
],
'h2' => [
'title' => __( 'H2', 'bdevselement' ),
'icon' => 'eicon-editor-h2'
],
'h3' => [
'title' => __( 'H3', 'bdevselement' ),
'icon' => 'eicon-editor-h3'
],
'h4' => [
'title' => __( 'H4', 'bdevselement' ),
'icon' => 'eicon-editor-h4'
],
'h5' => [
'title' => __( 'H5', 'bdevselement' ),
'icon' => 'eicon-editor-h5'
],
'h6' => [
'title' => __( 'H6', 'bdevselement' ),
'icon' => 'eicon-editor-h6'
]
],
'default' => 'h2',
'toggle' => false,
]
);
$this->add_responsive_control(
'align',
[
'label' => __( 'Alignment', 'bdevselement' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'bdevselement' ),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => __( 'Center', 'bdevselement' ),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => __( 'Right', 'bdevselement' ),
'icon' => 'fa fa-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}}' => 'text-align: {{VALUE}};'
]
]
);
$this->end_controls_section();
}
/**
* Register styles related controls
*/
protected function register_style_controls() {
$this->start_controls_section(
'_section_media_style',
[
'label' => __( 'Icon / Image', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'icon_size',
[
'label' => __( 'Size', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 10,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}} .video-btn' => 'font-size: {{SIZE}}{{UNIT}};',
],
'condition' => [
'type' => 'icon'
]
]
);
$this->add_responsive_control(
'image_width',
[
'label' => __( 'Width', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [
'min' => 1,
'max' => 400,
],
'%' => [
'min' => 1,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .video-btn' => 'width: {{SIZE}}{{UNIT}};',
],
'condition' => [
'type' => 'image'
]
]
);
$this->add_responsive_control(
'image_height',
[
'label' => __( 'Height', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 1,
'max' => 400,
],
],
'selectors' => [
'{{WRAPPER}} .video-btn' => 'height: {{SIZE}}{{UNIT}};',
],
'condition' => [
'type' => 'image'
]
]
);
$this->add_control(
'offset_toggle',
[
'label' => __( 'Offset', 'bdevselement' ),
'type' => Controls_Manager::POPOVER_TOGGLE,
'label_off' => __( 'None', 'bdevselement' ),
'label_on' => __( 'Custom', 'bdevselement' ),
'return_value' => 'yes',
]
);
$this->start_popover();
$this->add_responsive_control(
'media_offset_x',
[
'label' => __( 'Offset Left', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'condition' => [
'offset_toggle' => 'yes'
],
'range' => [
'px' => [
'min' => -1000,
'max' => 1000,
],
],
'render_type' => 'ui',
]
);
$this->add_responsive_control(
'media_offset_y',
[
'label' => __( 'Offset Top', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'condition' => [
'offset_toggle' => 'yes'
],
'range' => [
'px' => [
'min' => -1000,
'max' => 1000,
],
],
'selectors' => [
// Media translate styles
'(desktop){{WRAPPER}} .video-btn' => '-ms-transform: translate({{media_offset_x.SIZE || 0}}{{UNIT}}, {{media_offset_y.SIZE || 0}}{{UNIT}}); -webkit-transform: translate({{media_offset_x.SIZE || 0}}{{UNIT}}, {{media_offset_y.SIZE || 0}}{{UNIT}}); transform: translate({{media_offset_x.SIZE || 0}}{{UNIT}}, {{media_offset_y.SIZE || 0}}{{UNIT}});',
'(tablet){{WRAPPER}} .video-btn' => '-ms-transform: translate({{media_offset_x_tablet.SIZE || 0}}{{UNIT}}, {{media_offset_y_tablet.SIZE || 0}}{{UNIT}}); -webkit-transform: translate({{media_offset_x_tablet.SIZE || 0}}{{UNIT}}, {{media_offset_y_tablet.SIZE || 0}}{{UNIT}}); transform: translate({{media_offset_x_tablet.SIZE || 0}}{{UNIT}}, {{media_offset_y_tablet.SIZE || 0}}{{UNIT}});',
'(mobile){{WRAPPER}} .video-btn' => '-ms-transform: translate({{media_offset_x_mobile.SIZE || 0}}{{UNIT}}, {{media_offset_y_mobile.SIZE || 0}}{{UNIT}}); -webkit-transform: translate({{media_offset_x_mobile.SIZE || 0}}{{UNIT}}, {{media_offset_y_mobile.SIZE || 0}}{{UNIT}}); transform: translate({{media_offset_x_mobile.SIZE || 0}}{{UNIT}}, {{media_offset_y_mobile.SIZE || 0}}{{UNIT}});',
// Body text styles
'{{WRAPPER}} .video-btn' => 'margin-top: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_popover();
$this->add_responsive_control(
'media_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .video-btn' => 'margin-bottom: {{SIZE}}{{UNIT}} !important;',
],
]
);
$this->add_responsive_control(
'media_padding',
[
'label' => __( 'Padding', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .bdevs-infobox-figure--image img, {{WRAPPER}} .video-btn' => 'padding: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'media_border',
'selector' => '{{WRAPPER}} .bdevs-infobox-figure--image img, {{WRAPPER}} .video-btn',
]
);
$this->add_responsive_control(
'media_border_radius',
[
'label' => __( 'Border Radius', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .bdevs-infobox-figure--image img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
'{{WRAPPER}} .video-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'media_box_shadow',
'exclude' => [
'box_shadow_position',
],
'selector' => '{{WRAPPER}} .bdevs-infobox-figure--image img, {{WRAPPER}} .video-btn'
]
);
$this->add_control(
'icon_color',
[
'label' => __( 'Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-infobox-figure--icon' => 'color: {{VALUE}}',
],
'condition' => [
'type' => 'icon'
]
]
);
$this->add_control(
'icon_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .video-btn' => 'background-color: {{VALUE}};',
],
'condition' => [
'type' => 'icon'
]
]
);
$this->add_control(
'icon_bg_rotate',
[
'label' => __( 'Background Rotate', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'deg' ],
'default' => [
'unit' => 'deg',
],
'range' => [
'deg' => [
'min' => 0,
'max' => 360,
],
],
'selectors' => [
// Icon rotate styles
'{{WRAPPER}} .video-btn' => '-ms-transform: rotate(-{{SIZE}}{{UNIT}}); -webkit-transform: rotate(-{{SIZE}}{{UNIT}}); transform: rotate(-{{SIZE}}{{UNIT}});',
// Icon box transform styles
'(desktop){{WRAPPER}} .video-btn' => '-ms-transform: translate({{media_offset_x.SIZE || 0}}px, {{media_offset_y.SIZE || 0}}px) rotate({{SIZE}}deg); -webkit-transform: translate({{media_offset_x.SIZE || 0}}px, {{media_offset_y.SIZE || 0}}px) rotate({{SIZE}}deg); transform: translate({{media_offset_x.SIZE || 0}}px, {{media_offset_y.SIZE || 0}}px) rotate({{SIZE}}deg);',
'(tablet){{WRAPPER}} .video-btn' => '-ms-transform: translate({{media_offset_x_tablet.SIZE || 0}}px, {{media_offset_y_tablet.SIZE || 0}}px) rotate({{SIZE}}deg); -webkit-transform: translate({{media_offset_x_tablet.SIZE || 0}}px, {{media_offset_y_tablet.SIZE || 0}}px) rotate({{SIZE}}deg); transform: translate({{media_offset_x_tablet.SIZE || 0}}px, {{media_offset_y_tablet.SIZE || 0}}px) rotate({{SIZE}}deg);',
'(mobile){{WRAPPER}} .video-btn' => '-ms-transform: translate({{media_offset_x_mobile.SIZE || 0}}px, {{media_offset_y_mobile.SIZE || 0}}px) rotate({{SIZE}}deg); -webkit-transform: translate({{media_offset_x_mobile.SIZE || 0}}px, {{media_offset_y_mobile.SIZE || 0}}px) rotate({{SIZE}}deg); transform: translate({{media_offset_x_mobile.SIZE || 0}}px, {{media_offset_y_mobile.SIZE || 0}}px) rotate({{SIZE}}deg);',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_title_style',
[
'label' => __( 'Title & Description', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'content_padding',
[
'label' => __( 'Content Box Padding', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .section-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'title_heading',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Title', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'title_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .section-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'title_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-title' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => __( 'Typography', 'bdevselement' ),
'selector' => '{{WRAPPER}} .section-title',
'scheme' => Typography::TYPOGRAPHY_2
]
);
$this->add_control(
'description_heading',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Description', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'description_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .intro' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'description_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .intro' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'description_typography',
'label' => __( 'Typography', 'bdevselement' ),
'selector' => '{{WRAPPER}} .intro',
'scheme' => Typography::TYPOGRAPHY_3,
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$this->add_inline_editing_attributes( 'title', 'basic' );
$this->add_render_attribute( 'title', 'class', 'section-title' );
$this->add_inline_editing_attributes( 'name', 'basic' );
$this->add_render_attribute( 'name', 'class', 'name' );
$this->add_inline_editing_attributes( 'description', 'intermediate' );
$this->add_render_attribute( 'description', 'class', 'bdevs-infobox-text' );
if ( !empty($settings['bg_image']['id']) ) {
$bg_image = wp_get_attachment_image_url( $settings['bg_image']['id'], $settings['thumbnail_size'] );
if ( ! $bg_image ) {
$bg_image = !empty($settings['bg_image']['url']) ? $settings['bg_image']['url'] : '';
}
}
?>
<div class="services-details-video">
<img src="<?php print esc_attr($bg_image); ?>" alt="<?php echo get_post_meta(attachment_url_to_postid($bg_image), '_wp_attachment_image_alt', true); ?>">
<div class="video-paly">
<a href="<?php echo esc_url( $settings['video_link'] ); ?>" class="popup-video"><i class="fas fa-play"></i></a>
</div>
</div>
<?php
}
}