@@ -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