diff --git a/includes/API.php b/includes/API.php index 8ab4fe9..25f0c26 100644 --- a/includes/API.php +++ b/includes/API.php @@ -195,8 +195,22 @@ public function rest_pre_dispatch( $result, $server, $request ) { * @param WP_REST_Request $request Request used to generate the response. */ public function rest_request_before_callbacks( $response, $handler, $request ) { - $controller = get_class( $handler['callback'][0] ); + /** + * Here we attempt to determine the controller class from the handler. + * + * Note: the handler can be a closure, in which case we can't determine the controller. + */ + if ( isset( $handler['callback'] ) && is_array( $handler['callback'] ) && is_object( $handler['callback'][0] ) ) { + $controller = get_class( $handler['callback'][0] ); + } else if ( is_object( $handler['callback'] ) ) { + $controller = get_class( $handler['callback'] ); + } else { + return $response; + } + /** + * If the controller is one of the WooCommerce REST API controllers, we can hijack the request + */ switch ( $controller ) { case 'WC_REST_Orders_Controller': $this->wc_rest_api_handler = new API\Orders( $request ); diff --git a/includes/Gateways.php b/includes/Gateways.php index e7f359f..d9cd1b2 100644 --- a/includes/Gateways.php +++ b/includes/Gateways.php @@ -49,7 +49,7 @@ public function payment_gateways( array $gateways ) { * - Order and set default order * - Also going to remove icons from the gateways * - * - BUG: a user with WooCommerce Blocks is getting null for $gateways? + * - NOTE: lots of plugins/themes call this filter and I can't guarantee that $gateways is an array * * @param array | null $gateways * diff --git a/readme.txt b/readme.txt index b985be3..0a9b5f5 100644 --- a/readme.txt +++ b/readme.txt @@ -64,7 +64,8 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co == Changelog == = 1.1.1 - 2023/05/xx = -* Fix: remove private meta data from Order Preview modal +* Improvement: remove private meta data from Order Preview modal +* Bug Fix: 'Cannot use object of type Closure as array' in the API.php file = 1.1.0 - 2023/05/19 = * Fix: disable Lite Speed Cache for POS page