File "post-video-widget.php"
Full Path: /home/leadltht/fastlinkinternet.com/admin/wp-content/plugins/bdevs-element/widgets/post-video/post-video-widget.php
File size: 31.37 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace BdevsElement\Widget;
use \Elementor\Group_Control_Background;
use \Elementor\Repeater;
use \Elementor\Controls_Manager;
use \Elementor\Group_Control_Border;
use \Elementor\Group_Control_Image_Size;
use \Elementor\Group_Control_Typography;
Use \Elementor\Core\Schemes\Typography;
use \Elementor\Utils;
defined( 'ABSPATH' ) || die();
class Post_video 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 'post_video';
}
/**
* Get widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'Post Video', 'bdevselement' );
}
public function get_custom_help_url() {
return 'http://elementor.bdevs.net//widgets/fact/';
}
/**
* 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 [ 'brand', 'image', 'counter' ];
}
protected function register_content_controls() {
$this->start_controls_section(
'_section_media',
[
'label' => __( 'Icon / Image', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'image',
[
'label' => __( 'Image', 'bdevselement' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
'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'
]
]
);
$this->add_control(
'video_url',
[
'label' => __( 'Video URL', 'bdevselement' ),
'type' => Controls_Manager::TEXT,
'default' => __( '#', 'bdevselement' ),
'placeholder' => __( 'Set Video URL', 'bdevselement' ),
'label_block' => true,
'dynamic' => [
'active' => true,
]
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_title',
[
'label' => __( 'Title & Description', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'title',
[
'label' => __( 'Title', 'bdevselement' ),
'label_block' => true,
'type' => Controls_Manager::TEXTAREA,
'default' => __( 'bdevs Info Box Title', 'bdevselement' ),
'placeholder' => __( 'Type Info Box Title', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$this->add_control(
'subtitle',
[
'label' => __( 'Subtitle', 'bdevselement' ),
'label_block' => true,
'description' => bdevs_element_get_allowed_html_desc( 'intermediate' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'bdevs subtitle here', 'bdevselement' ),
'placeholder' => __( 'Type subtitle here', 'bdevselement' ),
'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();
$this->start_controls_section(
'_section_blog_list',
[
'label' => __( 'Blog List', 'bdevselement' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new Repeater();
$repeater->start_controls_tabs(
'_tab_title_image'
);
$repeater->start_controls_tab(
'_tab_member_info',
[
'label' => __( 'Image & Title', 'bdevselement' ),
]
);
$repeater->add_control(
'blog_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' ),
'default' => __( 'BDevs Title', 'bdevselement' ),
'placeholder' => __( 'Type title here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$repeater->add_control(
'post_url',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __( 'Post Url', 'bdevselement' ),
'default' => __( '#', 'bdevselement' ),
'placeholder' => __( 'Type url here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$repeater->end_controls_tab();
$repeater->start_controls_tab(
'_tab_meta_info',
[
'label' => __( 'Meta Info', 'bdevselement' ),
]
);
$repeater->add_control(
'show_meta',
[
'label' => __( 'Show Meta?', 'bdevselement' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Yes', 'bdevselement' ),
'label_off' => __( 'No', 'bdevselement' ),
'return_value' => 'no',
'style_transfer' => true,
]
);
$repeater->add_control(
'date_text',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __( 'Date Text', 'bdevselement' ),
'default' => __( 'November 15th 2019', 'bdevselement' ),
'placeholder' => __( 'Type title here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$repeater->add_control(
'date_url',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __( 'Date Url', 'bdevselement' ),
'default' => __( '#', 'bdevselement' ),
'placeholder' => __( 'Type date url here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$repeater->add_control(
'author_text',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __( 'Author Name', 'bdevselement' ),
'default' => __( 'Salim Rana', 'bdevselement' ),
'placeholder' => __( 'Type author name here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$repeater->add_control(
'author_url',
[
'type' => Controls_Manager::TEXT,
'label_block' => true,
'label' => __( 'Author Url', 'bdevselement' ),
'default' => __( '#', 'bdevselement' ),
'placeholder' => __( 'Type author url here', 'bdevselement' ),
'dynamic' => [
'active' => true,
]
]
);
$repeater->end_controls_tab();
$repeater->end_controls_tabs();
$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_thumbnail',
'default' => 'medium_large',
'separator' => 'before',
'exclude' => [
'custom'
]
]
);
$this->end_controls_section();
}
protected function register_style_controls() {
$this->start_controls_section(
'_section_style_item',
[
'label' => __( 'Slider Item', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'item_border',
'selector' => '{{WRAPPER}} .bdevs-slick-item',
]
);
$this->add_responsive_control(
'item_border_radius',
[
'label' => __( 'Border Radius', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .bdevs-slick-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow: hidden;',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_style_content',
[
'label' => __( 'Slide Content', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'content_padding',
[
'label' => __( 'Content Padding', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', 'em', '%' ],
'selectors' => [
'{{WRAPPER}} .bdevs-slick-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'content_background',
'selector' => '{{WRAPPER}} .bdevs-slick-content',
'exclude' => [
'image'
]
]
);
$this->add_control(
'_heading_title',
[
'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}} .bdevs-slick-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'title_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-slick-title' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title',
'selector' => '{{WRAPPER}} .bdevs-slick-title',
'scheme' => Typography::TYPOGRAPHY_2,
]
);
$this->add_control(
'_heading_subtitle',
[
'type' => Controls_Manager::HEADING,
'label' => __( 'Subtitle', 'bdevselement' ),
'separator' => 'before'
]
);
$this->add_responsive_control(
'subtitle_spacing',
[
'label' => __( 'Bottom Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .bdevs-slick-subtitle' => 'margin-bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'subtitle_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bdevs-slick-subtitle' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'subtitle',
'selector' => '{{WRAPPER}} .bdevs-slick-subtitle',
'scheme' => Typography::TYPOGRAPHY_3,
]
);
$this->end_controls_section();
$this->start_controls_section(
'_section_style_arrow',
[
'label' => __( 'Navigation - Arrow', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'arrow_position_toggle',
[
'label' => __( 'Position', 'bdevselement' ),
'type' => Controls_Manager::POPOVER_TOGGLE,
'label_off' => __( 'None', 'bdevselement' ),
'label_on' => __( 'Custom', 'bdevselement' ),
'return_value' => 'yes',
]
);
$this->start_popover();
$this->add_responsive_control(
'arrow_position_y',
[
'label' => __( 'Vertical', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'condition' => [
'arrow_position_toggle' => 'yes'
],
'range' => [
'px' => [
'min' => 0,
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .slick-prev, {{WRAPPER}} .slick-next' => 'top: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'arrow_position_x',
[
'label' => __( 'Horizontal', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'condition' => [
'arrow_position_toggle' => 'yes'
],
'range' => [
'px' => [
'min' => -100,
'max' => 250,
],
],
'selectors' => [
'{{WRAPPER}} .slick-prev' => 'left: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .slick-next' => 'right: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_popover();
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'arrow_border',
'selector' => '{{WRAPPER}} .slick-prev, {{WRAPPER}} .slick-next',
]
);
$this->add_responsive_control(
'arrow_border_radius',
[
'label' => __( 'Border Radius', 'bdevselement' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%' ],
'selectors' => [
'{{WRAPPER}} .slick-prev, {{WRAPPER}} .slick-next' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow: hidden;',
],
]
);
$this->start_controls_tabs( '_tabs_arrow' );
$this->start_controls_tab(
'_tab_arrow_normal',
[
'label' => __( 'Normal', 'bdevselement' ),
]
);
$this->add_control(
'arrow_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .slick-prev, {{WRAPPER}} .slick-next' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'arrow_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .slick-prev, {{WRAPPER}} .slick-next' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'_tab_arrow_hover',
[
'label' => __( 'Hover', 'bdevselement' ),
]
);
$this->add_control(
'arrow_hover_color',
[
'label' => __( 'Text Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .slick-prev:hover, {{WRAPPER}} .slick-next:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'arrow_hover_bg_color',
[
'label' => __( 'Background Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .slick-prev:hover, {{WRAPPER}} .slick-next:hover' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'arrow_hover_border_color',
[
'label' => __( 'Border Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'condition' => [
'arrow_border_border!' => '',
],
'selectors' => [
'{{WRAPPER}} .slick-prev:hover, {{WRAPPER}} .slick-next:hover' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'_section_style_dots',
[
'label' => __( 'Navigation - Dots', 'bdevselement' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'dots_nav_position_y',
[
'label' => __( 'Vertical Position', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'range' => [
'px' => [
'min' => -100,
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .slick-dots' => 'bottom: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'dots_nav_spacing',
[
'label' => __( 'Spacing', 'bdevselement' ),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px'],
'selectors' => [
'{{WRAPPER}} .slick-dots li' => 'margin-right: calc({{SIZE}}{{UNIT}} / 2); margin-left: calc({{SIZE}}{{UNIT}} / 2);',
],
]
);
$this->add_responsive_control(
'dots_nav_align',
[
'label' => __( 'Alignment', 'bdevselement' ),
'type' => Controls_Manager::CHOOSE,
'label_block' => false,
'options' => [
'left' => [
'title' => __( 'Left', 'bdevselement' ),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __( 'Center', 'bdevselement' ),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => __( 'Right', 'bdevselement' ),
'icon' => 'eicon-h-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .slick-dots' => 'text-align: {{VALUE}}'
]
]
);
$this->start_controls_tabs( '_tabs_dots' );
$this->start_controls_tab(
'_tab_dots_normal',
[
'label' => __( 'Normal', 'bdevselement' ),
]
);
$this->add_control(
'dots_nav_color',
[
'label' => __( 'Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .slick-dots li button:before' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'_tab_dots_hover',
[
'label' => __( 'Hover', 'bdevselement' ),
]
);
$this->add_control(
'dots_nav_hover_color',
[
'label' => __( 'Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .slick-dots li button:hover:before' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'_tab_dots_active',
[
'label' => __( 'Active', 'bdevselement' ),
]
);
$this->add_control(
'dots_nav_active_color',
[
'label' => __( 'Color', 'bdevselement' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .slick-dots .slick-active button:before' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$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( 'subtitle', 'class', 'bdevs-infobox-text' );
$image = wp_get_attachment_image_url( $settings['image']['id'], $settings['thumbnail_size'] );
if ( ! $image ) {
$image = $settings['image']['url'];
}
?>
<section class="blog-area">
<div class="container-fluid">
<div class="row no-gutters">
<div class="col-lg-6">
<div class="video-box">
<div class="video-thumb">
<img src="<?php echo esc_html($image); ?>" alt="">
</div>
<a class="video-btn popup-video" href="<?php echo esc_url( $settings['video_url'] ); ?>"><i class="fa fa-play"></i></a>
</div>
</div>
<div class="col-lg-6 my-auto">
<div class="blog-content-wrap">
<div class="section-heading mb-80">
<?php if ( $settings['subtitle'] ) : ?>
<h4 class="sub-title"><?php echo bdevs_element_kses_intermediate( $settings['subtitle'] ); ?></h4>
<?php endif; ?>
<?php if ( $settings['title' ] ) :
printf( '<%1$s %2$s>%3$s</%1$s>',
tag_escape( $settings['title_tag'] ),
$this->get_render_attribute_string( 'title' ),
bdevs_element_kses_basic( $settings['title' ] )
);
endif; ?>
</div>
<div class="blog-list">
<?php foreach ( $settings['slides'] as $id => $slide ) :
$blog_image = wp_get_attachment_image_url( $slide['blog_image']['id'], $settings['thumbnail_size'] );
if ( ! $blog_image ) {
$blog_image = $slide['blog_image']['url'];
}
?>
<div class="single-blog-item">
<div class="thumb">
<img class="rounded-circle" src="<?php echo $slide['blog_image']['url']; ?>" alt="">
</div>
<div class="content">
<?php if( !empty($slide['show_meta'] ) ) : ?>
<div class="blog-meta">
<ul>
<?php if ( !empty($slide['date_url']) ) : ?>
<li><a href="<?php echo esc_url( $slide['date_url'] ); ?>"><i class="fal fa-calendar-alt"></i> <?php echo bdevs_element_kses_basic( $slide['date_text'] ); ?></a></li>
<?php endif; ?>
<?php if ( !empty($slide['author_url']) ) : ?>
<li><a href="<?php echo esc_url( $slide['author_url'] ); ?>"><i class="fal fa-user"></i> <?php echo bdevs_element_kses_basic( $slide['author_text'] ); ?></a></li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
<h4 class="title"><a href="<?php echo esc_url( $slide['post_url'] ); ?>"><?php echo bdevs_element_kses_basic( $slide['title'] ); ?></a></h4>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
}
}