\WP_REST_Server::EDITABLE, 'callback' => array( $this, 'save_options' ), 'permission_callback' => $this->get_admin_permission_callback(), ), ); } /** * Method for saving options * * @param \WP_REST_Request $request The WP ReST request. * * @return \WP_REST_Response */ public function save_options( \WP_REST_Request $request ): \WP_REST_Response { $show_refresh_in_admin_bar = $request->get_param( 'show_refresh_in_admin_bar' ) ?? null; $refresh_interval = $request->get_param( 'refresh_interval' ) ?? null; $use_static_file_polling = $request->get_param( 'use_static_file_polling' ) ?? null; if ( null !== $show_refresh_in_admin_bar ) { Options_Storage_Service::set_option_show_in_admin_bar( $show_refresh_in_admin_bar ); } if ( null !== $refresh_interval ) { Options_Storage_Service::set_option_refresh_interval( $refresh_interval ); } if ( null !== $use_static_file_polling ) { $enabled = (bool) $use_static_file_polling; Options_Storage_Service::set_use_static_file_polling( $enabled ); if ( $enabled ) { Versions_Storage_Service::sync_version_file(); } } return $this->return_api_response( \WP_Http::CREATED, 'You\'ve successfully updated options.', ); } /** * Method for getting the endpoint for this service. * * @return string The service endpoint. */ public static function get_rest_endpoint(): string { return self::get_formatted_rest_endpoint( self::ENDPOINT_PATH, self::ENDPOINT_VERSION ); } }