/** * Prints HTML with meta information for the current post-date/time and author, as well as a link to the comments and the tags. * * The function is designed in such a way that each entity of the meta information may be added depending on the parameters set. * * Example: clearcontent_post_meta($show = array('byline', 'post_date', 'modified_date', 'comments', 'posted-in', 'tags')); * If the function is called like above, the keywords indicate in exactly the order they are placed in the array which meta information * should be printed. * * @param array $show Elements are keys which indicate which entity is echoed in exactly the order as supplied. * to the argument. * @param boolean $echosep If $echosep if true, echo a separator. * @return None This function does not have a return value. * */ function clearcontent_post_meta($show = array('byline', 'post_date', 'modified_date', 'comments', 'posted-in', 'tags'), $echosep = False) { $meta_data = array(); if (in_array('byline', $show)) { $meta_data[] = sprintf('<span class="byline">By <span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span></span>', esc_url(get_author_posts_url(get_the_author_meta('ID'))), esc_attr(sprintf(__('View all posts by %s', 'clearcontent'), get_the_author())), esc_html(get_the_author())); } if (in_array('post_date', $show)) { $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>'; $time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date())); list($year, $month, $day) = explode(' ', get_the_date('Y m d')); $meta_data[] = sprintf('<span class="posted-on">Posted on <a href="%1$s" title="%2$s" rel="bookmark">%3$s</a></span>', esc_url(get_day_link($year, $month, $day)), esc_attr(get_the_time()), $time_string); } if (in_array('modified_date', $show)) { if (get_the_time('U') !== get_the_modified_time('U') && get_the_modified_time()) { $updated = '<time class="updated" datetime="%1$s">%2$s</time>'; $updated = sprintf($updated, esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date())); $meta_data[] = sprintf('<span class="modified-on">Modified on <a href="%1$s" title="%2$s" rel="bookmark">%3$s</a></span>', esc_url(get_permalink()), esc_attr(get_the_time()), $updated); } } if (in_array('comments', $show) && (!post_password_required() && comments_open())) { $meta_data[] = sprintf('<span class="comments-link">%1$s</span>', comments_popup_link(__('Leave a comment ', 'clearcontent'), __('1 Comment ', 'clearcontent'), __('% Comments ', 'clearcontent'))); } /* The next two only when this is a real post (Not search page or other) */ if ('post' == get_post_type()) { if (in_array('posted', $show)) { /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list(__(', ', 'clearcontent')); if ($categories_list && clearcontent_categorized_blog()) { $meta_data[] = sprintf('<span class="cat-links">%1$s</span>', "Posted in {$categories_list}"); } } if (in_array('tags', $show)) { /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list('', __(', ', 'clearcontent')); $meta_data[] = sprintf('<span class="tags-links">%1$s</span>', $tags_list ? sprintf(__('Tagged %1$s', 'clearcontent'), $tags_list) : sprintf(__('No tags yet :(', 'clearcontent'), $tags_list)); } } printf(implode($meta_data, '<span class="separator">-</span>')); }
<div class="entry-content"> <?php the_content(); ?> <?php wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'clearcontent'), 'after' => '</div>')); ?> </div><!-- .entry-content --> <footer class="entry-meta"> <?php /* translators: used between list items, there is a space after the comma */ $category_list = get_the_category_list(__(', ', 'clearcontent')); /* translators: used between list items, there is a space after the comma */ $tag_list = get_the_tag_list('', __(', ', 'clearcontent')); if (!clearcontent_categorized_blog()) { // This blog only has 1 category so we just need to worry about tags in the meta text if ('' != $tag_list) { $meta_text = __('This entry was tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'clearcontent'); } else { $meta_text = __('Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'clearcontent'); } } else { // But this blog has loads of categories so we should probably display them here if ('' != $tag_list) { $meta_text = __('This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'clearcontent'); } else { $meta_text = __('This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.', 'clearcontent'); } } // end check for categories on this blog