/** * Register a shortcode to display an overview of our travels. * This shortcode will be used on the primary landing page for our plugin. * * Usage: [wanderlist-overview], by default will show a dashboard of stats and widgets. * If there are no upcoming locations, it will default to most-recently-visited locations. * * We'll set up a settings page later to fine-tune its output, or * potentially allow users to pass parameters. For now, no options. */ function wanderlist_overview_shortcode($atts, $content = null) { $a = shortcode_atts(array('show' => 'current'), $atts); $widgets[] = array('class' => 'wanderlist-map-widget', 'content' => wanderlist_show_map()); $widgets[] = array('class' => 'wanderlist-location-widget', 'title' => esc_html__('Coming up!', 'wanderlist'), 'content' => wanderlist_list_locations(10, 'upcoming')); $widgets[] = array('class' => 'wanderlist-location-widget', 'title' => esc_html__('Where I’ve been lately', 'wanderlist'), 'content' => wanderlist_list_locations(10, 'past')); $widgets[] = array('class' => 'wanderlist-trip-widget', 'title' => esc_html__('Long trips', 'wanderlist'), 'content' => wanderlist_list_trips()); $widgets[] = array('class' => 'wanderlist-country-widget', 'title' => esc_html__('Countries visited', 'wanderlist'), 'content' => wanderlist_list_countries('list')); $widgets[] = array('class' => 'wanderlist-number-widget', 'title' => esc_html__('Stats', 'wanderlist'), 'content' => '<div class="wanderlist-place-count">' . '<span class="wanderlist-number">' . wanderlist_count('places') . '</span><span class="wanderlist-item">' . esc_html__('Places', 'wanderlist') . '</span></div> <span class="wanderlist-connector">' . esc_html__('in', 'wanderlist') . '</span> <div class="wanderlist-country-count"><span class="wanderlist-number">' . wanderlist_count('countries') . '</span><span class="wanderlist-item">' . esc_html__('Countries', 'wanderlist') . '</span></div> <span class="wanderlist-connector">' . esc_html__('on', 'wanderlist') . '</span> <div class="wanderlist-continent-count"><span class="wanderlist-number">' . wanderlist_count('continents') . '</span><span class="wanderlist-item">' . esc_html__('Continents', 'wanderlist') . '</span></div>'); $return = '<div class="wanderlist-overview">'; foreach ($widgets as $widget) { if ('<dl></dl>' !== $widget['content'] && '<ul></ul>' !== $widget['content']) { $return .= '<div class="wanderlist-widget ' . $widget['class'] . '">'; if (isset($widget['title'])) { $return .= '<h3 class="widget-title">' . $widget['title'] . '</h3>'; } $return .= $widget['content']; $return .= '</div>'; } } $return .= '</div>'; return $return; }
<header class="page-header"> <?php the_archive_title('<h1 class="page-title archive-title">', '</h1>'); the_archive_description('<div class="taxonomy-description archive-meta">', '</div>'); ?> </header><!-- .page-header --> <?php if (have_posts()) { ?> <article class="hentry"> <div class="entry-content"> <div class="wanderlist-map-widget"> <?php echo wanderlist_show_map(); ?> </div> <?php /* Start the Loop */ ?> <div class="wanderlist-widget wanderlist-trip-overview-widget"> <h3 class="widget-title"><?php esc_html_e('Where I went', 'wanderlist'); ?> </h3> <dl> <?php while (have_posts()) { the_post();