acf_field_date_picker::render_field_settings()publicACF 3.6

Create extra options for your field. This is rendered when editing a field. The value of $field['name'] can be used (like bellow) to save extra data to the $field

@type action

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

Хуков нет.

Возвращает

null. Ничего.

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

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

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

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

Код acf_field_date_picker::render_field_settings() ACF 5.10.2

function render_field_settings( $field ) {

	// global
	global $wp_locale;

	// vars
	$d_m_Y = date_i18n( 'd/m/Y' );
	$m_d_Y = date_i18n( 'm/d/Y' );
	$F_j_Y = date_i18n( 'F j, Y' );
	$Ymd   = date_i18n( 'Ymd' );

	// display_format
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Display Format', 'acf' ),
			'instructions' => __( 'The format displayed when editing a post', 'acf' ),
			'type'         => 'radio',
			'name'         => 'display_format',
			'other_choice' => 1,
			'choices'      => array(
				'd/m/Y'  => '<span>' . $d_m_Y . '</span><code>d/m/Y</code>',
				'm/d/Y'  => '<span>' . $m_d_Y . '</span><code>m/d/Y</code>',
				'F j, Y' => '<span>' . $F_j_Y . '</span><code>F j, Y</code>',
				'other'  => '<span>' . __( 'Custom:', 'acf' ) . '</span>',
			),
		)
	);

	// save_format - compatibility with ACF < 5.0.0
	if ( ! empty( $field['save_format'] ) ) {

		// save_format
		acf_render_field_setting(
			$field,
			array(
				'label'        => __( 'Save Format', 'acf' ),
				'instructions' => __( 'The format used when saving a value', 'acf' ),
				'type'         => 'text',
				'name'         => 'save_format',
			// 'readonly'        => 1 // this setting was not readonly in v4
			)
		);

	} else {

		// return_format
		acf_render_field_setting(
			$field,
			array(
				'label'        => __( 'Return Format', 'acf' ),
				'instructions' => __( 'The format returned via template functions', 'acf' ),
				'type'         => 'radio',
				'name'         => 'return_format',
				'other_choice' => 1,
				'choices'      => array(
					'd/m/Y'  => '<span>' . $d_m_Y . '</span><code>d/m/Y</code>',
					'm/d/Y'  => '<span>' . $m_d_Y . '</span><code>m/d/Y</code>',
					'F j, Y' => '<span>' . $F_j_Y . '</span><code>F j, Y</code>',
					'Ymd'    => '<span>' . $Ymd . '</span><code>Ymd</code>',
					'other'  => '<span>' . __( 'Custom:', 'acf' ) . '</span>',
				),
			)
		);

	}

	// first_day
	acf_render_field_setting(
		$field,
		array(
			'label'        => __( 'Week Starts On', 'acf' ),
			'instructions' => '',
			'type'         => 'select',
			'name'         => 'first_day',
			'choices'      => array_values( $wp_locale->weekday ),
		)
	);

}