Automattic\WooCommerce\Internal\Admin\ProductReviews

ReviewsCommentsOverrides::exclude_reviews_from_comments()protectedWC 1.0

Excludes product reviews from showing in the comments page.

Method of the class: ReviewsCommentsOverrides{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->exclude_reviews_from_comments( $args ) : array;
$args(array|mixed) (required)
WP_Comment_Query{} query args.

ReviewsCommentsOverrides::exclude_reviews_from_comments() code WC 7.1.0

protected function exclude_reviews_from_comments( $args ) : array {

	if ( ! empty( $args['post_type'] ) && $args['post_type'] !== 'any' ) {
		$post_types = (array) $args['post_type'];
	} else {
		$post_types = get_post_types();
	}

	$index = array_search( 'product', $post_types );

	if ( $index !== false ) {
		unset( $post_types[ $index ] );
	}

	if ( ! is_array( $args ) ) {
		$args = [];
	}

	$args['post_type'] = $post_types;

	return $args;
}