ACF_Location_Nav_Menu::match()publicACF 5.9.0

Matches the provided rule against the screen args returning a bool result.

{} Это метод класса: ACF_Location_Nav_Menu{}

Хуков нет.

Возвращает

true|false.

Использование

$ACF_Location_Nav_Menu = new ACF_Location_Nav_Menu();
$ACF_Location_Nav_Menu->match( $rule, $screen, $field_group );
$rule(массив) (обязательный)
The location rule.
$screen(массив) (обязательный)
The screen args.
$field_group(массив) (обязательный)
The field group settings.

Список изменений

С версии 5.9.0 Введена.

Код ACF_Location_Nav_Menu::match() ACF 5.10.2

public function match( $rule, $screen, $field_group ) {

	// Check screen args.
	if ( isset( $screen['nav_menu'] ) ) {
		$nav_menu = $screen['nav_menu'];
	} else {
		return false;
	}

	// Allow for "location/xxx" rule value.
	$bits = explode( '/', $rule['value'] );
	if ( $bits[0] === 'location' ) {
		$location = $bits[1];

		// Get the map of menu locations [location => menu_id] and update $nav_menu to a location value.
		$menu_locations = get_nav_menu_locations();
		if ( isset( $menu_locations[ $location ] ) ) {
			$rule['value'] = $menu_locations[ $location ];
		}
	}

	// Compare rule against $nav_menu.
	return $this->compare_to_rule( $nav_menu, $rule );
}