ACF_Location::compare_to_rulepublicACF 5.8.1

Compares the given value and rule params returning true when they match.

Method of the class: ACF_Location{}

No Hooks.

Returns

true|false.

Usage

$ACF_Location = new ACF_Location();
$ACF_Location->compare_to_rule( $value, $rule );
$value(mixed) (required)
The value to compare against.
$rule(array) (required)
The location rule data.

Changelog

Since 5.8.1 Introduced.

ACF_Location::compare_to_rule() code ACF 6.0.4

public function compare_to_rule( $value, $rule ) {
	$result = ( $value == $rule['value'] );

	// Allow "all" to match any value.
	if ( $rule['value'] === 'all' ) {
		$result = true;
	}

	// Reverse result for "!=" operator.
	if ( $rule['operator'] === '!=' ) {
		return ! $result;
	}
	return $result;
}