acf_field_checkbox::walk() public ACF 1.0
{} Это метод класса: acf_field_checkbox{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$acf_field_checkbox = new acf_field_checkbox(); $acf_field_checkbox->walk( $choices, $args, $depth );
Код acf_field_checkbox::walk() acf field checkbox::walk ACF 5.9.1
function walk( $choices = array(), $args = array(), $depth = 0 ) {
// bail ealry if no choices
if( empty($choices) ) return '';
// defaults
$args = wp_parse_args($args, array(
'id' => '',
'type' => 'checkbox',
'name' => '',
'value' => array(),
'disabled' => array(),
));
// vars
$html = '';
// sanitize values for 'selected' matching
if( $depth == 0 ) {
$args['value'] = array_map('esc_attr', $args['value']);
$args['disabled'] = array_map('esc_attr', $args['disabled']);
}
// loop
foreach( $choices as $value => $label ) {
// open
$html .= '<li>';
// optgroup
if( is_array($label) ){
$html .= '<ul>' . "\n";
$html .= $this->walk( $label, $args, $depth+1 );
$html .= '</ul>';
// option
} else {
// vars
$esc_value = esc_attr($value);
$atts = array(
'id' => $args['id'] . '-' . str_replace(' ', '-', $value),
'type' => $args['type'],
'name' => $args['name'],
'value' => $value,
'label' => $label,
);
// selected
if( in_array( $esc_value, $args['value'] ) ) {
$atts['checked'] = 'checked';
} else {
$this->_all_checked = false;
}
// disabled
if( in_array( $esc_value, $args['disabled'] ) ) {
$atts['disabled'] = 'disabled';
}
// store value added
$this->_values[] = $esc_value;
// append
$html .= acf_get_checkbox_input($atts);
}
// close
$html .= '</li>' . "\n";
}
// return
return $html;
}