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
19 changes: 18 additions & 1 deletion includes/rest-api/class-acf-rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ public function register_field() {

$base = $this->request->object_sub_type;

// WordPress term controllers use the schema title as the object type for
// additional REST fields. For built-in tags, the taxonomy is "post_tag"
// but the REST object type is "tag".
if ( 'term' === $this->request->object_type && 'post_tag' === $base ) {
$base = 'tag';
}

// 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 ) {
Expand Down Expand Up @@ -218,7 +225,12 @@ public function load_fields( $object, $field_name, $request, $object_sub_type )
return $fields;
}

$object_sub_type = str_replace( '-revision', '', $object_sub_type );
// Preserve the taxonomy slug for ACF field-group matching.
if ( 'term' === $object_type && $this->request->object_sub_type ) {
$object_sub_type = $this->request->object_sub_type;
} else {
$object_sub_type = str_replace( '-revision', '', $object_sub_type );
}

// Get all field groups for the current object.
$field_groups = $this->get_field_groups_by_id( $object_id, $object_type, $object_sub_type );
Expand Down Expand Up @@ -285,6 +297,11 @@ public function update_fields( $data, $object, $property, $request, $object_sub_
);
}

// Preserve the taxonomy slug for ACF field-group matching.
if ( 'term' === $object_type && $this->request->object_sub_type ) {
$object_sub_type = $this->request->object_sub_type;
}

// Determine the ACF selector for the current object.
$post_id = $this->make_identifier( $object_id, $object_type );

Expand Down
Loading