Exemplo n.º 1
0
function wp_list_authors_art($args = '')
{
    global $wpdb;
    $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'echo' => true, 'orderby' => 'articles', 'days' => 30, 'show' => 5);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $return = '';
    // TODO:  Move select to get_authors().
    switch ($orderby) {
        case 'views':
            $authors = $wpdb->get_results("SELECT COUNT(b.ID) AS postsperuser, a.ID AS post_id, display_name, user_nicename, b.ID AS ID, sum(m.meta_value+0) AS visitas FROM wp_posts AS a, wp_users AS b, wp_postmeta AS m WHERE a.ID = m.post_id AND meta_key='views' AND a.post_author = b.ID AND post_type = 'post' AND post_status = 'publish' AND post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY b.ID ORDER BY visitas DESC LIMIT {$show}");
            $select = (array) $wpdb->get_results("SELECT DISTINCT p.post_author, COUNT(DISTINCT p.ID) AS posts, sum(m.meta_value+0) AS count FROM wp_posts AS p, wp_postmeta AS m WHERE p.ID = m.post_id AND meta_key='views' AND p.post_type = 'post' AND p.post_status = 'publish' AND " . get_private_posts_cap_sql('post') . " AND p.post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY p.post_author ORDER BY count DESC LIMIT {$show}");
            break;
        case 'votes':
            $authors = $wpdb->get_results("SELECT COUNT(b.ID) AS postsperuser, a.ID AS post_id, display_name, user_nicename, b.ID AS ID, sum(m.meta_value+0) AS visitas FROM wp_posts AS a, wp_users AS b, wp_postmeta AS m WHERE a.ID = m.post_id AND meta_key='_liked' AND a.post_author = b.ID AND post_type = 'post' AND post_status = 'publish' AND post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY b.ID ORDER BY visitas DESC LIMIT {$show}");
            $select = (array) $wpdb->get_results("SELECT DISTINCT p.post_author, COUNT(DISTINCT p.ID) AS posts, sum(m.meta_value+0) AS count FROM wp_posts AS p, wp_postmeta AS m WHERE p.ID = m.post_id AND meta_key='_liked' AND p.post_type = 'post' AND p.post_status = 'publish' AND " . get_private_posts_cap_sql('post') . " AND p.post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY p.post_author ORDER BY count DESC LIMIT {$show}");
            break;
        case 'all':
            $authors = $wpdb->get_results("SELECT a.ID AS post_id, display_name, user_nicename, b.ID AS ID, sum(views.meta_value+0) AS viewsc, sum(votos.meta_value+0) AS votosc, COUNT(b.ID) AS postsperuser FROM wp_posts AS a, wp_users AS b, wp_postmeta AS votos, wp_postmeta AS views WHERE a.ID = votos.post_id AND a.ID = views.post_id AND votos.meta_key='_liked' AND views.meta_key='views' AND a.post_author = b.ID AND post_type = 'post' AND post_status = 'publish' AND post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY b.ID ORDER BY viewsc DESC, votosc DESC, postsperuser DESC LIMIT {$show}");
            $select = (array) $wpdb->get_results("SELECT DISTINCT p.post_author, sum(views.meta_value+0) AS viewsc, sum(votos.meta_value+0) AS votosc, COUNT(DISTINCT p.ID) AS posts, ((sum(views.meta_value+0))+(sum(votos.meta_value+0))+(COUNT(DISTINCT p.ID))) AS count FROM wp_posts AS p, wp_postmeta AS votos, wp_postmeta AS views WHERE p.ID = votos.post_id AND p.ID = views.post_id AND votos.meta_key='_liked' AND views.meta_key='views' AND p.post_type = 'post' AND p.post_status = 'publish' AND " . get_private_posts_cap_sql('post') . " AND p.post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY p.post_author ORDER BY viewsc DESC, votosc DESC, posts DESC LIMIT {$show}");
            break;
        case 'follows':
            $authors = $wpdb->get_results("SELECT COUNT(b.ID) AS postsperuser, a.ID AS post_id, display_name, user_nicename, b.ID AS ID, COUNT(DISTINCT c.item_id) AS follows FROM wp_posts AS a, wp_users AS b, wp_follows AS c WHERE a.post_author = b.ID AND c.item_id = b.ID AND c.item_id = a.post_author AND c.item_type = 'author' AND post_type = 'post' AND post_status = 'publish' AND post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY b.ID ORDER BY follows DESC LIMIT {$show}");
            $select = (array) $wpdb->get_results("SELECT DISTINCT a.post_author, COUNT(DISTINCT b.item_id) AS count FROM wp_posts AS a, wp_follows AS b WHERE a.post_type = 'post' AND a.post_status = 'publish' AND b.item_id = a.post_author AND b.item_type = 'author' AND " . get_private_posts_cap_sql('post') . " AND a.post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY a.post_author ORDER BY count DESC LIMIT {$show}");
            break;
        default:
            $authors = $wpdb->get_results("SELECT COUNT(b.ID) AS postsperuser, a.ID AS post_id, display_name, user_nicename, b.ID AS ID FROM wp_posts AS a, wp_users AS b WHERE a.post_author = b.ID AND post_type = 'post' AND post_status = 'publish' AND post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY b.ID ORDER BY postsperuser DESC LIMIT {$show}");
            $select = (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(DISTINCT ID) AS count FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' AND " . get_private_posts_cap_sql('post') . " AND post_date > '" . date('Y-m-d', strtotime('-' . $days . ' days')) . "' GROUP BY post_author ORDER BY count DESC LIMIT {$show}");
            break;
    }
    $author_count = array();
    foreach ($select as $row) {
        $author_count[$row->post_author] = $row->count;
    }
    foreach ((array) $authors as $author) {
        $author = get_userdata($author->ID);
        $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
        $name = $author->display_name;
        if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
            $name = "{$author->first_name} {$author->last_name}";
        }
        if (!($posts == 0 && $hide_empty)) {
            $return .= '<li>';
        }
        if ($posts == 0) {
            if (!$hide_empty) {
                $link = $name;
            }
        } else {
            $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . $feed . '"';
                    $alt = ' alt="' . $feed . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"{$feed_image}\" border=\"0\"{$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if ($optioncount) {
                switch ($orderby) {
                    case 'views':
                        $link .= ' (' . $posts . ' lecturas)';
                        break;
                    case 'votes':
                        $link .= ' (' . $posts . ' votos)';
                        break;
                    case 'follows':
                        $link .= ' (' . $posts . ' seguidores)';
                        break;
                    case 'all':
                        $link .= ' (' . $posts . ' puntos)';
                        break;
                    default:
                        $link .= ' (' . $posts . ' artículos)';
                        break;
                }
            }
        }
        if (!($posts == 0 && $hide_empty)) {
            $return .= $link . '</li>';
        }
    }
    if (!$echo) {
        return $return;
    }
    echo $return;
}
function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
	global $wpdb;
	$query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
	$authors = $wpdb->get_results($query);

	foreach ( $authors as $author ) {
		$author = get_userdata( $author->ID );
		$posts = get_usernumposts($author->ID);
		$name = $author->nickname;

		if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
			$name = "$author->first_name $author->last_name";

		if ( !($posts == 0 && $hide_empty) )
			echo "<li>";
		if ( $posts == 0 ) {
			if ( !$hide_empty )
				$link = $name;
		} else {
			$link = '<a href="' . get_author_link(0, $author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), wp_specialchars($author->display_name)) . '">' . $name . '</a>';

			if ( (! empty($feed_image)) || (! empty($feed)) ) {
				$link .= ' ';
				if (empty($feed_image))
					$link .= '(';
				$link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';

				if ( !empty($feed) ) {
					$title = ' title="' . $feed . '"';
					$alt = ' alt="' . $feed . '"';
					$name = $feed;
					$link .= $title;
				}

				$link .= '>';

				if ( !empty($feed_image) )
					$link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
				else
					$link .= $name;

				$link .= '</a>';

				if ( empty($feed_image) )
					$link .= ')';
			}

			if ( $optioncount )
				$link .= ' ('. $posts . ')';

		}

		if ( !($posts == 0 && $hide_empty) )
			echo "$link</li>";
	}
}
Exemplo n.º 3
0
</p>
				<ul>
					<?php 
    if ($objAuthor->user_url != 'http://') {
        ?>
<li class="icon author"><a href="<?php 
        echo $objAuthor->user_url;
        ?>
"><?php 
        _e("Visit Author's Website", 'gluedideas_subtle');
        ?>
</a></li><?php 
    }
    ?>
					<li class="icon feed"><a href="<?php 
    get_author_rss_link(true, $objAuthor->ID, $objAuthor->user_login);
    ?>
"><?php 
    _e("Author's Feed", 'gluedideas_subtle');
    ?>
</a></li>
				</ul>
			</div></div>
<?php 
} else {
    ?>
			<div id="search" class="prominent reduced"><div class="inner">
				<h2><?php 
    _e("Find It Quickly", 'gluedideas_subtle');
    ?>
</h2>
function wp_list_authors($args = '')
{
    if (is_array($args)) {
        $r =& $args;
    } else {
        parse_str($args, $r);
    }
    $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '');
    $r = array_merge($defaults, $r);
    extract($r);
    global $wpdb;
    // TODO:  Move select to get_authors().
    $query = "SELECT ID, user_nicename from {$wpdb->users} " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
    $authors = $wpdb->get_results($query);
    foreach ((array) $authors as $author) {
        $author = get_userdata($author->ID);
        $posts = get_usernumposts($author->ID);
        $name = $author->nickname;
        if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
            $name = "{$author->first_name} {$author->last_name}";
        }
        if (!($posts == 0 && $hide_empty)) {
            echo "<li>";
        }
        if ($posts == 0) {
            if (!$hide_empty) {
                $link = $name;
            }
        } else {
            $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . $feed . '"';
                    $alt = ' alt="' . $feed . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"{$feed_image}\" border=\"0\"{$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if ($optioncount) {
                $link .= ' (' . $posts . ')';
            }
        }
        if (!($posts == 0 && $hide_empty)) {
            echo "{$link}</li>";
        }
    }
}
Exemplo n.º 5
0
get_header();
?>

<div id="userpage">
<div id="main">

<?php 
if (have_posts()) {
    $first_post = true;
    while (have_posts()) {
        the_post();
        $author_feed_url = '';
        if (function_exists('get_author_feed_link')) {
            $author_feed_url = get_author_feed_link(get_the_author_ID());
        } else {
            $author_feed_url = get_author_rss_link(false, get_the_author_ID(), get_the_author_nickname());
        }
        ?>

<?php 
        if ($first_post === true) {
            ?>
	<h2>
		<?php 
            echo get_avatar(get_the_author_email(), 48);
            ?>
		Updates from <?php 
            the_author_posts_link();
            ?>
		<a class="rss" href="<?php 
            echo $author_feed_url;
Exemplo n.º 6
0
)" href="<?php 
        get_author_rss_link(true, $author, $author_name);
        ?>
" />
<?php 
    } else {
        if (!empty($GLOBALS['p'])) {
            $_user = get_userdata($GLOBALS['post']->post_author);
            $author = $_user->ID;
            $author_name = $_user->user_login;
            ?>
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0(by <?php 
            echo $author_name;
            ?>
)" href="<?php 
            get_author_rss_link(true, $author, $author_name);
            ?>
" />
<?php 
        }
    }
}
if (get_settings('use_pingback')) {
    ?>
	<link rel="pingback" href="<?php 
    bloginfo('pingback_url');
    ?>
" />
<?php 
}
if (get_settings('xmlrpc_autodetect')) {
Exemplo n.º 7
0
            ?>
 <?php 
            the_author_meta('display_name');
            ?>
</h2>

				<p><?php 
            _e('You can follow entries authored by');
            ?>
 <?php 
            the_author_meta('user_nicename');
            ?>
 <?php 
            _e('via an');
            ?>
 <a href="<? echo get_author_rss_link(0, $author, $author_nicename); ?>" title="<?php 
            _e('RSS 2.0');
            ?>
"><?php 
            _e('author-only XML feed');
            ?>
</a>.</p>
				<p><?php 
            the_author_meta('user_nicename');
            ?>
 <?php 
            _e('has authored');
            ?>
 <?php 
            the_author_posts();
            ?>
function list_authors2($optioncount = false, $exclude_admin = true, $idmode = '', $hide_empty = true, $feed = '', $feed_image = '')
{
    global $wp_id, $wpdb, $blogfilename;
    $query = "SELECT ID, user_idmode, user_nickname, user_firstname, user_lastname, user_login from {$wpdb->users[$wp_id]} " . ($exclude_admin ? "WHERE ID <> 1 " : '') . "ORDER BY user_nickname";
    $authors = $wpdb->get_results($query);
    foreach ($authors as $author) {
        $posts = get_usernumposts($author->ID, true);
        $name = $author->user_nickname;
        if (empty($idmode)) {
            $idmode = $author->user_idmode;
        }
        if ($idmode == 'nickname') {
            $name = $author->user_nickname;
        }
        if ($idmode == 'login') {
            $name = $author->user_login;
        }
        if ($idmode == 'firstname') {
            $name = $author->user_firstname;
        }
        if ($idmode == 'lastname') {
            $name = $author->user_lastname;
        }
        if ($idmode == 'namefl') {
            $name = $author->user_firstname . ' ' . $author->user_lastname;
        }
        if ($idmode == 'namelf') {
            $name = $author->user_lastname . ' ' . $author->user_firstname;
        }
        if (!$idmode) {
            $name = $author->user_nickname;
        }
        if (!($posts == 0 && $hide_empty)) {
            echo "<li>";
        }
        if ($posts == 0) {
            if (!$hide_empty) {
                echo $name;
            }
        } else {
            $link = '<a href="' . get_author_link(0, $author->ID, $author->user_login) . '" title="' . sprintf("Posts by %s", htmlspecialchars($author->user_nickname)) . '">' . stripslashes($name) . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_login) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . stripslashes($feed) . '"';
                    $alt = ' alt="' . stripslashes($feed) . '"';
                    $name = stripslashes($feed);
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"{$feed_image}\" border=\"0\" align=\"absbottom\"{$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if ($optioncount) {
                $link .= ' (' . $posts . ')';
            }
        }
        if (!($posts == 0 && $hide_empty)) {
            echo "{$link}</li>";
        }
    }
}
 function list_authors2($optioncount = false, $exclude_admin = true, $idmode = '', $hide_empty = true, $feed = '', $feed_image = '', $echo = true)
 {
     $list_authors2 = '';
     if ($exclude_admin) {
         $criteria = new Criteria('ID', 1, '<>');
     } else {
         $criteria = new CriteriaCompo();
     }
     $criteria->setSort('user_nickname');
     $userHandler =& wp_handler('User');
     $userObjects =& $userHandler->getObjects($criteria);
     foreach ($userObjects as $userObject) {
         $author =& $userObject->exportWpObject($idmode);
         $name = htmlspecialchars(get_author_name($author->ID, $idmode), ENT_QUOTES);
         $posts = get_usernumposts($author->ID);
         if (!($posts == 0 && $hide_empty)) {
             $list_authors2 .= "<li>";
         }
         if ($posts == 0) {
             if (!$hide_empty) {
                 $list_authors2 .= $name;
             }
         } else {
             $link = '<a href="' . get_author_link(0, $author->ID, $author->user_login) . '" title="' . sprintf("Posts by %s", $name) . '">' . $name . '</a>';
             if (!empty($feed_image) || !empty($feed)) {
                 $link .= ' ';
                 if (empty($feed_image)) {
                     $link .= '(';
                 }
                 $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_login) . '"';
                 if (!empty($feed)) {
                     $title = ' title="' . $feed . '"';
                     $alt = ' alt="' . $feed . '"';
                     $name = $feed;
                     $link .= $title;
                 }
                 $link .= '>';
                 if (!empty($feed_image)) {
                     $link .= "<img src=\"{$feed_image}\" border=\"0\" align=\"bottom\"{$alt}{$title}" . ' />';
                 } else {
                     $link .= $name;
                 }
                 $link .= '</a>';
                 if (empty($feed_image)) {
                     $link .= ')';
                 }
             }
             if ($optioncount) {
                 $link .= ' (' . $posts . ')';
             }
         }
         if (!($posts == 0 && $hide_empty)) {
             $list_authors2 .= "{$link}</li>";
         }
     }
     return _echo($list_authors2, $echo);
 }
Exemplo n.º 10
0
/**
 * List all the authors of the blog, with several options available.
 *
 * optioncount (boolean) (false): Show the count in parenthesis next to the
 *		author's name.
 * exclude_admin (boolean) (true): Exclude the 'admin' user that is installed by
 *		default.
 * show_fullname (boolean) (false): Show their full names.
 * hide_empty (boolean) (true): Don't show authors without any posts.
 * feed (string) (''): If isn't empty, show links to author's feeds.
 * feed_image (string) (''): If isn't empty, use this image to link to feeds.
 * echo (boolean) (true): Set to false to return the output, instead of echoing.
 *
 * @link http://codex.wordpress.org/Template_Tags/wp_list_authors
 * @since 1.2
 * @param array $args The argument array.
 * @return null|string The output, if echo is set to false.
 */
function wp_list_authors($args = '')
{
    global $wpdb;
    $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true);
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $return = '';
    /** @todo Move select to get_authors(). */
    $users = get_users_of_blog();
    $author_ids = array();
    foreach ((array) $users as $user) {
        $author_ids[] = $user->user_id;
    }
    if (count($author_ids) > 0) {
        $author_ids = implode(',', $author_ids);
        $authors = $wpdb->get_results("SELECT ID, user_nicename from {$wpdb->users} WHERE ID IN({$author_ids}) " . ($exclude_admin ? "AND user_login <> 'admin' " : '') . "ORDER BY display_name");
    } else {
        $authors = array();
    }
    $author_count = array();
    foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM {$wpdb->posts} WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " GROUP BY post_author") as $row) {
        $author_count[$row->post_author] = $row->count;
    }
    foreach ((array) $authors as $author) {
        $author = get_userdata($author->ID);
        $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
        $name = $author->display_name;
        if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
            $name = "{$author->first_name} {$author->last_name}";
        }
        if (!($posts == 0 && $hide_empty)) {
            $return .= '<li>';
        }
        if ($posts == 0) {
            if (!$hide_empty) {
                $link = $name;
            }
        } else {
            $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . $feed . '"';
                    $alt = ' alt="' . $feed . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"{$feed_image}\" style=\"border: none;\"{$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if ($optioncount) {
                $link .= ' (' . $posts . ')';
            }
        }
        if (!($posts == 0 && $hide_empty)) {
            $return .= $link . '</li>';
        }
    }
    if (!$echo) {
        return $return;
    }
    echo $return;
}
function wp_list_authors($args = '') {
	global $wpdb;
	
	if ( is_array($args) )
		$r = &$args;
	else
		parse_str($args, $r);

	$defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true,
		'feed' => '', 'feed_image' => '');
	$r = array_merge($defaults, $r);
	extract($r, EXTR_SKIP);
	
	// TODO:  Move select to get_authors().
	$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");
	
	$author_count = array();
	foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_status = 'publish' GROUP BY post_author") as $row) {
		$author_count[$row->post_author] = $row->count;
	}

	foreach ( (array) $authors as $author ) {
		$author = get_userdata( $author->ID );
		$posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
		$name = $author->nickname;

		if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
			$name = "$author->first_name $author->last_name";

		if ( !($posts == 0 && $hide_empty) )
			echo "<li>";
		if ( $posts == 0 ) {
			if ( !$hide_empty )
				$link = $name;
		} else {
			$link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';

			if ( (! empty($feed_image)) || (! empty($feed)) ) {
				$link .= ' ';
				if (empty($feed_image))
					$link .= '(';
				$link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';

				if ( !empty($feed) ) {
					$title = ' title="' . $feed . '"';
					$alt = ' alt="' . $feed . '"';
					$name = $feed;
					$link .= $title;
				}

				$link .= '>';

				if ( !empty($feed_image) )
					$link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
				else
					$link .= $name;

				$link .= '</a>';

				if ( empty($feed_image) )
					$link .= ')';
			}

			if ( $optioncount )
				$link .= ' ('. $posts . ')';

		}

		if ( !($posts == 0 && $hide_empty) )
			echo "$link</li>";
	}
}
Exemplo n.º 12
0
function wpyou_authorlist($args = '')
{
    global $wpdb;
    $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'num' => '5');
    $r = wp_parse_args($args, $defaults);
    extract($r, EXTR_SKIP);
    $return = '';
    $num = (int) $num;
    if ($num < 1) {
        $num = 5;
    }
    $authors = $wpdb->get_results("SELECT DISTINCT u.ID, u.user_nicename, COUNT( p.ID ) AS count from {$wpdb->users} AS u, {$wpdb->posts} AS p " . ($exclude_admin ? "WHERE u.user_login <> 'admin' " : 'WHERE ') . "AND p.post_author = u.ID AND p.post_type = 'post' AND ( p.post_status = 'publish' OR p.post_status = 'private') GROUP BY p.post_author ORDER BY count DESC, display_name ASC LIMIT {$num}");
    $author_count = array();
    foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM {$wpdb->posts} WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " GROUP BY post_author") as $row) {
        $author_count[$row->post_author] = $row->count;
    }
    foreach ((array) $authors as $author) {
        $author = get_userdata($author->ID);
        $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
        $name = $author->display_name;
        if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
            $name = "{$author->first_name} {$author->last_name}";
        }
        if (!($posts == 0 && $hide_empty)) {
            $return .= '<li>';
        }
        if ($posts == 0) {
            if (!$hide_empty) {
                $link = $name;
            }
        } else {
            $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . $feed . '"';
                    $alt = ' alt="' . $feed . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"{$feed_image}\" style=\"border: none;\"{$alt}{$title}" . ' />';
                } else {
                    $link .= $name;
                }
                $link .= '</a>';
                if (empty($feed_image)) {
                    $link .= ')';
                }
            }
            if ($optioncount) {
                $link .= ' (' . $posts . ')';
            }
        }
        if (!($posts == 0 && $hide_empty)) {
            $return .= $link . '</li>';
        }
    }
    if (!$echo) {
        return $return;
    }
    echo $return;
}
Exemplo n.º 13
0
function wpu_feed_link($link)
{
    global $wpSettings;
    if (!empty($wpSettings['usersOwnBlogs'])) {
        //only works if not in admin.
        $authorID = wpu_get_author();
        if (!strstr($link, 'comment')) {
            $link = get_author_rss_link(FALSE, $authorID, '');
        } else {
            //	get author RSS link for comments
        }
    }
    return $link;
}
Exemplo n.º 14
0
function get_wpu_bloglist($showAvatars = TRUE, $maxEntries = 5)
{
    global $wpdb, $authordata, $scriptPath, $wpuAbs, $wpSettings, $wp_version, $phpEx;
    $start = 0;
    $start = (int) trim($_GET['start']);
    $start = $start < 0 ? 0 : $start;
    //get total count
    $sql = "SELECT count(DISTINCT {$wpdb->users}.ID) AS total\n\t\t\tFROM {$wpdb->users} \n\t\t\tINNER JOIN {$wpdb->posts}\n\t\t\tON {$wpdb->users}.ID={$wpdb->posts}.post_author\n\t\t\tWHERE {$wpdb->users}.user_login <> 'admin'";
    $count = $wpdb->get_results($sql);
    $numAuthors = $count[0]->total;
    $maxEntries = $maxEntries < 1 ? 5 : $maxEntries;
    //pull the data we want to display -- this doesn't appear to be very efficient, but it is the same method as  the built-in WP function
    // wp_list_authors uses. Let's hope the data gets cached!
    $sql = "SELECT DISTINCT {$wpdb->users}.ID, {$wpdb->users}.user_login, {$wpdb->users}.user_nicename \n\t\t\tFROM {$wpdb->users}\n\t\t\tINNER JOIN {$wpdb->posts} \n\t\t\tON {$wpdb->users}.ID={$wpdb->posts}.post_author \n\t\t\tWHERE {$wpdb->users}.user_login<>'admin' \n\t\t\tORDER BY {$wpdb->users}.display_name LIMIT {$start}, {$maxEntries}";
    $authors = $wpdb->get_results($sql);
    if (count($authors) > 0) {
        $d = get_settings('time_format');
        $time = mysql2date($d, $time);
        $itern = 1;
        $blogList = '';
        foreach ((array) $authors as $author) {
            $posts = 0;
            $_oldQuery = '';
            $avatar = '';
            $blogTitle = '';
            $blogDesc = '';
            $blogPath = '';
            $path_to_profile = '';
            $lastPostID = 0;
            $post = '';
            $lastPostTitle = '';
            $lastPostURL = '';
            $time = '';
            $lastPostTime = '';
            $posts = get_usernumposts($author->ID);
            if ($posts) {
                $author = get_userdata($author->ID);
                $pID = (int) $author->phpbb_userid;
                $name = $author->nickname;
                if ($show_fullname && ($author->first_name != '' && $author->last_name != '')) {
                    $name = "{$author->first_name} {$author->last_name}";
                }
                $avatar = avatar_create_image($author);
                $blogTitle = empty($author->blog_title) ? $wpuAbs->lang('default_blogname') : $author->blog_title;
                $blogDesc = empty($author->blog_tagline) ? $wpuAbs->lang('default_blogdesc') : $author->blog_tagline;
                if ((double) $wp_version >= 2.1) {
                    //WP >= 2.1 branch
                    $blogPath = get_author_posts_url($author->ID, $author->user_nicename);
                } else {
                    //deprecated branch
                    $blogPath = get_author_link(false, $author->ID, $author->user_nicename);
                }
                $wUsrName = sanitize_user($author->user_login, true);
                if ($wUsrName == $author->user_login) {
                    $pUsrName = $author->user_login;
                } else {
                    $pUsrName == $author->phpbb_userLogin;
                }
                $profile_path = $wpuAbs->ver == 'PHPBB2' ? "profile.{$phpEx}" : "memberlist.{$phpEx}";
                $path_to_profile = empty($pID) ? append_sid($blogPath) : append_sid(add_trailing_slash($scriptPath) . $profile_path . '?mode=viewprofile&amp;u=' . $pID);
                $rssLink = get_author_rss_link(0, $author->ID, $author->user_nicename);
                $lastPostID = $author->wpu_last_post;
                if (empty($lastPostID)) {
                    $_oldQuery = $GLOBALS['wp_query'];
                    query_posts('author=' . $author->ID . '&showposts=1');
                    if (have_posts()) {
                        the_post();
                        if ((double) $wp_version >= 2.1) {
                            //WP >= 2.1 branch
                            $lastPostID = get_the_ID();
                        } else {
                            //deprecated branch
                            global $id;
                            $lastPostID = $id;
                        }
                        update_usermeta($author->ID, 'wpu_last_post', $lastPostID);
                    }
                    $GLOBALS['wp_query'] = $_oldQuery;
                }
                $post = get_post($lastPostID);
                $lastPostTitle = wpu_censor($post->post_title);
                $blogTitle = wpu_censor($blogTitle);
                $blogDesc = wpu_censor($blogDesc);
                $lastPostURL = get_permalink($lastPostID);
                $time = $post->post_date;
                $lastPostTime = apply_filters('get_the_time', $time, $d, FALSE);
                $itern = $itern == 0 ? 1 : 0;
                $blogList .= "<div class=\"wpubl{$itern}\">\n\n";
                if (!empty($avatar)) {
                    $blogList .= "<img src=\"{$avatar}\" alt=\"avatar\"/>\n";
                }
                $blogList .= "<h2 class=\"wpublsubject\" ><a href=\"{$blogPath}\">{$blogTitle}</a>, " . __('by') . ' <a href="' . $path_to_profile . '">' . $name . "</a></h2>\n\n";
                $blogList .= '<p class="wpubldesc">' . $blogDesc . "</p>\n\n";
                $blogList .= '<small class="wpublnumposts">' . __('Total Entries:') . ' ' . $posts . "</small><br />\n\n";
                $blogList .= '<small class="wpublastpost">' . __('Last Entry:') . ' <a href="' . $lastPostURL . '">' . $lastPostTitle . '</a>, ' . __('posted on') . " {$time}</small><br />\n\n";
                if (!empty($rssLink)) {
                    $blogList .= '<small class="wpublrss">' . __('RSS Feed:') . ' <a href="' . $rssLink . '">' . __('Subscribe') . "</a></small><br />\n\n";
                }
                $blogList .= "<p class=\"wpublclr\">&nbsp;</p></div>\n\n";
            }
        }
    } else {
        $blogList .= "<div class=\"wpubl\">\n";
        $blogList .= '<p class="wpubldesc">' . __('There are no authors to show') . "</p>\n";
        $blogList .= "</div>\n";
    }
    if ($numAuthors > $maxEntries) {
        $base_url = append_sid(strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/'))) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']);
        $pagination = generate_pagination($base_url, $numAuthors, $maxEntries, $start, TRUE);
        $blogList .= '<p class="wpublpages">' . $pagination . '</p>';
    }
    return $blogList;
}
Exemplo n.º 15
0
/**
 * List all the *co-authors* of the blog, with several options available.
 * optioncount (boolean) (false): Show the count in parenthesis next to the author's name.
 * exclude_admin (boolean) (true): Exclude the 'admin' user that is installed by default.
 * show_fullname (boolean) (false): Show their full names.
 * hide_empty (boolean) (true): Don't show authors without any posts.
 * feed (string) (''): If isn't empty, show links to author's feeds.
 * feed_image (string) (''): If isn't empty, use this image to link to feeds.
 * echo (boolean) (true): Set to false to return the output, instead of echoing.
 * @param array $args The argument array.
 * @return null|string The output, if echo is set to false.
 */
function coauthors_wp_list_authors($args = ''){
	global $wpdb;

	$defaults = array(
		'optioncount' => false, 'exclude_admin' => true,
		'show_fullname' => false, 'hide_empty' => true,
		'feed' => '', 'feed_image' => '', 'echo' => true
	);

	$r = wp_parse_args( $args, $defaults );
	extract($r, EXTR_SKIP);

	$return = '';

	// TODO:  Move select to get_authors().
	$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name");

	$author_count = array();
	$sql = "SELECT DISTINCT
					p1.post_author,
					(COUNT(ID)+(SELECT COUNT(*)
								FROM $wpdb->posts p2, $wpdb->postmeta pm
								WHERE p2.ID = pm.post_id
									AND pm.meta_key = '_coauthor'
									AND pm.meta_value = p1.post_author)
								) AS count
			FROM $wpdb->posts p1
			WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . "
			GROUP BY post_author";
	
	foreach ((array)  $wpdb->get_results($sql) as $row) {
		$author_count[$row->post_author] = $row->count;
	}

	foreach ( (array) $authors as $author ) {
		$author = get_userdata( $author->ID );
		$posts = (isset($author_count[$author->ID])) ? $author_count[$author->ID] : 0;
		$name = $author->display_name;

		if ( $show_fullname && ($author->first_name != '' && $author->last_name != '') )
			$name = "$author->first_name $author->last_name";

		if ( !($posts == 0 && $hide_empty) )
			$return .= '<li>';
		if ( $posts == 0 ) {
			if ( !$hide_empty )
				$link = $name;
		} else {
			$link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . sprintf(__("Posts by %s"), attribute_escape($author->display_name)) . '">' . $name . '</a>';

			if ( (! empty($feed_image)) || (! empty($feed)) ) {
				$link .= ' ';
				if (empty($feed_image))
					$link .= '(';
				$link .= '<a href="' . get_author_rss_link(0, $author->ID, $author->user_nicename) . '"';

				if ( !empty($feed) ) {
					$title = ' title="' . $feed . '"';
					$alt = ' alt="' . $feed . '"';
					$name = $feed;
					$link .= $title;
				}

				$link .= '>';

				if ( !empty($feed_image) )
					$link .= "<img src=\"$feed_image\" border=\"0\"$alt$title" . ' />';
				else
					$link .= $name;

				$link .= '</a>';

				if ( empty($feed_image) )
					$link .= ')';
			}

			if ( $optioncount )
				$link .= ' ('. $posts . ')';

		}

		if ( !($posts == 0 && $hide_empty) )
			$return .= $link . '</li>';
	}
	if ( !$echo )
		return $return;
	echo $return;
}