acf_field_checkbox::get_rest_schema()publicACF 1.0

Return the schema array for the REST API.

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

Хуков нет.

Возвращает

Массив.

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

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

Код acf_field_checkbox::get_rest_schema() ACF 6.0.4

public function get_rest_schema( array $field ) {
	$schema = array(
		'type'     => array( 'string', 'array', 'null' ),
		'required' => isset( $field['required'] ) && $field['required'],
		'items'    => array(
			'type' => 'string',
		),
	);

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

	// If we allow custom values, nothing else to do here.
	if ( ! empty( $field['allow_custom'] ) ) {
		return $schema;
	}

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

	$schema['items']['enum'] = empty( $checkbox_keys ) ? $field['choices'] : $checkbox_keys;

	return $schema;
}