Guest User

Untitled

a guest
Nov 2nd, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. <?php
  2. class td_block_authors extends td_block {
  3.  
  4. function render($atts, $content = null) {
  5. parent::render($atts);
  6. global $wpdb;
  7.  
  8. $sort = '';
  9.  
  10. extract(shortcode_atts(
  11. array(
  12. 'sort' => '',
  13. 'exclude' => '',
  14. 'include' => ''
  15. ),$this->atts));
  16.  
  17.  
  18.  
  19. //print_r($atts);
  20. //die;
  21.  
  22. $get_users_array = array();
  23.  
  24. if (!empty($exclude)) {
  25. $exclude_array = explode(',', $exclude);
  26. $get_users_array['exclude'] = $exclude_array;
  27. }
  28.  
  29. if (!empty($include)) {
  30. $include_array = explode(',', $include);
  31. $get_users_array['include'] = $include_array;
  32. }
  33.  
  34.  
  35. if (empty($sort)) {
  36. $get_users_array['orderby'] = 'display_name';
  37. //$td_authors = get_users(array('orderby' => 'display_name'));
  38. } else {
  39. $get_users_array['orderby'] = 'post_count';
  40. $get_users_array['order'] = 'DESC';
  41. //$td_authors = get_users(array('orderby' => 'post_count', 'order' => 'DESC'));
  42. }
  43.  
  44.  
  45. $td_authors = get_users($get_users_array);
  46.  
  47.  
  48. $buffy = '';
  49. $buffy .= '<div class="' . $this->get_block_classes(array('td_top_authors')) . '">';
  50. $buffy .= $this->get_block_title();
  51.  
  52. if (!empty($td_authors)) {
  53. foreach ($td_authors as $td_author) {
  54. //echo td_global::$current_author_obj->ID;
  55. //echo $td_author->ID;
  56. //print_r($td_author);
  57.  
  58. $current_author_class = '';
  59. if (!empty(td_global::$current_author_obj->ID) and td_global::$current_author_obj->ID == $td_author->ID) {
  60. $current_author_class = ' td-active';
  61. }
  62. $buffy .= '<div class="td_mod_wrap td-pb-padding-side' . $current_author_class . '">';
  63. $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . get_avatar($td_author->user_email, '70') . '</a>';
  64. $buffy .= '<div class="item-details">';
  65.  
  66. $buffy .= '<div class="td-authors-name">';
  67. $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . $td_author->display_name . '</a>';
  68. $buffy .= '</div>';
  69.  
  70.  
  71. $buffy .= '<span class="td-author-post-count">';
  72. $buffy .= count_user_posts($td_author->ID). ' ' . __td('POSTS');
  73. $buffy .= '</span>';
  74.  
  75. $buffy .= '<span class="td-author-comments-count">';
  76. $comment_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) AS total FROM $wpdb->comments WHERE comment_approved = 1 AND user_id = %d", $td_author->ID));
  77. $buffy .= $comment_count . ' ' . __td('COMMENTS');
  78. $buffy .= '</span>';
  79.  
  80. $buffy .= '<div class="td-authors-url">';
  81. $last_article = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post' ORDER BY post_date DESC LIMIT 1", $td_author->ID), ARRAY_A);
  82. $buffy .= '<a href="' . get_post_permalink($last_article['ID']) . '">' . $last_article['post_title'] .'</a>';
  83. $buffy .= '</div>';
  84.  
  85. $buffy .= '</div>';
  86.  
  87. $buffy .= '</div>';
  88. }
  89. }
  90.  
  91.  
  92.  
  93. $buffy .= '</div>';
  94.  
  95.  
  96. return $buffy;
  97.  
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment