ACF_Rest_Api::get_fields()
Get all ACF fields for a given field group and allow third party filtering.
Метод класса: ACF_Rest_Api{}
Хуки из метода
Возвращает
Массив
.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_fields( $field_group, $object_id );
- $field_group(массив) (обязательный)
- This could technically be other possible values supported by acf_get_fields() but in this context, we're only using the field group arrays.
- $object_id(null|int)
- The ID of the object being prepared.
По умолчанию: null
Код ACF_Rest_Api::get_fields() ACF Rest Api::get fields ACF 6.0.4
private function get_fields( $field_group, $object_id = null ) { // Get all fields for this field group that are rest enabled. $fields = array_filter( acf_get_fields( $field_group ), function ( $field ) { $field_type = acf_get_field_type( $field['type'] ); return isset( $field_type->show_in_rest ) && $field_type->show_in_rest; } ); // Set up context array for use in the filter below. $resource = array( 'type' => $this->request->object_type, 'sub_type' => $this->request->object_sub_type, 'id' => $object_id, ); $http_method = $this->request->http_method; /** * Filter the fields available to the REST API. * * @param array $fields The ACF fields for this field group. * @param array $resource Contextual information about the current resource request. * @param string $http_method The HTTP method of the current request (GET, POST, PUT, PATCH, DELETE, OPTION, HEAD). */ return (array) apply_filters( 'acf/rest/get_fields', $fields, $resource, $http_method ); }