Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class td_block_authors extends td_block {
- function render($atts, $content = null) {
- parent::render($atts);
- global $wpdb;
- $sort = '';
- extract(shortcode_atts(
- array(
- 'sort' => '',
- 'exclude' => '',
- 'include' => ''
- ),$this->atts));
- //print_r($atts);
- //die;
- $get_users_array = array();
- if (!empty($exclude)) {
- $exclude_array = explode(',', $exclude);
- $get_users_array['exclude'] = $exclude_array;
- }
- if (!empty($include)) {
- $include_array = explode(',', $include);
- $get_users_array['include'] = $include_array;
- }
- if (empty($sort)) {
- $get_users_array['orderby'] = 'display_name';
- //$td_authors = get_users(array('orderby' => 'display_name'));
- } else {
- $get_users_array['orderby'] = 'post_count';
- $get_users_array['order'] = 'DESC';
- //$td_authors = get_users(array('orderby' => 'post_count', 'order' => 'DESC'));
- }
- $td_authors = get_users($get_users_array);
- $buffy = '';
- $buffy .= '<div class="' . $this->get_block_classes(array('td_top_authors')) . '">';
- $buffy .= $this->get_block_title();
- if (!empty($td_authors)) {
- foreach ($td_authors as $td_author) {
- //echo td_global::$current_author_obj->ID;
- //echo $td_author->ID;
- //print_r($td_author);
- $current_author_class = '';
- if (!empty(td_global::$current_author_obj->ID) and td_global::$current_author_obj->ID == $td_author->ID) {
- $current_author_class = ' td-active';
- }
- $buffy .= '<div class="td_mod_wrap td-pb-padding-side' . $current_author_class . '">';
- $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . get_avatar($td_author->user_email, '70') . '</a>';
- $buffy .= '<div class="item-details">';
- $buffy .= '<div class="td-authors-name">';
- $buffy .= '<a href="' . get_author_posts_url($td_author->ID) . '">' . $td_author->display_name . '</a>';
- $buffy .= '</div>';
- // $buffy .= '<span class="td-author-post-count">';
- // $buffy .= count_user_posts($td_author->ID). ' ' . __td('POSTS');
- // $buffy .= '</span>';
- //
- // $buffy .= '<span class="td-author-comments-count">';
- // $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));
- // $buffy .= $comment_count . ' ' . __td('COMMENTS');
- // $buffy .= '</span>';
- $buffy .= '<div class="td-authors-url">';
- $buffy .= '<a href="' . $td_author->user_url . '">' . $td_author->user_url .'</a>';
- $buffy .= '</div>';
- $buffy .= '<div class="author-description">';
- $buffy .= '<span> author description </span>';
- $buffy .= '</div>';
- $buffy .= '<div class="td-author-social">';
- foreach (td_social_icons::$td_social_icons_array as $td_social_id => $td_social_name) {
- //echo get_the_author_meta($td_social_id) . '<br>';
- $authorMeta = get_the_author_meta($td_social_id);
- if (!empty($authorMeta)) {
- //the theme can use the twitter id instead of the full url. This avoids problems with yoast plugin
- if ($td_social_id == 'twitter') {
- if (filter_var($authorMeta, FILTER_VALIDATE_URL)) {
- } else {
- $authorMeta = str_replace('@', '', $authorMeta);
- $authorMeta = 'http://twitter.com/' . $authorMeta;
- }
- }
- $buffy .= td_social_icons::get_icon($authorMeta, $td_social_id, 4, 16);
- }
- }
- $buffy .= '</div>';
- $buffy .= '</div>';
- $buffy .= '</div>';
- }
- }
- $buffy .= '</div>';
- return $buffy;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment