upk_is_edit_mode()) {
return ['swiper', 'upk-all-styles'];
} else {
return ['swiper', 'upk-font', 'upk-skide-slider'];
}
}
public function get_script_depends() {
if ($this->upk_is_edit_mode()) {
return ['swiper', 'upk-all-scripts'];
} else {
return ['swiper', 'upk-skide-slider'];
}
}
public function get_custom_help_url() {
return 'https://youtu.be/7-7PbdFi_Ks';
}
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(
'item_height',
[
'label' => esc_html__('Height', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'vh'],
'range' => [
'px' => [
'min' => 200,
'max' => 1080,
],
'vh' => [
'min' => 10,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-skide-item' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'content_max_width',
[
'label' => esc_html__('Content Max Width', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'size_units' => ['px', 'vw', '%'],
'range' => [
'px' => [
'min' => 200,
'max' => 1080,
],
'vw' => [
'min' => 10,
'max' => 100,
],
'%' => [
'min' => 10,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-content' => 'max-width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'content_alignment',
[
'label' => __('Alignment', 'ultimate-post-kit'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', 'ultimate-post-kit'),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __('Center', 'ultimate-post-kit'),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => __('Right', 'ultimate-post-kit'),
'icon' => 'eicon-h-align-right',
],
],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-content' => 'text-align: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'primary_thumbnail',
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude -- Elementor widget query built from user-configured controls; expected behaviour.
'exclude' => ['custom'],
'default' => 'full',
]
);
$this->add_control(
'hr_1',
[
'type' => Controls_Manager::DIVIDER,
]
);
//Global Title Controls
$this->register_title_controls();
$this->add_control(
'show_category',
[
'label' => esc_html__('Show Category', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'show_author',
[
'label' => esc_html__('Show Author', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'separator' => 'before'
]
);
$this->add_control(
'meta_separator',
[
'label' => __('Separator', 'ultimate-post-kit'),
'type' => Controls_Manager::TEXT,
'default' => '//',
'label_block' => false,
]
);
//Global Date Controls
$this->register_date_controls();
//Global Reading Time Controls
$this->register_reading_time_controls();
$this->add_control(
'show_comments',
[
'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
'separator' => 'before'
]
);
$this->add_control(
'show_top_stories',
[
'label' => esc_html__('Show Top Stories', 'ultimate-post-kit') . BDTUPK_PC,
'type' => Controls_Manager::SWITCHER,
'separator' => 'before',
'return_value' => 'yes',
'classes' => BDTUPK_IS_PC
]
);
$this->add_control(
'top_stories_query_heading',
[
'label' => __('Top Stories Item', 'ultimate-post-kit') . BDTUPK_NC,
'type' => Controls_Manager::HEADING,
'condition' => [
'show_top_stories' => 'yes'
]
]
);
$this->add_control(
'top_stories_selected_ids',
[
'label' => __('Select Posts', 'ultimate-post-kit'),
'type' => Dynamic_Select::TYPE,
'multiple' => true,
'label_block' => true,
'condition' => [
'show_top_stories' => 'yes'
]
]
);
$this->end_controls_section();
// Query Settings
$this->start_controls_section(
'section_post_query_builder',
[
'label' => __('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' => 12,
],
'condition' => [
'posts_source!' => 'current_query',
]
]
);
$this->register_query_builder_controls();
$this->end_controls_section();
$this->start_controls_section(
'section_carousel_settings',
[
'label' => __('Slider Settings', 'ultimate-post-kit'),
]
);
$this->add_control(
'autoplay',
[
'label' => __('Autoplay', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'autoplay_speed',
[
'label' => esc_html__('Autoplay Speed', 'ultimate-post-kit'),
'type' => Controls_Manager::NUMBER,
'default' => 5000,
'condition' => [
'autoplay' => 'yes',
],
]
);
$this->add_control(
'pauseonhover',
[
'label' => esc_html__('Pause on Hover', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'condition' => [
'autoplay' => 'yes',
],
]
);
$this->add_control(
'grab_cursor',
[
'label' => __('Grab Cursor', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
]
);
$this->add_control(
'loop',
[
'label' => __('Loop', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'default' => 'yes',
]
);
$this->add_control(
'speed',
[
'label' => __('Animation Speed (ms)', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'default' => [
'size' => 500,
],
'range' => [
'px' => [
'min' => 100,
'max' => 5000,
'step' => 50,
],
],
]
);
$this->add_control(
'observer',
[
'label' => __('Observer', 'ultimate-post-kit'),
'description' => __('When you use carousel in any hidden place (in tabs, accordion etc) keep it yes.', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
]
);
$this->end_controls_section();
//Style
$this->start_controls_section(
'upk_section_style',
[
'label' => esc_html__('Items', 'ultimate-post-kit'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'item_padding',
[
'label' => __('Padding', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'item_margin',
[
'label' => __('Margin', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-content' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$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_color',
[
'label' => esc_html__('Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .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-skide-slider .upk-title a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'title_background',
'selector' => '{{WRAPPER}} .upk-skide-slider .upk-title a',
]
);
$this->add_responsive_control(
'title_border_radius',
[
'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-title a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'title_padding',
[
'label' => __('Padding', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-title a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'title_spacing',
[
'label' => esc_html__('Spacing', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-title' => 'margin-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-skide-slider .upk-title',
]
);
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
[
'name' => 'title_text_shadow',
'label' => __('Text Shadow', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-skide-slider .upk-title a',
]
);
$this->add_group_control(
Group_Control_Text_Stroke::get_type(),
[
'name' => 'title_text_stroke',
'label' => __('Text Stroke', 'ultimate-post-kit') . BDTUPK_NC,
'selector' => '{{WRAPPER}} .upk-skide-slider .upk-title a',
]
);
$this->end_controls_section();
$this->start_controls_section(
'section_style_meta',
[
'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'
],
[
'name' => 'show_comments',
'value' => 'yes'
],
]
],
]
);
$this->add_control(
'meta_color',
[
'label' => esc_html__('Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-meta .upk-date-comments, {{WRAPPER}} .upk-skide-slider .upk-meta .upk-author-name a' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'meta_hover_color',
[
'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-meta .upk-author-name a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'meta_space_between',
[
'label' => esc_html__('Space Between', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-meta .upk-date-comments > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'meta_author_typography',
'label' => esc_html__('Author Typography', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-skide-slider .upk-meta .upk-author-name a',
'condition' => [
'show_author' => 'yes',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'meta_date_typography',
'label' => esc_html__('Date/Comments Typography', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-skide-slider .upk-meta .upk-date-comments',
]
);
$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-skide-slider .upk-category' => 'margin-bottom: {{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-skide-slider .upk-category a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'category_background',
'selector' => '{{WRAPPER}} .upk-skide-slider .upk-category a',
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'category_border',
'selector' => '{{WRAPPER}} .upk-skide-slider .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-skide-slider .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-skide-slider .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,
],
],
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'category_shadow',
'selector' => '{{WRAPPER}} .upk-skide-slider .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-skide-slider .upk-category a',
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_category_hover',
[
'label' => esc_html__('Hover', 'ultimate-post-kit'),
'condition' => [
'show_category' => 'yes'
]
]
);
$this->add_control(
'category_hover_color',
[
'label' => esc_html__('Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-skide-slider .upk-category a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'category_hover_background',
'selector' => '{{WRAPPER}} .upk-skide-slider .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-skide-slider .upk-category a:hover' => 'border-color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'section_style_thumbs',
[
'label' => esc_html__('Thumbs', 'ultimate-post-kit'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->start_controls_tabs('tabs_thumbs_style');
$this->start_controls_tab(
'tab_thumbs_image',
[
'label' => esc_html__('Image', 'ultimate-post-kit'),
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'thumbs_image_border',
'selector' => '{{WRAPPER}} .upk-skide-thumbs .upk-thumbs-img .upk-img',
]
);
$this->add_responsive_control(
'thumbs_image_border_radius',
[
'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .upk-skide-thumbs .upk-thumbs-img .upk-img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'thumbs_img_margin',
[
'label' => __('Margin', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .upk-skide-thumbs .upk-thumbs-img' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'tab_thumbs_title',
[
'label' => esc_html__('Title', 'ultimate-post-kit'),
]
);
$this->add_control(
'thumbs_title_color',
[
'label' => esc_html__('Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-skide-thumbs .upk-title a' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'thumbs_title_margin',
[
'label' => __('Margin', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .upk-skide-thumbs .upk-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'thumbs_title_typography',
'label' => esc_html__('Typography', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-skide-thumbs .upk-title',
]
);
$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();
$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_image($image_id, $size) {
$placeholder_image_src = Utils::get_placeholder_image_src();
$image_src = wp_get_attachment_image_src($image_id, $size);
if (!$image_src) {
$image_src = $placeholder_image_src;
} else {
$image_src = $image_src[0];
}
?>
get_settings_for_display();
if (!$this->get_settings('show_title')) {
return;
}
$title = get_the_title();
printf('<%1$s class="upk-title">%3$s%1$s>', esc_attr(Utils::get_valid_html_tag($settings['title_tags'])), esc_url( get_permalink() ), esc_html( $title ), esc_attr( $title ));
}
public function render_excerpt($excerpt_length) {
if (!$this->get_settings('show_excerpt')) {
return;
}
$strip_shortcode = $this->get_settings_for_display('strip_shortcode');
?>