upk_is_edit_mode() ) { return [ 'upk-all-styles' ]; } else { return [ 'upk-news-ticker' ]; } } public function get_script_depends() { if ( $this->upk_is_edit_mode() ) { return [ 'upk-all-scripts' ]; } else { return [ 'news-ticker-js', 'upk-news-ticker' ]; } } public function get_custom_help_url() { return 'https://youtu.be/xiKwQActvwk'; } public function get_query() { return $this->_query; } public function has_widget_inner_wrapper(): bool { return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' ); } protected function register_controls() { $this->start_controls_section( 'section_content_layout', [ 'label' => esc_html__( 'Layout', 'ultimate-post-kit' ), ] ); $this->add_control( 'show_label', [ 'label' => esc_html__( 'Label', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes' ] ); $this->add_control( 'news_label', [ 'label' => esc_html__( 'Label', 'ultimate-post-kit' ), 'type' => Controls_Manager::TEXT, 'dynamic' => [ 'active' => true ], 'default' => esc_html__( 'LATEST NEWS', 'ultimate-post-kit' ), 'placeholder' => esc_html__( 'LATEST NEWS', 'ultimate-post-kit' ), 'condition' => [ 'show_label' => 'yes' ] ] ); $this->add_control( 'news_content', [ 'label' => esc_html__( 'News Content', 'ultimate-post-kit' ), 'type' => Controls_Manager::SELECT, 'default' => 'title', 'options' => [ 'title' => esc_html__( 'Title', 'ultimate-post-kit' ), 'excerpt' => esc_html__( 'Excerpt', 'ultimate-post-kit' ), ], ] ); $this->add_control( 'show_date', [ 'label' => esc_html__( 'Date', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, 'condition' => [ 'news_content' => 'title' ], ] ); $this->add_control( 'date_reverse', [ 'label' => esc_html__( 'Date Reverse', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, 'condition' => [ 'show_date' => 'yes' ], ] ); $this->add_control( 'show_time', [ 'label' => esc_html__( 'Time', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, 'condition' => [ 'news_content' => 'title' ], ] ); $this->add_responsive_control( 'news_ticker_height', [ 'label' => __( 'Height', 'ultimate-post-kit' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 42, ], 'range' => [ 'px' => [ 'min' => 25, 'max' => 200, ], ], 'selectors' => [ '{{WRAPPER}} .upk-news-ticker' => 'height: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}}', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_content_navigation', [ 'label' => esc_html__( 'Navigation', 'ultimate-post-kit' ), ] ); $this->add_control( 'show_navigation', [ 'label' => esc_html__( 'Navigation', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes' ] ); $this->add_control( 'play_pause', [ 'label' => esc_html__( 'Play/Pause Button', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, ] ); $this->add_control( 'navigation_size', [ 'label' => esc_html__( 'Navigation Size', 'ultimate-post-kit' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 14, ], 'range' => [ 'px' => [ 'min' => 10, 'max' => 20, ], ], 'selectors' => [ '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-navigation svg' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}}', ], 'condition' => [ 'show_navigation' => 'yes' ] ] ); $this->end_controls_section(); // Query Settings $this->start_controls_section( 'section_post_query_builder', [ 'label' => __( 'Query', 'ultimate-post-kit' ) . BDTUPK_NC, 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'posts_limit', [ 'label' => esc_html__( 'Posts Limit', 'ultimate-post-kit' ), 'type' => Controls_Manager::NUMBER, 'default' => 5, ] ); $this->register_query_builder_controls(); $this->end_controls_section(); $this->start_controls_section( 'section_style_animation', [ 'label' => esc_html__( 'Animation', 'ultimate-post-kit' ), ] ); $this->add_control( 'slider_animations', [ 'label' => esc_html__( 'Animations', 'ultimate-post-kit' ), 'type' => Controls_Manager::SELECT, 'default' => 'fade', 'options' => [ 'scroll' => esc_html__( 'Scroll', 'ultimate-post-kit' ), 'slide-left' => esc_html__( 'Slide Left', 'ultimate-post-kit' ), 'slide-up' => esc_html__( 'Slide Up', 'ultimate-post-kit' ), 'slide-right' => esc_html__( 'Slide Right', 'ultimate-post-kit' ), 'slide-down' => esc_html__( 'Slide Down', 'ultimate-post-kit' ), 'fade' => esc_html__( 'Fade', 'ultimate-post-kit' ), 'typography' => esc_html__( 'Typography', 'ultimate-post-kit' ), ], ] ); $this->add_control( 'autoplay', [ 'label' => esc_html__( 'Autoplay', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); $this->add_control( 'autoplay_interval', [ 'label' => esc_html__( 'Autoplay Interval', 'ultimate-post-kit' ), 'type' => Controls_Manager::NUMBER, 'default' => 5000, 'condition' => [ 'autoplay' => 'yes', ], ] ); $this->add_control( 'pause_on_hover', [ 'label' => esc_html__( 'Pause on Hover', 'ultimate-post-kit' ), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', 'condition' => [ 'autoplay' => 'yes', ], ] ); $this->add_control( 'speed', [ 'label' => esc_html__( 'Animation Speed', 'ultimate-post-kit' ), 'type' => Controls_Manager::NUMBER, 'default' => 500, ] ); $this->add_control( 'scroll_speed', [ 'label' => __( 'Scroll Speed', 'ultimate-post-kit' ), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 1, ], 'range' => [ 'px' => [ 'min' => 1, 'max' => 10, ], ], 'condition' => [ 'slider_animations' => 'scroll', ], ] ); $this->end_controls_section(); $this->start_controls_section( 'section_style_news_ticker', [ 'label' => esc_html__( 'News Ticker', 'ultimate-post-kit' ), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'heading_label', [ 'label' => esc_html__( 'Label', 'ultimate-post-kit' ), 'type' => Controls_Manager::HEADING, 'condition' => [ 'show_label' => 'yes' ] ] ); $this->add_control( 'label_color', [ 'label' => esc_html__( 'Color', 'ultimate-post-kit' ), 'separator' => 'before', 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-label-inner' => 'color: {{VALUE}};', ], 'condition' => [ 'show_label' => 'yes' ] ] ); $border_side = is_rtl() ? 'right' : 'left'; $this->add_control( 'label_background', [ 'label' => esc_html__( 'Background', 'ultimate-post-kit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-label' => 'background-color: {{VALUE}};', '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-label:after' => 'border-' . $border_side . '-color: {{VALUE}};', ], 'condition' => [ 'show_label' => 'yes' ] ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'label_typography', 'label' => esc_html__( 'Typography', 'ultimate-post-kit' ), //'scheme' => Schemes\Typography::TYPOGRAPHY_1, 'selector' => '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-label-inner', 'condition' => [ 'show_label' => 'yes' ] ] ); $this->add_control( 'heading_content', [ 'label' => esc_html__( 'Content', 'ultimate-post-kit' ), 'type' => Controls_Manager::HEADING, ] ); $this->add_control( 'content_color', [ 'label' => esc_html__( 'Color', 'ultimate-post-kit' ), 'type' => Controls_Manager::COLOR, 'separator' => 'before', 'selectors' => [ '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-content a' => 'color: {{VALUE}};', '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-content span' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'content_background', [ 'label' => esc_html__( 'Background', 'ultimate-post-kit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-news-ticker' => 'background-color: {{VALUE}};', '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-content:before, {{WRAPPER}} .upk-news-ticker .upk-news-ticker-content:after' => 'box-shadow: 0 0 12px 12px {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'content_typography', 'label' => esc_html__( 'Typography', 'ultimate-post-kit' ), 'selector' => '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-content', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_style_navigation', [ 'label' => esc_html__( 'Navigation', 'ultimate-post-kit' ), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'show_navigation' => 'yes' ] ] ); $this->add_control( 'navigation_background', [ 'label' => esc_html__( 'Navigation Background', 'ultimate-post-kit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-navigation' => 'background-color: {{VALUE}}', ], ] ); $this->start_controls_tabs( 'tabs_arrow_style' ); $this->start_controls_tab( 'tab_arrow_normal', [ 'label' => esc_html__( 'Normal', 'ultimate-post-kit' ), ] ); $this->add_control( 'navigation_color', [ 'label' => esc_html__( 'Navigation Color', 'ultimate-post-kit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-navigation button span svg' => 'color: {{VALUE}}', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'tab_arrow_hover', [ 'label' => esc_html__( 'Hover', 'ultimate-post-kit' ), ] ); $this->add_control( 'hover_color', [ 'label' => esc_html__( 'Color', 'ultimate-post-kit' ), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-news-ticker .upk-news-ticker-navigation button:hover span svg' => 'color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); } /** * Main query render for this widget * @param $posts_per_page number item query limit */ public function query_posts( $posts_per_page ) { $default = $this->getGroupControlQueryArgs(); if ( $posts_per_page ) { $args['posts_per_page'] = $posts_per_page; } $args = array_merge( $default, $args ); $this->_query = new WP_Query( $args ); } public function render() { $settings = $this->get_settings_for_display(); $this->query_posts( $settings['posts_limit'] ); $wp_query = $this->get_query(); if ( ! $wp_query->found_posts ) { return; } $this->render_header($settings); while ( $wp_query->have_posts() ) { $wp_query->the_post(); $this->render_loop_item($settings); } $this->render_footer(); wp_reset_postdata(); } protected function render_title() { $classes = ['upk-news-ticker-content-title']; ?> render_date(); ?> render_time(); ?> add_render_attribute( [ 'slider-settings' => [ 'class' => [ 'upk-news-ticker', ], 'data-settings' => [ wp_json_encode(array_filter([ "effect" => $settings["slider_animations"], "autoPlay" => ($settings["autoplay"]) ? true : false, "interval" => $settings["autoplay_interval"], "pauseOnHover" => ($settings["pause_on_hover"]) ? true : false, "scrollSpeed" => (isset( $settings["scroll_speed"]["size"]) ? $settings["scroll_speed"]["size"] : 1), "direction" => (is_rtl()) ? 'rtl' : false ])) ], ] ] ); ?>
print_render_attribute_string( 'slider-settings' ); ?>>
  • render_title(substr($this->get_name(), 4)); ?> render_excerpt(); ?>