From efa99d8f091879682f582d206c5096751d1d7742 Mon Sep 17 00:00:00 2001 From: Naveen Giri <1naveengiri@gmail.com> Date: Fri, 29 Nov 2024 09:42:09 +0530 Subject: [PATCH] Add option to detect current CPT and show listing based on it --- .../class-geodir-widget-recently-viewed.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/widgets/class-geodir-widget-recently-viewed.php b/includes/widgets/class-geodir-widget-recently-viewed.php index fdc914b7..d6f69e35 100644 --- a/includes/widgets/class-geodir-widget-recently-viewed.php +++ b/includes/widgets/class-geodir-widget-recently-viewed.php @@ -85,7 +85,14 @@ public function set_arguments() { 'advanced' => true ); - + $widget_args['use_viewing_post_type'] = array( + 'title' => __("Use current viewing post type?", 'geodirectory'), + 'type' => 'checkbox', + 'desc_tip' => true, + 'value' => '1', + 'default' => '0', + 'advanced' => true, + ); // not needed in AUI if(!$design_style){ $widget_args['enqueue_slider'] = array( @@ -292,6 +299,15 @@ public function output( $args = array(), $widget_args = array(), $content = '' ) if ( ! geodir_is_gd_post_type( $post_type ) ) { $post_type = 'gd_place'; } + $use_viewing_post_type = ! empty( $args['use_viewing_post_type'] ) ? true : false; + // set post type to current viewing post type + if ( $use_viewing_post_type ) { + $current_post_type = geodir_get_current_posttype(); + if ( $current_post_type != '' && $current_post_type != $post_type ) { + $post_type = $current_post_type; + } + } + $enqueue_slider = ! empty( $args['enqueue_slider'] ) ? true : false; // Elementor pro