acf_get_checkbox_input()ACF 5.0.0

acf_get_checkbox_input

Returns the HTML of a checkbox input.

Хуков нет.

Возвращает

Строку.

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

acf_get_checkbox_input( $attrs );
$attrs(массив)
The array of attrs.
По умолчанию: array()

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

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

Код acf_get_checkbox_input() ACF 6.0.4

function acf_get_checkbox_input( $attrs = array() ) {

	// Allow radio or checkbox type.
	$attrs = wp_parse_args(
		$attrs,
		array(
			'type' => 'checkbox',
		)
	);

	// Get label.
	$label = '';
	if ( isset( $attrs['label'] ) ) {
		$label = $attrs['label'];
		unset( $attrs['label'] );
	}

	// Render.
	$checked = isset( $attrs['checked'] );
	return '<label' . ( $checked ? ' class="selected"' : '' ) . '><input ' . acf_esc_attr( $attrs ) . '/> ' . acf_esc_html( $label ) . '</label>';
}