示例#1
0
文件: core.php 项目: sovanda/Valenti
 function cb_byline($cb_cat = true, $cb_post_id = NULL, $cb_short_comment_line = false, $cb_posts_on = false, $cb_post_views_off = false)
 {
     if ($cb_post_id == NULL) {
         global $post;
         $cb_post_id = $post->ID;
     }
     $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on');
     $cb_byline_author = ot_get_option('cb_byline_author', 'on');
     $cb_byline_date = ot_get_option('cb_byline_date', 'on');
     $cb_byline_category = ot_get_option('cb_byline_category', 'on');
     $cb_byline_comments = ot_get_option('cb_byline_comments', 'on');
     $cb_byline_postviews = ot_get_option('cb_byline_postviews', 'off');
     $cb_disqus_code = ot_get_option('cb_disqus_shortname', NULL);
     $cb_byline = $cb_cat_output = $cb_comments = $cb_post_views = NULL;
     $cb_cats = get_the_category($cb_post_id);
     if (isset($cb_cats) && $cb_cat == true) {
         $cb_cat_output = ' <div class="cb-category cb-byline-element"><i class="fa fa-folder"></i> ';
         $i = 1;
         foreach ($cb_cats as $category) {
             if ($i != 1) {
                 $cb_cat_output .= ', ';
             }
             $cb_cat_output .= ' <a href="' . get_category_link($category->term_id) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $category->name)) . '">' . $category->cat_name . '</a>';
             $i++;
         }
         $cb_cat_output .= '</div>';
     }
     if ($cb_disqus_code == NULL) {
         if (get_comments_number($cb_post_id) > 0) {
             if ($cb_short_comment_line == true) {
                 $cb_comments = ' <div class="cb-comments cb-byline-element"><span><i class="fa fa-comment"></i><a href="' . get_comments_link($cb_post_id) . '">' . number_format_i18n(get_comments_number($cb_post_id)) . '</a></span></div>';
             } else {
                 $cb_comment_line = __('Comment', 'cubell');
                 $cb_comments_line = __('Comments', 'cubell');
                 $cb_comments = ' <div class="cb-comments cb-byline-element"><span><i class="fa fa-comment"></i><a href="' . get_comments_link($cb_post_id) . '">' . number_format_i18n(get_comments_number($cb_post_id)) . ' ' . get_comments_number_text($cb_comment_line, $cb_comment_line, $cb_comments_line) . '</a></span></div>';
             }
         }
     } else {
         $cb_comments = ' <div class="cb-comments cb-byline-element"><span><i class="fa fa-comment"></i><a href="' . get_permalink($cb_post_id) . '#disqus_thread"></a></span></div>';
     }
     if ($cb_post_views_off == false) {
         $cb_post_view_count = cb_get_post_viewcount($cb_post_id);
         if ($cb_post_view_count > 0) {
             $cb_post_views = '<div class="cb-post-views cb-byline-element"><span><i class="fa fa-eye"></i> ' . $cb_post_view_count . '</span></div>';
         }
     }
     $cb_author = '<div class="cb-author cb-byline-element">';
     if (function_exists('coauthors_posts_links')) {
         $cb_author .= '<i class="fa fa-user"></i> ' . coauthors_posts_links(null, null, null, null, false);
     } else {
         $cb_author .= '<i class="fa fa-user"></i> <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author() . '</a>';
     }
     $cb_author .= '</div>';
     $cb_date = ' <div class="cb-date cb-byline-element"><i class="fa fa-clock-o"></i> <time class="updated" datetime="' . get_the_time('Y-m-d', $cb_post_id) . '">' . date_i18n(get_option('date_format'), strtotime(get_the_time("Y-m-d", $cb_post_id))) . '</time></div>';
     if ($cb_byline_date == 'off') {
         $cb_date = NULL;
     }
     if ($cb_byline_author == 'off') {
         $cb_author = NULL;
     }
     if ($cb_byline_category == 'off') {
         $cb_cat_output = NULL;
     }
     if ($cb_byline_comments == 'off') {
         $cb_comments = NULL;
     }
     if ($cb_byline_postviews == 'off') {
         $cb_post_views = NULL;
     }
     if ($cb_meta_onoff == 'on' || $cb_posts_on == true) {
         $cb_byline = '<div class="cb-byline">' . $cb_author . $cb_date . $cb_cat_output . $cb_comments . $cb_post_views . '</div>';
     }
     return $cb_byline;
 }
 function cb_get_byline($cb_post_id, $cb_cat = NULL, $cb_is_post = NULL, $cb_views_on = NULL, $cb_override = NULL)
 {
     $cb_meta_onoff = ot_get_option('cb_meta_onoff', 'on');
     $cb_byline_author = ot_get_option('cb_byline_author', 'on');
     $cb_byline_date = ot_get_option('cb_byline_date', 'on');
     $cb_post_meta_views = ot_get_option('cb_byline_postviews', 'on');
     $cb_byline_sep = '<span class="cb-separator">' . ot_get_option('cb_byline_separator', '<i class="fa fa-times"></i>') . '</span>';
     $cb_byline = $cb_date = $cb_author = $cb_cat_output = $cb_author_avatar = $cb_views_output = NULL;
     $cb_post_meta_category = ot_get_option('cb_byline_category', 'on');
     if ($cb_byline_author != 'off') {
         if ($cb_is_post == true) {
             $cb_author_avatar = apply_filters('cb_byline_avatar', get_avatar(get_post_field('post_author', $cb_post_id), 20), $cb_post_id);
         }
         if (ot_get_option('cb_byline_author_av', 'on') == 'off') {
             $cb_author_avatar = NULL;
         }
         if (function_exists('coauthors_posts_links')) {
             $cb_author = apply_filters('cb_byline_coauthors', '<span class="cb-author"> ' . coauthors_posts_links(null, null, $cb_author_avatar, null, false) . '</span>', $cb_author_avatar);
         } else {
             $cb_author = apply_filters('cb_byline_author', '<span class="cb-author"> <a href="' . esc_url(get_author_posts_url(get_post_field('post_author', $cb_post_id))) . '">' . $cb_author_avatar . get_the_author_meta('display_name', get_post_field('post_author', $cb_post_id)) . '</a></span>', $cb_post_id, $cb_author_avatar);
         }
         if ($cb_byline_date != 'off') {
             $cb_author .= $cb_byline_sep;
         }
     }
     if ($cb_byline_date != 'off') {
         //$cb_date = apply_filters( 'cb_byline_date', '<span class="cb-date"><time class="updated" datetime="' . get_the_time('Y-m-d', $cb_post_id) . '">' .human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago' . '</time></span>', $cb_post_id );
         $cb_date = apply_filters('cb_byline_date', '<span class="cb-date"><time class="updated" datetime="' . get_the_time('Y-m-d', $cb_post_id) . '">' . date_i18n(get_option('date_format'), strtotime(get_the_time("Y-m-d", $cb_post_id))) . '</time></span>', $cb_post_id);
     }
     if ($cb_cat != NULL) {
         if ($cb_post_meta_category != 'off') {
             $cb_cats = get_the_category($cb_post_id);
             if (!empty($cb_cats)) {
                 foreach ($cb_cats as $cb_cat => $cb_current_cat) {
                     if ($cb_byline_date != 'off' || $cb_byline_author != 'off') {
                         $cb_cat_output .= $cb_byline_sep;
                     }
                     $cb_cat_output .= apply_filters('cb_byline_category', '<span class="cb-category cb-element"><a href="' . esc_url(get_category_link($cb_current_cat->term_id)) . '" title="' . esc_attr(sprintf(__("View all posts in %s", "cubell"), $cb_current_cat->name)) . '">' . $cb_current_cat->cat_name . '</a></span>', $cb_current_cat);
                 }
             }
         }
     }
     if ($cb_views_on != NULL) {
         if ($cb_post_meta_views != 'off') {
             $cb_view_count = cb_get_post_viewcount($cb_post_id);
             if ($cb_view_count != NULL) {
                 if ($cb_byline_date != 'off' || $cb_byline_author != 'off' || $cb_post_meta_category != 'off') {
                     $cb_views_output .= $cb_byline_sep;
                 }
                 $cb_views_output .= apply_filters('cb_byline_views', '<span class="cb-views cb-element">' . $cb_view_count . '</span>', $cb_view_count);
             }
         }
     }
     if ($cb_meta_onoff == 'on' || $cb_override == 'on') {
         $cb_byline = '<div class="cb-byline">' . apply_filters('cb_byline_start', '') . $cb_author . $cb_date . $cb_cat_output . $cb_views_output . apply_filters('cb_byline_end', '') . '</div>';
     }
     return $cb_byline;
 }