Skip to content

Commit

Permalink
Saving data from the settings endpoint to wp_options
Browse files Browse the repository at this point in the history
  • Loading branch information
aldavigdis committed Mar 5, 2024
1 parent 645d994 commit a8e6764
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Rest/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ public static function register_route(): bool {
public static function rest_api_callback(
WP_REST_Request $request
): WP_REST_Response {
return new WP_REST_Response(
array( 'status' => 200 )
$rest_body = $request->get_body();
$rest_json = json_decode( $rest_body );

update_option( '1984_woo_dk_api_key', $rest_json->api_key );

update_option(
'1984_woo_dk_payment_methods',
$rest_json->payment_methods
);

return new WP_REST_Response( array( 'status' => 200 ) );
}

/**
Expand Down

0 comments on commit a8e6764

Please sign in to comment.