Project

General

Profile

Feature #2301 » functions.php

Matt Gold, 2012-11-27 02:28 AM

 
1
<?php
2

    
3
if ( ! function_exists( 'twentytwelve_entry_meta_custom' ) ) :
4
/**
5
 * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
6
 *
7
 * Create your own twentytwelve_entry_meta() to override in a child theme.
8
 *
9
 * @since Twenty Twelve 1.0
10
 */
11
function twentytwelve_entry_meta_custom() {
12
	// Translators: used between list items, there is a space after the comma.
13
	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );
14

    
15
	// Translators: used between list items, there is a space after the comma.
16
	$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
17

    
18
	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s" pubdate>%4$s</time></a>',
19
		esc_url( get_permalink() ),
20
		esc_attr( get_the_time() ),
21
		esc_attr( get_the_date( 'c' ) ),
22
		esc_html( get_the_date() )
23
	);
24

    
25
	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
26
		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
27
		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
28
		get_the_author()
29
	);
30

    
31
	// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
32
	if ( $tag_list ) {
33
		$utility_text = __( '<span class="by-author"> by %4$s</span>', 'twentytwelve' );
34
	} elseif ( $categories_list ) {
35
		$utility_text = __( 'By %4$s</span>', 'twentytwelve' );
36
	} else {
37
		$utility_text = __( 'By %4$s</span>', 'twentytwelve' );
38
	}
39

    
40
	printf(
41
		$utility_text,
42
		$categories_list,
43
		$tag_list,
44
		$date,
45
		$author
46
	);
47
}
48
endif;
(2-2/4)