acf_field_checkbox::walk()publicACF 1.0

Метод класса: acf_field_checkbox{}

Хуков нет.

Возвращает

null. Ничего (null).

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

$acf_field_checkbox = new acf_field_checkbox();
$acf_field_checkbox->walk( $choices, $args, $depth );
$choices **
-
По умолчанию: array()
$args **
-
По умолчанию: array()
$depth **
-

Код acf_field_checkbox::walk() ACF 6.0.4

function walk( $choices = array(), $args = array(), $depth = 0 ) {

	// bail early 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;

}