ACF\AI\Abilities

FieldGroup::sanitize_location_rulesprivateACF 6.8.0

Sanitize location rules for a field group.

Method of the class: FieldGroup{}

No Hooks.

Returns

Array. The sanitized location rules.

Usage

// private - for code of main (parent) class only
$result = $this->sanitize_location_rules( $location ): array;
$location(array) (required)
The location rules array.

Changelog

Since 6.8.0 Introduced.

FieldGroup::sanitize_location_rules() code ACF 6.8.8

private function sanitize_location_rules( array $location ): array {
	foreach ( $location as &$group ) {
		if ( ! is_array( $group ) ) {
			continue;
		}

		foreach ( $group as &$rule ) {
			if ( ! is_array( $rule ) ) {
				continue;
			}

			if ( isset( $rule['param'] ) ) {
				$rule['param'] = sanitize_text_field( $rule['param'] );
			}

			if ( isset( $rule['operator'] ) ) {
				$rule['operator'] = sanitize_text_field( $rule['operator'] );
			}

			if ( isset( $rule['value'] ) ) {
				$rule['value'] = sanitize_text_field( $rule['value'] );
			}
		}
	}

	return $location;
}