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


PHP bp_core_get_suggestions函数代码示例

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


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

示例1: bp_legacy_theme_ajax_messages_autocomplete_results

/**
 * AJAX handler for autocomplete.
 *
 * Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
 *
 * @since BuddyPress (1.2.0)
 *
 * @return string HTML.
 */
function bp_legacy_theme_ajax_messages_autocomplete_results()
{
    /**
     * Filters the max results default value for ajax messages autocomplete results.
     *
     * @since BuddyPress (1.5.0)
     *
     * @param int $value Max results for autocomplete. Default 10.
     */
    $limit = isset($_GET['limit']) ? absint($_GET['limit']) : (int) apply_filters('bp_autocomplete_max_results', 10);
    $term = isset($_GET['q']) ? sanitize_text_field($_GET['q']) : '';
    // Include everyone in the autocomplete, or just friends?
    if (bp_is_current_component(bp_get_messages_slug())) {
        $only_friends = buddypress()->messages->autocomplete_all === false;
    } else {
        $only_friends = true;
    }
    $suggestions = bp_core_get_suggestions(array('limit' => $limit, 'only_friends' => $only_friends, 'term' => $term, 'type' => 'members'));
    if ($suggestions && !is_wp_error($suggestions)) {
        foreach ($suggestions as $user) {
            // Note that the final line break acts as a delimiter for the
            // autocomplete JavaScript and thus should not be removed
            printf('<span id="%s" href="#"></span><img src="%s" style="width: 15px"> &nbsp; %s (%s)' . "\n", esc_attr('link-' . $user->ID), esc_url($user->image), esc_html($user->name), esc_html($user->ID));
        }
    }
    exit;
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:36,代码来源:buddypress-functions.php

示例2: bp_groups_admin_autocomplete_handler

/**
 * AJAX handler for group member autocomplete requests.
 *
 * @since 1.7.0
 */
function bp_groups_admin_autocomplete_handler()
{
    // Bail if user user shouldn't be here, or is a large network
    if (!current_user_can('bp_moderate') || is_multisite() && wp_is_large_network('users')) {
        wp_die(-1);
    }
    $term = isset($_GET['term']) ? sanitize_text_field($_GET['term']) : '';
    $group_id = isset($_GET['group_id']) ? absint($_GET['group_id']) : 0;
    if (!$term || !$group_id) {
        wp_die(-1);
    }
    $suggestions = bp_core_get_suggestions(array('group_id' => -$group_id, 'limit' => 10, 'term' => $term, 'type' => 'members'));
    $matches = array();
    if ($suggestions && !is_wp_error($suggestions)) {
        foreach ($suggestions as $user) {
            $matches[] = array('label' => sprintf(__('%1$s (%2$s)', 'buddypress'), $user->name, $user->ID), 'value' => $user->ID);
        }
    }
    wp_die(json_encode($matches));
}
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:25,代码来源:bp-groups-admin.php

示例3: test_suggestions_with_type_groupmembers_hidden_and_exclude_group_from_results

 public function test_suggestions_with_type_groupmembers_hidden_and_exclude_group_from_results()
 {
     $suggestions = bp_core_get_suggestions(array('group_id' => self::$group_ids['hidden'], 'type' => 'members', 'term' => 'pig'));
     $this->assertTrue(is_wp_error($suggestions));
     // no access to group.
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:6,代码来源:suggestions-nonauth.php

示例4: bp_ajax_get_suggestions

/**
 * AJAX endpoint for Suggestions API lookups.
 *
 * @since 2.1.0
 */
function bp_ajax_get_suggestions()
{
    if (!bp_is_user_active() || empty($_GET['term']) || empty($_GET['type'])) {
        wp_send_json_error('missing_parameter');
        exit;
    }
    $args = array('term' => sanitize_text_field($_GET['term']), 'type' => sanitize_text_field($_GET['type']));
    // Support per-Group suggestions.
    if (!empty($_GET['group-id'])) {
        $args['group_id'] = absint($_GET['group-id']);
    }
    $results = bp_core_get_suggestions($args);
    if (is_wp_error($results)) {
        wp_send_json_error($results->get_error_message());
        exit;
    }
    wp_send_json_success($results);
}
开发者ID:swissspidy,项目名称:BuddyPress,代码行数:23,代码来源:bp-activity-actions.php

示例5: bp_ajax_get_suggestions

/**
 * AJAX endpoint for Suggestions API lookups.
 *
 * @since BuddyPress (2.1.0)
 */
function bp_ajax_get_suggestions()
{
    if (!bp_is_user_active() || empty($_GET['term']) || empty($_GET['type'])) {
        wp_send_json_error('missing_parameter');
        exit;
    }
    $results = bp_core_get_suggestions(array('term' => sanitize_text_field($_GET['term']), 'type' => sanitize_text_field($_GET['type'])));
    if (is_wp_error($results)) {
        wp_send_json_error($results->get_error_message());
        exit;
    }
    wp_send_json_success($results);
}
开发者ID:eresyyl,项目名称:mk,代码行数:18,代码来源:bp-activity-actions.php

示例6: test_suggestions_with_bad_term

 public function test_suggestions_with_bad_term()
 {
     // a non-empty term is mandatory
     $suggestions = bp_core_get_suggestions(array('term' => '', 'type' => 'members'));
     $this->assertTrue(is_wp_error($suggestions));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:6,代码来源:suggestions.php

示例7: ajax_group_search

 /**
  * Searches for groups given some characters and returns
  * the found suggestions
  *
  * @package WP Idea Stream
  * @subpackage buddypress/groups
  *
  * @since  2.0.0
  *
  * @uses   wp_idea_stream_user_can() to check for user's capability
  * @uses   sanitize_text_field() to sanitize the search terms
  * @uses   bp_loggedin_user_id() to get current user's ID
  * @uses   bp_core_get_suggestions() to get the matching suggestions
  * @return string the groups suggestions
  */
 public function ajax_group_search()
 {
     // Bail if user user shouldn't be here
     if (!wp_idea_stream_user_can('edit_ideas')) {
         wp_die(-1);
     }
     $term = '';
     if (isset($_GET['term'])) {
         $term = sanitize_text_field($_GET['term']);
     }
     $author = bp_loggedin_user_id();
     if (isset($_GET['user_id'])) {
         $author = absint($_GET['user_id']);
     }
     if (empty($term)) {
         wp_die(-1);
     }
     $suggestions = bp_core_get_suggestions(array('limit' => 10, 'term' => $term, 'type' => 'ideastream_groups', 'show_hidden' => true, 'meta_key' => '_group_ideastream_activate', 'meta_value' => 1, 'author' => $author));
     $matches = array();
     if ($suggestions && !is_wp_error($suggestions)) {
         foreach ($suggestions as $group) {
             $matches[] = array('label' => esc_html($group->name), 'value' => esc_attr($group->id), 'link' => esc_url($group->link));
         }
     }
     wp_die(json_encode($matches));
 }
开发者ID:mrjarbenne,项目名称:wp-idea-stream,代码行数:41,代码来源:groups.php


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