upk_is_edit_mode()) { return ['swiper', 'upk-all-styles']; } else { return ['swiper', 'upk-font', 'upk-alice-carousel']; } } public function get_script_depends() { if ($this->upk_is_edit_mode()) { return ['swiper', 'upk-all-scripts']; } else { return ['swiper', 'upk-alice-carousel']; } } public function get_custom_help_url() { return 'https://youtu.be/I0i6q45j6Ps'; } 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_responsive_control( 'columns', [ 'label' => esc_html__('Columns', 'ultimate-post-kit'), 'type' => Controls_Manager::SELECT, 'default' => 3, 'tablet_default' => 2, 'mobile_default' => 1, 'options' => [ 1 => esc_html__('1', 'ultimate-post-kit'), 2 => esc_html__('2', 'ultimate-post-kit'), 3 => esc_html__('3', 'ultimate-post-kit'), 4 => esc_html__('4', 'ultimate-post-kit'), 5 => esc_html__('5', 'ultimate-post-kit'), 6 => esc_html__('6', 'ultimate-post-kit'), ], ] ); $this->add_responsive_control( 'item_gap', [ 'label' => esc_html__('Item Gap', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'default' => [ 'size' => 20, ], 'tablet_default' => [ 'size' => 20, ], 'mobile_default' => [ 'size' => 20, ], 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], ] ); $this->add_responsive_control( 'item_height', [ 'label' => esc_html__('Item Height(px)', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 200, 'max' => 800, ], ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item' => 'height: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'content_position', [ 'label' => esc_html__('Content Position', 'ultimate-post-kit'), 'type' => Controls_Manager::CHOOSE, 'toggle' => false, 'default' => 'bottom-center', 'options' => [ 'bottom-left' => [ 'title' => esc_html__('Left', 'ultimate-post-kit'), 'icon' => 'eicon-text-align-left', ], 'bottom-center' => [ 'title' => esc_html__('Center', 'ultimate-post-kit'), 'icon' => 'eicon-text-align-center', ], 'bottom-right' => [ 'title' => esc_html__('Right', 'ultimate-post-kit'), 'icon' => 'eicon-text-align-right', ], ], ] ); $this->add_group_control( Group_Control_Image_Size::get_type(), [ 'name' => 'primary_thumbnail', 'exclude' => ['custom'], 'default' => 'medium', ] ); $this->end_controls_section(); // Query Settings $this->start_controls_section( 'section_post_query_builder', [ 'label' => esc_html__('Query', 'ultimate-post-kit'), 'tab' => Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'item_limit', [ 'label' => esc_html__('Item Limit', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 1, 'max' => 20, ], ], 'default' => [ 'size' => 5, ], 'condition' => [ 'posts_source!' => 'current_query', ] ] ); $this->register_query_builder_controls(); $this->end_controls_section(); $this->start_controls_section( 'section_content_additional', [ 'label' => esc_html__('Additional Options', 'ultimate-post-kit'), ] ); //Global Title Controls $this->register_title_controls(); $this->add_control( 'show_category', [ 'label' => esc_html__('Category', 'ultimate-post-kit'), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); $this->add_control( 'show_author', [ 'label' => esc_html__('Author', 'ultimate-post-kit'), 'type' => Controls_Manager::SWITCHER, 'default' => 'yes', ] ); //Global Date Controls $this->register_date_controls(); //Global Reading Time Controls $this->register_reading_time_controls(); $this->add_control( 'meta_separator', [ 'label' => esc_html__('Separator', 'ultimate-post-kit'), 'type' => Controls_Manager::TEXT, 'default' => '.', 'label_block' => false, ] ); $this->add_control( 'global_link', [ 'label' => esc_html__('Item Wrapper Link', 'ultimate-post-kit'), 'type' => Controls_Manager::SWITCHER, 'prefix_class' => 'upk-global-link-', 'description' => esc_html__('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'), 'separator' => 'before' ] ); $this->end_controls_section(); //Navigaiton Global Controls $this->register_navigation_controls('alice'); //Style $this->start_controls_section( 'upk_section_style', [ 'label' => esc_html__('Items', 'ultimate-post-kit'), 'tab' => Controls_Manager::TAB_STYLE, ] ); $this->add_responsive_control( 'content_padding', [ 'label' => esc_html__('Content Padding', 'ultimate-post-kit'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em', '%'], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->start_controls_tabs('tabs_item_style'); $this->start_controls_tab( 'tab_item_normal', [ 'label' => esc_html__('Normal', 'ultimate-post-kit'), ] ); $this->add_control( 'overlay_blur_effect', [ 'label' => esc_html__('Glassmorphism', 'ultimate-post-kit'), 'type' => Controls_Manager::SWITCHER, // translators: %1s: Opening anchor tag with link to MDN backdrop-filter documentation, %2s: Closing anchor tag 'description' => sprintf(__('This feature will not work in the Firefox browser untill you enable browser compatibility so please %1s look here %2s', 'ultimate-post-kit'), '', ''), ] ); $this->add_control( 'overlay_blur_level', [ 'label' => esc_html__('Blur Level', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'step' => 1, 'max' => 50, ] ], 'default' => [ 'size' => 5 ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item-box::before' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);' ], 'condition' => [ 'overlay_blur_effect' => 'yes' ] ] ); $this->add_control( 'item_overlay_color', [ 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item-box::before' => 'background: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'item_border', 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-item', ] ); $this->add_responsive_control( 'item_border_radius', [ 'label' => esc_html__('Border Radius', 'ultimate-post-kit'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item-box' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'item_padding', [ 'label' => esc_html__('Padding', 'ultimate-post-kit'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em', '%'], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'item_box_shadow', 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-item', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'tab_item_hover', [ 'label' => esc_html__('Hover', 'ultimate-post-kit'), ] ); $this->add_control( 'overlay_blur_level_hover', [ 'label' => esc_html__('Blur Level', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'step' => 1, 'max' => 50, ] ], 'default' => [ 'size' => 0 ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item:hover .upk-item-box::before' => 'backdrop-filter: blur({{SIZE}}px); -webkit-backdrop-filter: blur({{SIZE}}px);' ], 'condition' => [ 'overlay_blur_effect' => 'yes' ] ] ); $this->add_control( 'item_overlay_hover_color', [ 'label' => esc_html__('Overlay Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item:hover .upk-item-box::before' => 'background: {{VALUE}};', ], ] ); $this->add_control( 'item_hover_border_color', [ 'label' => esc_html__('Border Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'condition' => [ 'item_border_border!' => '', ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-item:hover' => 'border-color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'item_hover_box_shadow', 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-item:hover', ] ); $this->add_responsive_control( 'item_shadow_padding', [ 'label' => esc_html__('Match Padding', 'ultimate-post-kit'), 'description' => esc_html__('You have to add padding for matching overlaping normal/hover box shadow when you used Box Shadow option.', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'step' => 1, 'max' => 50, ] ], 'selectors' => [ '{{WRAPPER}} .swiper-carousel' => 'padding: {{SIZE}}{{UNIT}}; margin: 0 -{{SIZE}}{{UNIT}};' ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); $this->start_controls_section( 'section_style_title', [ 'label' => esc_html__('Title', 'ultimate-post-kit'), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'show_title' => 'yes', ], ] ); $this->add_control( 'title_style', [ 'label' => esc_html__('Style', 'ultimate-post-kit'), 'type' => Controls_Manager::SELECT, 'default' => 'underline', 'options' => [ 'underline' => esc_html__('Underline', 'ultimate-post-kit'), 'middle-underline' => esc_html__('Middle Underline', 'ultimate-post-kit'), 'overline' => esc_html__('Overline', 'ultimate-post-kit'), 'middle-overline' => esc_html__('Middle Overline', 'ultimate-post-kit'), ], ] ); $this->add_control( 'title_color', [ 'label' => esc_html__('Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-title a' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'title_hover_color', [ 'label' => esc_html__('Hover Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-title a:hover' => 'color: {{VALUE}};', ], ] ); $this->add_responsive_control( 'title_spacing', [ 'label' => esc_html__('Spacing', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-title' => 'padding-bottom: {{SIZE}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'label' => esc_html__('Typography', 'ultimate-post-kit'), 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-title', ] ); $this->add_group_control( Group_Control_Text_Shadow::get_type(), [ 'name' => 'title_text_shadow', 'label' => esc_html__('Text Shadow', 'ultimate-post-kit'), 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-title a', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_style_author', [ 'label' => esc_html__('Meta', 'ultimate-post-kit'), 'tab' => Controls_Manager::TAB_STYLE, 'conditions' => [ 'relation' => 'or', 'terms' => [ [ 'name' => 'show_author', 'value' => 'yes' ], [ 'name' => 'show_date', 'value' => 'yes' ] ] ], ] ); $this->add_control( 'author_color', [ 'label' => esc_html__('Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-meta *' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'author_hover_color', [ 'label' => esc_html__('Hover Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-meta .upk-author a:hover' => 'color: {{VALUE}};', ], ] ); // $this->add_control( // 'date_divider_color', // [ // 'label' => esc_html__('Divider Color', 'ultimate-post-kit'), // 'type' => Controls_Manager::COLOR, // 'selectors' => [ // '{{WRAPPER}} .upk-alice-carousel .upk-meta .upk-date:before' => 'background: {{VALUE}};', // ], // ] // ); // $this->add_responsive_control( // 'date_spacing', // [ // 'label' => esc_html__('Spacing', 'ultimate-post-kit'), // 'type' => Controls_Manager::SLIDER, // 'range' => [ // 'px' => [ // 'min' => 0, // 'max' => 50, // 'step' => 2, // ], // ], // 'selectors' => [ // '{{WRAPPER}} .upk-alice-carousel .upk-meta .upk-date' => 'margin-left: {{SIZE}}{{UNIT}}; padding-left: {{SIZE}}{{UNIT}};', // ], // ] // ); $this->add_responsive_control( 'date_spacing', [ 'label' => esc_html__('Space Between', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'author_typography', 'label' => esc_html__('Typography', 'ultimate-post-kit'), 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-meta *', ] ); $this->end_controls_section(); $this->start_controls_section( 'section_style_category', [ 'label' => esc_html__('Category', 'ultimate-post-kit'), 'tab' => Controls_Manager::TAB_STYLE, 'condition' => [ 'show_category' => 'yes', ], ] ); $this->add_responsive_control( 'category_bottom_spacing', [ 'label' => esc_html__('Spacing', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-category' => 'margin: {{SIZE}}{{UNIT}};', ], ] ); $this->start_controls_tabs('tabs_category_style'); $this->start_controls_tab( 'tab_category_normal', [ 'label' => esc_html__('Normal', 'ultimate-post-kit'), ] ); $this->add_control( 'category_color', [ 'label' => esc_html__('Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-category a' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'category_background', 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-category a', ] ); $this->add_group_control( Group_Control_Border::get_type(), [ 'name' => 'category_border', 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-category a', ] ); $this->add_responsive_control( 'category_border_radius', [ 'label' => esc_html__('Border Radius', 'ultimate-post-kit'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-category a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'category_padding', [ 'label' => esc_html__('Padding', 'ultimate-post-kit'), 'type' => Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em', '%'], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-category a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'category_spacing', [ 'label' => esc_html__('Space Between', 'ultimate-post-kit'), 'type' => Controls_Manager::SLIDER, 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, 'step' => 2, ], ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};', ], ] ); $this->add_group_control( Group_Control_Box_Shadow::get_type(), [ 'name' => 'category_shadow', 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-category a', ] ); $this->add_group_control( Group_Control_Typography::get_type(), [ 'name' => 'category_typography', 'label' => esc_html__('Typography', 'ultimate-post-kit'), 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-category a', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'tab_category_hover', [ 'label' => esc_html__('Hover', 'ultimate-post-kit'), ] ); $this->add_control( 'category_hover_color', [ 'label' => esc_html__('Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-category a:hover' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( Group_Control_Background::get_type(), [ 'name' => 'category_hover_background', 'selector' => '{{WRAPPER}} .upk-alice-carousel .upk-category a:hover', ] ); $this->add_control( 'category_hover_border_color', [ 'label' => esc_html__('Border Color', 'ultimate-post-kit'), 'type' => Controls_Manager::COLOR, 'condition' => [ 'category_border_border!' => '', ], 'selectors' => [ '{{WRAPPER}} .upk-alice-carousel .upk-category a:hover' => 'border-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->end_controls_section(); //Navigation Global Controls $this->register_navigation_style('swiper'); } /** * Main query render for this widget * @param $posts_per_page number item query limit */ public function query_posts($posts_per_page) { $default = $this->getGroupControlQueryArgs(); $args = []; 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_author() { if (!$this->get_settings('show_author')) { return; } ?>
get_settings_for_display(); //Global Function $this->render_header_attribute('alice'); ?>
print_render_attribute_string('carousel'); ?>>
print_render_attribute_string('swiper'); ?>>
get_settings_for_display(); if ('yes' == $settings['global_link']) { $this->add_render_attribute('carousel-item', 'onclick', "window.open('" . esc_url(get_permalink()) . "', '_self')", true); } $this->add_render_attribute('carousel-item', 'class', 'upk-item swiper-slide', true); ?>
print_render_attribute_string('carousel-item'); ?>>
render_image(get_post_thumbnail_id($post_id), $image_size); ?>
render_category(); ?>
render_title(substr($this->get_name(), 4)); ?>
render_author(); ?>
render_date(); ?>
get_settings_for_display(); $this->query_posts($settings['item_limit']['size']); $wp_query = $this->get_query(); if (!$wp_query->found_posts) { return; } $this->render_header(); while ($wp_query->have_posts()) { $wp_query->the_post(); $thumbnail_size = $settings['primary_thumbnail_size']; $this->render_post_grid_item(get_the_ID(), $thumbnail_size); } wp_reset_postdata(); $this->render_footer(); } }