'GET', 'callback' => [ $this, 'get_messages' ], 'permission_callback' => [ $this, 'has_permission' ], 'args' => [], ] ); } /** * Retrieves stored messages from the site options. * * This method fetches the messages stored in the 'backwpup_messages' site option * and returns them wrapped in an HTTP response. * * @param WP_REST_Request $request The REST API request object. * * @return WP_HTTP_Response The response containing the messages and HTTP status code 200. */ public function get_messages( WP_REST_Request $request ) { $messages = get_site_option( 'backwpup_messages', [] ); // delete it after messages send. update_site_option( 'backwpup_messages', [] ); return new WP_HTTP_Response( $messages, 200 ); } }