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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
<?php
/**
* @author Luke Shumaker
* @author Chris Aprea
*/
/**
* In child themes the functions.php is applied before the parent
* theme's functions.php. So we need to wait for the parent theme to add
* it's filter before we can remove it.
*/
function lnns_child_theme_setup() {
// Removes the filter that adds the "singular" class to the body element
// which centers the content and does not allow for a sidebar
remove_filter( 'body_class', 'twentyeleven_body_classes' );
}
add_action( 'after_setup_theme', 'lnns_child_theme_setup' );
function lnns_widgets_init() {
register_sidebar( array(
'name' => __('Index Header', 'northstar-twentyeleven'),
'id' => 'index-page-widgetarea',
'description' => __( 'An optional widget area at the top of the index page', 'northstar-twentyeleven'),
'before_widget' => '<div id="%1$s" class="widget %$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'lnns_widgets_init' );
function lnns_authors_loop($callback) {
$loop = false;
$authors = null;
if (function_exists('coauthors')) {
$loop = true;
$authors = new CoAuthorsIterator();
@$authors->iterate();
}
$authors_data = array();
do {
$callback(&$authors_data);
} while ($loop && $authors->iterate());
return $authors_data;
}
function _lnns_authors(&$strings) {
$tran = 'northstar-twentyeleven';
$url = get_author_posts_url(get_the_author_meta('ID'));
$name = get_the_author();
$strings[] = sprintf('<a href="%1$s">%2$s</a>',
esc_url($url),
$name);
}
function lnns_authors() {
$strings = lnns_authors_loop('_lnns_authors');
return implode(__(' and '), $strings);
}
/**
* Prints HTML with meta information for the current post-date/time and author.
* If CoAuthors is set up, will loop through all authors.
*/
function _twentyeleven_posted_on(&$authors_data) {
$id = get_the_author_meta('ID');
$author_data = array();
$author_data['url'] = get_author_posts_url($id);
$author_data['name'] = get_the_author();
$user = new WP_User($id);
$roles = array();
if ( !empty( $user->roles ) && is_array( $user->roles ) ) {
foreach ( $user->roles as $role ) {
$roles[] = str_replace('_', ' ', $role);
}
}
$author_data['roles'] = $roles;
$authors_data[] = $author_data;
}
function twentyeleven_posted_on() {
$tran = 'northstar-twentyeleven';
$authors_data = lnns_authors_loop('_twentyeleven_posted_on');
// Now print it all //////////////////////////////////////////
$format = __('<span class="author vcard">'.
'<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a>'.
' <span class="role">%4$s</span>'.
'</span>', $tran);
$authors = array();
foreach ($authors_data as $author) {
$authors[] = sprintf($format,
esc_url($author['url']),
sprintf(esc_attr__('View all posts by %s', $tran),
$author['name'] ),
esc_html($author['name']),
esc_html(implode(' ', $author['roles']))
);
}
$authors_string = implode( __('<span class="sep"> and </span>', $tran),
$authors);
printf( __('<span class="authors">%s</span>', $tran), $authors_string);
// Print the date.
printf( __(' <span class="entry-date"><span class="sep">Published on </span>'.
'<a href="%1$s" title="%2$s" rel="bookmark">'.
'<time class="entry-date" datetime="%3$s" pubdate>%4$s</time>'.
'</a></span>', $tran),
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
}
|