Advertisement
rdusnr

Untitled

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