acf_field_select::get_rest_schema()publicACF 1.0

Return the schema array for the REST API.

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

Хуков нет.

Возвращает

Массив.

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

$acf_field_select = new acf_field_select();
$acf_field_select->get_rest_schema( $field );
$field(массив) (обязательный)
-

Код acf_field_select::get_rest_schema() ACF 6.0.4

public function get_rest_schema( array $field ) {
	/**
	 * If a user has defined keys for the select options,
	 * we should use the keys for the available options to POST to,
	 * since they are what is displayed in GET requests.
	 */
	$option_keys = array_diff(
		array_keys( $field['choices'] ),
		array_values( $field['choices'] )
	);

	$schema = array(
		'type'     => array( 'string', 'array', 'int', 'null' ),
		'required' => ! empty( $field['required'] ),
		'items'    => array(
			'type' => array( 'string', 'int' ),
			'enum' => empty( $option_keys ) ? $field['choices'] : $option_keys,
		),
	);

	if ( empty( $field['allow_null'] ) ) {
		$schema['minItems'] = 1;
	}

	if ( empty( $field['multiple'] ) ) {
		$schema['maxItems'] = 1;
	}

	if ( isset( $field['default_value'] ) && '' !== $field['default_value'] ) {
		$schema['default'] = $field['default_value'];
	}

	return $schema;
}