File: /home/confeduphaar/public_html/wp-content/plugins/ova-framework/ova-elementor/widgets/ova_title.php
<?php
namespace ova_framework\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Border;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class ova_title extends Widget_Base {
public function get_name() {
return 'ova_title';
}
public function get_title() {
return __( 'Title Slide', 'ova-framework' );
}
public function get_icon() {
return 'eicon-slides';
}
public function get_categories() {
return [ 'ovatheme' ];
}
public function get_script_depends() {
// Carousel
wp_enqueue_style( 'owl-carousel', OVA_PLUGIN_URI.'assets/libs/owl-carousel/assets/owl.carousel.min.css' );
wp_enqueue_script( 'owl-carousel', OVA_PLUGIN_URI.'assets/libs/owl-carousel/owl.carousel.min.js', array('jquery'), false, true );
return [ 'script-elementor' ];
}
protected function register_controls() {
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories=get_categories($args);
$cate_array = array();
$arrayCateAll = array( 'all' => 'All categories ' );
if ($categories) {
foreach ( $categories as $cate ) {
$cate_array[$cate->cat_name] = $cate->slug;
}
} else {
$cate_array["No content Category found"] = 0;
}
//SECTION CONTENT
$this->start_controls_section(
'section_content',
[
'label' => __( 'Content', 'ova-framework' ),
]
);
$this->add_control(
'category',
[
'label' => __( 'Category', 'ova-framework' ),
'type' => Controls_Manager::SELECT,
'default' => 'all',
'options' => array_merge($arrayCateAll,$cate_array),
]
);
$this->add_control(
'total_count',
[
'label' => __( 'Post Total', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'default' => 3,
]
);
$this->add_control(
'order_by',
[
'label' => __('Order', 'ova-framework'),
'type' => Controls_Manager::SELECT,
'default' => 'desc',
'options' => [
'asc' => __('Ascending', 'ova-framework'),
'desc' => __('Descending', 'ova-framework'),
]
]
);
$this->end_controls_section();
//END SECTION CONTENT
$this->start_controls_section(
'section_additional_options',
[
'label' => __( 'Additional Options', 'ova-framework' ),
]
);
/*************************** VERSION 1 ***********************/
$this->add_control(
'margin_items',
[
'label' => __( 'Margin Right Items', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'default' => 30,
]
);
$this->add_control(
'item_number',
[
'label' => __( 'Item Number', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'description' => __( 'Number Item', 'ova-framework' ),
'default' => 4,
]
);
$this->add_control(
'slides_to_scroll',
[
'label' => __( 'Slides to Scroll', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'description' => __( 'Set how many slides are scrolled per swipe.', 'ova-framework' ),
'default' => 1,
]
);
$this->add_control(
'pause_on_hover',
[
'label' => __( 'Pause on Hover', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'infinite',
[
'label' => __( 'Infinite Loop', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'autoplay',
[
'label' => __( 'Autoplay', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'autoplay_speed',
[
'label' => __( 'Autoplay Speed', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'default' => 3000,
'step' => 500,
'condition' => [
'autoplay' => 'yes',
],
'frontend_available' => true,
]
);
$this->add_control(
'smartspeed',
[
'label' => __( 'Smart Speed', 'ova-framework' ),
'type' => Controls_Manager::NUMBER,
'default' => 500,
]
);
$this->add_control(
'center',
[
'label' => __( 'Center', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'no',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'nav_control',
[
'label' => __( 'Show Nav', 'ova-framework' ),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'options' => [
'yes' => __( 'Yes', 'ova-framework' ),
'no' => __( 'No', 'ova-framework' ),
],
'frontend_available' => true,
]
);
$this->end_controls_section();
//SECTION TAB STYLE TITLE
$this->start_controls_section(
'section_title',
[
'label' => __( 'Title', 'ova-framework' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'selector' => '{{WRAPPER}} .title-slide .title_slide',
]
);
$this->add_control(
'color_title',
[
'label' => __( 'Color Title', 'ova-framework' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .title-slide .title_slide' => 'color : {{VALUE}};',
],
]
);
$this->add_control(
'color_title_hover',
[
'label' => __( 'Color Title Hover', 'ova-framework' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .title-slide .title_slide:hover' => 'color : {{VALUE}};',
],
]
);
$this->end_controls_section();
//END SECTION TAB STYLE TITLE
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
*
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
$category = $settings['category'];
$total_count = $settings['total_count'];
$order = $settings['order_by'];
$data_options['items'] = $settings['item_number'];
$data_options['slideBy'] = $settings['slides_to_scroll'];
$data_options['margin'] = $settings['margin_items'];
$data_options['autoplayHoverPause'] = $settings['pause_on_hover'] === 'yes' ? true : false;
$data_options['loop'] = $settings['infinite'] === 'yes' ? true : false;
$data_options['autoplay'] = $settings['autoplay'] === 'yes' ? true : false;
$data_options['autoplayTimeout'] = $settings['autoplay_speed'];
$data_options['smartSpeed'] = $settings['smartspeed'];
$data_options['dots'] = ( isset( $settings['dot_control'] ) && $settings['dot_control'] === 'yes' ) ? true : false;
$data_options['nav'] = $settings['nav_control'] === 'yes' ? true : false;
$data_options['center'] = $settings['center'] === 'yes' ? true : false;
$args = [];
if ($category == 'all') {
$args=[
'post_type' => 'post',
'posts_per_page' => $total_count,
'order' => $order,
];
} else {
$args=[
'post_type' => 'post',
'category_name'=>$category,
'posts_per_page' => $total_count,
'order' => $order,
];
}
$title_slide = new \WP_Query($args);
?>
<div class="title-slide owl-carousel owl-theme" data-options="<?php echo esc_attr(json_encode($data_options)) ?>">
<?php
if($title_slide->have_posts()) : while($title_slide->have_posts()) : $title_slide->the_post();
$title = get_the_title();
?>
<a href="<?php echo get_the_permalink() ?>" >
<div class="title_slide">
<?php echo $title ?>
</div>
</a>
<?php
endwhile; endif; wp_reset_postdata();
?>
</div>
<?php
}
}