acf_field_clone::get_rest_schema
Return the schema array for the REST API.
Метод класса: acf_field_clone{}
Хуков нет.
Возвращает
Массив.
Использование
$acf_field_clone = new acf_field_clone(); $acf_field_clone->get_rest_schema( $field );
- $field(массив) (обязательный)
- .
Код acf_field_clone::get_rest_schema() acf field clone::get rest schema ACF 6.4.2
public function get_rest_schema( array $field ) {
$schema = array(
'type' => array( 'object', 'null' ),
'required' => ! empty( $field['required'] ) ? array() : false,
'items' => array(
'type' => 'object',
'properties' => array(),
),
);
foreach ( $field['sub_fields'] as $sub_field ) {
/** @var acf_field $type */
$type = acf_get_field_type( $sub_field['type'] );
if ( ! $type ) {
continue;
}
$sub_field_schema = $type->get_rest_schema( $sub_field );
// Passing null to nested fields has no effect. Remove this as a possible type to prevent
// confusion in the schema.
$null_type_index = array_search( 'null', $sub_field_schema['type'] );
if ( $null_type_index !== false ) {
unset( $sub_field_schema['type'][ $null_type_index ] );
}
$schema['items']['properties'][ $sub_field['name'] ] = $sub_field_schema;
/**
* If the clone field itself is marked as required, all subfields are required,
* regardless of the status of the original fields.
*/
if ( is_array( $schema['required'] ) ) {
$schema['required'][] = $sub_field['name'];
}
}
return $schema;
}