本文整理汇总了PHP中get_posts_by_author_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_posts_by_author_sql函数的具体用法?PHP get_posts_by_author_sql怎么用?PHP get_posts_by_author_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_posts_by_author_sql函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: parse_orderby
/**
* Parse and sanitize 'orderby' keys passed to the user query.
*
* @since 4.2.0
* @access protected
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $orderby Alias for the field to order by.
* @return string Value to used in the ORDER clause, if `$orderby` is valid.
*/
protected function parse_orderby($orderby)
{
global $wpdb;
$meta_query_clauses = $this->meta_query->get_clauses();
$_orderby = '';
if (in_array($orderby, array('login', 'nicename', 'email', 'url', 'registered'))) {
$_orderby = 'user_' . $orderby;
} elseif (in_array($orderby, array('user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered'))) {
$_orderby = $orderby;
} elseif ('name' == $orderby || 'display_name' == $orderby) {
$_orderby = 'display_name';
} elseif ('post_count' == $orderby) {
// todo: avoid the JOIN
$where = get_posts_by_author_sql('post');
$this->query_from .= " LEFT OUTER JOIN (\n\t\t\t\tSELECT post_author, COUNT(*) as post_count\n\t\t\t\tFROM {$wpdb->posts}\n\t\t\t\t{$where}\n\t\t\t\tGROUP BY post_author\n\t\t\t) p ON ({$wpdb->users}.ID = p.post_author)\n\t\t\t";
$_orderby = 'post_count';
} elseif ('ID' == $orderby || 'id' == $orderby) {
$_orderby = 'ID';
} elseif ('meta_value' == $orderby || $this->get('meta_key') == $orderby) {
$_orderby = "{$wpdb->usermeta}.meta_value";
} elseif ('meta_value_num' == $orderby) {
$_orderby = "{$wpdb->usermeta}.meta_value+0";
} elseif ('include' === $orderby && !empty($this->query_vars['include'])) {
$include = wp_parse_id_list($this->query_vars['include']);
$include_sql = implode(',', $include);
$_orderby = "FIELD( {$wpdb->users}.ID, {$include_sql} )";
} elseif (isset($meta_query_clauses[$orderby])) {
$meta_clause = $meta_query_clauses[$orderby];
$_orderby = sprintf("CAST(%s.meta_value AS %s)", esc_sql($meta_clause['alias']), esc_sql($meta_clause['cast']));
}
return $_orderby;
}
开发者ID:kadrim1,项目名称:metsayhistu,代码行数:43,代码来源:class-wp-user-query.php
示例2: ae_count_user_posts_by_type
/**
* count user post by post type
* @param (integer) $userID (required) The ID of the user to count posts for.
* @param (string) $post_type The post type you want to count, Default is post.
* @version 1.0
* @author dakachi
* @package AE
* http://codex.wordpress.org/Function_Reference/count_user_posts
*/
function ae_count_user_posts_by_type($userid, $post_type = 'post')
{
global $wpdb;
$where = get_posts_by_author_sql($post_type, true, $userid);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
return apply_filters('get_usernumposts', $count, $userid);
}
开发者ID:rinodung,项目名称:wp-question,代码行数:16,代码来源:functions.php
示例3: amr_count_user_posts
function amr_count_user_posts($userid, $post_type)
{
// wordpress function does not allow for custom post types
global $wpdb;
if (!post_type_exists($post_type)) {
return false;
}
$where = get_posts_by_author_sql($post_type, true, $userid);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
return apply_filters('get_usernumposts', $count, $userid);
}
开发者ID:googlecode-mirror,项目名称:wpmu-demo,代码行数:11,代码来源:ameta-list.php
示例4: count_user_posts_by_type
function count_user_posts_by_type($user_id = '', $post_type = 'post')
{
global $wpdb;
if (!$user_id) {
$user_id = um_user('ID');
}
if (!$user_id) {
return 0;
}
$where = get_posts_by_author_sql($post_type, true, $user_id);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
return apply_filters('um_pretty_number_formatting', $count);
}
开发者ID:Makenrro,项目名称:repos,代码行数:13,代码来源:um-user-posts.php
示例5: ssmf_count_user_posts_by_type
function ssmf_count_user_posts_by_type($userid, $post_type = 'subscribe_me_forms')
{
global $wpdb;
$userid = get_current_user_id();
$where = get_posts_by_author_sql($post_type, true, $userid);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
$screen = get_current_screen();
if (current_user_can('edit_posts') and $screen->post_type === 'subscribe_me_forms') {
//Is admin and all users - so impose the limit
if ($count >= 2) {
header("Location: /wp-content/plugins/mailchimp-subscribe-sm/phuf.php");
}
}
}
开发者ID:phupx,项目名称:phamlook,代码行数:14,代码来源:ssm_cs_post_type.php
示例6: mpsp_count_user_posts_by_type
function mpsp_count_user_posts_by_type($userid, $post_type = 'mpsp_slider')
{
global $wpdb;
$userid = get_current_user_id();
$where = get_posts_by_author_sql($post_type, true, $userid);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
$screen = get_current_screen();
if (current_user_can('edit_posts') and $screen->post_type === 'mpsp_slider') {
//Is admin and all users - so impose the limit
if ($count >= 300) {
header("Location: /wp-content/plugins/Posts-Slider-NEW/phuf.php");
}
}
}
开发者ID:webprese,项目名称:dev.mgeonline,代码行数:14,代码来源:mpsp_cs_post_type.php
示例7: ap_count_user_posts_by_type
/**
* Count user posts by post type
* @param int $userid
* @param string $post_type
* @return int
* @since unknown
*/
function ap_count_user_posts_by_type($userid, $post_type = 'question')
{
global $wpdb;
$where = get_posts_by_author_sql($post_type, true, $userid);
$query = "SELECT COUNT(*) FROM {$wpdb->posts} {$where}";
$key = md5($query);
$cache = wp_cache_get($key, 'count');
if ($cache === false) {
$count = $wpdb->get_var($query);
wp_cache_set($key, $count, 'count');
} else {
$count = $cache;
}
return apply_filters('ap_count_user_posts_by_type', $count, $userid);
}
开发者ID:VLabsInc,项目名称:WordPressPlatforms,代码行数:22,代码来源:user.php
示例8: km_rpbt_related_posts_by_taxonomy
/**
* Gets related posts by taxonomy.
*
* @since 0.1
*
* @global object $wpdb
*
* @param int $post_id The post id to get related posts for.
* @param array|string $taxonomies The taxonomies to retrieve related posts from
* @param array|string $args Optional. Change what is returned
* @return array Empty array if no related posts found. Array with post objects.
*/
function km_rpbt_related_posts_by_taxonomy($post_id = 0, $taxonomies = 'category', $args = '')
{
global $wpdb;
if (!absint($post_id)) {
return array();
}
$defaults = array('post_types' => 'post', 'posts_per_page' => 5, 'order' => 'DESC', 'fields' => '', 'limit_posts' => -1, 'limit_year' => '', 'limit_month' => '', 'orderby' => 'post_date', 'exclude_terms' => '', 'include_terms' => '', 'exclude_posts' => '', 'post_thumbnail' => '', 'related' => true);
$args = wp_parse_args($args, $defaults);
$taxonomies = !empty($taxonomies) ? $taxonomies : array('category');
if (!is_array($taxonomies)) {
$taxonomies = array_unique(explode(',', (string) $taxonomies));
}
$terms = array();
// validates ids and returns an array
$included = km_rpbt_related_posts_by_taxonomy_validate_ids($args['include_terms']);
if (!$args['related'] && !empty($included)) {
// related, use included term ids
$terms = $included;
} else {
// related and not related terms
$terms = wp_get_object_terms($post_id, array_map('trim', (array) $taxonomies), array('fields' => 'ids'));
if (is_wp_error($terms) || empty($terms)) {
return array();
}
// only use included terms from the post terms
if ($args['related'] && !empty($included)) {
$terms = array_values(array_intersect($included, $terms));
}
}
// exclude terms
if (empty($included)) {
// validates ids and returns an array
$excluded = km_rpbt_related_posts_by_taxonomy_validate_ids($args['exclude_terms']);
$terms = array_values(array_diff($terms, $excluded));
}
if (empty($terms)) {
return array();
}
$args['related_terms'] = $terms;
// term ids sql
if (count($terms) > 1) {
$term_ids_sql = "tt.term_id IN (" . implode(', ', $terms) . ")";
} else {
$term_ids_sql = isset($terms[0]) ? "tt.term_id = " . $terms[0] : "tt.term_id = 0";
}
// validates ids and returns an array
$exclude_posts = km_rpbt_related_posts_by_taxonomy_validate_ids($args['exclude_posts']);
// add current post ID to exclude
$exclude_posts[] = $post_id;
$exclude_posts = array_unique($exclude_posts);
// post ids sql
$post_ids_sql = "AND {$wpdb->posts}.ID";
if (count($exclude_posts) > 1) {
$post_ids_sql .= " NOT IN (" . implode(', ', $exclude_posts) . ")";
} else {
$post_ids_sql .= " != {$post_id}";
}
// post types
if (!is_array($args['post_types'])) {
$args['post_types'] = explode(',', (string) $args['post_types']);
}
// sanitize post type names and remove duplicates
$post_types = array_unique(array_map('sanitize_key', (array) $args['post_types']));
$post_types = array_filter($post_types, 'post_type_exists');
// default to post type post if no post types are found
$post_types = !empty($post_types) ? $post_types : array('post');
// where sql (post types and post status)
if (count($post_types) > 1) {
$where = get_posts_by_author_sql('post');
$post_type_sql = "'" . implode("', '", $post_types) . "'";
$where_sql = preg_replace("/post_type = 'post'/", "post_type IN ({$post_type_sql})", $where);
} else {
$where_sql = get_posts_by_author_sql($post_types[0]);
}
$order_by_rand = false;
// order sql
switch (strtoupper((string) $args['order'])) {
case 'ASC':
$order_sql = 'ASC';
break;
case 'RAND':
$order_sql = 'RAND()';
$order_by_rand = true;
break;
default:
$order_sql = 'DESC';
break;
}
//.........这里部分代码省略.........
开发者ID:peternem,项目名称:vlt-wp,代码行数:101,代码来源:functions.php
示例9: test_user_has_access_only_to_private_posts_for_certain_post_types
public function test_user_has_access_only_to_private_posts_for_certain_post_types()
{
register_post_type('foo', array('capabilities' => array('read_private_posts' => 'read_private_foo')));
register_post_type('bar', array('capabilities' => array('read_private_posts' => 'read_private_bar')));
register_post_type('baz', array('capabilities' => array('read_private_posts' => 'read_private_baz')));
$current_user = get_current_user_id();
$u = self::factory()->user->create(array('role' => 'editor'));
$editor_role = get_role('editor');
$editor_role->add_cap('read_private_baz');
wp_set_current_user($u);
$maybe_string = get_posts_by_author_sql(array('foo', 'bar', 'baz'));
$editor_role->remove_cap('read_private_baz');
$this->assertNotContains("post_type = 'foo' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string);
$this->assertNotContains("post_type = 'bar' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string);
$this->assertContains("post_type = 'baz' AND ( post_status = 'publish' OR post_status = 'private' )", $maybe_string);
_unregister_post_type('foo');
_unregister_post_type('bar');
_unregister_post_type('baz');
wp_set_current_user($current_user);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:20,代码来源:getPostsByAuthorSql.php
示例10: select_sorting_order_criteria
/**
* Get the users based on sorting criteria and order
*
* Function identificator: fn0
*
*/
function select_sorting_order_criteria()
{
global $wpdb;
$qv =& $this->query_vars;
$this->fn0_query_results_array = array();
$this->fn0_query_fields = "wppb_t1.ID";
$this->fn0_query_from = "FROM {$wpdb->users} AS wppb_t1";
if ($qv['sorting_criteria'] == 'ID') {
$criteria = 'wppb_t1.ID';
} elseif ($qv['sorting_criteria'] == 'login') {
$criteria = 'wppb_t1.user_login';
} elseif ($qv['sorting_criteria'] == 'email') {
$criteria = 'wppb_t1.user_email';
} elseif ($qv['sorting_criteria'] == 'url') {
$criteria = 'wppb_t1.user_url';
} elseif ($qv['sorting_criteria'] == 'registered') {
$criteria = 'wppb_t1.user_registered';
} elseif ($qv['sorting_criteria'] == 'nicename') {
$criteria = 'wppb_t1.display_name';
} elseif ($qv['sorting_criteria'] == 'post_count') {
$where = get_posts_by_author_sql('post');
$this->fn0_query_from .= " LEFT OUTER JOIN (SELECT post_author, COUNT(*) AS post_count FROM {$wpdb->posts} {$where} GROUP BY post_author) p ON wppb_t1.ID = p.post_author";
$criteria = 'wppb_t1.ID';
} elseif ($qv['sorting_criteria'] == 'bio') {
$this->fn0_query_from .= " LEFT OUTER JOIN {$wpdb->usermeta} AS wppb_t2 ON wppb_t1.ID = wppb_t2.user_id AND wppb_t2.meta_key = 'description'";
$criteria = 'wppb_t2.meta_value';
} elseif ($qv['sorting_criteria'] == 'aim') {
$this->fn0_query_from .= " LEFT OUTER JOIN {$wpdb->usermeta} AS wppb_t2 ON wppb_t1.ID = wppb_t2.user_id AND wppb_t2.meta_key = 'aim'";
$criteria = 'wppb_t2.meta_value';
} elseif ($qv['sorting_criteria'] == 'yim') {
$this->fn0_query_from .= " LEFT OUTER JOIN {$wpdb->usermeta} AS wppb_t2 ON wppb_t1.ID = wppb_t2.user_id AND wppb_t2.meta_key = 'yim'";
$criteria = 'wppb_t2.meta_value';
} elseif ($qv['sorting_criteria'] == 'jabber') {
$this->fn0_query_from .= " LEFT OUTER JOIN {$wpdb->usermeta} AS wppb_t2 ON wppb_t1.ID = wppb_t2.user_id AND wppb_t2.meta_key = 'jabber'";
$criteria = 'wppb_t2.meta_value';
} elseif ($qv['sorting_criteria'] == 'firstname') {
$this->fn0_query_from .= " LEFT OUTER JOIN {$wpdb->usermeta} AS wppb_t2 ON wppb_t1.ID = wppb_t2.user_id AND wppb_t2.meta_key = 'first_name'";
$criteria = 'wppb_t2.meta_value';
} elseif ($qv['sorting_criteria'] == 'lastname') {
$this->fn0_query_from .= " LEFT OUTER JOIN {$wpdb->usermeta} AS wppb_t2 ON wppb_t1.ID = wppb_t2.user_id AND wppb_t2.meta_key = 'last_name'";
$criteria = 'wppb_t2.meta_value';
} else {
$wppbFetchArray = get_option('wppb_custom_fields', 'not_found');
if ($wppbFetchArray != 'not_found') {
foreach ($wppbFetchArray as $thisKey => $thisValue) {
if ($thisValue['item_type'] != 'heading') {
if ($qv['sorting_criteria'] == $thisValue['item_metaName']) {
$this->fn0_query_from .= " LEFT OUTER JOIN {$wpdb->usermeta} AS wppb_t2 ON wppb_t1.ID = wppb_t2.user_id AND wppb_t2.meta_key = '" . $thisValue['item_metaName'] . "'";
$criteria = 'wppb_t2.meta_value';
}
}
}
}
}
$this->fn0_query_where = "WHERE 1";
$this->fn0_query_orderby = "ORDER BY {$criteria} " . strtoupper(trim($qv['sorting_order']));
$this->fn0_query_limit = "";
do_action_ref_array('wppb_pre_select_by_sorting_order_and_criteria', array(&$this));
$this->fn0_query_results = apply_filters('wppb_select_by_sorting_order_and_criteria_result', $wpdb->get_results(trim("SELECT {$this->fn0_query_fields} {$this->fn0_query_from} {$this->fn0_query_where} {$this->fn0_query_orderby} {$this->fn0_query_limit}")));
//create an array with IDs from result
foreach ($this->fn0_query_results as $qr_key => $qr_value) {
array_push($this->fn0_query_results_array, $qr_value->ID);
}
$this->fn0_query_results_array = apply_filters('wppb_select_by_sorting_order_and_criteria_array', $this->fn0_query_results_array);
do_action_ref_array('wppb_post_select_by_sorting_order_and_criteria', array(&$this));
}
开发者ID:serker72,项目名称:T3S,代码行数:72,代码来源:userlisting.class.php
示例11: count_many_users_posts
/**
* Number of posts written by a list of users.
*
* @since 3.0.0
* @param array $userid User ID number list.
* @return array Amount of posts each user has written.
*/
function count_many_users_posts($users)
{
global $wpdb;
$count = array();
if (!is_array($users) || empty($users)) {
return $count;
}
$userlist = implode(',', $users);
$where = get_posts_by_author_sql('post');
$result = $wpdb->get_results("SELECT post_author, COUNT(*) FROM {$wpdb->posts} {$where} AND post_author IN ({$userlist}) GROUP BY post_author", ARRAY_N);
foreach ($result as $row) {
$count[$row[0]] = $row[1];
}
foreach ($users as $id) {
if (!isset($count[$id])) {
$count[$id] = 0;
}
}
return $count;
}
开发者ID:hacklabr,项目名称:toquenobrasil,代码行数:27,代码来源:user.php
示例12: count_user_posts_by_type
function count_user_posts_by_type($userid, $post_type = 'post')
{
global $wpdb;
$where = get_posts_by_author_sql($post_type, true, $userid);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
return $count;
}
开发者ID:NetserviceLab,项目名称:Co-Authors-Plus,代码行数:7,代码来源:co-authors-plus.php
示例13: count_user_posts_by_type
function count_user_posts_by_type($userid, $post_type = 'post', $public_only = false)
{
global $wpdb;
$where = get_posts_by_author_sql($post_type, true, $userid, $public_only);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} WHERE ( ( post_type = 'quote' AND ( post_status = 'publish' ) ) ) AND post_author = 684");
return $where;
//apply_filters( 'get_usernumposts', $count, $userid );
}
开发者ID:vossavant,项目名称:phoenix,代码行数:8,代码来源:functions.php
示例14: marketify_count_user_downloads
function marketify_count_user_downloads($userid, $post_type = 'download')
{
if (false === ($count = get_transient($userid . $post_type))) {
global $wpdb;
$where = get_posts_by_author_sql($post_type, true, $userid);
$count = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
set_transient($userid . $post_type, $count, 12 * HOUR_IN_SECONDS);
}
return apply_filters('get_usernumposts', $count, $userid);
}
开发者ID:evinw,项目名称:project_3dBP,代码行数:10,代码来源:functions.php
示例15: bbp_get_user_reply_count_raw
/**
* Return the raw database count of replies by a user
*
* @since bbPress (r3633)
* @global WPDB $wpdb
* @uses bbp_get_user_id()
* @uses get_posts_by_author_sql()
* @uses bbp_get_reply_post_type()
* @uses apply_filters()
* @return int Raw DB count of replies
*/
function bbp_get_user_reply_count_raw($user_id = 0)
{
$user_id = bbp_get_user_id($user_id);
if (empty($user_id)) {
return false;
}
global $wpdb;
$where = get_posts_by_author_sql(bbp_get_reply_post_type(), true, $user_id);
$count = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->posts} {$where}");
return (int) apply_filters('bbp_get_user_reply_count_raw', $count, $user_id);
}
开发者ID:hscale,项目名称:webento,代码行数:22,代码来源:functions.php
示例16: test_administrator_should_have_access_to_private_posts_when_public_only_is_false
public function test_administrator_should_have_access_to_private_posts_when_public_only_is_false(){
$current_user = get_current_user_id();
$u = $this->factory->user->create( array( 'role' => 'administrator' ) );
wp_set_current_user( $u );
$maybe_string = get_posts_by_author_sql( 'post', true, null, false );
$this->assertContains( "post_status = 'private'", $maybe_string );
$this->assertNotContains( 'post_author', $maybe_string );
wp_set_current_user( $current_user );
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:11,代码来源:getPostsByAuthorSql.php
示例17: getItemByReviewer
function getItemByReviewer($reviewer)
{
$where = get_posts_by_author_sql($this->post_type, true, $reviewer);
return array_shift($this->dbo->get_col("SELECT * FROM {$this->dbo->posts} {$where}"));
}
开发者ID:quangnpd,项目名称:jobshop_web,代码行数:5,代码来源:reviews.php
示例18: search_result
//.........这里部分代码省略.........
}
}
}
}
$this->search_query_role_param = '';
if ($this->profile_role) {
$this->profile_role = explode(',', $this->profile_role);
if (count($this->profile_role) > 0) {
foreach ($this->profile_role as $key => $value) {
$this->search_query_role_param[] = "(mt.meta_key = '_upme_search_cache' AND mt.meta_value LIKE '%role::" . $value . "%')";
}
}
$role_operator = 'AND';
$this->search_query_role_param = ' ' . $role_operator . ' ( ' . implode(' OR ', $this->search_query_role_param) . ' ) ';
}
// Hiding Admins from the list when attribute is set
if (!current_user_can('manage_options') && !current_user_can('manage_upme_options') && $this->hide_admin_role && ($this->hide_admin_role == 'yes' || $this->hide_admin_role == 'true')) {
$search_query_role_param[] = "(mt.meta_key = '_upme_search_cache' AND mt.meta_value NOT LIKE '%role::administrator%')";
$role_operator = 'AND';
$this->search_query_role_param .= ' ' . $role_operator . ' ( ' . implode(' OR ', $search_query_role_param) . ' ) ';
}
// Setting up order data, This is required before adding search conditions
$post_count_sort = '';
if (in_array($this->profile_order_field, array('nicename', 'email', 'url', 'registered'))) {
$orderby = 'users.user_' . $this->profile_order_field;
} elseif (in_array($this->profile_order_field, array('user_nicename', 'user_email', 'user_url', 'user_registered'))) {
$orderby = 'users.' . $this->profile_order_field;
} elseif ('name' == $this->profile_order_field || 'display_name' == $this->profile_order_field) {
$orderby = 'users.display_name';
} elseif ('ID' == $this->profile_order_field || 'id' == $this->profile_order_field) {
$orderby = 'users.ID';
} else {
if ('post_count' == $this->profile_order_field) {
$where = get_posts_by_author_sql('post');
$post_count_sort = " LEFT OUTER JOIN (\r\n SELECT post_author, COUNT(*) as post_count\r\n FROM {$wpdb->posts}\r\n {$where}\r\n GROUP BY post_author\r\n ) p ON (users.ID = p.post_author)\r\n ";
$orderby = 'post_count';
} else {
if ($this->profile_orderby_custom_status || 'yes' == $this->profile_orderby_custom_status) {
$orderby = 'mta.meta_value';
} else {
$orderby = 'users.user_login';
}
}
}
// Add custom query conditions into the query
$search_query_custom_params = '';
if (count($this->search_query_custom_param) > 0) {
$search_query_custom_params = ' AND ' . implode(' AND ', $this->search_query_custom_param);
}
if (count($this->search_query_search_param) > 0) {
// Results after searching - POST variables are available
$this->search_query_string .= ' INNER JOIN ' . $wpdb->usermeta . ' as mt ON (users.ID = mt.user_id) ' . $orderby_meta_join . ' ' . $orderby_meta_custom_joins . ' ' . $post_count_sort . ' WHERE 1=1 AND (' . implode(' ' . $this->search_args['operator'] . ' ', $this->search_query_search_param) . ') ' . $search_query_custom_params;
$this->count_search_query_string .= ' INNER JOIN ' . $wpdb->usermeta . ' as mt ON (users.ID = mt.user_id) ' . $orderby_meta_join . ' ' . $orderby_meta_custom_joins . ' ' . $post_count_sort . ' WHERE 1=1 AND (' . implode(' ' . $this->search_args['operator'] . ' ', $this->search_query_search_param) . ') ' . $search_query_custom_params;
// Search users with provided cusotm field and provided custom value
if ($this->upme_args['group_meta'] != '' && $this->upme_args['group_meta_value'] != '') {
$this->search_query_string .= " AND (mt.meta_key = '_upme_search_cache' AND mt.meta_value LIKE '%" . $this->upme_args['group_meta'] . "::" . $this->upme_args['group_meta_value'] . "%')";
$this->count_search_query_string .= " AND (mt.meta_key = '_upme_search_cache' AND mt.meta_value LIKE '%" . $this->upme_args['group_meta'] . "::" . $this->upme_args['group_meta_value'] . "%')";
}
} else {
// Default results before searching - POST variables not available
if ($this->upme_args['group_meta'] != '' && $this->upme_args['group_meta_value'] != '') {
// Search users with provided cusotm field and provided custom value
$this->search_query_string .= " INNER JOIN " . $wpdb->usermeta . " as mt ON (users.ID = mt.user_id) " . $orderby_meta_join . " " . $orderby_meta_custom_joins . " " . $post_count_sort . " WHERE 1=1 AND (mt.meta_key = '_upme_search_cache' AND mt.meta_value LIKE '%" . $this->upme_args['group_meta'] . "::" . $this->upme_args['group_meta_value'] . "%')" . $search_query_custom_params;
$this->count_search_query_string .= " INNER JOIN " . $wpdb->usermeta . " as mt ON (users.ID = mt.user_id) " . $orderby_meta_join . " " . $orderby_meta_custom_joins . " " . $post_count_sort . " WHERE 1=1 AND (mt.meta_key = '_upme_search_cache' AND mt.meta_value LIKE '%" . $this->upme_args['group_meta'] . "::" . $this->upme_args['group_meta_value'] . "%')" . $search_query_custom_params;
} else {
$default_join_status = false;
开发者ID:nikwin333,项目名称:pcu_project,代码行数:67,代码来源:class-upme.php
示例19: wp_idea_stream_users_ideas_count_by_user
/**
* Get idea authors sorted by count
*
* count_many_users_posts() does not match the need
*
* @package WP Idea Stream
* @subpackage users/functions
*
* @since 2.0.0
*
* @global $wpdb
* @param int $max the number of users to limit the query
* @uses get_posts_by_author_sql() to get the sql part for the author request
* @uses wp_idea_stream_get_post_type() to get the ideas post type identifier
* @return array list of users ordered by ideas count.
*/
function wp_idea_stream_users_ideas_count_by_user($max = 10)
{
global $wpdb;
$sql = array();
$sql['select'] = "SELECT p.post_author, COUNT(p.ID) as count_ideas, u.user_nicename";
$sql['from'] = "FROM {$wpdb->posts} p LEFT JOIN {$wpdb->users} u ON ( p.post_author = u.ID )";
$sql['where'] = get_posts_by_author_sql(wp_idea_stream_get_post_type(), true, null, true);
$sql['groupby'] = 'GROUP BY p.post_author';
$sql['order'] = 'ORDER BY count_ideas DESC';
$sql['limit'] = $wpdb->prepare('LIMIT 0, %d', $max);
$query = apply_filters('wp_idea_stream_users_ideas_count_by_user_query', join(' ', $sql), $sql, $max);
return $wpdb->get_results($query);
}
开发者ID:mrjarbenne,项目名称:wp-idea-stream,代码行数:29,代码来源:functions.php
示例20: count_future_events
/**
* count_future_events function
*
* @return Count future events
**/
public function count_future_events($user_id = null)
{
if (is_admin()) {
$settings = $this->_registry->get('model.settings');
$current_time = $this->_registry->get('date.time');
$current_time->set_timezone($settings->get('timezone_string'));
$current_time = $current_time->format_to_gmt();
$user_id = get_current_user_id();
$where = get_posts_by_author_sql(AI1EC_POST_TYPE, true, $user_id);
$db = $this->_registry->get('dbi.dbi');
$posts = $db->get_table_name('posts');
$table_name = $db->get_table_name('ai1ec_events');
$sql = "SELECT COUNT(*) FROM {$table_name} INNER JOIN {$posts} on {$table_name}.post_id = {$posts}.ID" . " {$where} AND {$table_name}.start > {$current_time}";
//future event
return $db->get_var($sql);
} else {
return 0;
}
}
开发者ID:andyUA,项目名称:kabmin-new,代码行数:24,代码来源:all-events.php
注:本文中的get_posts_by_author_sql函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论