Skip to content

Commit

Permalink
Merge pull request #3709 from 10up/feature/feature-settings-ui
Browse files Browse the repository at this point in the history
Only update settings from schema.
  • Loading branch information
felipeelia committed Oct 18, 2023
2 parents e2e0d4f + bc3f5ac commit b0fecdb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion includes/classes/REST/Features.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,29 @@ public function check_permission() {
* @return void
*/
public function update_settings( \WP_REST_Request $request ) {
$settings = $request->get_params();
$settings = [];

$features = \ElasticPress\Features::factory()->registered_features;

foreach ( $features as $slug => $feature ) {
$param = $request->get_param( $slug );

if ( ! $param ) {
continue;
}

$settings[ $slug ] = [];

$schema = $feature->get_settings_schema();

foreach ( $schema as $schema ) {
$key = $schema['key'];

if ( isset( $param[ $key ] ) ) {
$settings[ $slug ][ $key ] = $param[ $key ];
}
}
}

Utils\update_option( 'ep_feature_settings', $settings );

Expand Down

0 comments on commit b0fecdb

Please sign in to comment.