Inventory_Presser_Additional_Listings_Pages::is_valid_rule( array $rule )

is_valid_rule


Description Description

True or false, a given additional listing page rule has settings that allow us to create the page. User might not provide the URL path, for example.


Top ↑

Parameters Parameters

$rule

(array) (Required)


Top ↑

Return Return

(bool)


Top ↑

Source Source

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

	public static function is_valid_rule( $rule )
	{
		if( empty( $rule ) )
		{
			return false;
		}

		if( empty( $rule['url_path'] ) )
		{
			return false;
		}

		/**
		 * If the operator is greater than or less than and there is no
		 * comparison value or a comparison value that is not a number, you
		 * might have a bad time.
		 */
		if( ( empty( $rule['value'] ) || ! is_numeric( $rule['value'] ) )
			&& ( 'less_than' == $rule['operator'] || 'greater_than' == $rule['operator'] ) )
		{
			return false;
		}

		/**
		 * If the key points to a value that is not a number and the operator
		 * is less than or greater than, you might have a bad time.
		 */
		if( ! INVP::meta_value_is_number( apply_filters( 'invp_prefix_meta_key', $rule['key'] ) )
			&& ( 'less_than' == $rule['operator'] || 'greater_than' == $rule['operator'] ) )
		{
			return false;
		}

		//you're probably good man
		return true;
	}