Example #1
0
 function largo_byline($echo = true, $exclude_date = false, $post = null)
 {
     if (!empty($post)) {
         if (is_object($post)) {
             $post_id = $post->ID;
         } else {
             if (is_numeric($post)) {
                 $post_id = $post;
             }
         }
     } else {
         $post_id = get_the_ID();
     }
     $values = get_post_custom($post_id);
     if (function_exists('get_coauthors') && !isset($values['largo_byline_text'])) {
         $coauthors = get_coauthors($post_id);
         foreach ($coauthors as $author) {
             $byline_text = $author->display_name;
             if ($org = $author->organization) {
                 $byline_text .= ' (' . $org . ')';
             }
             $out[] = '<a class="url fn n" href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__('Read All Posts By %s', 'largo'), $author->display_name)) . '" rel="author">' . esc_html($byline_text) . '</a>';
         }
         if (count($out) > 1) {
             end($out);
             $key = key($out);
             reset($out);
             $authors = implode(', ', array_slice($out, 0, -1));
             $authors .= ' <span class="and">' . __('and', 'largo') . '</span> ' . $out[$key];
         } else {
             $authors = $out[0];
         }
     } else {
         $authors = largo_author_link(false, $post_id);
     }
     $output = '<span class="by-author"><span class="by">' . __('By', 'largo') . '</span> <span class="author vcard" itemprop="author">' . $authors . '</span></span>';
     if (!$exclude_date) {
         $output .= '<span class="sep"> | </span><time class="entry-date updated dtstamp pubdate" datetime="' . esc_attr(get_the_date('c', $post_id)) . '">' . largo_time(false, $post_id) . '</time>';
     }
     if (current_user_can('edit_post', $post_id)) {
         $output .= '<span class="sep"> | </span><span class="edit-link"><a href="' . get_edit_post_link($post_id) . '">' . __('Edit This Post', 'largo') . '</a></span>';
     }
     if (is_single() && of_get_option('clean_read') === 'byline') {
         $output .= '<a href="#" class="clean-read">' . __('View as "Clean Read"', 'largo') . '</a>';
     }
     if ($echo) {
         echo $output;
     } else {
         return $output;
     }
 }
Example #2
0
 function largo_byline($echo = true, $exclude_date = false, $post = null)
 {
     if (!empty($post)) {
         if (is_object($post)) {
             $post_id = $post->ID;
         } else {
             if (is_numeric($post)) {
                 $post_id = $post;
             }
         }
     } else {
         $post_id = get_the_ID();
     }
     $values = get_post_custom($post_id);
     if (function_exists('get_coauthors') && !isset($values['largo_byline_text'])) {
         $coauthors = get_coauthors($post_id);
         foreach ($coauthors as $author) {
             $byline_text = $author->display_name;
             if ($org = $author->organization) {
                 $byline_text .= ' (' . $org . ')';
             }
             $out[] = '<a class="url fn n" href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__('Read All Posts By %s', 'largo'), $author->display_name)) . '" rel="author">' . esc_html($byline_text) . '</a>';
         }
         if (count($out) > 1) {
             end($out);
             $key = key($out);
             reset($out);
             $authors = implode(', ', array_slice($out, 0, -1));
             $authors .= ' <span class="and">' . __('and', 'largo') . '</span> ' . $out[$key];
         } else {
             $authors = $out[0];
         }
     } else {
         $authors = largo_author_link(false, $post_id);
     }
     $output = '<span class="by-author"><span class="by">' . __('By', 'largo') . '</span> <span class="author vcard" itemprop="author">' . $authors . '</span></span>';
     if (!$exclude_date) {
         $output .= '<span class="sep"> | </span><time class="entry-date updated dtstamp pubdate" datetime="' . esc_attr(get_the_date('c', $post_id)) . '">' . largo_time(false, $post_id) . '</time>';
     }
     /**
      * Filter the largo_byline output text to allow adding items at the beginning or the end of the text.
      *
      * @since 0.5.4
      * @param string $partial The HTML of the output of largo_byline(), before the edit link is added.
      * @link https://github.com/INN/Largo/issues/1070
      */
     $output = apply_filters('largo_byline', $output);
     if (current_user_can('edit_post', $post_id)) {
         $output .= '<span class="sep"> | </span><span class="edit-link"><a href="' . get_edit_post_link($post_id) . '">' . __('Edit This Post', 'largo') . '</a></span>';
     }
     if ($echo) {
         echo $output;
     } else {
         return $output;
     }
 }