upk_is_edit_mode()) {
return ['upk-all-styles'];
} else {
return ['upk-font', 'upk-scott-list'];
}
}
public function get_script_depends() {
if ($this->upk_is_edit_mode()) {
return ['upk-all-scripts'];
} else {
return ['upk-ajax-loadmore'];
}
}
public function get_custom_help_url() {
return 'https://youtu.be/twaysnvoWkM';
}
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'),
]
);
//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(
'show_comments',
[
'label' => esc_html__('Show Comments', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
]
);
$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(
'hr',
[
'type' => Controls_Manager::DIVIDER,
]
);
$this->add_group_control(
Group_Control_Image_Size::get_type(),
[
'name' => 'primary_thumbnail',
'exclude' => ['custom'],
'default' => 'medium',
]
);
$this->add_control(
'show_pagination',
[
'label' => esc_html__('Show Pagination', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'separator' => 'before'
]
);
//Global Ajax Controls
$this->register_ajax_loadmore_controls();
$this->add_control(
'global_link',
[
'label' => __('Item Wrapper Link', 'ultimate-post-kit'),
'type' => Controls_Manager::SWITCHER,
'prefix_class' => 'upk-global-link-',
'description' => __('Be aware! When Item Wrapper Link activated then title link and read more link will not work', 'ultimate-post-kit'),
]
);
$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' => 3,
],
'condition' => [
'posts_source!' => 'current_query',
]
]
);
$this->register_query_builder_controls();
$this->end_controls_section();
//Style
$this->start_controls_section(
'upk_section_style',
[
'label' => esc_html__('Item', 'ultimate-post-kit'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'item_border_style',
[
'label' => esc_html__('Border Style', 'ultimate-post-kit'),
'type' => Controls_Manager::SELECT,
'default' => 'solid',
'options' => [
'none' => esc_html__('None', 'ultimate-post-kit'),
'solid' => esc_html__('Solid', 'ultimate-post-kit'),
'dashed' => esc_html__('Dashed', 'ultimate-post-kit'),
'dotted' => esc_html__('Dotted', 'ultimate-post-kit'),
'double' => esc_html__('Double', 'ultimate-post-kit'),
],
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item' => 'border-top-style: {{VALUE}};',
],
]
);
$this->add_control(
'item_border_color',
[
'label' => esc_html__('Border Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item' => 'border-top-color: {{VALUE}};',
],
'condition' => [
'item_border_style!' => 'none'
]
]
);
$this->add_responsive_control(
'item_border_width',
[
'label' => esc_html__('Border Width', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item' => 'border-top-width: {{SIZE}}{{UNIT}};',
],
'condition' => [
'item_border_style!' => 'none'
]
]
);
$this->add_responsive_control(
'item_border_spacing',
[
'label' => esc_html__('Spacing', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item' => 'padding-top: {{SIZE}}{{UNIT}}; margin-top: {{SIZE}}{{UNIT}};',
],
]
);
$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-scott-list .upk-item .upk-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'separator' => 'before'
]
);
$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__('Style 01', 'ultimate-post-kit'),
'middle-underline' => esc_html__('Style 02', 'ultimate-post-kit'),
'overline' => esc_html__('Style 03', 'ultimate-post-kit'),
'middle-overline' => esc_html__('Style 04', 'ultimate-post-kit'),
'style-5' => esc_html__('Style 05', 'ultimate-post-kit'),
'style-6' => esc_html__('Style 06', 'ultimate-post-kit'),
],
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__('Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-title a' => 'color: {{VALUE}};',
],
'separator' => 'before'
]
);
$this->add_control(
'title_hover_color',
[
'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-title a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__('Typography', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .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-scott-list .upk-item .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-scott-list .upk-item .upk-meta, {{WRAPPER}} .upk-scott-list .upk-item .upk-meta .upk-author-name-wrap .upk-author-name' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'meta_hover_color',
[
'label' => esc_html__('Hover Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-meta .upk-author-name-wrap .upk-author-name:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'meta_spacing',
[
'label' => esc_html__('Spacing', 'ultimate-post-kit'),
'type' => Controls_Manager::SLIDER,
'range' => [
'px' => [
'min' => 0,
'max' => 50,
],
],
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-meta' => 'padding-top: {{SIZE}}{{UNIT}};',
],
]
);
$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-scott-list .upk-item .upk-meta > div:before' => 'margin: 0 {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'meta_typography',
'label' => esc_html__('Typography', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .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-scott-list .upk-item .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-scott-list .upk-item .upk-category a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'category_background',
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-category a',
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'category_border',
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .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-scott-list .upk-item .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-scott-list .upk-item .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-scott-list .upk-item .upk-category a+a' => 'margin-left: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Box_Shadow::get_type(),
[
'name' => 'category_shadow',
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .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-scott-list .upk-item .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-scott-list .upk-item .upk-category a:hover' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'category_hover_background',
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .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-scott-list .upk-item .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_counter_number',
[
'label' => esc_html__('Image', 'ultimate-post-kit'),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'image_overlay_color',
[
'label' => esc_html__('Overlay Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap .upk-img-overlay:before' => 'background: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Border::get_type(),
[
'name' => 'image_border',
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap',
]
);
$this->add_responsive_control(
'image_border_radius',
[
'label' => esc_html__('Border Radius', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', '%'],
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap, {{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap img' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'image_padding',
[
'label' => esc_html__('Padding', 'ultimate-post-kit'),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => ['px', 'em', '%'],
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'counter_number_heading',
[
'label' => esc_html__('Counter Number', 'ultimate-post-kit'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'counter_number_color',
[
'label' => esc_html__('Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:before' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'counter_number_typography',
'label' => esc_html__('Typography', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:before',
]
);
$this->add_control(
'icon_heading',
[
'label' => esc_html__('Icon', 'ultimate-post-kit'),
'type' => Controls_Manager::HEADING,
'separator' => 'before'
]
);
$this->add_control(
'icon_color',
[
'label' => esc_html__('Color', 'ultimate-post-kit'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:after' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'icon_typography',
'label' => esc_html__('Typography', 'ultimate-post-kit'),
'selector' => '{{WRAPPER}} .upk-scott-list .upk-item .upk-image-wrap:after',
]
);
$this->end_controls_section();
//Global Pagination Controls
$this->register_pagination_controls();
//Global Ajax Loadmore Style Controls
$this->register_ajax_loadmore_style_controls();
}
/**
* Get post query builder arguments
*/
public function query_posts( $posts_per_page ) {
$settings = $this->get_settings();
$posts_per_page = isset( $posts_per_page ) ? (int) $posts_per_page : 0;
$args = $this->getGroupControlQueryArgs();
$is_current_query = ( ! empty( $settings['posts_source'] ) && $settings['posts_source'] === 'current_query' );
if ( $is_current_query ) {
unset( $args['offset'] );
unset( $args['no_found_rows'] );
$posts_per_page = 0;
}
if ( $posts_per_page > 0 ) {
$args['posts_per_page'] = $posts_per_page;
} else {
$args['posts_per_page'] = (int) get_option( 'posts_per_page', 10 );
}
if ( $settings['show_pagination'] ) {
$args['paged'] = max( 1, (int) get_query_var( 'paged' ), (int) get_query_var( 'page' ) );
}
$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('show_author')) {
return;
}
?>