• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP get_private_posts_cap_sql函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中get_private_posts_cap_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_private_posts_cap_sql函数的具体用法?PHP get_private_posts_cap_sql怎么用?PHP get_private_posts_cap_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_private_posts_cap_sql函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wppriv_fix_post_count

function wppriv_fix_post_count($terms, $taxonomies, $args)
{
    global $wpdb;
    if (!in_array('category', $taxonomies) && !in_array('post_tag', $taxonomies)) {
        return $terms;
    }
    foreach ($terms as $term) {
        $term->count = $wpdb->get_var($wpdb->prepare("SELECT count(ID) FROM " . "{$wpdb->term_relationships} AS tr INNER JOIN " . "{$wpdb->posts} AS p ON (tr.object_id = p.ID) INNER JOIN " . "{$wpdb->term_taxonomy} AS tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) " . "WHERE tt.term_id = %s AND p.post_type = 'post' AND " . get_private_posts_cap_sql('post'), $term->term_id));
    }
    return $terms;
}
开发者ID:sergiorgiraldo,项目名称:wp-priv-post-access,代码行数:11,代码来源:wp-priv-post-access.php


示例2: wp_list_authors_art

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;
    }
//.........这里部分代码省略.........
开发者ID:Gestiopolis,项目名称:GestiopolisExp1,代码行数:101,代码来源:extras.php


示例3: get_usernumposts

/**
 * Number of posts user has written.
 *
 * @since 0.71
 * @uses $wpdb WordPress database object for queries.
 *
 * @param int $userid User ID.
 * @return int Amount of posts user has written.
 */
function get_usernumposts($userid)
{
    global $wpdb;
    $userid = (int) $userid;
    $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_author = %d AND post_type = 'post' AND ", $userid) . get_private_posts_cap_sql('post'));
    return apply_filters('get_usernumposts', $count, $userid);
}
开发者ID:schr,项目名称:wordpress,代码行数:16,代码来源:user.php


示例4: get_permalink

        } else {
            echo '<a href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '" ' . $this->htmltarget('_blank', TRUE) . '>';
        }
        echo sprintf(__('%1$s on %2$s'), strip_tags($comment->comment_author), get_the_title($comment->comment_post_ID));
        echo "</a></li>\n";
    }
    if (count($comments) == $numitems && current_user_can('moderate_comments')) {
        echo '<li><a href="' . $this->admin_url . '/edit-comments.php?wphone=ajax">' . __('More &raquo;') . "</a></li>\n";
    }
    if (!$this->iscompat) {
        echo "</ul>\n</li>\n";
    }
}
# Recent posts
if (function_exists('get_private_posts_cap_sql')) {
    $recentpostssql = "SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '" . current_time('mysql', 1) . "' ORDER BY post_date DESC LIMIT {$numitems}";
} else {
    $recentpostssql = "SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' AND post_date_gmt < '" . current_time('mysql', 1) . "' ORDER BY post_date DESC LIMIT {$numitems}";
}
if ($recentposts = $wpdb->get_results($recentpostssql)) {
    echo '<li class="group">' . __('Recent Posts', 'wphone');
    if (!$this->iscompat) {
        echo "\n<ul>\n";
    } else {
        echo "</li>\n";
    }
    $count = 0;
    foreach ($recentposts as $post) {
        $count++;
        if ($count >= $numitems) {
            break;
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:31,代码来源:dashboard.php


示例5: load_wp_users

    /**
     * Loads a list of WordPress users according to the user mapper options
     * @access private
     */
    private function load_wp_users()
    {
        global $wpdb, $phpbbForum, $db;
        $where = '';
        $mainWhere = '';
        $mainWhereAnd = '';
        $postClause = '';
        if (!empty($this->showSpecificUsers)) {
            /**
             * We don't have a need for "show specific users" yet
             */
            $mainWhere = '';
            trigger_error('UNIMPLEMENTED');
            die;
        }
        if (!empty($this->showUsersLike)) {
            // find similar users for autocomplete
            $mainWhere = $wpdb->prepare("UCASE(user_login) LIKE '%s'", '%' . strtoupper($this->showUsersLike) . '%');
            $mainWhereAnd = " AND {$mainWhere}";
            $mainWhere = " WHERE {$mainWhere}";
        }
        /** 
         * For all normal queries we need to calculate a total user count so the results can be paginated
         * @TODO: This pulls post count and/or integrated phpBB usr info. These are pulled later on again as
         * part of the user load. This is inefficient -- should consider grabbing all data here (at the expense of readability)
         */
        // if the total number of users depends on an integrated/unintegrated filter, need to start in phpBB
        if (!empty($this->showOnlyInt) || !empty($this->showOnlyUnInt)) {
            /**
             * First we pull the users to use as a filter
             * The filter could be a block or a pass filter, so we don't use LIMIT here.
             */
            $fStateChanged = $phpbbForum->foreground();
            $sql = 'SELECT user_wpuint_id 
						FROM ' . USERS_TABLE . ' 
						WHERE (user_type = ' . USER_NORMAL . ' OR user_type = ' . USER_FOUNDER . ') 
							AND user_wpuint_id > 0';
            if (!($fResults = $db->sql_query($sql))) {
                $phpbbForum->background($fStateChanged);
                return;
            }
            $usersToFetch = array();
            while ($fResult = $db->sql_fetchrow($fResults)) {
                $usersToFetch[] = $fResult['user_wpuint_id'];
            }
            $this->numUsers = sizeof($usersToFetch);
            $db->sql_freeresult();
            $phpbbForum->background($fStateChanged);
            if (!empty($this->showOnlyInt) && !sizeof($usersToFetch)) {
                return;
            }
            // Now create the filter for the WP query
            if (sizeof($usersToFetch)) {
                $set = implode(',', $usersToFetch);
                if (!empty($this->showOnlyInt)) {
                    $where = ' WHERE ID IN (' . $set . ')' . $mainWhereAnd;
                } else {
                    $where = ' WHERE ID NOT IN (' . $set . ')' . $mainWhereAnd;
                }
            }
            // If this is "show only unintegrated", we need to run a separate count query
            $this->numUsers = $wpdb->get_var('SELECT COUNT(*) AS numusers
				FROM ' . $wpdb->users . $where);
            // For other filter types (or no filter), we can just count in WordPress.
        } else {
            if ($this->showOnlyPosts) {
                $postClause = ', ' . $wpdb->posts . ' ';
                $where = ' WHERE (u.ID = post_author AND post_type = \'post\' AND ' . get_private_posts_cap_sql('post') . ')' . $mainWhereAnd;
                $this->numUsers = $wpdb->get_var('SELECT COUNT(*) AS numusers
						FROM ' . $wpdb->users . ' AS u' . $postClause . $where);
            } else {
                if ($this->showOnlyNoPosts) {
                    $postClause = ', ' . $wpdb->posts . ' ';
                    $where = ' WHERE (u.ID <> post_author AND post_type = \'post\' AND ' . get_private_posts_cap_sql('post') . ')' . $mainWhereAnd;
                    $this->numUsers = $wpdb->get_var('SELECT COUNT(*) AS numusers
						FROM ' . $wpdb->users . ' AS u' . $postClause . $where);
                } else {
                    $where = $mainWhere;
                    $this->numUsers = $wpdb->get_var('SELECT COUNT(*) AS count
						FROM ' . $wpdb->users . $where);
                }
            }
        }
        // return for all other than autocomplete if there aren't any users
        if (!$this->numUsers) {
            return;
        }
        // Now fetch the users
        $sql = "SELECT u.ID\r\n\t\t\t\tFROM {$wpdb->users} AS u {$postClause} \r\n\t\t\t\t{$where} \r\n\t\t\t\tORDER BY user_login \r\n\t\t\t\tLIMIT {$this->numStart}, {$this->numToShow}";
        $results = $wpdb->get_results($sql);
        foreach ((array) $results as $item => $result) {
            $mUser = new WPU_Mapped_WP_User($result->ID);
            $this->users[$result->ID] = $mUser;
        }
    }
开发者ID:snitchashor,项目名称:wp-united,代码行数:99,代码来源:user-mapper.php


示例6: get_usernumposts

function get_usernumposts($userid) {
	global $wpdb;
	$userid = (int) $userid;
	return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_type = 'post' AND " . get_private_posts_cap_sql('post'));
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:5,代码来源:user.php


示例7: form


//.........这里部分代码省略.........

		<p id="dt_author" class="dt-hide-it"<?php 
        echo $is_author;
        ?>
>
			<label class="head" for="<?php 
        echo $this->get_field_id('author');
        ?>
">
				Select Author:
            </label>
			<select name="<?php 
        echo $this->get_field_name('author');
        ?>
" id="<?php 
        echo $this->get_field_id('author');
        ?>
" class="widefat">

			<?php 
        $users = get_users();
        $author_ids = array();
        foreach ((array) $users as $user) {
            $author_ids[] = $user->user_id;
        }
        global $wpdb;
        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}) 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_id = intval($author->ID);
            $author = get_userdata($author->ID);
            $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
            if ($posts == 0) {
                continue;
            }
            $author_name = $author->display_name;
            ?>
				<option value="<?php 
            echo $author_id;
            ?>
"<?php 
            selected($instance['author'], $author_id);
            ?>
><?php 
            echo $author_name;
            ?>
 (<?php 
            echo $posts;
            ?>
 posts)</option>
<?php 
        }
        ?>
			</select>
		</p>

		<p>
			<label for="<?php 
开发者ID:jainankit,项目名称:suggstme,代码行数:67,代码来源:widget-getposts.php


示例8: wp_list_authors

/**
 * List all the authors of the blog, with several options available.
 *
 * <ul>
 * <li>optioncount (boolean) (false): Show the count in parenthesis next to the
 * author's name.</li>
 * <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is
 * installed bydefault.</li>
 * <li>show_fullname (boolean) (false): Show their full names.</li>
 * <li>hide_empty (boolean) (true): Don't show authors without any posts.</li>
 * <li>feed (string) (''): If isn't empty, show links to author's feeds.</li>
 * <li>feed_image (string) (''): If isn't empty, use this image to link to
 * feeds.</li>
 * <li>echo (boolean) (true): Set to false to return the output, instead of
 * echoing.</li>
 * <li>style (string) ('list'): Whether to display list of authors in list form
 * or as a string.</li>
 * <li>html (bool) (true): Whether to list the items in html form or plaintext.
 * </li>
 * </ul>
 *
 * @link http://codex.wordpress.org/Template_Tags/wp_list_authors
 * @since 1.2.0
 * @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('orderby' => 'name', 'order' => 'ASC', 'number' => '', 'optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'style' => 'list', 'html' => true);
    $args = wp_parse_args($args, $defaults);
    extract($args, EXTR_SKIP);
    $return = '';
    $query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'number'));
    $query_args['fields'] = 'ids';
    $authors = get_users($query_args);
    $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 ($authors as $author_id) {
        $author = get_userdata($author_id);
        if ($exclude_admin && 'admin' == $author->display_name) {
            continue;
        }
        $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
        if (!$posts && $hide_empty) {
            continue;
        }
        $link = '';
        if ($show_fullname && $author->first_name && $author->last_name) {
            $name = "{$author->first_name} {$author->last_name}";
        } else {
            $name = $author->display_name;
        }
        if (!$html) {
            $return .= $name . ', ';
            continue;
            // No need to go further to process HTML.
        }
        if ('list' == $style) {
            $return .= '<li>';
        }
        $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__("Posts by %s"), $author->display_name)) . '">' . $name . '</a>';
        if (!empty($feed_image) || !empty($feed)) {
            $link .= ' ';
            if (empty($feed_image)) {
                $link .= '(';
            }
            $link .= '<a href="' . get_author_feed_link($author->ID) . '"';
            $alt = $title = '';
            if (!empty($feed)) {
                $title = ' title="' . esc_attr($feed) . '"';
                $alt = ' alt="' . esc_attr($feed) . '"';
                $name = $feed;
                $link .= $title;
            }
            $link .= '>';
            if (!empty($feed_image)) {
                $link .= '<img src="' . esc_url($feed_image) . '" style="border: none;"' . $alt . $title . ' />';
            } else {
                $link .= $name;
            }
            $link .= '</a>';
            if (empty($feed_image)) {
                $link .= ')';
            }
        }
        if ($optioncount) {
            $link .= ' (' . $posts . ')';
        }
        $return .= $link;
        $return .= 'list' == $style ? '</li>' : ', ';
    }
    $return = rtrim($return, ', ');
    if (!$echo) {
        return $return;
    }
    echo $return;
}
开发者ID:radman,项目名称:noobyo-blog,代码行数:100,代码来源:author-template.php


示例9: wiziapp_get_authors

function wiziapp_get_authors($chars, $return_id = FALSE)
{
    global $wpdb;
    //    $hide_empty = TRUE;
    //    $html = FALSE;
    //
    //
    //    $defaults = array(
    //        'optioncount' => false, 'exclude_admin' => true,
    //        'show_fullname' => false, 'hide_empty' => true,
    //        'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
    //        'style' => 'list', 'html' => true
    //    );
    // @todo Refactor the authors and author_count queries to one, or replace with get_author when such a fucntion will exist
    $sql = $wpdb->prepare("SELECT ID, display_name from {$wpdb->users} WHERE display_name LIKE %s ORDER BY display_name", "%{$chars}%");
    $authors = $wpdb->get_results($sql);
    $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;
    }
    $returnAuthors = array();
    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 ($posts != 0) {
            if ($return_id) {
                $returnAuthors[$name] = $author->ID;
            } else {
                $returnAuthors[] = $name;
            }
        }
    }
    return $returnAuthors;
}
开发者ID:sajidsan,项目名称:sajidsan.github.io,代码行数:35,代码来源:search.php


示例10: coauthors_wp_list_authors

/**
 * 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, $coauthors_plus;
    $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'style' => 'list', 'html' => 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();
    $query = "SELECT DISTINCT {$wpdb->users}.ID AS post_author, {$wpdb->terms}.name AS user_name, {$wpdb->term_taxonomy}.count AS count";
    $query .= " FROM {$wpdb->posts}";
    $query .= " INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)";
    $query .= " INNER JOIN {$wpdb->term_taxonomy} ON ({$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id)";
    $query .= " INNER JOIN {$wpdb->terms} ON ({$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id)";
    $query .= " INNER JOIN {$wpdb->users} ON ({$wpdb->terms}.name = {$wpdb->users}.user_login)";
    $query .= " WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post');
    $query .= " AND {$wpdb->term_taxonomy}.taxonomy = '{$coauthors_plus->coauthor_taxonomy}'";
    $query .= " GROUP BY post_author";
    foreach ((array) $wpdb->get_results($query) as $row) {
        $author_count[$row->post_author] = $row->count;
    }
    foreach ((array) $authors as $author) {
        $link = '';
        $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 (!$html) {
            if ($posts == 0) {
                if (!$hide_empty) {
                    $return .= $name . ', ';
                }
            } else {
                $return .= $name . ', ';
            }
            // No need to go further to process HTML.
            continue;
        }
        if (!($posts == 0 && $hide_empty) && 'list' == $style) {
            $return .= '<li>';
        }
        if ($posts == 0) {
            if (!$hide_empty) {
                $link = $name;
            }
        } else {
            $link = '<a href="' . get_author_posts_url($author->ID, $author->user_nicename) . '" title="' . esc_attr(sprintf(__("Posts by %s", 'co-authors-plus'), $author->display_name)) . '">' . $name . '</a>';
            if (!empty($feed_image) || !empty($feed)) {
                $link .= ' ';
                if (empty($feed_image)) {
                    $link .= '(';
                }
                $link .= '<a href="' . get_author_feed_link($author->ID) . '"';
                if (!empty($feed)) {
                    $title = ' title="' . esc_attr($feed) . '"';
                    $alt = ' alt="' . esc_attr($feed) . '"';
                    $name = $feed;
                    $link .= $title;
                }
                $link .= '>';
                if (!empty($feed_image)) {
                    $link .= "<img src=\"" . esc_url($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) && 'list' == $style) {
            $return .= $link . '</li>';
        } else {
            if (!$hide_empty) {
                $return .= $link . ', ';
            }
        }
    }
    $return = trim($return, ', ');
    if (!$echo) {
        return $return;
//.........这里部分代码省略.........
开发者ID:jayfresh,项目名称:SweetSpot,代码行数:101,代码来源:template-tags.php


示例11: wp_authors

 function wp_authors($type, $args = '')
 {
     global $wpdb;
     $this->type = $type;
     $defaults = array('orderby' => 'name', 'order' => 'ASC', 'number' => '', 'optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'style' => 'list', 'html' => true, 'exclude' => '', 'include' => '', 'post_types' => array('post'), 'combo_box' => '');
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     $return = '';
     $query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'number', 'exclude', 'include'));
     $query_args['fields'] = 'ids';
     $authors = get_users($query_args);
     //build where conditions for post types...
     $where_conditions = array();
     $post_type_count = count($post_types);
     $where_query = '';
     if ($post_type_count > 0) {
         foreach ($post_types as $post_type) {
             if (post_type_exists($post_type)) {
                 $post_type = esc_attr($post_type);
                 $where_conditions[] = " (post_type = '{$post_type}' AND " . get_private_posts_cap_sql($post_type) . ")";
             }
         }
         $where_query = implode(" OR", $where_conditions);
     }
     $author_count = array();
     foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM {$wpdb->posts} WHERE{$where_query} GROUP BY post_author") as $row) {
         $author_count[$row->post_author] = $row->count;
     }
     $elem_attr = "";
     if ($this->type == "select") {
         if ($combo_box == 1) {
             $elem_attr = ' data-combobox="1"';
         }
         $return .= '<select name="' . $args['name'] . '"' . $elem_attr . '>';
         $return .= '<option class="level-0 ' . SF_ITEM_CLASS_PRE . '0" value="0">' . $args['all_items_label'] . '</option>';
     } else {
         if ($this->type == "radio") {
             $return .= '<ul>';
         } else {
             if ($this->type == "checkbox") {
                 $return .= '<ul>';
             } else {
                 if ($this->type == "multiselect") {
                     if ($combo_box == 1) {
                         $elem_attr = ' data-combobox="1"';
                     }
                     $return .= '<select multiple="multiple" name="' . $args['name'] . '[]"' . $elem_attr . '>';
                 }
             }
         }
     }
     foreach ($authors as $author_id) {
         $author = get_userdata($author_id);
         if ($exclude_admin && 'admin' == $author->display_name) {
             continue;
         }
         $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
         if (!$posts && $hide_empty) {
             continue;
         }
         $link = '';
         if ($show_fullname && $author->first_name && $author->last_name) {
             $name = "{$author->first_name} {$author->last_name}";
         } else {
             $name = $author->display_name;
         }
         if (!$html) {
             $return .= $name . ', ';
             continue;
             // No need to go further to process HTML.
         }
         /*if ( 'list' == $style ) {
         			$return .= '<li>';
         		}*/
         $selected = "";
         $checked = "";
         if (isset($args['defaults'])) {
             $noselected = count($args['defaults']);
             if ($noselected > 0 && is_array($args['defaults'])) {
                 if (in_array($author->ID, $args['defaults'])) {
                     $selected = ' selected="selected"';
                     $checked = ' checked="checked"';
                 }
             }
         }
         if ($this->type == "select" || $this->type == "multiselect") {
             $return .= '<option class="level-0 ' . SF_ITEM_CLASS_PRE . esc_attr($author->ID) . '" value="' . esc_attr($author->ID) . '"' . $selected . '>';
         } else {
             if ($this->type == "radio" || $this->type == "checkbox") {
                 $return .= '<li class="' . SF_ITEM_CLASS_PRE . esc_attr($author->ID) . '">';
             }
         }
         //$link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>';
         if ($this->type == "select" || $this->type == "multiselect") {
             $link = $name;
         } else {
             if ($this->type == "radio") {
                 $link = '<label><input type="radio" name="' . $args['name'] . '[]" value="' . esc_attr($author->ID) . '"' . $checked . '> ' . esc_html($name);
             } else {
                 if ($this->type == "checkbox") {
//.........这里部分代码省略.........
开发者ID:baerdaniel,项目名称:MAT-wordpress,代码行数:101,代码来源:class-search-filter-author-walker.php


示例12: writeMetaAuthors

 public function writeMetaAuthors()
 {
     // authors
     global $wpdb;
     $plugin_dir = plugin_dir_path(__FILE__);
     $dir = $this->destination . '/authors/';
     $defaults = array('orderby' => 'name', 'order' => 'ASC', 'number' => '', 'optioncount' => false, 'exclude_admin' => false, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'style' => 'list', 'html' => false, 'exclude' => '', 'include' => '');
     $authors = get_users($defaults);
     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 ($author_count as $author_id => $cnt) {
         $author = get_userdata($author_id);
         $authorDir = $dir . $author->user_nicename;
         $authorFile = $authorDir . '/author.md';
         if (!is_dir($authorDir)) {
             wp_mkdir_p($authorDir);
         }
         // include export template by type
         ob_start();
         include $plugin_dir . '../templates/export/author.md';
         $content = ob_get_contents();
         ob_end_clean();
         //        $data = file_get_contents($permalink);
         file_put_contents($authorFile, $content);
     }
     // category, tags
 }
开发者ID:giteugen,项目名称:wordpress-wp2grav-markdown-exporter,代码行数:28,代码来源:wp2grav.class.php


示例13: wp_authors

 function wp_authors($args = '')
 {
     global $wpdb;
     $defaults = array('orderby' => 'name', 'order' => 'ASC', 'number' => '', 'optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true, 'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true, 'style' => 'list', 'html' => true, 'exclude' => '', 'include' => '', 'post_types' => array('post'), 'combo_box' => '');
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     $return = '';
     $query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'number', 'exclude', 'include'));
     $query_args['fields'] = 'ids';
     $authors = get_users($query_args);
     //build where conditions for post types...
     $where_conditions = array();
     $post_type_count = count($post_types);
     $where_query = '';
     if ($post_type_count > 0) {
         foreach ($post_types as $post_type) {
             if (post_type_exists($post_type)) {
                 $post_type = esc_attr($post_type);
                 $where_conditions[] = " (post_type = '{$post_type}' AND " . get_private_posts_cap_sql($post_type) . ")";
             }
         }
         $where_query = implode(" OR", $where_conditions);
     }
     $author_count = array();
     foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM {$wpdb->posts} WHERE{$where_query} GROUP BY post_author") as $row) {
         $author_count[$row->post_author] = $row->count;
     }
     $show_option_all_sf = $args['show_option_all_sf'];
     $show_default_option_sf = $args['show_default_option_sf'];
     if (isset($show_option_all_sf) && $show_default_option_sf == true) {
         $default_option = new stdClass();
         $default_option->label = $show_option_all_sf;
         $default_option->attributes = array('class' => SF_CLASS_PRE . 'level-0 ' . SF_ITEM_CLASS_PRE . '0');
         $default_option->value = "";
         $default_option->count = 0;
         array_push($this->options, $default_option);
     }
     foreach ($authors as $author_id) {
         $author = get_userdata($author_id);
         //var_dump($author);
         if ($exclude_admin && 'admin' == $author->display_name) {
             continue;
         }
         $option_count = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0;
         if (!$option_count && $hide_empty) {
             continue;
         }
         $link = '';
         if ($show_fullname && $author->first_name && $author->last_name) {
             $name = "{$author->first_name} {$author->last_name}";
         } else {
             $name = $author->display_name;
         }
         /*if ( !$html ) {
         				$return .= $name . ', ';
         
         				continue; // No need to go further to process HTML.
         			}*/
         if ($optioncount) {
             if ($show_count_format_sf == "inline") {
                 $name .= ' (' . number_format_i18n($option_count) . ')';
             } else {
                 if ($show_count_format_sf == "html") {
                     $name .= '<span class="' . SF_CLASS_PRE . 'count">(' . number_format_i18n($option_count) . ')</span>';
                 }
             }
         }
         $option = new stdClass();
         $option->attributes = array('class' => SF_CLASS_PRE . 'level-0');
         $option->value = $author->user_nicename;
         //$option->selected_value = $author->ID; //we want to match defaults based on ID
         $option->label = $name;
         $option->count = $option_count;
         array_push($this->options, $option);
     }
     $this->options_obj->set($this->options);
 }
开发者ID:alvarpoon,项目名称:aeg,代码行数:77,代码来源:class-search-filter-author-object-walker.php


示例14: foreach

    if ($comments) {
        foreach ($comments as $comment) {
            echo '<li>' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="' . get_permalink($comment->comment_post_ID) . '#comment-' . $comment->comment_ID . '">' . apply_filters('the_title', get_the_title($comment->comment_post_ID)) . '</a>');
            edit_comment_link(__("Edit"), ' <small>(', ')</small>');
            echo '</li>';
        }
    }
    ?>
</ul>
</div>
<?php 
}
?>

<?php 
if ($recentposts = $wpdb->get_results("SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type = 'post' AND " . get_private_posts_cap_sql('post') . " AND post_date_gmt < '{$today}' ORDER BY post_date DESC LIMIT 5")) {
    ?>
<div>
<h3><?php 
    _e('Posts');
    ?>
 <a href="edit.php" title="<?php 
    _e('More posts...');
    ?>
">&raquo;</a></h3>
<ul>
<?php 
    foreach ($recentposts as $post) {
        if ($post->post_title == '') {
            $post->post_title = sprintf(__('Post #%s'), $post->ID);
        }
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:31,代码来源:index.php


示例15: wp_list_authors

/**
 * List all the authors of the blog, with several options available.
 *
 * <ul>
 * <li>optioncount (boolean) (false): Show the count in parenthesis next to the
 * author's name.</li>
 * <li>exclude_admin (boolean) (true): Exclude the 'admin' user that is
 * installed bydefault.</li>
 * <li>show_fullname (boolean) (false): Show their full names.</li>
 * <li>hide_empty (boolean) (true): Don't show authors without any posts.</li>
 * <li>feed (string)  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_private_setting函数代码示例发布时间:2022-05-15
下一篇:
PHP get_price函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap