rdusnr

Untitled

Feb 18th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1.  
  2.  
  3. if ( ! function_exists( 'kleo_entry_meta' ) ) :
  4. /**
  5. * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
  6. * Create your own kleo_entry_meta() to override in a child theme.
  7. * @since 1.0
  8. */
  9. function kleo_entry_meta( $echo = true, $att = array() ) {
  10.  
  11. global $kleo_config;
  12. $meta_list = array();
  13. $author_links = '';
  14. $meta_elements = sq_option( 'blog_meta_elements', $kleo_config['blog_meta_defaults'] );
  15.  
  16. // Translators: used between list items, there is a space after the comma.
  17. if ( in_array( 'categories', $meta_elements ) ) {
  18. $categories_list = get_the_category_list( __( ', ', 'kleo_framework' ) );
  19. }
  20.  
  21. // Translators: used between list items, there is a space after the comma.
  22. if ( in_array( 'tags', $meta_elements ) ) {
  23. $tag_list = get_the_tag_list( '', __( ', ', 'kleo_framework' ) );
  24. }
  25.  
  26. $date = sprintf( '<a href="%1$s" rel="bookmark" class="post-time">' .
  27. '<time class="entry-date" datetime="%2$s">%3$s</time>' .
  28. '<time class="modify-date hide hidden updated" datetime="%4$s">%5$s</time>' .
  29. '</a>',
  30. esc_url( get_permalink() ),
  31. esc_attr( get_the_date( 'c' ) ),
  32. esc_html( get_the_date() ),
  33. esc_html( get_the_modified_date( 'c' ) ),
  34. esc_html( get_the_modified_date() )
  35. );
  36.  
  37.  
  38. if ( is_array( $meta_elements ) && ! empty( $meta_elements ) ) {
  39.  
  40.  
  41. if ( in_array( 'author_link', $meta_elements ) || in_array( 'avatar', $meta_elements ) ) {
  42.  
  43. $author_link = esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) );
  44. $author_title = esc_attr( sprintf( __( 'View all POSTS by %s', 'kleo_framework' ), get_the_author() ) );
  45.  
  46.  
  47. $author = sprintf( '<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s %4$s</a>',
  48. $author_link,
  49. $author_title,
  50. in_array( 'avatar', $meta_elements ) ? get_avatar( get_the_author_meta( 'ID' ), 50 ) : '',
  51. in_array( 'author_link', $meta_elements ) ? '<span class="author-name">' . get_the_author() . '</span>' : ''
  52. );
  53.  
  54. $meta_list[] = '<small class="meta-author author vcard">' . $author . '</small>';
  55. }
  56.  
  57. if ( in_array( 'archive', $meta_elements ) ) {
  58. $author_links .= '<a href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' .
  59. '<i class="icon-docs hover-tip" ' .
  60. 'data-original-title="' . esc_attr( sprintf( __( 'View all posts by %s', 'kleo_framework' ), get_the_author() ) ) . '" ' .
  61. 'data-toggle="tooltip" ' .
  62. 'data-placement="top"></i>' .
  63. '</a>';
  64. }
  65. }
  66.  
  67. if ( '' != $author_links ) {
  68. $meta_list[] = '<small class="meta-links">' . $author_links . '</small>';
  69. }
  70.  
  71. if ( in_array( 'date', $meta_elements ) ) {
  72. $meta_list[] = '<small>' . $date . '</small>';
  73. }
  74.  
  75. $cat_tag = array();
  76.  
  77. if ( isset( $categories_list ) && $categories_list ) {
  78. $cat_tag[] = $categories_list;
  79. }
  80.  
  81. if ( isset( $tag_list ) && $tag_list ) {
  82. $cat_tag[] = $tag_list;
  83. }
  84. if ( ! empty( $cat_tag ) ) {
  85. $meta_list[] = '<small class="meta-category">' . implode( ', ', $cat_tag ) . '</small>';
  86. }
  87.  
  88. //comments
  89. if ( ( ! isset( $att['comments'] ) || ( isset( $att['comments'] ) && false != $att['comments'] ) ) && in_array( 'comments', $meta_elements ) ) {
  90. $meta_list[] = '<small class="meta-comment-count"><a href="' . get_permalink() . '#comments">' . get_comments_number() .
  91. ' <i class="icon-chat-1 hover-tip" ' .
  92. 'data-original-title="' . sprintf( _n( 'This article has one comment', 'This article has %1$s comments', get_comments_number(), 'kleo_framework' ), number_format_i18n( get_comments_number() ) ) . '" ' .
  93. 'data-toggle="tooltip" ' .
  94. 'data-placement="top"></i>' .
  95. '</a></small>';
  96. }
  97.  
  98. $meta_separator = isset( $att['separator'] ) ? $att['separator'] : sq_option( 'blog_meta_sep', ', ' );
  99.  
  100. if ( $echo ) {
  101. echo implode( $meta_separator, $meta_list );
  102. } else {
  103. return implode( $meta_separator, $meta_list );
  104. }
  105.  
  106.  
  107. }
  108. endif;
Advertisement
Add Comment
Please, Sign In to add comment