Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions v3/lib/endpoints/class-acf-to-rest-api-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public function register_routes() {
}

public function register_field() {
register_rest_field( $this->type, 'acf', array(
$type = ( 'post_tag' === $this->type ) ? 'tag' : $this->type;
register_rest_field( $type, 'acf', array(
'get_callback' => array( $this, 'register_field_callback' ),
'schema' => array(
'description' => __( 'Expose advanced custom fields.', 'acf-to-rest-api' ),
Expand Down Expand Up @@ -123,7 +124,7 @@ public function update_item( $request ) {
update_field( $field['key'], $value, $item['id'] );
} else {
do_action( 'acf/update_value', $value, $item['id'], $field );
}
}
}
}
}
Expand All @@ -136,13 +137,13 @@ public function update_item( $request ) {

public function rest_insert( $object, $request, $creating ) {
if ( $request instanceof WP_REST_Request ) {
$id = $this->acf->get_id( $object );
$id = $this->acf->get_id( $object );
if ( ! $id ) {
$id = $this->acf->get_id( $request );
}
$request->set_param( 'id', $id );
}

return $this->update_item( $request );
}

Expand Down