Skip to content

Beta feature: Add endpoint to retrieve custom fields of a post type. #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 5, 2025

Conversation

cbravobernal
Copy link
Contributor

@cbravobernal cbravobernal commented Apr 30, 2025

What

Adds a new field scf_field_groups to the WordPress REST API's type(s) endpoints, providing information about field groups and fields associated with each post type. Includes metadata such as field group titles, field labels, and field types

Why

Serves as the foundation to integrate the post metadata in the editor sidebar, as it requires knowing what fields a post type has.

Testing instructions

  1. Ensure REST API is enabled in WordPress
  2. Make a GET request to /wp-json/wp/v2/types
  3. Verify each post type has a scf_field_groups property containing an array of field groups
  4. For post types with assigned field groups, confirm each field group includes the title and fields
  5. Test with a post type that has multiple field groups to ensure all are returned
  6. Test with post types that have no field groups to ensure an empty array is returned

@priethor priethor marked this pull request as ready for review May 5, 2025 11:35
Copy link
Contributor

@priethor priethor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

I'm also working on adding a new parameter to the same endpoint and needed to create the same `class-acf-rest-types-endpoint, so I started adding it in this same PR to avoid collisions but I'll add it in a follow-up in the end.

In the process, I removed the dependency with the beta features as the Command Palette will depend on the types endpoint changes. If we want to hide this behind the beta features, it should only be the part that registers the new fields, not the whole class. What do you think, @cbravobernal ?

* REST API
*
* @package Secure Custom Fields
* @since 6.4.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important note here: using 6.4.0 as we are not introducing the REST API in this PR, only fixing the missing file annotation that resulted in errors.

No action required!

@cbravobernal
Copy link
Contributor Author

cbravobernal commented May 5, 2025

What do you think, @cbravobernal ?

Sure, let's only hide the field registration.

Done in 6c7beef

@cbravobernal cbravobernal changed the title Draft: Add endpoint to retrieve custom fields of a post type. Beta feature: Add endpoint to retrieve custom fields of a post type. May 5, 2025
@cbravobernal cbravobernal added the [Type] Enhancement New feature or request label May 5, 2025
@cbravobernal cbravobernal merged commit a734037 into trunk May 5, 2025
5 checks passed
@cbravobernal
Copy link
Contributor Author

I cannot approve my own PR, but looks good.

@priethor priethor added this to the 6.5.0 milestone May 14, 2025
@kraftbj kraftbj deleted the experiment/fields-endpoint branch May 14, 2025 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants