From e68d70857f7030058c690f6b9cff879f348dba18 Mon Sep 17 00:00:00 2001 From: Sorin Marta Date: Mon, 20 Jul 2026 20:59:19 +0300 Subject: [PATCH] Fix AWPCPBROWSECATS to render categories list Route the shortcode to View Categories UI and update page detection callers. --- frontend/class-categories-switcher.php | 2 +- frontend/class-query.php | 2 +- ...wards-compatibility-redirection-helper.php | 2 +- frontend/shortcode.php | 23 +++++++++++++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/frontend/class-categories-switcher.php b/frontend/class-categories-switcher.php index 3b1aa0fe2..4bb55023d 100644 --- a/frontend/class-categories-switcher.php +++ b/frontend/class-categories-switcher.php @@ -38,7 +38,7 @@ public function __construct() { * @param array $params An array of parameters for the Categories Switcher component. */ public function render( $params = array() ) { - if ( $this->query->is_browse_listings_page() || $this->query->is_browse_categories_page() ) { + if ( $this->query->is_browse_listings_page() ) { $action_url = awpcp_current_url(); } else { $action_url = awpcp_get_browse_categories_page_url(); diff --git a/frontend/class-query.php b/frontend/class-query.php index 4b59a6da1..6c0fd8410 100644 --- a/frontend/class-query.php +++ b/frontend/class-query.php @@ -71,7 +71,7 @@ public function is_page_that_has_shortcode( $shortcode ) { } public function is_browse_categories_page() { - return $this->is_browse_listings_page(); + return $this->is_page_that_has_shortcode( 'AWPCPBROWSECATS' ); } public function is_renew_listing_page() { diff --git a/frontend/class-url-backwards-compatibility-redirection-helper.php b/frontend/class-url-backwards-compatibility-redirection-helper.php index c05220f7c..33929d96b 100644 --- a/frontend/class-url-backwards-compatibility-redirection-helper.php +++ b/frontend/class-url-backwards-compatibility-redirection-helper.php @@ -122,7 +122,7 @@ public function maybe_redirect_frontend_request() { return; } - if ( $this->query->is_browse_listings_page() || $this->query->is_browse_categories_page() ) { + if ( $this->query->is_browse_listings_page() ) { $this->maybe_redirect_browse_listings_request(); return; } diff --git a/frontend/shortcode.php b/frontend/shortcode.php index 0ed37b1f7..4a5df413e 100644 --- a/frontend/shortcode.php +++ b/frontend/shortcode.php @@ -64,7 +64,7 @@ public function init() { add_shortcode( 'AWPCPPAYMENTTHANKYOU', array( $this, 'noop' ) ); add_shortcode( 'AWPCPCANCELPAYMENT', array( $this, 'noop' ) ); - add_shortcode( 'AWPCPBROWSECATS', array( $this->browse_ads, 'dispatch' ) ); + add_shortcode( 'AWPCPBROWSECATS', array( $this, 'browse_categories' ) ); add_shortcode( 'AWPCPBROWSEADS', array( $this->browse_ads, 'dispatch' ) ); add_shortcode( 'AWPCPSHOWAD', array( $this, 'show_ad' ) ); @@ -141,6 +141,25 @@ public function search_ads() { return $this->output['search-ads']; } + /** + * Renders the View Categories list (same UI as main-page layout=2). + * + * Previously aliased to Browse Ads for backwards compatibility. + * + * @since x.x + * + * @return string + */ + public function browse_categories() { + if ( ! isset( $this->output['browse-categories'] ) ) { + awpcp_enqueue_main_script(); + + $this->output['browse-categories'] = awpcp_display_the_classifieds_page_body( '' ); + } + + return $this->output['browse-categories']; + } + public function reply_to_ad() { if ( ! isset( $this->output['reply-to-ad'] ) ) { do_action( 'awpcp-shortcode', 'reply-to-ad' ); @@ -492,7 +511,7 @@ function awpcp_get_menu_items( $params ) { } if ( $show_browse_ads_item ) { - if ( awpcp_is_browse_listings_page() || awpcp_is_browse_categories_page() ) { + if ( awpcp_is_browse_listings_page() ) { if ( get_awpcp_option( 'main_page_display' ) ) { $browse_cats_url = awpcp_get_view_categories_url(); } else {