From 8191ee2ef1beadec0ce61651f8001ba91bc626c5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 29 Sep 2011 16:29:59 -0400 Subject: initial commit --- functions.php | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 functions.php (limited to 'functions.php') diff --git a/functions.php b/functions.php new file mode 100644 index 0000000..ecb0644 --- /dev/null +++ b/functions.php @@ -0,0 +1,121 @@ + __('Index Header', 'northstar-twentyeleven'), + 'id' => 'index-page-widgetarea', + 'description' => __( 'An optional widget area at the top of the index page', 'northstar-twentyeleven'), + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

', + ) ); +} +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('%2$s', + 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 = __(''. + ''. + ' %4$s'. + '', $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( __(' and ', $tran), + $authors); + printf( __('%s', $tran), $authors_string); + + // Print the date. + printf( __(' Published on '. + ''. + ''. + '', $tran), + esc_url( get_permalink() ), + esc_attr( get_the_time() ), + esc_attr( get_the_date( 'c' ) ), + esc_html( get_the_date() ) + ); +} -- cgit v1.2.3