From 2e87ec3bf110c10120d72b35c2105aa081fbcb9e Mon Sep 17 00:00:00 2001 From: claudiulodro Date: Fri, 24 Aug 2018 10:46:57 -0700 Subject: [PATCH] Only suppress comments number on unsupported theme shop page --- includes/class-wc-template-loader.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-template-loader.php b/includes/class-wc-template-loader.php index 67243f59055..5795f29196c 100644 --- a/includes/class-wc-template-loader.php +++ b/includes/class-wc-template-loader.php @@ -212,7 +212,7 @@ class WC_Template_Loader { private static function unsupported_theme_shop_page_init() { add_filter( 'the_content', array( __CLASS__, 'unsupported_theme_shop_content_filter' ), 10 ); add_filter( 'the_title', array( __CLASS__, 'unsupported_theme_title_filter' ), 10, 2 ); - add_filter( 'comments_number', '__return_empty_string' ); + add_filter( 'comments_number', array( __CLASS__, 'unsupported_theme_comments_number_filter' ) ); } /** @@ -501,6 +501,21 @@ class WC_Template_Loader { return $content; } + /** + * Suppress the comments number on the Shop page for unsupported themes since there is no commenting on the Shop page. + * + * @since 3.4.5 + * @param string $comments_number The comments number text. + * @return string + */ + public static function unsupported_theme_comments_number_filter( $comments_number ) { + if ( is_page( self::$shop_page_id ) ) { + return ''; + } + + return $comments_number; + } + /** * Are we filtering content for unsupported themes? *