Skip to content

Commit

Permalink
fix: check returned array has items (#1905)
Browse files Browse the repository at this point in the history
Update the `getEmbedPage` function to check that the returned
array has items.
  • Loading branch information
patheard authored Sep 11, 2024
1 parent a8f832d commit f9a35fb
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getEmbedPage()
$response = wp_remote_get("https://articles.alpha.canada.ca/wp-json/wp/v2/pages/?slug=updates");
$responseBody = wp_remote_retrieve_body($response);
$result = json_decode($responseBody);
if (is_array($result) && ! is_wp_error($result)) {
if (is_array($result) && $result && ! is_wp_error($result)) {
$content = $result[0]->content->rendered;
$content = apply_filters('the_content', $content);
return $content;
Expand Down

0 comments on commit f9a35fb

Please sign in to comment.