当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_parse_id_list函数代码示例

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


在下文中一共展示了wp_parse_id_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: es_get_posts

 /**
  * Retrieve list of latest posts or posts matching criteria.
  *
  * The defaults are as follows:
  *     'numberposts' - Default is 5. Total number of posts to retrieve.
  *     'offset' - Default is 0. See {@link WP_Query::query()} for more.
  *     'category' - What category to pull the posts from.
  *     'orderby' - Default is 'date', which orders based on post_date. How to order the posts.
  *     'order' - Default is 'DESC'. The order to retrieve the posts.
  *     'include' - See {@link WP_Query::query()} for more.
  *     'exclude' - See {@link WP_Query::query()} for more.
  *     'meta_key' - See {@link WP_Query::query()} for more.
  *     'meta_value' - See {@link WP_Query::query()} for more.
  *     'post_type' - Default is 'post'. Can be 'page', or 'attachment' to name a few.
  *     'post_parent' - The parent of the post or post type.
  *     'post_status' - Default is 'publish'. Post status to retrieve.
  *
  * @uses WP_Query::query() See for more default arguments and information.
  * @uses ES_WP_Query
  * @link http://codex.wordpress.org/Template_Tags/get_posts
  *
  * @param array $args Optional. Overrides defaults.
  * @return array List of posts.
  */
 function es_get_posts($args = null)
 {
     $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => 0, 'orderby' => 'date', 'order' => 'DESC', 'include' => array(), 'exclude' => array(), 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'suppress_filters' => true);
     $r = wp_parse_args($args, $defaults);
     if (empty($r['post_status'])) {
         $r['post_status'] = 'attachment' == $r['post_type'] ? 'inherit' : 'publish';
     }
     if (!empty($r['numberposts']) && empty($r['posts_per_page'])) {
         $r['posts_per_page'] = $r['numberposts'];
     }
     if (!empty($r['category'])) {
         $r['cat'] = $r['category'];
     }
     if (!empty($r['include'])) {
         $incposts = wp_parse_id_list($r['include']);
         $r['posts_per_page'] = count($incposts);
         // only the number of posts included
         $r['post__in'] = $incposts;
     } elseif (!empty($r['exclude'])) {
         $r['post__not_in'] = wp_parse_id_list($r['exclude']);
     }
     $r['ignore_sticky_posts'] = true;
     $r['no_found_rows'] = true;
     $get_posts = new ES_WP_Query();
     return $get_posts->query($r);
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:50,代码来源:functions.php

示例3: setup_group_ids

 function setup_group_ids()
 {
     global $wpdb, $bp;
     $sql = "SELECT group_id FROM {$bp->groups->table_name_groupmeta} WHERE ";
     $join_clauses = array();
     $where_clauses = array();
     $counter = 1;
     $filter_count = count($this->filters);
     foreach ($this->filters as $key => $value) {
         $table_shortname = 'gmf' . $counter;
         $join_sql = $counter > 1 ? " LEFT JOIN {$bp->groups->table_name_groupmeta} {$table_shortname} ON gmf1.group_id = {$table_shortname}.group_id " : "{$bp->groups->table_name_groupmeta} {$table_shortname}";
         $join_clauses[] = $join_sql;
         $clause = $wpdb->prepare("{$table_shortname}.meta_key = %s", $key);
         if (false !== $value) {
             $clause .= $wpdb->prepare(" AND {$table_shortname}.meta_value = %s", $value);
         }
         $where_clauses[] = $clause;
         // If this key matches the orderby param, stash the table shortname
         if (!empty($this->orderby) && $this->orderby == $key) {
             $this->orderby_shortname = $table_shortname;
         }
         $counter++;
     }
     if (!empty($where_clauses)) {
         $sql = "SELECT gmf1.group_id FROM " . implode(' ', $join_clauses) . " WHERE " . implode(' AND ', $where_clauses);
     } else {
         $sql = $wpdb->get_results("SELECT id FROM {$bp->groups->table_name} WHERE 1 = 0");
     }
     $this->group_ids = wp_parse_id_list($wpdb->get_col($sql));
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:30,代码来源:groupmeta-query.php

示例4: meta

 /**
  * Standard meta retrieval
  *
  * @param int   $post_id
  * @param bool  $saved
  * @param array $field
  *
  * @return array
  */
 public static function meta($post_id, $saved, $field)
 {
     $meta = get_post_meta($post_id, $field['id'], true);
     $meta = wp_parse_id_list($meta);
     $meta = array_filter($meta);
     return $meta;
 }
开发者ID:warfare-plugins,项目名称:social-warfare,代码行数:16,代码来源:taxonomy-advanced.php

示例5: taxonomy_filter

 /**
  * Filters out product categories the user does not have access to. 
  * @since 2.5.8
  * @global type $wpdb
  * @param array $args
  * @param array $taxonomies
  * @return array
  */
 public function taxonomy_filter($args, $taxonomies)
 {
     global $wpdb;
     if (in_array('product_cat', $taxonomies)) {
         $disallowed = $this->get_cached_exclusions('cat');
         if ($disallowed === false) {
             $user_roles = $this->get_roles_for_current_user();
             $sql = " SELECT term_id FROM {$wpdb->prefix}term_taxonomy WHERE taxonomy = 'product_cat' AND term_id NOT IN (\n\t\t\t\tSELECT term_id FROM {$wpdb->prefix}term_taxonomy WHERE taxonomy = 'product_cat' AND term_id NOT IN (SELECT {$wpdb->prefix}woocommerce_termmeta.woocommerce_term_id FROM {$wpdb->prefix}woocommerce_termmeta WHERE meta_key = '_wc_restrictions')\n\t\t\t\tUNION ALL \n\t\t\t\tSELECT {$wpdb->prefix}woocommerce_termmeta.woocommerce_term_id FROM {$wpdb->prefix}woocommerce_termmeta WHERE ( (meta_key ='_wc_restrictions' AND meta_value = 'public') OR (meta_key = '_wc_restrictions_allowed' AND meta_value IN ('" . implode("','", $user_roles) . "') ) ) )";
             $disallowed = $wpdb->get_col($sql);
             if ($disallowed !== false) {
                 $session_id = WC_Catalog_Visibility_Compatibility::WC()->session->get_customer_id();
                 set_transient('twccr_' . $session_id . '_cat', $disallowed, 60 * 60 * 24);
             }
         }
         if ($disallowed && count($disallowed)) {
             $disallowed = array_map('intval', $disallowed);
             if (isset($args['include']) && !empty($args['include'])) {
                 $include = wp_parse_id_list($args['include']);
                 $allowed = array_filter(array_diff($include, $disallowed));
                 if (empty($allowed)) {
                     $args['include'] = array();
                     $args['exclude'] = $disallowed;
                 } else {
                     $args['include'] = $allowed;
                 }
             } else {
                 $exclude = wp_parse_id_list($args['exclude']);
                 $args['exclude'] = isset($exclude) && !empty($exclude) ? array_merge($exclude, $disallowed) : $disallowed;
             }
         }
     } else {
     }
     return $args;
 }
开发者ID:Junaid-Farid,项目名称:gocnex,代码行数:42,代码来源:class-wc-catalog-restrictions-query.php

示例6: circleflip_post_formats_save_metabox

function circleflip_post_formats_save_metabox($post_id)
{
    if (!isset($_POST['_circleflip_post_formats']) || !wp_verify_nonce($_POST['_circleflip_post_formats']['_nonce'], __FILE__) || defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || !current_user_can('edit_post', $post_id)) {
        return $post_id;
    }
    $format = get_post_format($post_id);
    $data = array();
    if ('audio' === $format) {
        if (!empty($_POST['_circleflip_post_formats']['audio_id'])) {
            $data['audio_id'] = (int) $_POST['_circleflip_post_formats']['audio_id'];
        } else {
            $data['audio_embed'] = $_POST['_circleflip_post_formats']['audio_embed'];
        }
    } else {
        if ('video' === $format) {
            if (!empty($_POST['_circleflip_post_formats']['video_id'])) {
                $data['video_id'] = (int) $_POST['_circleflip_post_formats']['video_id'];
            } else {
                $data['video_embed'] = $_POST['_circleflip_post_formats']['video_embed'];
            }
        } else {
            if ('gallery' === $format) {
                $ids_string = $_POST['_circleflip_post_formats']['gallery'];
                $data['gallery'] = wp_parse_id_list($ids_string);
                $data['gallery_layout'] = $_POST['_circleflip_post_formats']['layout'];
            }
        }
    }
    update_post_meta($post_id, '_circleflip_post_formats', $data);
}
开发者ID:purgesoftwares,项目名称:purges,代码行数:30,代码来源:circleflip-post-formats-metabox.php

示例7: pre_user_query

 /**
  * Modify query to filter users by group.
  * 
  * @param WP_User_Query $user_query
  * @return WP_User_Query
  */
 public static function pre_user_query($user_query)
 {
     global $pagenow, $wpdb;
     if ($pagenow == 'users.php' && empty($_GET['page'])) {
         if (isset($_REQUEST['group'])) {
             $group_id = $_REQUEST['group'];
             if (Groups_Group::read($group_id)) {
                 $group = new Groups_Group($group_id);
                 $users = $group->users;
                 $include = array();
                 if (count($users) > 0) {
                     foreach ($users as $user) {
                         $include[] = $user->user->ID;
                     }
                 } else {
                     // no results
                     $include[] = 0;
                 }
                 $ids = implode(',', wp_parse_id_list($include));
                 $user_query->query_where .= " AND {$wpdb->users}.ID IN ({$ids})";
             }
         }
     }
     return $user_query;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:31,代码来源:class-groups-admin-users.php

示例8: test_get_current_threads_for_user_with_old_args

 /**
  * @group get_current_threads_for_user
  * @expectedDeprecated BP_Messages_Thread::get_current_threads_for_user
  */
 public function test_get_current_threads_for_user_with_old_args()
 {
     $u1 = $this->factory->user->create();
     $u2 = $this->factory->user->create();
     $t1 = $this->factory->message->create(array('sender_id' => $u1, 'recipients' => array($u2), 'subject' => 'Foo'));
     $t2 = $this->factory->message->create(array('sender_id' => $u1, 'recipients' => array($u2), 'subject' => 'Bar'));
     $threads = BP_Messages_Thread::get_current_threads_for_user($u1, 'sentbox', 'all', null, null, 'ar');
     $expected = array($t2);
     $found = wp_parse_id_list(wp_list_pluck($threads['threads'], 'thread_id'));
     $this->assertSame($expected, $found);
 }
开发者ID:AceMedia,项目名称:BuddyPress,代码行数:15,代码来源:class.bp-messages-thread.php

示例9: find

 public function find($ids)
 {
     if (is_numeric($ids)) {
         return $this->get_term($ids);
     }
     $incposts = wp_parse_id_list($ids);
     $this->posts_per_page = count($incposts);
     // only the number of posts included
     $this->post__in = $incposts;
     return count($incposts) == 1 ? $this->first() : $this->get();
 }
开发者ID:solutionworks,项目名称:theme-setup,代码行数:11,代码来源:Term.php

示例10: mb_remove_user_topic_bookmark

function mb_remove_user_topic_bookmark($user_id, $topic_id)
{
    $user_id = mb_get_user_id($user_id);
    $topic_id = mb_get_topic_id($topic_id);
    $favs = mb_get_user_topic_bookmarks($user_id);
    if (in_array($topic_id, $favs)) {
        wp_cache_delete('mb_get_topic_bookmarkers_' . $topic_id, 'message-board-users');
        $_sub = array_search($topic_id, $favs);
        unset($favs[$_sub]);
        $favs = implode(',', wp_parse_id_list(array_filter($favs)));
        return update_user_meta($user_id, mb_get_user_topic_bookmarks_meta_key(), $favs);
    }
    return false;
}
开发者ID:justintadlock,项目名称:message-board,代码行数:14,代码来源:bookmarks.php

示例11: read_children

 /**
  * Loads variation child IDs.
  * @param  WC_Product
  * @param  bool $force_read True to bypass the transient.
  * @return WC_Product
  */
 public function read_children(&$product, $force_read = false)
 {
     $children_transient_name = 'wc_product_children_' . $product->get_id();
     $children = get_transient($children_transient_name);
     if (empty($children) || !is_array($children) || !isset($children['all']) || !isset($children['visible']) || $force_read) {
         $all_args = $visible_only_args = array('post_parent' => $product->get_id(), 'post_type' => 'product_variation', 'orderby' => 'menu_order', 'order' => 'ASC', 'fields' => 'ids', 'post_status' => 'publish', 'numberposts' => -1);
         if ('yes' === get_option('woocommerce_hide_out_of_stock_items')) {
             $visible_only_args['meta_query'][] = array('key' => '_stock_status', 'value' => 'instock', 'compare' => '=');
         }
         $children['all'] = get_posts(apply_filters('woocommerce_variable_children_args', $all_args, $product, false));
         $children['visible'] = get_posts(apply_filters('woocommerce_variable_children_args', $visible_only_args, $product, true));
         set_transient($children_transient_name, $children, DAY_IN_SECONDS * 30);
     }
     $product->set_children(wp_parse_id_list((array) $children['all']));
     $product->set_visible_children(wp_parse_id_list((array) $children['visible']));
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:22,代码来源:class-wc-product-variable-data-store-cpt.php

示例12: bp_friends_filter_user_query_populate_extras

/**
 * Filter BP_User_Query::populate_extras to add confirmed friendship status.
 *
 * Each member in the user query is checked for confirmed friendship status
 * against the logged-in user.
 *
 * @since 1.7.0
 *
 * @global WPDB $wpdb WordPress database access object.
 *
 * @param BP_User_Query $user_query   The BP_User_Query object.
 * @param string        $user_ids_sql Comma-separated list of user IDs to fetch extra
 *                                    data for, as determined by BP_User_Query.
 */
function bp_friends_filter_user_query_populate_extras(BP_User_Query $user_query, $user_ids_sql)
{
    global $wpdb;
    // Stop if user isn't logged in.
    if (!($user_id = bp_loggedin_user_id())) {
        return;
    }
    $maybe_friend_ids = wp_parse_id_list($user_ids_sql);
    foreach ($maybe_friend_ids as $friend_id) {
        $status = BP_Friends_Friendship::check_is_friend($user_id, $friend_id);
        $user_query->results[$friend_id]->friendship_status = $status;
        if ('is_friend' == $status) {
            $user_query->results[$friend_id]->is_friend = 1;
        }
    }
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:30,代码来源:bp-friends-filters.php

示例13: __construct

 /**
  * Setup the object
  *
  * @param array $args Arguments containing from taxonomy, to taxonomy,
  *                    and additional optional params
  *
  * @since 1.0.0
  */
 public function __construct($args = array())
 {
     $args = wp_parse_args($args, array('from_tax' => '', 'to_tax' => '', 'parent' => '', 'terms' => ''));
     if (!$args['from_tax'] || !$args['to_tax']) {
         return;
     }
     if (!empty($args['parent'])) {
         $this->parent = absint($args['parent']);
     }
     if (!empty($args['terms'])) {
         $this->terms = wp_parse_id_list($args['terms']);
     }
     $this->is_ui = isset($_GET['page']) && 'taxonomy-switcher' == $_GET['page'];
     $this->from = sanitize_text_field($args['from_tax']);
     $this->to = sanitize_text_field($args['to_tax']);
 }
开发者ID:sc0ttkclark,项目名称:taxonomy-switcher,代码行数:24,代码来源:Taxonomy_Switcher.php

示例14: exclude

 public function exclude($taxonomy, $string)
 {
     global $yarpp;
     echo "<div class='yarpp_form_row yarpp_form_exclude'><div class='yarpp_form_label'>";
     echo $string;
     echo "</div><div class='yarpp_scroll_wrapper'><div class='exclude_terms' id='exclude_{$taxonomy}'>";
     $exclude_tt_ids = wp_parse_id_list(yarpp_get_option('exclude'));
     $exclude_term_ids = $yarpp->admin->get_term_ids_from_tt_ids($taxonomy, $exclude_tt_ids);
     if (count($exclude_term_ids)) {
         $terms = get_terms($taxonomy, array('include' => $exclude_term_ids));
         foreach ($terms as $term) {
             echo "<input type='checkbox' name='exclude[{$term->term_taxonomy_id}]' id='exclude_{$term->term_taxonomy_id}' value='true' checked='checked' /> <label for='exclude_{$term->term_taxonomy_id}'>" . esc_html($term->name) . "</label> ";
         }
     }
     echo "</div></div></div>";
 }
开发者ID:WackoMako,项目名称:stonedape,代码行数:16,代码来源:YARPP_Meta_Box_Pool.php

示例15: bp_update_meta_cache

/**
 * Update the metadata cache for the specified objects.
 *
 * @since BuddyPress (1.6)
 * @global $wpdb WordPress database object for queries.
 * @param array $args See $defaults definition for more details
 * @return mixed Metadata cache for the specified objects, or false on failure.
 */
function bp_update_meta_cache($args = array())
{
    global $wpdb;
    $defaults = array('object_ids' => array(), 'object_type' => '', 'meta_table' => '', 'object_column' => '', 'cache_key_prefix' => '');
    $r = wp_parse_args($args, $defaults);
    extract($r);
    if (empty($object_ids) || empty($object_type) || empty($meta_table)) {
        return false;
    }
    if (empty($cache_key_prefix)) {
        $cache_key_prefix = $meta_table;
    }
    if (empty($object_column)) {
        $object_column = $object_type . '_id';
    }
    $object_ids = wp_parse_id_list($object_ids);
    $cache = array();
    // Get meta info
    $id_list = join(',', $object_ids);
    $meta_list = $wpdb->get_results($wpdb->prepare("SELECT {$object_column}, meta_key, meta_value FROM {$meta_table} WHERE {$object_column} IN ({$id_list})", $object_type), ARRAY_A);
    if (!empty($meta_list)) {
        foreach ($meta_list as $metarow) {
            $mpid = intval($metarow[$object_column]);
            $mkey = $metarow['meta_key'];
            $mval = $metarow['meta_value'];
            // Force subkeys to be array type:
            if (!isset($cache[$mpid]) || !is_array($cache[$mpid])) {
                $cache[$mpid] = array();
            }
            if (!isset($cache[$mpid][$mkey]) || !is_array($cache[$mpid][$mkey])) {
                $cache[$mpid][$mkey] = array();
            }
            // Add a value to the current pid/key:
            $cache[$mpid][$mkey][] = $mval;
        }
    }
    foreach ($object_ids as $id) {
        if (!isset($cache[$id])) {
            $cache[$id] = array();
        }
        foreach ($cache[$id] as $meta_key => $meta_value) {
            wp_cache_set($cache_key_prefix . '_' . $id . '_' . $meta_key, $meta_value, 'bp');
        }
    }
    return $cache;
}
开发者ID:pyropictures,项目名称:wordpress-plugins,代码行数:54,代码来源:bp-core-cache.php


注:本文中的wp_parse_id_list函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。