Tribe__Events__Aggregator__Errors::hide_error_comments( obj $query )

Exclude Aggregator Errors (comments) from showing in Recent Comments widgets Note: On WP 4.1 and above


Parameters

$query

(obj) (Required) WordPress Comment Query Object


Top ↑

Return

(void)


Top ↑

Source

File: src/Tribe/Aggregator/Errors.php

	public function hide_error_comments( $query ) {
		global $wp_version;

		// Only Apply on 4.1 and above
		if ( version_compare( floatval( $wp_version ), '4.1', '<' ) ) {
			return;
		}

		// Prevent this happening if we don't have EA active
		if ( ! tribe( 'events-aggregator.main' )->is_active( true ) ) {
			return;
		}

		// If we passed this type is because we want to query it
		if ( false !== strpos( $query->query_vars['type'], self::$comment_type ) ) {
			return;
		}

		if (
			( // If We have passed type__in as string and we have the comment type, bail
				is_string( $query->query_vars['type__in'] ) &&
				false !== strpos( $query->query_vars['type__in'], self::$comment_type )
			) ||
			( // If we passed type__in as array and we have the comment type, bail
				is_array( $query->query_vars['type__in'] ) &&
				in_array( self::$comment_type, $query->query_vars['type__in'])
			)
		) {
			return;
		}

		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
		if ( ! is_array( $types ) ) {
			$types = array( $types );
		}

		$types[] = self::$comment_type;
		$query->query_vars['type__not_in'] = $types;
	}

Top ↑

Changelog

Changelog
Version Description
4.3.2 Introduced.