Skip to content

Commit

Permalink
Merge pull request #340 from ErikIDX/IMPB-1296-bugfixes
Browse files Browse the repository at this point in the history
Various bugfixes
  • Loading branch information
ErikIDX authored Apr 12, 2021
2 parents 047a0c5 + d8aaca5 commit 17d0f78
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion idx/admin/rest-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ protected function convert_idx_api_error( $error ) {
$code = $error->get_error_code();
$message = $error->get_error_message();
$data = $error->get_error_data();
$status = 'Generic' === $data['status'] ? 500 : $data['status'];
if ( 'idx_api_error' === $code ) {
return new \WP_Error(
$code,
$data['rest_error'],
[
'status' => $data['status'],
'status' => $status,
]
);
}
Expand Down
5 changes: 3 additions & 2 deletions idx/idx-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public function __construct() {
public function apiResponse( $response ) {
if ( ! $response || ! is_array( $response ) || ! isset( $response['response'] ) ) {
return array(
'code' => 'Generic',
'error' => 'Unable to complete API call.',
'code' => 'Generic',
'error' => 'Unable to complete API call.',
'rest_error' => 'Unable to complete API call.',
);
}
$response_code = $response['response']['code'];
Expand Down
10 changes: 8 additions & 2 deletions idx/register-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,9 +819,15 @@ public function get_widget_list_options() {
$idx_widgets = $this->idx_api->idx_api_get_widgetsrc();
$widget_list = [];

if ( $idx_widgets ) {
if ( $idx_widgets && ! is_wp_error( $idx_widgets ) ) {
foreach ( $idx_widgets as $widget ) {
array_push( $widget_list, [ 'label' => $widget->name, 'value' => $widget->uid ] );
array_push(
$widget_list,
[
'label' => $widget->name,
'value' => $widget->uid,
]
);
}
}
return $widget_list;
Expand Down
2 changes: 1 addition & 1 deletion idx/social-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function get_article() {
'PUT'
);

if ( ! is_wp_error( $article ) ) {
if ( is_wp_error( $article ) ) {
return $this->convert_idx_api_error( $article );
}

Expand Down

0 comments on commit 17d0f78

Please sign in to comment.