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 8.7.0

protected function exclude_reviews_from_comments( $args ) : array {
	$screen = get_current_screen();

	// We only wish to intervene if the edit comments screen has been requested.
	if ( ! $screen instanceof WP_Screen || 'edit-comments' !== $screen->id ) {
		return $args;
	}

	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;
}