Skip to content

Commit

Permalink
Tweak logic avoiding errors if response is not WP_REST_RESPONSE
Browse files Browse the repository at this point in the history
  • Loading branch information
puntope committed Aug 15, 2024
1 parent 9290727 commit 42281ed
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Integration/WPCOMProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ protected function register_callbacks() {
* @param WP_REST_Request $request The request object.
*/
function ( $response, $handler, $request ) {
if ( ! $this->is_gla_request( $request ) ) {
if ( ! $this->is_gla_request( $request ) || ! $response instanceof WP_REST_Response ) {
return $response;
}

$data = $response->get_data();

if ( $request->get_route() === '/wc/v3/settings/general' && $response instanceof WP_REST_Response ) {
if ( $request->get_route() === '/wc/v3/settings/general' ) {
$data[] = [
'id' => 'gla_target_audience',
'label' => 'Google for WooCommerce: Target Audience',
Expand All @@ -194,7 +194,6 @@ function ( $response, $handler, $request ) {
}

$response->set_data( $this->prepare_data( $response->get_data() ) );

return $response;
},
10,
Expand Down

0 comments on commit 42281ed

Please sign in to comment.