Advertisement
rdusnr

Untitled

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