Skip to content
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

Add feature settings REST API #3676

Merged
merged 4 commits into from
Oct 4, 2023
Merged

Add feature settings REST API #3676

merged 4 commits into from
Oct 4, 2023

Conversation

JakePT
Copy link
Contributor

@JakePT JakePT commented Oct 3, 2023

Description of the Change

Adds a REST API endpoint at /wp-json/elasticpress/v1/features for updating feature settings. The endpoint uses the settings schema added to features by #3655 to provide validation for updating the ep_feature_settings via a PUT request.

This PR also creates a Dashboard screen class to register the endpoint (for consistency with Sync). The name dashboard was for consistency with the dashboard-page.php file used to render it.

How to test the Change

  1. Make an OPTIONS request to /wp-json/elasticpress/v1/features. The feature settings and their types and possible values should be shown as supported args.
  2. Copy the saved ep_feature_settings option from the database and unserialize it as JSON. Make modifications and send it as the body in a PUT request to /wp-json/elasticpress/v1/features. Valid changes according to the definitions in the OPTIONS response should update the feature settings, and be reflected in the admin, while changes that are invalid should result in a 400 error.

Changelog Entry

Added - Added a REST API endpoint at elasticpress/v1/features for updating feature settings.

Credits

Props @JakePT

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@JakePT JakePT requested a review from felipeelia October 3, 2023 07:36
@JakePT JakePT self-assigned this Oct 3, 2023
@JakePT JakePT added this to the 5.0.0 milestone Oct 3, 2023
Copy link
Member

@felipeelia felipeelia left a comment

Choose a reason for hiding this comment

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

Everything looks good @JakePT, the only thing I think we need to change is a @since tag.

includes/classes/Screen/Dashboard.php Outdated Show resolved Hide resolved
@felipeelia felipeelia merged commit 8d94a5e into 5.0.0 Oct 4, 2023
9 checks passed
@felipeelia felipeelia deleted the feature/features-api branch October 4, 2023 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants