Guest User

custom-renew-post-meta

a guest
Jul 22nd, 2016
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. function x_renew_entry_meta() {
  2.  
  3. //
  4. // Author.
  5. //
  6.  
  7. $author = sprintf( '<span>%s</span>',
  8. get_the_author()
  9. );
  10.  
  11.  
  12. //
  13. // Date.
  14. //
  15.  
  16. $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
  17. esc_attr( get_the_modified_date( 'c' ) ),
  18. esc_html( get_the_modified_date() )
  19. );
  20.  
  21.  
  22. //
  23. // Categories.
  24. //
  25.  
  26. if ( get_post_type() == 'x-portfolio' ) {
  27. if ( has_term( '', 'portfolio-category', NULL ) ) {
  28. $categories = get_the_terms( get_the_ID(), 'portfolio-category' );
  29. $separator = ', ';
  30. $categories_output = '';
  31. foreach ( $categories as $category ) {
  32. $categories_output .= '<a href="'
  33. . get_term_link( $category->slug, 'portfolio-category' )
  34. . '" title="'
  35. . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
  36. . '"> '
  37. . $category->name
  38. . '</a>'
  39. . $separator;
  40. }
  41.  
  42. $categories_list = sprintf( '<span>%s</span>',
  43. trim( $categories_output, $separator )
  44. );
  45. } else {
  46. $categories_list = '';
  47. }
  48. } else {
  49. $categories = get_the_category();
  50. $separator = ', ';
  51. $categories_output = '';
  52. foreach ( $categories as $category ) {
  53. $categories_output .= '<a href="'
  54. . get_category_link( $category->term_id )
  55. . '" title="'
  56. . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
  57. . '">'
  58. . $category->name
  59. . '</a>'
  60. . $separator;
  61. }
  62.  
  63. $categories_list = sprintf( '<span>%s</span>',
  64. trim( $categories_output, $separator )
  65. );
  66. }
  67.  
  68.  
  69. //
  70. // Comments link.
  71. //
  72.  
  73. if ( comments_open() ) {
  74.  
  75. $title = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
  76. $link = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
  77. $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );
  78.  
  79.  
  80. $text = ( 0 === $number ) ? 'Leave a Comment' : sprintf( _n( '%s Comment', '%s Comments', $number, '__x__' ), $number );
  81.  
  82.  
  83. $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
  84. esc_url( $link ),
  85. esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
  86. $text
  87. );
  88.  
  89. } else {
  90.  
  91. $comments = '';
  92.  
  93. }
  94.  
  95.  
  96. //
  97. // Output.
  98. //
  99.  
  100. if ( x_does_not_need_entry_meta() ) {
  101. return;
  102. } else {
  103. printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
  104. $author,
  105. $date,
  106. $categories_list,
  107. $comments
  108. );
  109. }
  110.  
  111. }
Advertisement
Add Comment
Please, Sign In to add comment