Guest User

Untitled

a guest
Sep 22nd, 2015
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 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. $buffy .= '<a href="' . $td_author->user_url . '">' . $td_author->user_url .'</a>';
  82. $buffy .= '</div>';
  83.  
  84. $buffy .= '<div class="author-description">';
  85. $buffy .= '<span> author description </span>';
  86. $buffy .= '</div>';
  87.  
  88. $buffy .= '<div class="td-author-social">';
  89. foreach (td_social_icons::$td_social_icons_array as $td_social_id => $td_social_name) {
  90. //echo get_the_author_meta($td_social_id) . '<br>';
  91. $authorMeta = get_the_author_meta($td_social_id);
  92. if (!empty($authorMeta)) {
  93.  
  94. //the theme can use the twitter id instead of the full url. This avoids problems with yoast plugin
  95. if ($td_social_id == 'twitter') {
  96. if (filter_var($authorMeta, FILTER_VALIDATE_URL)) {
  97.  
  98. } else {
  99. $authorMeta = str_replace('@', '', $authorMeta);
  100. $authorMeta = 'http://twitter.com/' . $authorMeta;
  101. }
  102. }
  103. $buffy .= td_social_icons::get_icon($authorMeta, $td_social_id, 4, 16);
  104. }
  105. }
  106. $buffy .= '</div>';
  107.  
  108. $buffy .= '</div>';
  109.  
  110. $buffy .= '</div>';
  111. }
  112. }
  113.  
  114.  
  115.  
  116. $buffy .= '</div>';
  117.  
  118.  
  119. return $buffy;
  120.  
  121. }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment