summaryrefslogtreecommitdiff
path: root/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'functions.php')
-rw-r--r--functions.php121
1 files changed, 121 insertions, 0 deletions
diff --git a/functions.php b/functions.php
new file mode 100644
index 0000000..ecb0644
--- /dev/null
+++ b/functions.php
@@ -0,0 +1,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() )
+ );
+}