Inventory_Presser_Additional_Listings_Pages::get_query_meta_array( array $rule )

get_query_meta_array


Description Description

Turns additional listing page rules into SQL query pieces.


Top ↑

Parameters Parameters

$rule

(array) (Required)


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-additional-listings-pages.php

	public static function get_query_meta_array( $rule )
	{
		$new = null;
		switch( $rule['operator'] )
		{
			case 'does_not_exist':
				$new = array(
					'relation' => 'AND',
					array(
						'key'     => apply_filters( 'invp_prefix_meta_key', $rule['key'] ),
						'compare' => 'NOT EXISTS'
					),
				);
				break;

			case 'equal_to':
			case 'not_equal_to':
				$new = array(
					'relation' => 'AND',
					array(
						'key'     => apply_filters( 'invp_prefix_meta_key', $rule['key'] ),
						'compare' => ( 'equal_to' == $rule['operator'] ? '=' : '!=' ),
						'value'   => $rule['value'],
					),
				);
				break;

			case 'exists':
				$new = array(
					'relation' => 'AND',
					array(
						'key'     => apply_filters( 'invp_prefix_meta_key', $rule['key'] ),
						'compare' => 'EXISTS'
					),
					array(
						'key'     => apply_filters( 'invp_prefix_meta_key', $rule['key'] ),
						'value'   => array( '', 0 ),
						'compare' => 'NOT IN'
					),
				);
				break;

			case 'greater_than':
			case 'less_than':
				$new = array(
					'relation' => 'AND',
					array(
						'key'     => apply_filters( 'invp_prefix_meta_key', $rule['key'] ),
						'compare' => ( 'greater_than' == $rule['operator'] ? '>' : '<' ),
						'value'   => ((float)$rule['value']),
						'type'    => 'NUMERIC',
					),
				);
				break;
		}
		return $new;
	}