acf_build_bidirectional_target_current_choices()
Build the complete choices argument for rendering the select2 field for bidirectional target based on the currently selected choices
Хуков нет.
Возвращает
Массив.
Использование
acf_build_bidirectional_target_current_choices( $choices );
- $choices(массив) (обязательный)
- The currently selected choices (as an array of field keys).
Список изменений
| С версии 6.2 | Введена. |
Код acf_build_bidirectional_target_current_choices() acf build bidirectional target current choices ACF 6.4.2
function acf_build_bidirectional_target_current_choices( $choices ) {
if ( empty( $choices ) ) {
return array();
}
$results = array();
foreach ( $choices as $choice ) {
if ( empty( $choice ) || ! is_string( $choice ) ) {
continue;
}
$field_object = get_field_object( $choice );
if ( is_array( $field_object ) && ! empty( $field_object['label'] ) ) {
$results[ $choice ] = $field_object['label'];
} else {
$results[ $choice ] = $choice;
}
}
return $results;
}