From 4a4b5201a32fbc232b1fe38f3115fa3b7dd43d7b Mon Sep 17 00:00:00 2001 From: hofmannsven Date: Wed, 21 May 2014 23:15:20 +0200 Subject: [PATCH] Add fallback for empty dashboard if everything is in trash --- admin/views/dashboard.php | 40 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/admin/views/dashboard.php b/admin/views/dashboard.php index bfa2946..26455e4 100755 --- a/admin/views/dashboard.php +++ b/admin/views/dashboard.php @@ -16,7 +16,7 @@ /** - * Get marker + * Get marker terms * * @since 1.0.0 */ @@ -25,29 +25,33 @@ ); $markers = get_terms( 'marker', $marker_args ); +/** + * Get all markers but trashed + * + * @since 1.0.7 + */ +global $wpdb; +$marker_items = ''; +if ( ! empty( $markers ) ) : + foreach ( $markers as $marker ) : + $trashed = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p JOIN $wpdb->term_relationships rl ON p.ID = rl.object_id WHERE rl.term_taxonomy_id = $marker->term_id AND p.post_status = 'trash' LIMIT 1" ); + $count = $marker->count - $trashed; + if ( $count > 0 ) : + $marker_items .= '
  • ' . $count . ' ' . $marker->name . '
  • '; + endif; + endforeach; +endif; + ?>
    - +