acf_field_date_and_time_picker::render_field()publicACF 3.6

Create the HTML interface for your field

{} Это метод класса: acf_field_date_and_time_picker{}

Хуков нет.

Возвращает

null. Ничего.

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

$acf_field_date_and_time_picker = new acf_field_date_and_time_picker();
$acf_field_date_and_time_picker->render_field( $field );
$field (обязательный)
-

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

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

Код acf_field_date_and_time_picker::render_field() ACF 5.10.2

<?php
function render_field( $field ) {

	// Set value.
	$hidden_value  = '';
	$display_value = '';

	if ( $field['value'] ) {
		$hidden_value  = acf_format_date( $field['value'], 'Y-m-d H:i:s' );
		$display_value = acf_format_date( $field['value'], $field['display_format'] );
	}

	// Convert "display_format" setting to individual date and time formats.
	$formats = acf_split_date_time( $field['display_format'] );

	// Elements.
	$div          = array(
		'class'            => 'acf-date-time-picker acf-input-wrap',
		'data-date_format' => acf_convert_date_to_js( $formats['date'] ),
		'data-time_format' => acf_convert_time_to_js( $formats['time'] ),
		'data-first_day'   => $field['first_day'],
	);
	$hidden_input = array(
		'id'    => $field['id'],
		'class' => 'input-alt',
		'name'  => $field['name'],
		'value' => $hidden_value,
	);
	$text_input   = array(
		'class' => 'input',
		'value' => $display_value,
	);
	foreach ( array( 'readonly', 'disabled' ) as $k ) {
		if ( ! empty( $field[ $k ] ) ) {
			$hidden_input[ $k ] = $k;
			$text_input[ $k ]   = $k;
		}
	}

	// Output.
	?>
<div <?php acf_esc_attr_e( $div ); ?>>
	<?php acf_hidden_input( $hidden_input ); ?>
	<?php acf_text_input( $text_input ); ?>
</div>
	<?php

}