_s: Simplify entry meta output

- Fix entry-footer inconsistency between content-*.php files
- Move in a function <code>_s_entry_meta()</code> to avoid duplication

---

At the moment there is an inconsistency between content.php and
content-single.php regarding the .entry-footer output.

In my opinion content.php output is would be better to use because it's
easier to translate and allow more customisation.

Finally by moving it into <code>inc/template-tags.php</code> we are
getting rid of some duplicated code.
This commit is contained in:
Thomas Guillot 2014-06-30 16:43:07 +01:00
parent a78658a393
commit ba1258f365
5 changed files with 37 additions and 91 deletions

View File

@ -20,7 +20,8 @@
) );
?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php edit_post_link( __( 'Edit', '_s' ), '<span class="edit-link">', '</span>' ); ?>
<?php _s_entry_meta(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->

View File

@ -24,32 +24,6 @@
</div><!-- .entry-summary -->
<footer class="entry-footer">
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', '_s' ) );
if ( $categories_list && _s_categorized_blog() ) :
?>
<span class="cat-links">
<?php printf( __( 'Posted in %1$s', '_s' ), $categories_list ); ?>
</span>
<?php endif; // End if categories ?>
<?php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', '_s' ) );
if ( $tags_list ) :
?>
<span class="tags-links">
<?php printf( __( 'Tagged %1$s', '_s' ), $tags_list ); ?>
</span>
<?php endif; // End if $tags_list ?>
<?php endif; // End if 'post' == get_post_type() ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', '_s' ), __( '1 Comment', '_s' ), __( '% Comments', '_s' ) ); ?></span>
<?php endif; ?>
<?php edit_post_link( __( 'Edit', '_s' ), '<span class="edit-link">', '</span>' ); ?>
<?php _s_entry_meta(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->
</article><!-- #post-## -->

View File

@ -24,39 +24,6 @@
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php
/* translators: used between list items, there is a space after the comma */
$category_list = get_the_category_list( __( ', ', '_s' ) );
/* translators: used between list items, there is a space after the comma */
$tag_list = get_the_tag_list( '', __( ', ', '_s' ) );
if ( ! _s_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" rel="bookmark">permalink</a>.', '_s' );
} else {
$meta_text = __( 'Bookmark the <a href="%3$s" rel="bookmark">permalink</a>.', '_s' );
}
} 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" rel="bookmark">permalink</a>.', '_s' );
} else {
$meta_text = __( 'This entry was posted in %1$s. Bookmark the <a href="%3$s" rel="bookmark">permalink</a>.', '_s' );
}
} // end check for categories on this blog
printf(
$meta_text,
$category_list,
$tag_list,
get_permalink()
);
?>
<?php edit_post_link( __( 'Edit', '_s' ), '<span class="edit-link">', '</span>' ); ?>
<?php _s_entry_meta(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->

View File

@ -26,32 +26,6 @@
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', '_s' ) );
if ( $categories_list && _s_categorized_blog() ) :
?>
<span class="cat-links">
<?php printf( __( 'Posted in %1$s', '_s' ), $categories_list ); ?>
</span>
<?php endif; // End if categories ?>
<?php
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', '_s' ) );
if ( $tags_list ) :
?>
<span class="tags-links">
<?php printf( __( 'Tagged %1$s', '_s' ), $tags_list ); ?>
</span>
<?php endif; // End if $tags_list ?>
<?php endif; // End if 'post' == get_post_type() ?>
<?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', '_s' ), __( '1 Comment', '_s' ), __( '% Comments', '_s' ) ); ?></span>
<?php endif; ?>
<?php edit_post_link( __( 'Edit', '_s' ), '<span class="edit-link">', '</span>' ); ?>
<?php _s_entry_meta(); ?>
</footer><!-- .entry-footer -->
</article><!-- #post-## -->
</article><!-- #post-## -->

View File

@ -133,3 +133,33 @@ function _s_category_transient_flusher() {
}
add_action( 'edit_category', '_s_category_transient_flusher' );
add_action( 'save_post', '_s_category_transient_flusher' );
if ( ! function_exists( '_s_entry_meta' ) ) :
/**
* Prints HTML with meta information for the categories, tags, comments and edit link.
*/
function _s_entry_meta() {
/* Hide category and tag text for pages */
if ( 'post' == get_post_type() ) {
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', '_s' ) );
if ( $categories_list && _s_categorized_blog() ) {
printf( '<span class="cat-links">' . __( 'Posted in %1$s', '_s' ) . '</span>', $categories_list );
}
/* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', '_s' ) );
if ( $tags_list ) {
printf( '<span class="tags-links">' . __( 'Tagged %1$s', '_s' ) . '</span>', $tags_list );
}
}
if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) {
echo '<span class="comments-link">';
comments_popup_link( __( 'Leave a comment', '_s' ), __( '1 Comment', '_s' ), __( '% Comments', '_s' ) );
echo '</span>';
}
edit_post_link( __( 'Edit', '_s' ), '<span class="edit-link">', '</span>' );
}
endif;