agentswall

td_block_authors

Feb 19th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. Here is the php file
  2.  
  3.  
  4. <?php
  5. class td_block_authors extends td_block {
  6.  
  7. function render($atts, $content = null) {
  8. global $wpdb;
  9.  
  10. $title = '';
  11. $sort = '';
  12.  
  13. extract(shortcode_atts(
  14. array(
  15. 'title' => '',
  16. 'sort' => '',
  17. 'header_color' => '',
  18. 'exclude' => '',
  19. 'include' => ''
  20. ),$atts));
  21.  
  22. if (trim($title) == '') {
  23. $title = __td('OUR AUTHORS');
  24. }
  25.  
  26. //print_r($atts);
  27. //die;
  28.  
  29. $get_users_array = array(‘role’ => ('administrator'));
  30.  
  31. if (!empty($exclude)) {
  32. $exclude_array = explode(',', $exclude);
  33. $get_users_array['exclude'] = $exclude_array;
  34. }
  35.  
  36. if (!empty($include)) {
  37. $include_array = explode(',', $include);
  38. $get_users_array['include'] = $include_array;
  39. }
  40.  
  41.  
  42. if (empty($sort)) {
  43. $get_users_array['orderby'] = 'display_name';
  44. //$td_authors = get_users(array('orderby' => 'display_name'));
  45. } else {
  46. $get_users_array['orderby'] = 'post_count';
  47. $get_users_array['order'] = 'DESC';
  48. //$td_authors = get_users(array('orderby' => 'post_count', 'order' => 'DESC'));
  49. }
  50.  
  51.  
  52. $td_authors = get_users($get_users_array);
  53. //print_r($td_authors);
  54.  
  55. $td_authors = array_merge($td_authors, get_users(array('role' => 'author')));
  56.  
  57. $buffy = '';
  58. $buffy .= '<div class="td_block_wrap td_top_authors">';
  59. $buffy .= '<h4 class="block-title"><span>' . $title . '</span></h4>';
  60.  
  61. if (!empty($td_authors)) {
  62. foreach ($td_authors as $td_author) {
  63. //echo td_global::$current_author_obj->ID;
  64. //echo $td_author->ID;
  65. //print_r($td_author);
  66.  
  67. $current_author_class = '';
  68. if (!empty(td_global::$current_author_obj->ID) and td_global::$current_author_obj->ID == $td_author->ID) {
  69. $current_author_class = ' td-active';
  70. }
  71. $buffy .= '<div class="td_mod_wrap td-pb-padding-side' . $current_author_class . '">';
  72. $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . get_avatar($td_author->user_email, '70') . '</a>';
  73. $buffy .= '<div class="item-details">';
  74.  
  75. $buffy .= '<div class="td-authors-name">';
  76. $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . $td_author->display_name . '</a>';
  77. $buffy .= '</div>';
  78.  
  79.  
  80. $buffy .= '<span class="td-author-post-count">';
  81. $buffy .= count_user_posts($td_author->ID). ' ' . __td('POSTS');
  82. $buffy .= '</span>';
  83.  
  84. $buffy .= '<span class="td-author-comments-count">';
  85. $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));
  86. $buffy .= $comment_count . ' ' . __td('COMMENTS');
  87. $buffy .= '</span>';
  88.  
  89. $buffy .= '<div class="td-authors-url">';
  90. $buffy .= '<a href="' . $td_author->user_url . '">' . $td_author->user_url .'</a>';
  91. $buffy .= '</div>';
  92.  
  93. $buffy .= '</div>';
  94.  
  95. $buffy .= '</div>';
  96. }
  97. }
  98.  
  99.  
  100.  
  101. $buffy .= '</div>';
  102.  
  103.  
  104. return $buffy;
  105.  
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment