Current File : /home/bravrvjk/cepurhuye.rw/wp-content/plugins/bopea-function/block//newsticker.php
<?php
namespace bopeaElementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Image_Size;
use Elementor\Group_Control_Typography;
use Elementor\Schemes\Color;
use Elementor\Schemes\Typography;
use Elementor\Utils;
use Elementor\Control_Media;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Background;
use Elementor\Repeater;
use Elementor\Icons_Manager;
defined('ABSPATH') || die();
class bopea_newsticker_text extends Widget_Base {
public function get_name() {
return 'bopea-newsticker-text';
}
public function get_title() {
return esc_html__( 'Newsticker Text', 'bopea-function' );
}
public function get_icon() {
return 'eicon-elementor-circle jl-icons';
}
public function get_categories() {
return [ 'bopea-elements' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_tab',
[
'label' => esc_html__('Post Query And Settings', 'bopea-function'),
]
);
$this->add_control(
'jl_label_title', [
'label' => esc_html__( 'Label title', 'bopea-function' ),
'default' => 'Top News',
'type' => Controls_Manager::TEXT,
'label_block' => true
]
);
$this->add_control(
'post_type',
[
'label' =>esc_html__('Post types', 'bopea-function'),
'description' => esc_html__( 'Choose post type to display posts', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'default' => 'post',
'options' => $this->post_get_type(),
]
);
$this->add_control(
'post_type_tax',
[
'label' =>esc_html__('Post taxonomy', 'bopea-function'),
'description' => esc_html__( 'Choose post type (category or tag)', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => $this->post_get_taxs(),
'condition' => [
'post_type!' => ['post']
]
]
);
$this->add_control(
'term_slugs', [
'label' => esc_html__( 'Term Slug', 'bopea-function' ),
'description' => esc_html__( 'Example: slug1,slug2,slug3', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'condition' => [
'post_type!' => ['post']
]
]
);
$this->add_control(
'categories',
[
'label' =>esc_html__('Select Categories', 'bopea-function'),
'type' => Controls_Manager::SELECT2,
'options' => $this->post_categories(),
'label_block' => true,
'multiple' => true,
'condition' => [
'post_type' => ['post']
]
]
);
$this->add_control(
'tags', [
'label' => esc_html__( 'Tag Slug', 'bopea-function' ),
'description' => esc_html__( 'Example: tagslug1,tagslug2,tagslug3', 'bopea-function' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
'condition' => [
'post_type' => ['post']
]
]
);
$this->add_control(
'author',
[
'label' =>esc_html__('Author Filter', 'bopea-function'),
'type' => Controls_Manager::SELECT,
'default' => 'none',
'options' => $this->post_author(),
'condition' => [
'post_type' => ['post']
]
]
);
// $this->add_control(
// 'author',
// [
// 'label' =>esc_html__('Select Author', 'bopea-function'),
// 'type' => Controls_Manager::SELECT2,
// 'options' => $this->post_author(),
// 'label_block' => true,
// 'multiple' => true,
// ]
// );
$this->add_control(
'posts_per_page',
array(
'label' => esc_html__( 'Posts per Page', 'bopea-function' ),
'type' => Controls_Manager::NUMBER,
'default' => '6'
)
);
$this->add_control(
'offset',
array(
'label' => esc_html__( 'Post Offset', 'bopea-function' ),
'type' => Controls_Manager::NUMBER,
'default' => '',
)
);
$this->add_control(
'format',
array(
'label' => esc_html__( 'Post Format', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'0' => esc_html__( 'All', 'bopea-function' ),
'gallery' => esc_html__( 'Gallery', 'bopea-function' ),
'video' => esc_html__( 'Video', 'bopea-function' ),
'audio' => esc_html__( 'Audio', 'bopea-function' ),
'quote' => esc_html__( 'Quote', 'bopea-function' ),
],
'default' => '0',
'condition' => [
'post_type' => ['post']
]
)
);
$this->add_control(
'post_not_in', [
'label' => esc_html__( 'Exclude Post IDs', 'bopea-function' ),
'description' => esc_html__( 'Example: 1,2,3', 'bopea-function' ),
'default' => '',
'type' => Controls_Manager::TEXT,
'label_block' => true
]
);
$this->add_control(
'post_in', [
'label' => esc_html__( 'Post IDs Filter', 'bopea-function' ),
'description' => esc_html__( 'Example: 1,2,3', 'bopea-function' ),
'default' => '',
'type' => Controls_Manager::TEXT,
'label_block' => true
]
);
$this->add_control(
'ignore_sticky_posts',
[
'label' => esc_html__( 'Enable sticky posts', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'order',
[
'label' =>esc_html__( 'Sort Order', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'default' => 'date_post',
'options' => [
'date_post' =>esc_html__( 'Latest post', 'bopea-function' ),
'rand' =>esc_html__( 'Random', 'bopea-function' ),
'update' =>esc_html__( 'Latest updated', 'bopea-function' ),
'comment_count' =>esc_html__( 'Popular comment', 'bopea-function' ),
'author' =>esc_html__( 'Author', 'bopea-function' ),
'popular_most' =>esc_html__( 'Popular views', 'bopea-function' ),
'popular_by_month' =>esc_html__( 'Popular views by month', 'bopea-function' ),
'popular_by_week' =>esc_html__( 'Popular views by week', 'bopea-function' ),
'alphabetical_order_decs' =>esc_html__( 'Title DECS', 'bopea-function' ),
'alphabetical_order_asc' =>esc_html__( 'Title ACS', 'bopea-function' ),
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_tab_style', [
'label' => esc_html__( 'Title Style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'tag',
[
'label' => __( 'Title Tag', 'bopea-function' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'div' => 'div'
],
'default' => 'h2',
]
);
$this->add_control(
'slider_speed',
[
'label' => esc_html__('Speed', 'bopea-function'),
'type' => Controls_Manager::NUMBER,
'default' => 300,
]
);
$this->add_control(
'slider_autoplay_delay',
[
'label' => esc_html__('Autoplay Delay', 'bopea-function'),
'type' => Controls_Manager::NUMBER,
'default' => 3500,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_list_text_typography',
'label' => __( 'Title Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl-newsticker-li .jl_fe_title',
]
);
$this->add_control(
'jl_list_text_color',
[
'label' => __( 'Title Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl-newsticker-li .jl_fe_title a' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_list_text_color_dark',
[
'label' => __( 'Title Color Dark Mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jl-newsticker-li .jl_fe_title a' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_color',
[
'label' => __( 'Arrow color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--tarrow-color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_color_dark',
[
'label' => __( 'Arrow color dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--tarrow-color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_color_bg',
[
'label' => __( 'Arrow background', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--tarrow-bg: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_color_bg_dark',
[
'label' => __( 'Arrow background dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--tarrow-bg: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_hcolor',
[
'label' => __( 'Arrow color hover', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--tarrow-color-h: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_hcolor_dark',
[
'label' => __( 'Arrow color hover dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--tarrow-color-h: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_hcolor_bg',
[
'label' => __( 'Arrow hover background', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}}' => '--tarrow-bg-h: {{VALUE}}',
],
]
);
$this->add_control(
'jl_arrow_hcolor_bg_dark',
[
'label' => __( 'Arrow hover background dark mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}}' => '--tarrow-bg-h: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'jl_arrow_spacing',
[
'label' => esc_html__( 'Arrow Spacing', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--tarrow-space: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_arrow_size',
[
'label' => esc_html__( 'Arrow Size', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--tarrow-wh: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_arrow_font_size',
[
'label' => esc_html__( 'Arrow Font Size', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--tarrow-fsize: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_arrow_rounded',
[
'label' => esc_html__( 'Arrow Border Rounded', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}}' => '--tarrow-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'jl_hide_meta',
[
'label' => esc_html__( 'Hide date', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_control(
'jl_hide_arr',
[
'label' => esc_html__( 'Hide arrow', 'bopea-function' ),
'type' => Controls_Manager::SWITCHER,
'selectors' => array(
'{{WRAPPER}} .jl_arpw' => 'display: none !important;',
)
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_label_style', [
'label' => esc_html__( 'Label Style', 'bopea-function' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'jl_label_typography',
'label' => __( 'Label Typography', 'bopea-function' ),
'selector' => '{{WRAPPER}} .jl_ticker_lbl',
]
);
$this->add_control(
'jl_label_color',
[
'label' => __( 'Label Color', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl_ticker_lbl' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_label_color_dark',
[
'label' => __( 'Label Color Dark Mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jl_ticker_lbl' => 'color: {{VALUE}}',
],
]
);
$this->add_control(
'jl_label_background',
[
'label' => __( 'Label Background', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .jl_ticker_lbl' => 'background: {{VALUE}}',
],
]
);
$this->add_control(
'jl_label_background_dark',
[
'label' => __( 'Label Background Dark Mode', 'bopea-function' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'.options_dark_skin {{WRAPPER}} .jl_ticker_lbl' => 'background: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'jl_label_spacing',
[
'label' => esc_html__( 'Label spacing', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jl_ticker_wp' => 'gap: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_label_rounded',
[
'label' => esc_html__( 'Label border rounded', 'bopea-function' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px'],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .jl_ticker_lbl' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'jl_label_padding',
[
'label' => __( 'Label padding', 'bopea-function' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%'],
'selectors' => [
'{{WRAPPER}} .jl_ticker_lbl' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
]
]
);
$this->end_controls_section();
}
protected function render( ) {
$settings = $this->get_settings();
if ( function_exists( 'bopea_m_list' ) ) {
$settings['blockid'] = 'blockid_' . $this->get_id();
if(!empty($settings['categories'])){
$settings['categories'] = implode(',', $settings['categories']);
}
echo \bopea_newsticker( $settings );
}
}
public function post_categories() {
$terms = get_terms( array(
'taxonomy' => 'category',
'hide_empty' => false,
'posts_per_page' => -1,
'suppress_filters' => false,
) );
$cat_list = [];
foreach($terms as $post) {
$cat_list[$post->term_id] = [$post->name];
}
return $cat_list;
}
public function post_author() {
$blogusers = get_users( array(
'role__not_in' => array( 'subscriber' ),
'fields' => array( 'ID', 'display_name' )
) );
$user_list = [];
$user_list['none']= esc_html__( 'None', 'bopea-function' );
foreach($blogusers as $user) {
$user_list[$user->ID] = [$user->display_name];
}
return $user_list;
}
public function post_get_type() {
$post_types = get_post_types( '', 'names' );
$type_list = [];
$type_list['none']= esc_html__( 'None', 'bopea-function' );
if ( ! empty( $post_types ) ){
foreach($post_types as $p_type) {
$type_list[$p_type] = [$p_type];
}
}
return $type_list;
}
public function post_get_taxs() {
$taxonomies = get_taxonomies();
$type_taxs = [];
$type_taxs['none']= esc_html__( 'None', 'bopea-function' );
if ( ! empty( $taxonomies ) ){
foreach($taxonomies as $p_taxs) {
$type_taxs[$p_taxs] = [$p_taxs];
}
}
return $type_taxs;
}
}