Inventory_Presser_Plugin::maybe_add_meta_query( array $meta_query, string $key, string $value, string $compare, string $type )

maybe_add_meta_query


Description Description

Filter callback that changes a query's meta_query value if the meta_query does not already contain the provided $key.


Top ↑

Parameters Parameters

$meta_query

(array) (Required) The meta_query member of a WP_Query, retrieved with WP_Query->get('meta_query')

$key

(string) (Required)

$value

(string) (Required)

$compare

(string) (Required)

$type

(string) (Required)


Top ↑

Return Return

(array) The modified $meta_query array


Top ↑

Source Source

File: inventory-presser.php

	function maybe_add_meta_query( $meta_query, $key, $value, $compare, $type )
	{
		//Make sure there is not already $key item in the meta_query
		if( $this->meta_query_contains_key( $meta_query, $key ) )
		{
			return $meta_query;
		}

		$meta_query[] = array(
			'key'     => $key,
			'value'   => $value,
			'compare' => $compare,
			'type'    => $type,
		);
		return $meta_query;
	}