Skip to content

Commit 590f4cb

Browse files
author
Mizanur Rahaman
committed
updated config file
1 parent b780621 commit 590f4cb

File tree

2 files changed

+74
-14
lines changed

2 files changed

+74
-14
lines changed

config.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@
574574
'youtube_url' => '',
575575
'description' => 'Enhance your site’s usability by creating responsive, stylish, and fully customizable navigation menus.'
576576
],
577-
'mega-menu' => [
577+
'mega-menu' => [
578578
'label' => 'Mega Menu',
579579
'location' => [
580580
'cTab' => 'all'
@@ -1067,6 +1067,21 @@
10671067
'youtube_url' => '',
10681068
'description' => 'Add a search form widget for users to efficiently locate content across your website.'
10691069
],
1070+
'advanced-search' => [
1071+
'label' => 'Advanced Search',
1072+
'location' => [
1073+
'cTab' => 'all'
1074+
],
1075+
'is_active' => false,
1076+
'is_pro' => true,
1077+
'is_extension' => false,
1078+
'is_upcoming' => false,
1079+
'icon' => "wcf-icon-Search-Form",
1080+
'demo_url' => '',
1081+
'doc_url' => '',
1082+
'youtube_url' => '',
1083+
'description' => ''
1084+
],
10701085
'search-query' => [
10711086
'label' => 'Search Query',
10721087
'location' => [
@@ -1097,6 +1112,21 @@
10971112
'youtube_url' => '',
10981113
'description' => 'Customize the "no results" message with rich text, media, or links for better user direction.'
10991114
],
1115+
'live-events' => [
1116+
'label' => 'Live Events',
1117+
'location' => [
1118+
'cTab' => 'all'
1119+
],
1120+
'is_active' => false,
1121+
'is_pro' => true,
1122+
'is_extension' => false,
1123+
'is_upcoming' => false,
1124+
'icon' => "wcf-icon-Search-No-Result",
1125+
'demo_url' => '',
1126+
'doc_url' => '',
1127+
'youtube_url' => '',
1128+
'description' => ''
1129+
],
11001130
]
11011131
],
11021132
'form-elements' => [

inc/trait-wcf-post-query.php

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ protected function register_query_controls() {
9595
'top_post_week',
9696
'most_popular',
9797
'trending_score',
98-
'most_share_count'
98+
'most_share_count',
99+
'last_12_hours',
100+
'last_24_hours'
99101
]
100102
],
101103
]
@@ -249,19 +251,19 @@ protected function register_query_controls() {
249251
'type' => Controls_Manager::SELECT2,
250252
'default' => [],
251253
'multiple' => true,
252-
'options' => $this->get_taxonomy_terms('category'), // Fetch categories dynamically
254+
'options' => $this->get_taxonomy_terms( 'category' ), // Fetch categories dynamically
253255
'condition' => [ 'post_type' => [ 'post' ], 'include' => 'terms' ],
254256
]
255257
);
256-
258+
257259
$this->add_control(
258260
'post_tags',
259261
[
260262
'label' => esc_html__( 'Post Tags', 'animation-addons-for-elementor' ),
261263
'type' => Controls_Manager::SELECT2,
262264
'default' => [],
263265
'multiple' => true,
264-
'options' => $this->get_taxonomy_terms('post_tag'), // Fetch tags dynamically
266+
'options' => $this->get_taxonomy_terms( 'post_tag' ), // Fetch tags dynamically
265267
'condition' => [ 'post_type' => [ 'post' ], 'include' => 'terms' ],
266268
]
267269
);
@@ -412,7 +414,7 @@ protected function query_arg() {
412414
if ( ! empty( $this->get_settings( 'include' ) ) ) {
413415
if ( in_array( 'terms', $this->get_settings( 'include' ) ) ) {
414416
$query_args['tax_query'] = [];
415-
417+
416418
if ( ! empty( $this->get_settings( 'include_term_ids' ) ) ) {
417419
$terms = [];
418420

@@ -437,23 +439,23 @@ protected function query_arg() {
437439
}
438440
}
439441
//post_categories
440-
if ( ! empty( $this->get_settings( 'post_categories' ) ) ) {
442+
if ( ! empty( $this->get_settings( 'post_categories' ) ) ) {
441443
// Add category filter using term names
442444
$query_args['tax_query'][] = [
443445
'taxonomy' => 'category',
444446
'field' => 'name', // Use 'name' instead of 'term_id'
445447
'terms' => $this->get_settings( 'post_categories' )
446448
];
447449
}
448-
if ( ! empty( $this->get_settings( 'post_tags' ) ) ) {
450+
if ( ! empty( $this->get_settings( 'post_tags' ) ) ) {
449451
// Add tag filter using term names
450452
$query_args['tax_query'][] = [
451453
'taxonomy' => 'post_tag',
452454
'field' => 'name', // Use 'name' instead of 'term_id'
453455
'terms' => $this->get_settings( 'post_tags' )
454456
];
455457
}
456-
458+
457459
}
458460

459461
if ( ! empty( $this->get_settings( 'include_authors' ) ) ) {
@@ -519,6 +521,34 @@ protected function query_arg() {
519521
}
520522
}
521523

524+
if ( 'last_12_hours' === $this->get_settings( 'query_type' ) ) {
525+
$query_args['order'] = 'DESC';
526+
$query_args['date_query'] = [
527+
[
528+
'after' => '-12 hours',
529+
'inclusive' => true,
530+
],
531+
];
532+
533+
if ( isset( $query_args['ignore_sticky_posts'] ) ) {
534+
unset( $query_args['ignore_sticky_posts'] );
535+
}
536+
}
537+
538+
if ( 'last_24_hours' === $this->get_settings( 'query_type' ) ) {
539+
$query_args['order'] = 'DESC';
540+
$query_args['date_query'] = [
541+
[
542+
'after' => '-24 hours',
543+
'inclusive' => true,
544+
],
545+
];
546+
547+
if ( isset( $query_args['ignore_sticky_posts'] ) ) {
548+
unset( $query_args['ignore_sticky_posts'] );
549+
}
550+
}
551+
522552
if ( 'most_popular' === $this->get_settings( 'query_type' ) ) {
523553

524554
$query_args['orderby'] = array(
@@ -630,24 +660,24 @@ protected function query_arg() {
630660
if ( 'recent_visited' === $this->get_settings( 'query_type' ) ) {
631661
// Retrieve and decode the cookie data
632662
$visited_posts = isset( $_COOKIE['aae_visited_posts'] ) ? json_decode( sanitize_text_field( wp_unslash( $_COOKIE['aae_visited_posts'] ) ), true ) : [];
633-
663+
634664
// Check if the decoded data is an array
635665
if ( is_array( $visited_posts ) ) {
636666
$post_type = $this->get_settings( 'post_type' );
637-
667+
638668
// Check if the post type exists in the visited posts array and is an array
639669
if ( isset( $visited_posts[ $post_type ] ) && is_array( $visited_posts[ $post_type ] ) ) {
640670
// Sanitize each post ID to ensure they are positive integers
641671
$post_ids = array_map( 'absint', $visited_posts[ $post_type ] );
642-
672+
643673
// If there are valid post IDs, assign them to the query arguments
644674
if ( ! empty( $post_ids ) ) {
645675
$query_args['post__in'] = $post_ids;
646676
}
647677
}
648678
}
649679
}
650-
680+
651681
if ( $this->get_settings( 'post_layout' ) && ( $this->get_settings( 'post_layout' ) == 'layout-gallery' || $this->get_settings( 'post_layout' ) == 'layout-gallery-2' ) ) {
652682
$query_args['tax_query'][] = [
653683
'taxonomy' => 'post_format',
@@ -673,7 +703,7 @@ protected function query_arg() {
673703
];
674704
}
675705

676-
706+
677707
return $query_args;
678708
}
679709

0 commit comments

Comments
 (0)