本文整理汇总了PHP中bp_core_get_component_search_query_arg函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_get_component_search_query_arg函数的具体用法?PHP bp_core_get_component_search_query_arg怎么用?PHP bp_core_get_component_search_query_arg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_get_component_search_query_arg函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor method.
*
* @see BP_Groups_Group::get() for an in-depth description of arguments.
*
* @param array $args {
* Array of arguments. Accepts all arguments accepted by
* {@link BP_Groups_Group::get()}. In cases where the default
* values of the params differ, they have been discussed below.
* @type int $per_page Default: 20.
* @type int $page Default: 1.
* }
*/
function __construct($args = array())
{
// Backward compatibility with old method of passing arguments.
if (!is_array($args) || func_num_args() > 1) {
_deprecated_argument(__METHOD__, '1.7', sprintf(__('Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress'), __METHOD__, __FILE__));
$old_args_keys = array(0 => 'user_id', 1 => 'type', 2 => 'page', 3 => 'per_page', 4 => 'max', 5 => 'slug', 6 => 'search_terms', 7 => 'populate_extras', 8 => 'include', 9 => 'exclude', 10 => 'show_hidden', 11 => 'page_arg');
$func_args = func_get_args();
$args = bp_core_parse_args_array($old_args_keys, $func_args);
}
$defaults = array('page' => 1, 'per_page' => 20, 'page_arg' => 'grpage', 'max' => false, 'type' => 'active', 'order' => 'DESC', 'orderby' => 'date_created', 'show_hidden' => false, 'user_id' => 0, 'slug' => false, 'include' => false, 'exclude' => false, 'search_terms' => '', 'meta_query' => false, 'populate_extras' => true, 'update_meta_cache' => true);
$r = wp_parse_args($args, $defaults);
extract($r);
$this->pag_arg = sanitize_key($r['page_arg']);
$this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $r['page']);
$this->pag_num = bp_sanitize_pagination_arg('num', $r['per_page']);
if (bp_current_user_can('bp_moderate') || is_user_logged_in() && $user_id == bp_loggedin_user_id()) {
$show_hidden = true;
}
if ('invites' == $type) {
$this->groups = groups_get_invites_for_user($user_id, $this->pag_num, $this->pag_page, $exclude);
} elseif ('single-group' == $type) {
$this->single_group = true;
if (groups_get_current_group()) {
$group = groups_get_current_group();
} else {
$group = groups_get_group(array('group_id' => BP_Groups_Group::get_id_from_slug($r['slug']), 'populate_extras' => $r['populate_extras']));
}
// Backwards compatibility - the 'group_id' variable is not part of the
// BP_Groups_Group object, but we add it here for devs doing checks against it
//
// @see https://buddypress.trac.wordpress.org/changeset/3540
//
// this is subject to removal in a future release; devs should check against
// $group->id instead.
$group->group_id = $group->id;
$this->groups = array($group);
} else {
$this->groups = groups_get_groups(array('type' => $type, 'order' => $order, 'orderby' => $orderby, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'search_terms' => $search_terms, 'meta_query' => $meta_query, 'include' => $include, 'exclude' => $exclude, 'populate_extras' => $populate_extras, 'update_meta_cache' => $update_meta_cache, 'show_hidden' => $show_hidden));
}
if ('invites' == $type) {
$this->total_group_count = (int) $this->groups['total'];
$this->group_count = (int) $this->groups['total'];
$this->groups = $this->groups['groups'];
} elseif ('single-group' == $type) {
if (empty($group->id)) {
$this->total_group_count = 0;
$this->group_count = 0;
} else {
$this->total_group_count = 1;
$this->group_count = 1;
}
} else {
if (empty($max) || $max >= (int) $this->groups['total']) {
$this->total_group_count = (int) $this->groups['total'];
} else {
$this->total_group_count = (int) $max;
}
$this->groups = $this->groups['groups'];
if (!empty($max)) {
if ($max >= count($this->groups)) {
$this->group_count = count($this->groups);
} else {
$this->group_count = (int) $max;
}
} else {
$this->group_count = count($this->groups);
}
}
// Build pagination links.
if ((int) $this->total_group_count && (int) $this->pag_num) {
$pag_args = array($this->pag_arg => '%#%');
if (defined('DOING_AJAX') && true === (bool) DOING_AJAX) {
$base = remove_query_arg('s', wp_get_referer());
} else {
$base = '';
}
$add_args = array('num' => $this->pag_num, 'sortby' => $this->sort_by, 'order' => $this->order);
if (!empty($search_terms)) {
$query_arg = bp_core_get_component_search_query_arg('groups');
$add_args[$query_arg] = urlencode($search_terms);
}
$this->pag_links = paginate_links(array('base' => add_query_arg($pag_args, $base), 'format' => '', 'total' => ceil((int) $this->total_group_count / (int) $this->pag_num), 'current' => $this->pag_page, 'prev_text' => _x('←', 'Group pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Group pagination next text', 'buddypress'), 'mid_size' => 1, 'add_args' => $add_args));
}
}
示例2: bp_directory_groups_search_form
/**
* @since 1.0.0
*/
function bp_directory_groups_search_form()
{
$query_arg = bp_core_get_component_search_query_arg('groups');
if (!empty($_REQUEST[$query_arg])) {
$search_value = stripslashes($_REQUEST[$query_arg]);
} else {
$search_value = bp_get_search_default_text('groups');
}
$search_form_html = '<form action="" method="get" id="search-groups-form">
<label for="groups_search"><input type="text" name="' . esc_attr($query_arg) . '" id="groups_search" placeholder="' . esc_attr($search_value) . '" /></label>
<input type="submit" id="groups_search_submit" name="groups_search_submit" value="' . __('Search', 'buddypress') . '" />
</form>';
/**
* Filters the HTML markup for the groups search form.
*
* @since 1.9.0
*
* @param string $search_form_html HTML markup for the search form.
*/
echo apply_filters('bp_directory_groups_search_form', $search_form_html);
}
示例3: xprofile_filter_link_profile_data
/**
* Filter an Extended Profile field value, and attempt to make clickable links
* to members search results out of them.
*
* - Not run on datebox field types.
* - Not run on values without commas with less than 5 words.
* - URL's are made clickable.
* - To disable: remove_filter( 'bp_get_the_profile_field_value', 'xprofile_filter_link_profile_data', 9, 2 );
*
* @since 1.1.0
*
* @param string $field_value Profile field data value.
* @param string $field_type Profile field type.
* @return string
*/
function xprofile_filter_link_profile_data($field_value, $field_type = 'textbox')
{
if ('datebox' === $field_type) {
return $field_value;
}
if (!strpos($field_value, ',') && count(explode(' ', $field_value)) > 5) {
return $field_value;
}
$values = explode(',', $field_value);
if (!empty($values)) {
foreach ((array) $values as $value) {
$value = trim($value);
// If the value is a URL, skip it and just make it clickable.
if (preg_match('@(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.]*(\\?\\S+)?)?)?)@', $value)) {
$new_values[] = make_clickable($value);
// Is not clickable.
} else {
// More than 5 spaces.
if (count(explode(' ', $value)) > 5) {
$new_values[] = $value;
// Less than 5 spaces.
} else {
$query_arg = bp_core_get_component_search_query_arg('members');
$search_url = add_query_arg(array($query_arg => urlencode($value)), bp_get_members_directory_permalink());
$new_values[] = '<a href="' . esc_url($search_url) . '" rel="nofollow">' . $value . '</a>';
}
}
}
$values = implode(', ', $new_values);
}
return $values;
}
示例4: __construct
/**
* Constructor method.
*
* @see BP_User_Query for an in-depth description of parameters.
*
* @param string $type Sort order.
* @param int $page_number Page of results.
* @param int $per_page Number of results per page.
* @param int $max Max number of results to return.
* @param int $user_id Limit to friends of a user.
* @param string $search_terms Limit to users matching search terms.
* @param array $include Limit results by these user IDs.
* @param bool $populate_extras Fetch optional extras.
* @param array $exclude Exclude these IDs from results.
* @param array $meta_key Limit to users with a meta_key.
* @param array $meta_value Limit to users with a meta_value (with meta_key).
* @param string $page_arg Optional. The string used as a query parameter in pagination links.
* Default: 'upage'.
* @param array|string $member_type Array or comma-separated string of member types to limit results to.
* @param array|string $member_type__in Array or comma-separated string of member types to limit results to.
* @param array|string $member_type__not_in Array or comma-separated string of member types to exclude
* from results.
*/
function __construct($type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value, $page_arg = 'upage', $member_type = '', $member_type__in = '', $member_type__not_in = '')
{
$this->pag_arg = sanitize_key($page_arg);
$this->pag_page = bp_sanitize_pagination_arg($this->pag_arg, $page_number);
$this->pag_num = bp_sanitize_pagination_arg('num', $per_page);
$this->type = $type;
if (!empty($_REQUEST['letter'])) {
$this->members = BP_Core_User::get_users_by_letter($_REQUEST['letter'], $this->pag_num, $this->pag_page, $populate_extras, $exclude);
} else {
$this->members = bp_core_get_users(array('type' => $this->type, 'per_page' => $this->pag_num, 'page' => $this->pag_page, 'user_id' => $user_id, 'include' => $include, 'search_terms' => $search_terms, 'populate_extras' => $populate_extras, 'exclude' => $exclude, 'meta_key' => $meta_key, 'meta_value' => $meta_value, 'member_type' => $member_type, 'member_type__in' => $member_type__in, 'member_type__not_in' => $member_type__not_in));
}
if (!$max || $max >= (int) $this->members['total']) {
$this->total_member_count = (int) $this->members['total'];
} else {
$this->total_member_count = (int) $max;
}
$this->members = $this->members['users'];
if ($max) {
if ($max >= count($this->members)) {
$this->member_count = count($this->members);
} else {
$this->member_count = (int) $max;
}
} else {
$this->member_count = count($this->members);
}
if ((int) $this->total_member_count && (int) $this->pag_num) {
$pag_args = array($this->pag_arg => '%#%');
if (defined('DOING_AJAX') && true === (bool) DOING_AJAX) {
$base = remove_query_arg('s', wp_get_referer());
} else {
$base = '';
}
/**
* Defaults to an empty array to make sure paginate_links()
* won't add the $page_arg to the links which would break
* pagination in case JavaScript is disabled.
*/
$add_args = array();
if (!empty($search_terms)) {
$query_arg = bp_core_get_component_search_query_arg('members');
$add_args[$query_arg] = urlencode($search_terms);
}
$this->pag_links = paginate_links(array('base' => add_query_arg($pag_args, $base), 'format' => '', 'total' => ceil((int) $this->total_member_count / (int) $this->pag_num), 'current' => (int) $this->pag_page, 'prev_text' => _x('←', 'Member pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Member pagination next text', 'buddypress'), 'mid_size' => 1, 'add_args' => $add_args));
}
}
示例5: bp_get_search_placeholder
/**
* Get the placeholder text for the search box for a given component.
*
* @since 2.7.0
*
* @param string $component Component name. Defaults to current component.
* @return string Placeholder text for the search field.
*/
function bp_get_search_placeholder($component = '')
{
$query_arg = bp_core_get_component_search_query_arg($component);
if ($query_arg && !empty($_REQUEST[$query_arg])) {
$placeholder = wp_unslash($_REQUEST[$query_arg]);
} else {
$placeholder = bp_get_search_default_text($component);
}
return $placeholder;
}
示例6: bp_has_activities
//.........这里部分代码省略.........
* is a member.
* @type string|bool $spam Spam status. 'ham_only', 'spam_only', or false to show all activity
* regardless of spam status. Default: 'ham_only'.
* @type bool $populate_extras Whether to pre-fetch the activity metadata for the queried items.
* Default: true.
* }
* @return bool Returns true when activities are found, otherwise false.
*/
function bp_has_activities($args = '')
{
global $activities_template;
// Get BuddyPress.
$bp = buddypress();
/*
* Smart Defaults.
*/
// User filtering.
$user_id = bp_displayed_user_id() ? bp_displayed_user_id() : false;
// Group filtering.
if (bp_is_group()) {
$object = $bp->groups->id;
$primary_id = bp_get_current_group_id();
$show_hidden = (bool) (groups_is_user_member(bp_loggedin_user_id(), $primary_id) || bp_current_user_can('bp_moderate'));
} else {
$object = false;
$primary_id = false;
$show_hidden = false;
}
// The default scope should recognize custom slugs.
$scope = array_key_exists(bp_current_action(), (array) $bp->loaded_components) ? $bp->loaded_components[bp_current_action()] : bp_current_action();
// Support for permalinks on single item pages: /groups/my-group/activity/124/.
$include = bp_is_current_action(bp_get_activity_slug()) ? bp_action_variable(0) : false;
$search_terms_default = false;
$search_query_arg = bp_core_get_component_search_query_arg('activity');
if (!empty($_REQUEST[$search_query_arg])) {
$search_terms_default = stripslashes($_REQUEST[$search_query_arg]);
}
/*
* Parse Args.
*/
// Note: any params used for filtering can be a single value, or multiple
// values comma separated.
$r = bp_parse_args($args, array('display_comments' => 'threaded', 'include' => $include, 'exclude' => false, 'in' => false, 'sort' => 'DESC', 'page' => 1, 'per_page' => 20, 'page_arg' => 'acpage', 'max' => false, 'fields' => 'all', 'count_total' => false, 'show_hidden' => $show_hidden, 'spam' => 'ham_only', 'scope' => $scope, 'user_id' => $user_id, 'object' => $object, 'action' => false, 'primary_id' => $primary_id, 'secondary_id' => false, 'offset' => false, 'since' => false, 'meta_query' => false, 'date_query' => false, 'filter_query' => false, 'search_terms' => $search_terms_default, 'update_meta_cache' => true), 'has_activities');
/*
* Smart Overrides.
*/
// Translate various values for 'display_comments'
// This allows disabling comments via ?display_comments=0
// or =none or =false. Final true is a strict type check. See #5029.
if (in_array($r['display_comments'], array(0, '0', 'none', 'false'), true)) {
$r['display_comments'] = false;
}
// Ignore pagination if an offset is passed.
if (!empty($r['offset'])) {
$r['page'] = 0;
}
// Search terms.
if (!empty($_REQUEST['s']) && empty($r['search_terms'])) {
$r['search_terms'] = $_REQUEST['s'];
}
// Do not exceed the maximum per page.
if (!empty($r['max']) && (int) $r['per_page'] > (int) $r['max']) {
$r['per_page'] = $r['max'];
}
/**
* Filters whether BuddyPress should enable afilter support.
示例7: esc_attr
echo esc_attr(bp_current_component());
?>
-dir-search" class="dir-search" role="search">
<form action="" method="get" id="search-<?php
echo esc_attr(bp_current_component());
?>
-form">
<label for="<?php
bp_search_input_name();
?>
" class="bp-screen-reader-text"><?php
bp_search_placeholder();
?>
</label>
<input type="text" name="<?php
echo esc_attr(bp_core_get_component_search_query_arg());
?>
" id="<?php
bp_search_input_name();
?>
" placeholder="<?php
bp_search_placeholder();
?>
" />
<input type="submit" id="<?php
echo esc_attr(bp_get_search_input_name());
?>
_submit" name="<?php
bp_search_input_name();
?>