Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/happy-elementor-addons/plugin.php
+++ b/happy-elementor-addons/plugin.php
@@ -4,12 +4,12 @@
* Plugin Name: Happy Elementor Addons
* Plugin URI: https://happyaddons.com/
* Description: <a href="https://happyaddons.com/">Happy Addons for Elementor</a> Is the Best Elementor Addons Comes With 44+ Free Elementor Widgets Including Table Builder, Testimonial, Event Calendar,Slider,News Ticker, Image Grid, etc & Features Like Elementor Equal Height, Text Stroke, Shape Dividers, Floating Effect, Grid Layout, 500+ Elementor Icons, 450+ Template Packs & More.
- * Version: 3.20.8
+ * Version: 3.21.0
* Author: Leevio
* Author URI: https://happyaddons.com/
* Requires Plugins: elementor
- * Elementor tested up to: 3.34
- * Elementor Pro tested up to: 3.34
+ * Elementor tested up to: 3.35
+ * Elementor Pro tested up to: 3.35
* License: GPLv2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: happy-elementor-addons
@@ -40,9 +40,9 @@
if ( defined( 'HAPPY_ADDONS_DEV' ) && true == HAPPY_ADDONS_DEV ) {
- define('HAPPY_ADDONS_VERSION', '3.20.8' . time() );
+ define('HAPPY_ADDONS_VERSION', '3.21.0' . time() );
} else {
- define( 'HAPPY_ADDONS_VERSION', '3.20.8' );
+ define( 'HAPPY_ADDONS_VERSION', '3.21.0' );
}
define('HAPPY_ADDONS__FILE__', __FILE__);
define('HAPPY_ADDONS_DIR_PATH', plugin_dir_path(HAPPY_ADDONS__FILE__));
--- a/happy-elementor-addons/widgets/archive-posts/widget.php
+++ b/happy-elementor-addons/widgets/archive-posts/widget.php
@@ -311,6 +311,8 @@
'options' => [
'' => esc_html__('None', 'happy-elementor-addons'),
'numbers' => esc_html__('Numbers', 'happy-elementor-addons'),
+ 'prev_next' => esc_html__('Previous/Next', 'happy-elementor-addons'),
+ 'numbers_and_prev_next' => esc_html__('Numbers and Previous/Next', 'happy-elementor-addons'),
],
'frontend_available' => true,
]
@@ -341,9 +343,9 @@
'default' => esc_html__('« Previous', 'happy-elementor-addons'),
'condition' => [
'pagination_type' => [
- 'numbers',
- // 'prev_next',
- // 'numbers_and_prev_next',
+ // 'numbers',
+ 'prev_next',
+ 'numbers_and_prev_next',
],
],
]
@@ -356,9 +358,9 @@
'default' => esc_html__('Next »', 'happy-elementor-addons'),
'condition' => [
'pagination_type' => [
- 'numbers',
- // 'prev_next',
- // 'numbers_and_prev_next',
+ // 'numbers',
+ 'prev_next',
+ 'numbers_and_prev_next',
],
],
'dynamic' => [
@@ -626,33 +628,42 @@
$this->add_responsive_control(
'image_width',
[
- 'label' => esc_html__('Width', 'happy-elementor-addons'),
+ 'label' => esc_html__('Size', 'happy-elementor-addons'),
'type' => Controls_Manager::SLIDER,
'range' => [
- '%' => [
- 'min' => 10,
- 'max' => 100,
- ],
+ // '%' => [
+ // 'min' => 10,
+ // 'max' => 100,
+ // ],
'px' => [
'min' => 10,
- 'max' => 600,
+ 'max' => 1000,
],
],
'default' => [
- 'size' => 100,
- 'unit' => '%',
- ],
- 'tablet_default' => [
- 'size' => '',
- 'unit' => '%',
- ],
- 'mobile_default' => [
- 'size' => 100,
- 'unit' => '%',
+ 'size' => 250,
+ 'unit' => 'px',
],
+ // 'tablet_default' => [
+ // 'size' => '',
+ // 'unit' => '%',
+ // ],
+ // 'mobile_default' => [
+ // 'size' => 100,
+ // 'unit' => '%',
+ // ],
'size_units' => ['%', 'px'],
'selectors' => [
- '{{WRAPPER}} .ha-archive-posts__thumbnail__link' => 'width: {{SIZE}}{{UNIT}};',
+ // '{{WRAPPER}} .ha-archive-posts__thumbnail__link' => 'width: {{SIZE}}{{UNIT}};',
+ // '{{WRAPPER}}.ha-archive-posts--thumbnail-top .ha-archive-posts__thumbnail__link' => 'width: 100%;',
+
+ '{{WRAPPER}}.ha-archive-posts--thumbnail-top .ha-archive-posts__thumbnail__link' => 'height: {{SIZE}}{{UNIT}}; width: 100%;',
+ '{{WRAPPER}}.ha-archive-posts--thumbnail-left .ha-archive-posts__thumbnail__link' => 'width: {{SIZE}}{{UNIT}}; height: 100%;',
+ '{{WRAPPER}}.ha-archive-posts--thumbnail-right .ha-archive-posts__thumbnail__link' => 'width: {{SIZE}}{{UNIT}};height: 100%;',
+
+ // '{{WRAPPER}}.ha-archive-posts--thumbnail-top .ha-archive-posts__thumbnail' => 'height: {{SIZE}}{{UNIT}}; width: 100%;',
+ '{{WRAPPER}}.ha-archive-posts--thumbnail-left .ha-archive-posts__thumbnail' => 'width: {{SIZE}}{{UNIT}}; height: 100%;',
+ '{{WRAPPER}}.ha-archive-posts--thumbnail-right .ha-archive-posts__thumbnail' => 'width: {{SIZE}}{{UNIT}};height: 100%;',
],
'condition' => [
'thumbnail!' => 'none',
@@ -711,17 +722,6 @@
]
);
- $this->add_control(
- 'title_color',
- [
- 'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-title' => 'color: {{VALUE}}',
- ],
- ]
- );
-
$this->add_group_control(
Group_Control_Typography::get_type(),
[
@@ -749,26 +749,58 @@
]
);
+ $this->start_controls_tabs( 'title_tab' );
+
+ $this->start_controls_tab(
+ 'title_normal',
+ [
+ 'label' => esc_html__( 'Normal', 'happy-elementor-addons' ),
+ ]
+ );
+
$this->add_control(
- 'content_meta',
+ 'title_color',
[
- 'label' => esc_html__( 'Meta', 'happy-elementor-addons' ),
- 'type' => Controls_Manager::HEADING,
- 'separator' => 'before'
+ 'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-title' => 'color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+
+ $this->start_controls_tab(
+ 'title_hover',
+ [
+ 'label' => esc_html__( 'Hover', 'happy-elementor-addons' ),
]
);
$this->add_control(
- 'meta_color',
+ 'title_hover_color',
[
'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
- '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-meta-wrap' => 'color: {{VALUE}}',
+ '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-title:hover' => 'color: {{VALUE}}',
],
]
);
+ $this->end_controls_tab();
+ $this->end_controls_tabs();
+
+ $this->add_control(
+ 'content_meta',
+ [
+ 'label' => esc_html__( 'Meta', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::HEADING,
+ 'separator' => 'before'
+ ]
+ );
+
$this->add_group_control(
Group_Control_Typography::get_type(),
[
@@ -796,6 +828,48 @@
]
);
+ $this->start_controls_tabs( 'meta_tab' );
+ $this->start_controls_tab(
+ 'meta_normal',
+ [
+ 'label' => esc_html__( 'Normal', 'happy-elementor-addons' ),
+ ]
+ );
+
+ $this->add_control(
+ 'meta_color',
+ [
+ 'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-meta-wrap' => 'color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+
+ $this->start_controls_tab(
+ 'meta_hover',
+ [
+ 'label' => esc_html__( 'Hover', 'happy-elementor-addons' ),
+ ]
+ );
+
+ $this->add_control(
+ 'meta_hover_color',
+ [
+ 'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-meta-wrap:hover' => 'color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+ $this->end_controls_tabs();
+
$this->add_control(
'content_excerpt',
[
@@ -852,17 +926,6 @@
]
);
- $this->add_control(
- 'readmore_color',
- [
- 'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
- 'type' => Controls_Manager::COLOR,
- 'selectors' => [
- '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-readmore' => 'color: {{VALUE}}',
- ],
- ]
- );
-
$this->add_group_control(
Group_Control_Typography::get_type(),
[
@@ -890,6 +953,48 @@
]
);
+ $this->start_controls_tabs( 'readmore_tab' );
+ $this->start_controls_tab(
+ 'readmore_normal',
+ [
+ 'label' => esc_html__( 'Normal', 'happy-elementor-addons' ),
+ ]
+ );
+
+ $this->add_control(
+ 'readmore_color',
+ [
+ 'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-readmore' => 'color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+
+ $this->start_controls_tab(
+ 'readmore_hover',
+ [
+ 'label' => esc_html__( 'Hover', 'happy-elementor-addons' ),
+ ]
+ );
+
+ $this->add_control(
+ 'readmore_hover_color',
+ [
+ 'label' => esc_html__( 'Color', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::COLOR,
+ 'selectors' => [
+ '{{WRAPPER}} .ha-archive-posts-container .ha-archive-posts-readmore:hover' => 'color: {{VALUE}}',
+ ],
+ ]
+ );
+
+ $this->end_controls_tab();
+ $this->end_controls_tabs();
+
$this->end_controls_section();
}
@@ -1140,30 +1245,69 @@
public function get_pagination($query) {
- if ('numbers' !== $this->settings['pagination_type']) {
+ if ( empty( $this->settings['pagination_type'] ) ) {
return;
}
- $paged = intval(isset($query->query['paged']) ? $query->query['paged'] : max(1, get_query_var('paged')));
+ // if ( 'numbers' !== $this->settings['pagination_type'] ) {
+ // return;
+ // }
+
+ $pagination_wrap_class = '';
+ if( 'numbers' === $this->settings['pagination_type'] ) {
+ $pagination_wrap_class = 'numbers';
+ } elseif( 'numbers_and_prev_next' === $this->settings['pagination_type'] ) {
+ $pagination_wrap_class = 'numbers-prev-next';
+ } elseif( 'prev_next' === $this->settings['pagination_type'] ) {
+ $pagination_wrap_class = 'prev-next';
+ }
+
+ $paged = intval( isset($query->query['paged']) ? $query->query['paged'] : max(1, get_query_var('paged')) );
+ $total = intval( !empty($this->settings['pagination_page_limit']) ? $this->settings['pagination_page_limit'] : $query->max_num_pages );
+
$big = 99999999; // need an unlikely integer
- $html = paginate_links(
- array(
- 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
- 'format' => '/page/%#%',
- 'current' => max(1, $paged),
- 'total' => intval(!empty($this->settings['pagination_page_limit']) ? $this->settings['pagination_page_limit'] : $query->max_num_pages),
- 'end_size' => 2,
- 'show_all' => 'yes',
- 'type' => 'list',
- 'prev_text' => $this->settings['pagination_prev_label'],
- 'next_text' => $this->settings['pagination_next_label'],
- )
- );
+ $arg = [
+ 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
+ 'format' => '/page/%#%',
+ 'current' => max(1, $paged),
+ 'total' => $total,
+ 'end_size' => 2,
+ 'show_all' => 'yes',
+ 'type' => 'list',
+ 'prev_next' => false,
+ ];
+
+ if( 'numbers_and_prev_next' === $this->settings['pagination_type'] || 'prev_next' === $this->settings['pagination_type'] ) {
+ $arg['prev_next'] = true;
+ $arg['prev_text'] = $this->settings['pagination_prev_label'] ? esc_html( $this->settings['pagination_prev_label'] ) : '«';
+ $arg['next_text'] = $this->settings['pagination_next_label'] ? esc_html( $this->settings['pagination_next_label'] ) : '»';
+ }
+ $prev = '';
+ $next = '';
+ if( 'prev_next' === $this->settings['pagination_type'] ) {
+ if( 1 == $paged ) {
+ $prev = sprintf(
+ '<span class="page-numbers disable">%s</span>',
+ $this->settings['pagination_prev_label'] ? esc_html( $this->settings['pagination_prev_label'] ) : '«'
+ );
+ }
+ if( $paged == $total ) {
+ $next = sprintf(
+ '<span class="page-numbers disable">%s</span>',
+ $this->settings['pagination_next_label'] ? esc_html( $this->settings['pagination_next_label'] ) : '»'
+ );
+ }
+ }
+
+ $html = paginate_links( $arg );
echo sprintf(
- '<div class="ha-archive-posts-pagination">%s</div>',
- wp_kses($html, ha_get_allowed_html_tags('intermediate'))
+ '<div class="ha-archive-posts-pagination %s">%s%s%s</div>',
+ esc_attr( $pagination_wrap_class ),
+ wp_kses($prev, ha_get_allowed_html_tags('intermediate')),
+ wp_kses($html, ha_get_allowed_html_tags('intermediate')),
+ wp_kses($next, ha_get_allowed_html_tags('intermediate'))
);
}
@@ -1250,7 +1394,7 @@
<div class="ha-archive-posts-excerpt">
<?php printf('<p>%1$s</p>', ha_get_excerpt(get_the_ID(), $excerpt_length)); ?>
</div>
-<?php
+ <?php
}
protected function render_read_more($read_more = false, $read_more_text = '') {
--- a/happy-elementor-addons/widgets/post-list/widget.php
+++ b/happy-elementor-addons/widgets/post-list/widget.php
@@ -60,7 +60,7 @@
*/
public function get_post_types() {
$post_types = ha_get_post_types( [], [ 'elementor_library', 'attachment' ] );
- return $post_types;
+ return array_merge($post_types, [ 'current_query' => 'Current Query' ]);
}
/**
@@ -100,6 +100,28 @@
'options' => [
'recent' => __( 'Recent Post', 'happy-elementor-addons' ),
'selected' => __( 'Selected Post', 'happy-elementor-addons' ),
+ 'category' => __( 'Category', 'happy-elementor-addons' ),
+ // 'category' => __( 'Category (only compatible with post type.)', 'happy-elementor-addons' ),
+ ],
+ 'condition' => [
+ 'post_type!' => [ 'current_query' ],
+ ],
+
+ ]
+ );
+
+ $this->add_control(
+ 'category',
+ [
+ 'label' => __( 'Categories', 'happy-elementor-addons' ),
+ 'show_label' => false,
+ 'label_block' => true,
+ 'type' => Controls_Manager::SELECT2,
+ 'options' => $this->get_terms(),
+ 'multiple' => true,
+ 'condition' => [
+ 'post_type' => [ 'post' ],
+ 'show_post_by' => [ 'category' ],
],
]
@@ -113,7 +135,22 @@
'default' => 3,
'dynamic' => [ 'active' => true ],
'condition' => [
- 'show_post_by' => [ 'recent' ],
+ 'post_type!' => [ 'current_query' ],
+ 'show_post_by!' => [ 'selected' ],
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'offset',
+ [
+ 'label' => __( 'Offset', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::NUMBER,
+ // 'default' => 0,
+ 'dynamic' => [ 'active' => false ],
+ 'condition' => [
+ 'post_type!' => [ 'current_query' ],
+ 'show_post_by!' => [ 'selected' ],
],
]
);
@@ -279,6 +316,7 @@
[
'label' => __( 'Icon', 'happy-elementor-addons' ),
'type' => Controls_Manager::ICONS,
+ 'skin' => 'inline',
'label_block' => true,
'default' => [
'value' => 'far fa-check-circle',
@@ -335,6 +373,7 @@
[
'label' => __( 'Author Icon', 'happy-elementor-addons' ),
'type' => Controls_Manager::ICONS,
+ 'skin' => 'inline',
'default' => [
'value' => 'far fa-user',
'library' => 'reguler',
@@ -366,6 +405,7 @@
[
'label' => __( 'Date Icon', 'happy-elementor-addons' ),
'type' => Controls_Manager::ICONS,
+ 'skin' => 'inline',
'default' => [
'value' => 'far fa-calendar-check',
'library' => 'reguler',
@@ -378,6 +418,28 @@
);
$this->add_control(
+ 'date_format',
+ [
+ 'label' => __( 'Date Format', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::SELECT,
+ 'default' => 'site_default',
+ 'options' => [
+ 'site_default' => esc_html__('Site Default', 'happy-elementor-addons'),
+ 'format_1' => esc_html__( date('F j, Y'), 'happy-elementor-addons'),
+ 'format_2' => esc_html__( date('M j, Y'), 'happy-elementor-addons'),
+ 'format_3' => esc_html__( date('Y-m-d'), 'happy-elementor-addons'),
+ 'format_4' => esc_html__( date('m/d/Y'), 'happy-elementor-addons'),
+ 'format_5' => esc_html__( date('d/m/Y'), 'happy-elementor-addons'),
+ 'format_6' => esc_html__( date('d.m.Y'), 'happy-elementor-addons'),
+ ],
+ 'condition' => [
+ 'meta' => 'yes',
+ 'date_meta' => 'yes',
+ ],
+ ]
+ );
+
+ $this->add_control(
'category_meta',
[
'label' => __( 'Category', 'happy-elementor-addons' ),
@@ -398,6 +460,7 @@
[
'label' => __( 'Category Icon', 'happy-elementor-addons' ),
'type' => Controls_Manager::ICONS,
+ 'skin' => 'inline',
'default' => [
'value' => 'far fa-folder-open',
'library' => 'reguler',
@@ -411,6 +474,56 @@
);
$this->add_control(
+ 'custom_meta',
+ [
+ 'label' => __( 'Custom', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::SWITCHER,
+ 'label_on' => __( 'Show', 'happy-elementor-addons' ),
+ 'label_off' => __( 'Hide', 'happy-elementor-addons' ),
+ 'return_value' => 'yes',
+ 'default' => '',
+ 'condition' => [
+ 'meta' => 'yes',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'custom_meta_key',
+ [
+ 'label' => __( 'Custom Meta Key', 'happy-elementor-addons' ),
+ 'description' => __( 'Set custom meta key to show the value. value must be string or integer.', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::TEXT,
+ 'label_block' => true,
+ 'show_label' => false,
+ 'dynamic' => [
+ 'active' => false,
+ ],
+ 'condition' => [
+ 'meta' => 'yes',
+ 'custom_meta' => 'yes',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'custom_meta_icon',
+ [
+ 'label' => __( 'Custom Icon', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::ICONS,
+ 'skin' => 'inline',
+ 'default' => [
+ 'value' => 'far fa-hand-point-right',
+ 'library' => 'reguler',
+ ],
+ 'condition' => [
+ 'meta' => 'yes',
+ 'custom_meta' => 'yes',
+ ],
+ ]
+ );
+
+ $this->add_control(
'meta_position',
[
'label' => __( 'Meta Position', 'happy-elementor-addons' ),
@@ -426,6 +539,27 @@
]
);
+ // $this->add_control(
+ // 'meta_separator',
+ // [
+ // 'label' => esc_html__('Meta Separator', 'happy-elementor-addons'),
+ // 'type' => Controls_Manager::TEXT,
+ // 'default' => '///',
+ // 'ai' => [
+ // 'active' => false,
+ // ],
+ // 'selectors' => [
+ // '{{WRAPPER}} .ha-post-list-meta-wrap span:after' => 'content: "{{VALUE}}";',
+ // ],
+ // 'condition' => [
+ // 'meta' => 'yes',
+ // ],
+ // 'dynamic' => [
+ // 'active' => true
+ // ],
+ // ]
+ // );
+
$this->add_control(
'title_tag',
[
@@ -1049,7 +1183,18 @@
'label' => __( 'Space Between', 'happy-elementor-addons' ),
'type' => Controls_Manager::SLIDER,
'selectors' => [
- '{{WRAPPER}} .ha-post-list-meta-wrap span i' => 'margin-right: {{SIZE}}{{UNIT}};',
+ '{{WRAPPER}} .ha-post-list-meta-wrap span :is(i, svg)' => 'margin-right: {{SIZE}}{{UNIT}};',
+ ],
+ ]
+ );
+
+ $this->add_responsive_control(
+ 'meta_separator_space',
+ [
+ 'label' => __( 'Separator Space', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::SLIDER,
+ 'selectors' => [
+ '{{WRAPPER}} .ha-post-list-meta-wrap span:after' => 'margin-left: {{SIZE}}{{UNIT}};',
],
]
);
@@ -1057,6 +1202,36 @@
$this->end_controls_section();
}
+ protected function get_terms() {
+ $data = [];
+ $terms = get_terms( [
+ 'taxonomy' => 'category',
+ 'hide_empty' => false,
+ ] );
+
+
+ if ( is_wp_error( $terms ) || empty( $terms ) ) {
+ return $data;
+ }
+
+ foreach ( $terms as $term ) {
+ $label = $term->name;
+ // $taxonomy_name = self::get_taxonomy_label( $term->taxonomy );
+ // if ( $taxonomy_name ) {
+ // $label = "{$taxonomy_name}: {$label}";
+ // }
+
+ // $data[] = [
+ // 'id' => $term->term_taxonomy_id,
+ // 'text' => $label,
+ // ];
+
+ $data[ $term->term_taxonomy_id ] = $label;
+ }
+
+ return $data;
+ }
+
protected function render() {
$settings = $this->get_settings_for_display();
@@ -1071,8 +1246,15 @@
'suppress_filters' => false,
];
- if ( 'recent' === $settings['show_post_by'] ) {
+ if ( 'recent' === $settings['show_post_by'] || 'category' === $settings['show_post_by'] ) {
$args['posts_per_page'] = $settings['posts_per_page'];
+ if ( !empty( $settings['offset'] ) ) {
+ $args['offset'] = $settings['offset'];
+ }
+ }
+
+ if ( 'post' === $settings['post_type'] && 'category' === $settings['show_post_by'] && isset($settings['category']) && ! empty( $settings['category'] ) ) {
+ $args['category__in'] = $settings['category'];
}
$customize_title = [];
@@ -1101,12 +1283,33 @@
$args['orderby'] = 'post__in';
}
- if ( 'selected' === $settings['show_post_by'] && empty( $ids ) ) {
+ if ( 'current_query' === $settings['post_type'] ) {
+ global $wp_query;
+ // echo '<pre>';
+ // var_dump($wp_query->query_vars );
+ // var_dump($wp_query);
+ // echo '</pre>';
+ $args = $wp_query->query_vars;
+ // $args['posts_per_page'] = $settings['posts_per_page'];
+ }
+
+ if ( ('selected' === $settings['show_post_by'] && empty( $ids )) || ( 'category' === $settings['show_post_by'] && empty( $settings['category'] ) ) ) {
$posts = [];
} else {
$posts = get_posts( $args );
}
+ $date_format = [
+ 'site_default' => get_option( 'date_format' ),
+ 'format_1' => 'F j, Y',
+ 'format_2' => 'M j, Y',
+ 'format_3' => 'Y-m-d',
+ 'format_4' => 'm/d/Y',
+ 'format_5' => 'd/m/Y',
+ 'format_6' => 'd.m.Y',
+ ];
+ $date_format = isset( $settings['date_format'] ) ? $date_format[ $settings['date_format'] ] : get_option( 'date_format' );
+
$this->add_render_attribute( 'wrapper', 'class', [ 'ha-post-list-wrapper' ] );
$this->add_render_attribute( 'wrapper-inner', 'class', [ 'ha-post-list' ] );
if ( 'inline' === $settings['view'] ) {
@@ -1166,7 +1369,7 @@
if ( $settings['date_icon'] ) :
Icons_Manager::render_icon( $settings['date_icon'], [ 'aria-hidden' => 'true' ] );
endif;
- echo get_the_date( get_option( 'date_format' ), $post->ID );
+ echo get_the_date( $date_format, $post->ID );
?>
</span>
<?php endif; ?>
@@ -1192,6 +1395,28 @@
</span>
<?php endif; ?>
+ <?php if ( 'yes' === $settings['custom_meta'] ) : ?>
+ <span class="ha-post-list-custom-meta">
+ <?php
+ if ( $settings['custom_meta_icon'] ) :
+ Icons_Manager::render_icon( $settings['custom_meta_icon'], [ 'aria-hidden' => 'true' ] );
+ endif;
+ $custom_meta_key = get_post_meta( $post->ID, $settings['custom_meta_key'], true );
+ if ( $custom_meta_key && ('string' == gettype($custom_meta_key) || 'integer' == gettype($custom_meta_key)) ) {
+ echo esc_html( $custom_meta_key );
+ }
+ // echo wp_kses( $custom_meta_key, [
+ // 'a' => [
+ // 'href' => [],
+ // 'title' => [],
+ // 'rel' => [],
+ // ],
+ // 'time' => [],
+ // ] );
+ ?>
+ </span>
+ <?php endif; ?>
+
</div>
<?php endif; ?>
<?php
--- a/happy-elementor-addons/widgets/taxonomy-list/widget.php
+++ b/happy-elementor-addons/widgets/taxonomy-list/widget.php
@@ -330,6 +330,63 @@
);
$this->add_control(
+ 'item_counter_enable',
+ [
+ 'label' => __( 'Item Counter Enable?', 'happy-elementor-addons' ),
+ 'description' => __( 'Enable item counter for each taxonomy item.', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::SWITCHER,
+ 'return_value' => 'yes',
+ 'default' => 'no',
+ ]
+ );
+
+ $this->add_control(
+ 'item_counter_align',
+ [
+ 'label' => __( 'Item Counter Align', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::CHOOSE,
+ 'options' => [
+ 'center' => [
+ 'title' => __( 'Center', 'happy-elementor-addons' ),
+ 'icon' => 'eicon-h-align-center',
+ ],
+ 'stretch' => [
+ 'title' => __( 'Stretch', 'happy-elementor-addons' ),
+ 'icon' => 'eicon-h-align-stretch',
+ ],
+ ],
+ 'toggle' => true,
+ 'selectors_dictionary' => [
+ // 'center' => 'margin-left: 0px',
+ 'center' => '',
+ 'stretch' => 'margin-left: auto;',
+ ],
+ 'selectors' => [
+ '{{WRAPPER}} .ha-taxonomy-list .ha-taxonomy-list-item a span.ha-taxonomy-list-count' => '{{VALUE}};',
+ ],
+ 'condition' => [
+ 'item_counter_enable' => 'yes',
+ 'view' => 'list',
+ ]
+ ]
+ );
+
+ $this->add_control(
+ 'item_counter_align_note',
+ [
+ 'type' => Controls_Manager::NOTICE,
+ 'notice_type' => 'info',
+ 'dismissible' => false,
+ 'content' => __( 'Selecting Item Counter Align "Stretch" will make default alignment unusable.', 'happy-elementor-addons' ),
+ 'condition' => [
+ 'item_counter_enable' => 'yes',
+ 'view' => 'list',
+ 'item_counter_align' => 'stretch',
+ ]
+ ]
+ );
+
+ $this->add_control(
'item_align',
[
'label' => __( 'Alignment', 'happy-elementor-addons' ),
@@ -374,6 +431,7 @@
$this->__list_style_controls();
$this->__title_style_controls();
$this->__icon_image_style_controls();
+ $this->__counter_style_controls();
}
protected function __list_style_controls() {
@@ -569,7 +627,7 @@
'global' => [
'default' => Global_Typography::TYPOGRAPHY_SECONDARY,
],
- 'selector' => '{{WRAPPER}} .ha-taxonomy-list-title',
+ 'selector' => '{{WRAPPER}} .ha-taxonomy-list-title, {{WRAPPER}} .ha-taxonomy-list-count',
]
);
@@ -589,6 +647,7 @@
'default' => '#000000',
'selectors' => [
'{{WRAPPER}} .ha-taxonomy-list-title' => 'color: {{VALUE}}',
+ '{{WRAPPER}} .ha-taxonomy-list-count' => 'color: {{VALUE}}',
],
]
);
@@ -608,6 +667,7 @@
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ha-taxonomy-list .ha-taxonomy-list-item a:hover .ha-taxonomy-list-title' => 'color: {{VALUE}}',
+ '{{WRAPPER}} .ha-taxonomy-list .ha-taxonomy-list-item a:hover .ha-taxonomy-list-count' => 'color: {{VALUE}}',
],
]
);
@@ -724,6 +784,71 @@
$this->end_controls_section();
}
+ protected function __counter_style_controls() {
+
+ $this->start_controls_section(
+ '_section_counter_style',
+ [
+ 'label' => __( 'Counter', 'happy-elementor-addons' ),
+ 'tab' => Controls_Manager::TAB_STYLE,
+ 'condition' => [
+ 'item_counter_enable' => 'yes',
+ ]
+ ]
+ );
+
+ $this->add_group_control(
+ Group_Control_Typography::get_type(),
+ [
+ 'name' => 'counter_typography',
+ 'label' => __( 'Typography', 'happy-elementor-addons' ),
+ 'global' => [
+ 'default' => Global_Typography::TYPOGRAPHY_SECONDARY,
+ ],
+ 'selector' => '{{WRAPPER}} .ha-taxonomy-list-item span.ha-taxonomy-list-count',
+ ]
+ );
+
+ $this->add_control(
+ 'counter_color',
+ [
+ 'label' => __( 'Color', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::COLOR,
+ 'default' => '',
+ 'selectors' => [
+ '{{WRAPPER}} .ha-taxonomy-list-item span.ha-taxonomy-list-count' => 'color: {{VALUE}};',
+ ],
+ ]
+ );
+
+ $this->add_control(
+ 'counter_hvr_color',
+ [
+ 'label' => __( 'Hover Color', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::COLOR,
+ 'default' => '',
+ 'selectors' => [
+ // '{{WRAPPER}} .ha-taxonomy-list-item span.ha-taxonomy-list-count' => 'color: {{VALUE}};',
+ '{{WRAPPER}} .ha-taxonomy-list .ha-taxonomy-list-item a:hover span.ha-taxonomy-list-count' => 'color: {{VALUE}};',
+ ],
+ ]
+ );
+
+ $this->add_responsive_control(
+ 'counter_space_between',
+ [
+ 'label' => __( 'Space Between', 'happy-elementor-addons' ),
+ 'type' => Controls_Manager::SLIDER,
+ 'size_units' => [ 'px' ],
+ 'selectors' => [
+ '{{WRAPPER}} span.ha-taxonomy-list-count' => 'margin-left: {{SIZE}}{{UNIT}};',
+ ],
+ ]
+ );
+
+ $this->end_controls_section();
+ }
+
protected function render() {
$settings = $this->get_settings_for_display();
@@ -763,6 +888,8 @@
}
$this->add_render_attribute( 'item', 'class', [ 'ha-taxonomy-list-item' ] );
+ // error_log( print_r( $lists , 1 ) );
+
if ( count( $terms ) !== 0 && count( $lists ) !== 0 ) :?>
<div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
<ul <?php $this->print_render_attribute_string( 'wrapper-inner' ); ?> >
@@ -792,12 +919,19 @@
if ( array_key_exists( $terms[$index]->term_id, $customize_title ) ) {
$title = $customize_title[$terms[$index]->term_id];
}
+ // $title = "{$title} ({$terms[$index]->count})";
if ( $title ) {
printf( '<%1$s %2$s>%3$s</%1$s>',
ha_escape_tags( $settings['title_tag'], 'h2' ),
'class="ha-taxonomy-list-title"',
esc_html( $title )
);
+ if( 'yes' === $settings['item_counter_enable'] ) {
+ printf( '<span %s>(%s)</span>',
+ 'class="ha-taxonomy-list-count"',
+ esc_html( $terms[$index]->count )
+ );
+ }
}
?>
</a>