ACF_Rest_Api::register_field
Register our custom property as a REST field.
Метод класса: ACF_Rest_Api{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$ACF_Rest_Api = new ACF_Rest_Api(); $ACF_Rest_Api->register_field();
Код ACF_Rest_Api::register_field() ACF Rest Api::register field ACF 6.4.2
public function register_field() {
if ( ! acf_get_setting( 'rest_api_enabled' ) ) {
return;
}
if ( ! $this->request instanceof ACF_Rest_Request ) {
$this->request = new ACF_Rest_Request();
$this->request->parse_request( null );
}
$base = $this->request->object_sub_type;
// If the object sub type ($post_type, $taxonomy, 'user') cannot be determined from the current request,
// we don't know what endpoint to register the field against. Bail if that is the case.
if ( ! $base ) {
return;
}
if ( $this->request->child_object_type ) {
$base = $this->request->child_object_type;
}
// If we've already registered this route, no need to do it again.
if ( acf_did( 'acf/register_rest_field' ) ) {
global $wp_rest_additional_fields;
if ( isset( $wp_rest_additional_fields[ $base ], $wp_rest_additional_fields[ $base ]['acf'] ) ) {
return;
}
}
register_rest_field(
$base,
'acf',
array(
'schema' => $this->get_schema(),
'get_callback' => array( $this, 'load_fields' ),
'update_callback' => array( $this, 'update_fields' ),
)
);
}