namespace, '/'. $this->rest_base, array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_items' ), 'permission_callback' => array( $this, 'get_items_permissions_check' ), 'args' => array( 'context' => $this->get_context_param( [ 'default' => 'view' ] ) ) ), array( 'methods' => WP_REST_Server::DELETABLE, 'callback' => array( $this, 'delete_item' ), 'permission_callback' => array( $this, 'delete_item_permissions_check' ), ) ) ); } /** * Retrieves a collection of log. * * @since 1.3.9 * * @param WP_REST_Request $request Full details about the request. * * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. **/ public function get_items( $request ) { $file = weforms_log_file_path(); if ( ! file_exists( $file ) ) { return new WP_Error( 'rest_weforms_invalid_data', __( 'file not exist', 'weforms') , array( 'status' => 404 ) ); } $data = file_get_contents( $file ); $data = explode( "\n", $data ); $data = array_reverse( $data ); $data = array_filter( $data ); if ( empty( $data ) ) { return new WP_Error( 'rest_weforms_invalid_data', __( 'data not exist', 'weforms') , array( 'status' => 404 ) ); } $logs = array(); foreach ( $data as $key => $row ) { preg_match( '/\[(?