/** * Output the deposits search form. * * @return string html output */ function humcore_deposits_search_form() { $default_search_value = bp_get_search_default_text('humcore_deposits'); $search_value = ''; if (!empty($_REQUEST['s'])) { $search_value = stripslashes($_REQUEST['s']); } $search_form_html = '<form action="" method="get" id="search-deposits-form"> <label><input type="text" name="s" id="search-deposits-term" value="' . esc_attr($search_value) . '" placeholder="' . esc_attr($default_search_value) . '" /></label> <input type="hidden" name="facets" id="search-deposits-facets"></input> <input type="submit" id="search-deposits-submit" name="search_deposits_submit" value="' . __('Search', 'humcore_domain') . '" /> </form>'; echo apply_filters('humcore_deposits_search_form', $search_form_html); // XSS OK. }
function bp_directory_course_search_form() { $default_search_value = bp_get_search_default_text(BP_COURSE_SLUG); $search_value = !empty($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : $default_search_value; $search_form_html = '<form action="" method="get" id="search-course-form"> <label><input type="text" name="s" id="groups_search" placeholder="' . esc_attr($search_value) . '" /></label> <input type="submit" id="course_search_submit" name="course_search_submit" value="' . __('Search', 'vibe') . '" /> </form>'; echo apply_filters('bp_directory_course_search_form', $search_form_html); }
function bp_dtheme_ajax_querystring($query_string, $object) { global $bp; if (empty($object)) { return false; } /* Set up the cookies passed on this AJAX request. Store a local var to avoid conflicts */ if (!empty($_POST['cookie'])) { $_BP_COOKIE = wp_parse_args(str_replace('; ', '&', urldecode($_POST['cookie']))); } else { $_BP_COOKIE =& $_COOKIE; } $qs = false; /*** * Check if any cookie values are set. If there are then override the default params passed to the * template loop */ if (!empty($_BP_COOKIE['bp-' . $object . '-filter']) && '-1' != $_BP_COOKIE['bp-' . $object . '-filter']) { $qs[] = 'type=' . $_BP_COOKIE['bp-' . $object . '-filter']; $qs[] = 'action=' . $_BP_COOKIE['bp-' . $object . '-filter']; // Activity stream filtering on action } if (!empty($_BP_COOKIE['bp-' . $object . '-scope'])) { if ('personal' == $_BP_COOKIE['bp-' . $object . '-scope']) { $user_id = $bp->displayed_user->id ? $bp->displayed_user->id : $bp->loggedin_user->id; $qs[] = 'user_id=' . $user_id; } if ('all' != $_BP_COOKIE['bp-' . $object . '-scope'] && empty($bp->displayed_user->id) && !$bp->is_single_item) { $qs[] = 'scope=' . $_BP_COOKIE['bp-' . $object . '-scope']; } // Activity stream scope only on activity directory. } /* If page and search_terms have been passed via the AJAX post request, use those */ if (!empty($_POST['page']) && '-1' != $_POST['page']) { $qs[] = 'page=' . $_POST['page']; } $object_search_text = bp_get_search_default_text($object); if (!empty($_POST['search_terms']) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms']) { $qs[] = 'search_terms=' . $_POST['search_terms']; } /* Now pass the querystring to override default values. */ $query_string = empty($qs) ? '' : join('&', (array) $qs); $object_filter = ''; if (isset($_BP_COOKIE['bp-' . $object . '-filter'])) { $object_filter = $_BP_COOKIE['bp-' . $object . '-filter']; } $object_scope = ''; if (isset($_BP_COOKIE['bp-' . $object . '-scope'])) { $object_scope = $_BP_COOKIE['bp-' . $object . '-scope']; } $object_page = ''; if (isset($_BP_COOKIE['bp-' . $object . '-page'])) { $object_page = $_BP_COOKIE['bp-' . $object . '-page']; } $object_search_terms = ''; if (isset($_BP_COOKIE['bp-' . $object . '-search-terms'])) { $object_search_terms = $_BP_COOKIE['bp-' . $object . '-search-terms']; } $object_extras = ''; if (isset($_BP_COOKIE['bp-' . $object . '-extras'])) { $object_extras = $_BP_COOKIE['bp-' . $object . '-extras']; } return apply_filters('bp_dtheme_ajax_querystring', $query_string, $object, $object_filter, $object_scope, $object_page, $object_search_terms, $object_extras); }
/** * @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); }
/** * Output the forums directory search form. */ function bp_directory_forums_search_form() { $default_search_value = bp_get_search_default_text('forums'); $search_value = !empty($_REQUEST['fs']) ? stripslashes($_REQUEST['fs']) : $default_search_value; $search_form_html = '<form action="" method="get" id="search-forums-form"> <label><input type="text" name="s" id="forums_search" placeholder="' . esc_attr($search_value) . '" /></label> <input type="submit" id="forums_search_submit" name="forums_search_submit" value="' . __('Search', 'buddypress') . '" /> </form>'; echo apply_filters('bp_directory_forums_search_form', $search_form_html); }
/** * This function looks scarier than it actually is. :) * Each object loop (activity/members/groups/blogs/forums) contains default * parameters to show specific information based on the page we are currently * looking at. * * The following function will take into account any cookies set in the JS and * allow us to override the parameters sent. That way we can change the results * returned without reloading the page. * * By using cookies we can also make sure that user settings are retained * across page loads. * * @return string Query string for the component loops * @since BuddyPress (1.2) */ function bp_legacy_theme_ajax_querystring($query_string, $object) { if (empty($object)) { return ''; } // Set up the cookies passed on this AJAX request. Store a local var to avoid conflicts if (!empty($_POST['cookie'])) { $_BP_COOKIE = wp_parse_args(str_replace('; ', '&', urldecode($_POST['cookie']))); } else { $_BP_COOKIE =& $_COOKIE; } $qs = array(); /** * Check if any cookie values are set. If there are then override the * default params passed to the template loop. */ // Activity stream filtering on action if (!empty($_BP_COOKIE['bp-' . $object . '-filter']) && '-1' != $_BP_COOKIE['bp-' . $object . '-filter']) { $qs[] = 'type=' . $_BP_COOKIE['bp-' . $object . '-filter']; $qs[] = 'action=' . $_BP_COOKIE['bp-' . $object . '-filter']; } if (!empty($_BP_COOKIE['bp-' . $object . '-scope'])) { if ('personal' == $_BP_COOKIE['bp-' . $object . '-scope']) { $user_id = bp_displayed_user_id() ? bp_displayed_user_id() : bp_loggedin_user_id(); $qs[] = 'user_id=' . $user_id; } // Activity stream scope only on activity directory. if ('all' != $_BP_COOKIE['bp-' . $object . '-scope'] && !bp_displayed_user_id() && !bp_is_single_item()) { $qs[] = 'scope=' . $_BP_COOKIE['bp-' . $object . '-scope']; } } // If page and search_terms have been passed via the AJAX post request, use those. if (!empty($_POST['page']) && '-1' != $_POST['page']) { $qs[] = 'page=' . absint($_POST['page']); } // excludes activity just posted and avoids duplicate ids if (!empty($_POST['exclude_just_posted'])) { $just_posted = wp_parse_id_list($_POST['exclude_just_posted']); $qs[] = 'exclude=' . implode(',', $just_posted); } // to get newest activities if (!empty($_POST['offset'])) { $qs[] = 'offset=' . intval($_POST['offset']); } $object_search_text = bp_get_search_default_text($object); if (!empty($_POST['search_terms']) && $object_search_text != $_POST['search_terms'] && 'false' != $_POST['search_terms'] && 'undefined' != $_POST['search_terms']) { $qs[] = 'search_terms=' . urlencode($_POST['search_terms']); } // Now pass the querystring to override default values. $query_string = empty($qs) ? '' : join('&', (array) $qs); $object_filter = ''; if (isset($_BP_COOKIE['bp-' . $object . '-filter'])) { $object_filter = $_BP_COOKIE['bp-' . $object . '-filter']; } $object_scope = ''; if (isset($_BP_COOKIE['bp-' . $object . '-scope'])) { $object_scope = $_BP_COOKIE['bp-' . $object . '-scope']; } $object_page = ''; if (isset($_BP_COOKIE['bp-' . $object . '-page'])) { $object_page = $_BP_COOKIE['bp-' . $object . '-page']; } $object_search_terms = ''; if (isset($_BP_COOKIE['bp-' . $object . '-search-terms'])) { $object_search_terms = $_BP_COOKIE['bp-' . $object . '-search-terms']; } $object_extras = ''; if (isset($_BP_COOKIE['bp-' . $object . '-extras'])) { $object_extras = $_BP_COOKIE['bp-' . $object . '-extras']; } /** * Filters the AJAX query string for the component loops. * * @since BuddyPress (1.7.0) * * @param string $query_string The query string we are working with. * @param string $object The type of page we are on. * @param string $object_filter The current object filter. * @param string $object_scope The current object scope. * @param string $object_page The current object page. * @param string $object_search_terms The current object search terms. * @param string $object_extras The current object extras. */ return apply_filters('bp_legacy_theme_ajax_querystring', $query_string, $object, $object_filter, $object_scope, $object_page, $object_search_terms, $object_extras); }
function bp_directory_groups_search_form() { global $bp; $default_search_value = bp_get_search_default_text('groups'); $search_value = !empty($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : $default_search_value; ?> <form action="" method="get" id="search-groups-form"> <label><input type="text" name="s" id="groups_search" value="<?php echo esc_attr($search_value); ?> " onfocus="if (this.value == '<?php echo $default_search_value; ?> ') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php echo $default_search_value; ?> ';}" /></label> <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e('Search', 'buddypress'); ?> " /> </form> <?php }
<?php if (bp_has_members(bp_ajax_querystring('members'))) { ?> <form action="" method="post" id="members-directory-form" class="dir-form"> <h1 class="post-title red-text"><?php _e('People', 'thatcamp'); ?> </h1> <div id="members-dir-search" class="dir-search" role="search"> <?php $default_search_value = bp_get_search_default_text('members'); $search_value = !empty($_REQUEST['msearch']) ? stripslashes($_REQUEST['msearch']) : $default_search_value; ?> <form action="" method="get" id="search-members-form"> <label><input type="text" name="msearch" id="members_search" placeholder="Find people" /></label> <input type="submit" id="members_search_submit" name="members_search_submit" value="<?php _e('Search', 'buddypress'); ?> " /> </form> </div> </form> <div id="pag-top" class="pagination no-ajax"> <div class="pag-count" id="member-dir-count-top">
function bp_directory_groups_search_form() { $default_search_value = bp_get_search_default_text('groups'); $search_value = !empty($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : $default_search_value; ?> <form action="" method="get" id="search-groups-form"> <label><input type="text" name="s" id="groups_search" placeholder="<?php echo esc_attr($search_value); ?> " /></label> <input type="submit" id="groups_search_submit" name="groups_search_submit" value="<?php _e('Search', 'buddypress'); ?> " /> </form> <?php }
/** * Output the default text for the search box for a given component. * * @since 1.5.0 * * @see bp_get_search_default_text() * * @param string $component See {@link bp_get_search_default_text()}. */ function bp_search_default_text($component = '') { echo bp_get_search_default_text($component); }
/** * Output the Private Message search form. * * @todo Move markup to template part in: /members/single/messages/search.php * @since 1.6.0 */ function bp_message_search_form() { // Get the default search text. $default_search_value = bp_get_search_default_text('messages'); // Setup a few values based on what's being searched for. $search_submitted = !empty($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : $default_search_value; $search_placeholder = $search_submitted === $default_search_value ? ' placeholder="' . esc_attr($search_submitted) . '"' : ''; $search_value = $search_submitted !== $default_search_value ? ' value="' . esc_attr($search_submitted) . '"' : ''; // Start the output buffer, so form can be filtered. ob_start(); ?> <form action="" method="get" id="search-message-form"> <label for="messages_search" class="bp-screen-reader-text"><?php esc_html_e('Search Messages', 'buddypress'); ?> </label> <input type="text" name="s" id="messages_search"<?php echo $search_placeholder . $search_value; ?> /> <input type="submit" class="button" id="messages_search_submit" name="messages_search_submit" value="<?php esc_html_e('Search', 'buddypress'); ?> " /> </form> <?php // Get the search form from the above output buffer. $search_form_html = ob_get_clean(); /** * Filters the private message component search form. * * @since 2.2.0 * * @param string $search_form_html HTML markup for the message search form. */ echo apply_filters('bp_message_search_form', $search_form_html); }
/** * Output the blog directory search form. */ function bp_directory_blogs_search_form() { $default_search_value = bp_get_search_default_text(); $search_value = !empty($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : $default_search_value; $search_form_html = '<form action="" method="get" id="search-blogs-form"> <label><input type="text" name="s" id="blogs_search" placeholder="' . esc_attr($search_value) . '" /></label> <input type="submit" id="blogs_search_submit" name="blogs_search_submit" value="' . __('Search', 'buddypress') . '" /> </form>'; /** * Filters the output for the blog directory search form. * * @since BuddyPress (1.9.0) * * @param string $search_form_html HTML markup for blog directory search form. */ echo apply_filters('bp_directory_blogs_search_form', $search_form_html); }
/** * Output the Private Message search form * * @since BuddyPress (1.6) */ function bp_message_search_form() { $default_search_value = bp_get_search_default_text('messages'); $search_value = !empty($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : $default_search_value; ?> <form action="" method="get" id="search-message-form"> <label><input type="text" name="s" id="messages_search" <?php if ($search_value === $default_search_value) { ?> placeholder="<?php echo esc_html($search_value); ?> "<?php } ?> <?php if ($search_value !== $default_search_value) { ?> value="<?php echo esc_html($search_value); ?> "<?php } ?> /></label> <input type="submit" id="messages_search_submit" name="messages_search_submit" value="<?php _e('Search', 'buddypress'); ?> " /> </form> <?php }
/** * Output the Private Message search form. * * @todo Move markup to template part in: /members/single/messages/search.php * @since BuddyPress (1.6.0) */ function flat_sassy_boots_bp_message_search_form() { // Get the default search text $default_search_value = bp_get_search_default_text('messages'); // Setup a few values based on what's being searched for $search_submitted = !empty($_REQUEST['s']) ? stripslashes($_REQUEST['s']) : $default_search_value; $search_placeholder = $search_submitted === $default_search_value ? ' placeholder="' . esc_attr($search_submitted) . '"' : ''; $search_value = $search_submitted !== $default_search_value ? ' value="' . esc_attr($search_submitted) . '"' : ''; // Start the output buffer, so form can be filtered ob_start(); ?> <form action="" method="get" id="search-message-form"> <div class="input-group"> <input class = "form-control" type="text" name="s" id="messages_search"<?php echo $search_placeholder . $search_value; ?> /> <span class="input-group-btn"> <input type="submit" class="button" id="messages_search_submit" name="messages_search_submit" value="<?php esc_html_e('Search', 'buddypress'); ?> " /> </span> </div> </form> <?php // Get the search form from the above output buffer $search_form_html = ob_get_clean(); /** * Filters the private message component search form. * * @since BuddyPress (2.2.0) * * @param string $search_form_html HTML markup for the message search form. */ echo apply_filters('bp_message_search_form', $search_form_html); }
/** * Restrict group listing to top-level groups */ function bp_group_hierarchy_get_groups_tree($groups, $params, $parent_id = 0) { global $bp, $groups_template; if (isset($_POST['scope']) && $_POST['object'] == 'tree' && $_POST['scope'] != 'all') { $parent_id = substr($_POST['scope'], 8); $parent_id = (int) $parent_id; } /** * Replace retrieved list with toplevel groups * unless on a group page (member groups list) or viewing "My Groups" */ if (!isset($bp->groups->current_group->id) && !$params['user_id']) { /** remove search placeholder text for BP 1.5 */ if (function_exists('bp_get_search_default_text') && trim($params['search_terms']) == bp_get_search_default_text('groups')) { $params['search_terms'] = ''; } if (empty($params['search_terms'])) { $params['parent_id'] = $parent_id; $toplevel_groups = bp_group_hierarchy_get_by_hierarchy($params); $groups = $toplevel_groups; } } return $groups; }
/** * Fire the WP_Query */ public function get($args = array()) { if (empty($this->query)) { $default = array('id' => 0, 'author_id' => 0, 'title' => null, 'description' => null, 'url' => null, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s'), 'tags' => array(), 'search_terms' => null); $r = wp_parse_args($args, $defaults); extract($r); $this->prpage = isset($page) ? $page : 1; $this->num = isset($posts_per_page) ? $posts_per_page : 10; $query_args = array('post_status' => 'publish', 'post_type' => 'portfolio', 'posts_per_page' => $this->num, 'paged' => $this->prpage, 'meta_query' => array()); // Filter by post id $id = $id ? $id : $this->id; if ($id) { $query_args['p'] = $id; } // Filter by author $author_id = $author_id ? $author_id : $this->author_id; if ($author_id) { $query_args['author'] = $author_id; } // Filter by search terms if (isset($search_terms) and $search_terms != bp_get_search_default_text('portfolio')) { $query_args['s'] = $search_terms; } $this->query = new WP_Query($query_args); // Set up some pagination $this->pag_links = paginate_links(array('base' => add_query_arg(array('prpage' => '%#%', 'num' => (int) $this->num)), 'format' => '', 'total' => ceil((int) $this->query->found_posts / (int) $this->num), 'current' => (int) $this->prpage, 'prev_text' => _x('←', 'Project pagination previous text', 'buddypress'), 'next_text' => _x('→', 'Project pagination next text', 'buddypress'), 'mid_size' => 1)); } }