src/class-extended-cpt.php
public static function get_filter_vars( array $query, array $filters ) : array {

		$return = [];

		foreach ( $filters as $filter_key => $filter ) {

			if ( ! isset( $query[ $filter_key ] ) || ( '' === $query[ $filter_key ] ) ) {
				continue;
			}
			if ( isset( $filter['cap'] ) && ! current_user_can( $filter['cap'] ) ) {
				continue;
			}

			if ( isset( $filter['meta_key'] ) ) {
				$meta_query = [
					'key'   => $filter['meta_key'],
					'value' => wp_unslash( $query[ $filter_key ] ),
				];
			} elseif ( isset( $filter['meta_search_key'] ) ) {
				$meta_query = [
					'key'     => $filter['meta_search_key'],
					'value'   => wp_unslash( $query[ $filter_key ] ),
					'compare' => 'LIKE',
				];
			} elseif ( isset( $filter['meta_exists'] ) ) {
				$meta_query = [
					'key'     => wp_unslash( $query[ $filter_key ] ),
					'compare' => 'NOT IN',
					'value'   => [ '', '0', 'false', 'null' ],
				];
			} else {
				continue;
			}

			if ( isset( $filter['meta_query'] ) ) {
				$meta_query = array_merge( $meta_query, $filter['meta_query'] );
			}

			if ( ! empty( $meta_query ) ) {
				$return['meta_query'][] = $meta_query;
			}
		}

		return $return;

	}
public static function get_filter_vars( array $query, array $filters ) : array {

		$return = [];

		foreach ( $filters as $filter_key => $filter ) {

			if ( ! isset( $query[ $filter_key ] ) || ( '' === $query[ $filter_key ] ) ) {
				continue;
			}
			if ( isset( $filter['cap'] ) && ! current_user_can( $filter['cap'] ) ) {
				continue;
			}

			if ( isset( $filter['meta_key'] ) ) {
				$meta_query = [
					'key'   => $filter['meta_key'],
					'value' => wp_unslash( $query[ $filter_key ] ),
				];
			} elseif ( isset( $filter['meta_search_key'] ) ) {
				$meta_query = [
					'key'     => $filter['meta_search_key'],
					'value'   => wp_unslash( $query[ $filter_key ] ),
					'compare' => 'LIKE',
				];
			} elseif ( isset( $filter['meta_exists'] ) ) {
				$meta_query = [
					'key'     => wp_unslash( $query[ $filter_key ] ),
					'compare' => 'NOT IN',
					'value'   => [ '', '0', 'false', 'null' ],
				];
			} else {
				continue;
			}

			if ( isset( $filter['meta_query'] ) ) {
				$meta_query = array_merge( $meta_query, $filter['meta_query'] );
			}

			if ( ! empty( $meta_query ) ) {
				$return['meta_query'][] = $meta_query;
			}
		}

		return $return;

	}
public static function get_filter_vars ( array $ query , array $ filters ) : array { $ return = [ ] ; foreach ( $ filters as $ filter_key => $ filter ) { if ( ! isset ( $ query [ $ filter_key ] ) || ( '' === $ query [ $ filter_key ] ) ) { continue ; } if ( isset ( $ filter [ 'cap' ] ) && ! current_user_can ( $ filter [ 'cap' ] ) ) { continue ; } if ( isset ( $ filter [ 'meta_key' ] ) ) { $ meta_query = [ 'key' => $ filter [ 'meta_key' ] , 'value' => wp_unslash ( $ query [ $ filter_key ] ) , ] ; } elseif ( isset ( $ filter [ 'meta_search_key' ] ) ) { $ meta_query = [ 'key' => $ filter [ 'meta_search_key' ] , 'value' => wp_unslash ( $ query [ $ filter_key ] ) , 'compare' => 'LIKE' , ] ; } elseif ( isset ( $ filter [ 'meta_exists' ] ) ) { $ meta_query = [ 'key' => wp_unslash ( $ query [ $ filter_key ] ) , 'compare' => 'NOT IN' , 'value' => [ '' , '0' , 'false' , 'null' ] , ] ; } else { continue ; } if ( isset ( $ filter [ 'meta_query' ] ) ) { $ meta_query = array_merge ( $ meta_query , $ filter [ 'meta_query' ] ) ; } if ( ! empty ( $ meta_query ) ) { $ return [ 'meta_query' ] [ ] = $ meta_query ; } } return $ return ; }
Get the array of private query vars for the given filters, to apply to the current query in order to filter it by the
given public query vars.

@param  array $query   The public query vars, usually from `$wp_query->query`.
@param  array $filters The filters valid for this query (usually the value of the `admin_filters` or
`site_filters` argument when registering an extended post type).
@return array          The list of private query vars to apply to the query.
Get the array of private query vars for the given filters to apply to the current query in order to filter it by the given public query vars .