Skip to content

Commit

Permalink
Check for null (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
karimkawambwa committed Apr 1, 2020
1 parent 7f74a5f commit cbfd103
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions wp-content/plugins/hurumap/index.php
Expand Up @@ -100,7 +100,10 @@ function enqueue_scripts()
]);
$sections = array();
foreach ($results as $result) {
array_push($sections, json_decode($result->post_content));
$decoded = json_decode($result->post_content);
if ($decoded) {
array_push($sections, $decoded);
}
}

/**
Expand Down Expand Up @@ -161,7 +164,10 @@ function enqueue_scripts()
]);
$charts = array();
foreach ($results as $result) {
array_push($charts, json_decode($result->post_content));
$decoded = json_decode($result->post_content);
if ($decoded) {
array_push($charts, $decoded);
}
}
$results = get_posts([
'post_type' => 'hurumap-section',
Expand All @@ -171,7 +177,10 @@ function enqueue_scripts()
]);
$sections = array();
foreach ($results as $result) {
array_push($sections, json_decode($result->post_content));
$decoded = json_decode($result->post_content);
if ($decoded) {
array_push($sections, $decoded);
}
}

$_section = get_post();
Expand Down Expand Up @@ -276,7 +285,7 @@ function hurumap_visual_column( $column, $post_id ) {
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
])[0];
$definition = json_decode($post->post_content, true);
if (is_array($definition['inTopics'])) {
if ($definition && is_array($definition['inTopics'])) {
$in_topics = $definition['inTopics'];
?>
<ul>
Expand Down

0 comments on commit cbfd103

Please sign in to comment.