Thats perfect! But check that you are on menu editing page needed, otherwise you’ll get error message on page editor.
function acf_location_rules_types($choices)
{
$choices['Menu']['menu_level'] = 'Menu Depth';
return $choices;
}
add_filter('acf/location/rule_types', 'acf_location_rules_types');
add_filter('acf/location/rule_values/menu_level', 'acf_location_rule_values_level');
function acf_location_rule_values_level($choices)
{
$choices[0] = '0';
$choices[1] = '1';
return $choices;
}
add_filter('acf/location/rule_match/menu_level', 'acf_location_rule_match_level', 10, 4);
function acf_location_rule_match_level($match, $rule, $options, $field_group)
{
$current_screen = get_current_screen();
if ($current_screen->base == 'nav-menus') {
if ($rule['operator'] == "==") {
$match = ($options['nav_menu_item_depth'] == $rule['value']);
}
}
return $match;
}