/
functions.php
54 lines (49 loc) · 1.48 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* Mitlib-Courtyard-blog functions and definitions.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package Mitlib-Courtyard-blog
*/
/**
* Posted_on rewrite
*/
function courtyard_posted_on() {
print '<span class="sep">' . esc_html__( 'Posted on ', 'twentyeleven' ) . '</span>';
printf( '<time class="entry-date" datetime="%1$s" pubdate>%2$s</time>',
esc_attr( get_the_date( 'c' ) ),
esc_html__( get_the_date(), 'twentyeleven' )
);
}
/**
* Post title (with link)
*/
function courtyard_entry_link() {
printf( '<a href="%s" rel="bookmark">', esc_url( get_permalink() ) );
courtyard_entry_title();
print '</a>';
}
/**
* Post title rewrite
*/
function courtyard_entry_title() {
// Translators: used between list items, there is a space after the comma.
$category_single = get_the_category();
$category_single = $category_single[0]->name;
// Translators: used between list items, there is a space after the comma.
$tag_single = str_replace( 'sticky', '', strip_tags( get_the_tag_list( '', '', '' ) ) );
if ( $tag_single ) {
$courtyard_post_title = __( '%1$s: %2$s', 'courtyard-blog' );
} elseif ( $category_single ) {
$courtyard_post_title = __( '%1$s Update', 'courtyard-blog' );
} else {
// It _should_ be impossible to have an uncategorized post, but...
$courtyard_post_title = __( 'General Update', 'courtyard-blog' );
}
printf(
esc_html( $courtyard_post_title ),
esc_html( $category_single ),
esc_html( $tag_single )
);
}