acf_field_flexible_content::get_rest_schema()
Return the schema array for the REST API.
Метод класса: acf_field_flexible_content{}
Хуков нет.
Возвращает
Массив
.
Использование
$acf_field_flexible_content = new acf_field_flexible_content(); $acf_field_flexible_content->get_rest_schema( $field );
- $field(массив) (обязательный)
- -
Код acf_field_flexible_content::get_rest_schema() acf field flexible content::get rest schema ACF 6.0.4
public function get_rest_schema( array $field ) { $schema = array( 'type' => array( 'array', 'null' ), 'required' => ! empty( $field['required'] ), 'items' => array( 'oneOf' => array(), ), ); // Loop through layouts building up a schema for each. foreach ( $field['layouts'] as $layout ) { $layout_schema = array( 'type' => 'object', 'properties' => array( 'acf_fc_layout' => array( 'type' => 'string', 'required' => true, // By using a pattern match against the layout name, data sent in must match an available // layout on the flexible field. If it doesn't, a 400 Bad Request response will result. 'pattern' => '^' . $layout['name'] . '$', ), ), ); foreach ( $layout['sub_fields'] as $sub_field ) { if ( $sub_field_schema = acf_get_field_rest_schema( $sub_field ) ) { $layout_schema['properties'][ $sub_field['name'] ] = $sub_field_schema; } } $schema['items']['oneOf'][] = $layout_schema; } if ( ! empty( $field['min'] ) ) { $schema['minItems'] = (int) $field['min']; } if ( ! empty( $field['max'] ) ) { $schema['maxItems'] = (int) $field['max']; } return $schema; }