Skip to content

Commit

Permalink
Merge pull request #4 from CodeForAfrica/hotfix/unpublished-posts
Browse files Browse the repository at this point in the history
HOTFIX draft posts don't show in dashboard
  • Loading branch information
karimkawambwa committed Apr 1, 2020
2 parents a3705b8 + 7c22cf0 commit 7f74a5f
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions wp-content/plugins/hurumap/index.php
Expand Up @@ -95,7 +95,8 @@ function enqueue_scripts()
$results = get_posts([
'post_type' => 'hurumap-section',
'numberposts' => -1,
'suppress_filters' => 0
'suppress_filters' => 0,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
]);
$sections = array();
foreach ($results as $result) {
Expand All @@ -108,7 +109,13 @@ function enqueue_scripts()
* Get post then use get_posts to get the post with language filters
*/
$_post = get_post();
$post = get_posts(['numberposts' => 1, 'post_type' => $_post->post_type, 'post__in' => [$_post->ID], 'suppress_filters' => 0])[0];
$post = get_posts([
'numberposts' => 1,
'post_type' => $_post->post_type,
'post__in' => [$_post->ID],
'suppress_filters' => 0,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
])[0];

wp_localize_script('hurumap-definitions-admin-script-index.js', 'initial',
array(
Expand Down Expand Up @@ -149,7 +156,8 @@ function enqueue_scripts()
$results = get_posts([
'post_type' => 'hurumap-visual',
'numberposts' => -1,
'suppress_filters' => 0
'suppress_filters' => 0,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
]);
$charts = array();
foreach ($results as $result) {
Expand All @@ -158,7 +166,8 @@ function enqueue_scripts()
$results = get_posts([
'post_type' => 'hurumap-section',
'numberposts' => -1,
'suppress_filters' => 0
'suppress_filters' => 0,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
]);
$sections = array();
foreach ($results as $result) {
Expand All @@ -170,7 +179,8 @@ function enqueue_scripts()
'post_type' => $_section->post_type,
'post__in' => [$_section->ID],
'numberposts' => 1,
'suppress_filters' => 0
'suppress_filters' => 0,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
])[0];

// Provide index js with initial data
Expand Down Expand Up @@ -247,12 +257,24 @@ function hurumap_visual_column( $column, $post_id ) {
switch ( $column ) {
case 'visual_type' :
$_post = get_post($post_id);
$post = get_posts(['numberposts' => 1, 'post_type' => $_post->post_type, 'post__in' => [$_post->ID], 'suppress_filters' => 0])[0];
$post = get_posts([
'numberposts' => 1,
'post_type' => $_post->post_type,
'post__in' => [$_post->ID],
'suppress_filters' => 0,
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit', 'trash')
])[0];
echo $post->post_excerpt;
break;
case 'in_topics' : {
$_post = get_post($post_id);
$post = get_posts(['numberposts' => 1, 'post_type' => $_post->post_type, 'post__in' => [$_post->ID], 'suppress_filters' => 0])[0];
$post = get_posts([
'numberposts' => 1,
'post_type' => $_post->post_type,
'post__in' => [$_post->ID],
'suppress_filters' => 0,
'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'])) {
$in_topics = $definition['inTopics'];
Expand Down

0 comments on commit 7f74a5f

Please sign in to comment.