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


PHP bbp_get_search_terms函数代码示例

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


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

示例1: bbp_get_search_query_args

/**
 * Return the search's query args
 *
 * @since bbPress (r4579)
 *
 * @uses bbp_get_search_terms() To get the search terms
 * @return array Query arguments
 */
function bbp_get_search_query_args()
{
    // Get search terms
    $search_terms = bbp_get_search_terms();
    $retval = !empty($search_terms) ? array('s' => $search_terms) : array();
    return apply_filters('bbp_get_search_query_args', $retval);
}
开发者ID:ReLiFeD,项目名称:irreversible.eu,代码行数:15,代码来源:functions.php

示例2: bbp_search_url

<form role="search" method="get" class="searchform bbp-search-form search-form" action="<?php 
bbp_search_url();
?>
">
	<div class="search-table">
		<label class="screen-reader-text hidden" for="bbp_search"><?php 
_e('Search for:', 'bbpress');
?>
</label>
		<input type="hidden" name="action" value="bbp-search-request" />
		<div class="search-field">
			<input tabindex="<?php 
bbp_tab_index();
?>
" type="text" value="<?php 
echo esc_attr(bbp_get_search_terms());
?>
" placeholder="<?php 
_e('Search the Forum...', 'Avada');
?>
" name="bbp_search" id="bbp_search" />
		</div>
		<div class="search-button">
			<input tabindex="<?php 
bbp_tab_index();
?>
" class="fusion-button button submit" type="submit" id="bbp_search_submit" value="&#xf002;" />
		</div>
		<div class="clearfix"></div>
	</div>
</form>
开发者ID:universal-youth,项目名称:www.universal-youth.com,代码行数:31,代码来源:form-search.php

示例3: do_action

	<?php 
do_action('bbp_template_before_search');
?>

	<?php 
if (bbp_has_search_results()) {
    ?>

		 <?php 
    bbp_get_template_part('loop', 'search');
    ?>


	<?php 
} elseif (bbp_get_search_terms()) {
    ?>

		 <?php 
    bbp_get_template_part('feedback', 'no-search');
    ?>

	<?php 
} else {
    ?>

		<?php 
    bbp_get_template_part('form', 'search');
    ?>

	<?php 
开发者ID:CamionCiterne,项目名称:wordpress_fbpc,代码行数:30,代码来源:content-search.php

示例4: bbp_search_terms

/**
 * Output the search terms
 *
 * @since bbPress (r4579)
 *
 * @param string $search_terms Optional. Search terms
 * @uses bbp_get_search_terms() To get the search terms
 */
function bbp_search_terms($search_terms = '')
{
    echo bbp_get_search_terms($search_terms);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:12,代码来源:template.php

示例5: bbp_get_breadcrumb


//.........这里部分代码省略.........
        // Implode the results of the tag data
        $pre_current_text = sprintf(__('Topic Tag: %s', 'bbpress'), implode(' ', $tag_data));
        // Edit Topic Tag
    } elseif (bbp_is_topic_tag_edit()) {
        $pre_current_text = __('Edit', 'bbpress');
        // Single
    } else {
        $pre_current_text = get_the_title();
    }
    /** Parse Args ********************************************************/
    // Parse args
    $r = bbp_parse_args($args, array('before' => '<div class="bbp-breadcrumb"><p>', 'after' => '</p></div>', 'sep' => is_rtl() ? __('&lsaquo;', 'bbpress') : __('&rsaquo;', 'bbpress'), 'pad_sep' => 1, 'sep_before' => '<span class="bbp-breadcrumb-sep">', 'sep_after' => '</span>', 'crumb_before' => '', 'crumb_after' => '', 'include_home' => $pre_include_home, 'home_text' => $pre_front_text, 'include_root' => $pre_include_root, 'root_text' => $pre_root_text, 'include_current' => $pre_include_current, 'current_text' => $pre_current_text, 'current_before' => '<span class="bbp-breadcrumb-current">', 'current_after' => '</span>'), 'get_breadcrumb');
    /** Ancestors *********************************************************/
    // Get post ancestors
    if (is_singular() || bbp_is_forum_edit() || bbp_is_topic_edit() || bbp_is_reply_edit()) {
        $ancestors = array_reverse((array) get_post_ancestors(get_the_ID()));
    }
    // Do we want to include a link to home?
    if (!empty($r['include_home']) || empty($r['home_text'])) {
        $crumbs[] = '<a href="' . trailingslashit(home_url()) . '" class="bbp-breadcrumb-home">' . $r['home_text'] . '</a>';
    }
    // Do we want to include a link to the forum root?
    if (!empty($r['include_root']) || empty($r['root_text'])) {
        // Page exists at root slug path, so use its permalink
        $page = bbp_get_page_by_path(bbp_get_root_slug());
        if (!empty($page)) {
            $root_url = get_permalink($page->ID);
            // Use the root slug
        } else {
            $root_url = get_post_type_archive_link(bbp_get_forum_post_type());
        }
        // Add the breadcrumb
        $crumbs[] = '<a href="' . esc_url($root_url) . '" class="bbp-breadcrumb-root">' . $r['root_text'] . '</a>';
    }
    // Ancestors exist
    if (!empty($ancestors)) {
        // Loop through parents
        foreach ((array) $ancestors as $parent_id) {
            // Parents
            $parent = get_post($parent_id);
            // Skip parent if empty or error
            if (empty($parent) || is_wp_error($parent)) {
                continue;
            }
            // Switch through post_type to ensure correct filters are applied
            switch ($parent->post_type) {
                // Forum
                case bbp_get_forum_post_type():
                    $crumbs[] = '<a href="' . esc_url(bbp_get_forum_permalink($parent->ID)) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title($parent->ID) . '</a>';
                    break;
                    // Topic
                // Topic
                case bbp_get_topic_post_type():
                    $crumbs[] = '<a href="' . esc_url(bbp_get_topic_permalink($parent->ID)) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title($parent->ID) . '</a>';
                    break;
                    // Reply (Note: not in most themes)
                // Reply (Note: not in most themes)
                case bbp_get_reply_post_type():
                    $crumbs[] = '<a href="' . esc_url(bbp_get_reply_permalink($parent->ID)) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title($parent->ID) . '</a>';
                    break;
                    // WordPress Post/Page/Other
                // WordPress Post/Page/Other
                default:
                    $crumbs[] = '<a href="' . esc_url(get_permalink($parent->ID)) . '" class="bbp-breadcrumb-item">' . get_the_title($parent->ID) . '</a>';
                    break;
            }
        }
        // Edit topic tag
    } elseif (bbp_is_topic_tag_edit()) {
        $crumbs[] = '<a href="' . esc_url(get_term_link(bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id())) . '" class="bbp-breadcrumb-topic-tag">' . sprintf(__('Topic Tag: %s', 'bbpress'), bbp_get_topic_tag_name()) . '</a>';
        // Search
    } elseif (bbp_is_search() && bbp_get_search_terms()) {
        $crumbs[] = '<a href="' . esc_url(bbp_get_search_url()) . '" class="bbp-breadcrumb-search">' . esc_html__('Search', 'bbpress') . '</a>';
    }
    /** Current ***********************************************************/
    // Add current page to breadcrumb
    if (!empty($r['include_current']) || empty($r['current_text'])) {
        $crumbs[] = $r['current_before'] . $r['current_text'] . $r['current_after'];
    }
    /** Separator *********************************************************/
    // Wrap the separator in before/after before padding and filter
    if (!empty($r['sep'])) {
        $sep = $r['sep_before'] . $r['sep'] . $r['sep_after'];
    }
    // Pad the separator
    if (!empty($r['pad_sep'])) {
        if (function_exists('mb_strlen')) {
            $sep = str_pad($sep, mb_strlen($sep) + (int) $r['pad_sep'] * 2, ' ', STR_PAD_BOTH);
        } else {
            $sep = str_pad($sep, strlen($sep) + (int) $r['pad_sep'] * 2, ' ', STR_PAD_BOTH);
        }
    }
    /** Finish Up *********************************************************/
    // Filter the separator and breadcrumb
    $sep = apply_filters('bbp_breadcrumb_separator', $sep);
    $crumbs = apply_filters('bbp_breadcrumbs', $crumbs);
    // Build the trail
    $trail = !empty($crumbs) ? $r['before'] . $r['crumb_before'] . implode($sep . $r['crumb_after'] . $r['crumb_before'], $crumbs) . $r['crumb_after'] . $r['after'] : '';
    return apply_filters('bbp_get_breadcrumb', $trail, $crumbs, $r);
}
开发者ID:danielcoats,项目名称:schoolpress,代码行数:101,代码来源:template.php

示例6: add_search_page_search_form

    /**
     * Render a special "new search" form on top of the search results page.
     */
    public function add_search_page_search_form()
    {
        ?>
		<div class="search-page-search-form search-page-search-form-top">
			<h2><?php 
        echo __('Need a new search?', 'Avada');
        ?>
</h2>
			<p><?php 
        echo __('If you didn\'t find what you were looking for, try a new search!', 'Avada');
        ?>
</p>
			<form role="search" method="get" class="bbp-search-form seach-form searchform" action="<?php 
        bbp_search_url();
        ?>
">
				<div class="search-table">
					<label class="screen-reader-text hidden" for="bbp_search"><?php 
        _e('Search for:', 'bbpress');
        ?>
</label>
					<input type="hidden" name="action" value="bbp-search-request" />
					<div class="search-field">
						<input tabindex="<?php 
        bbp_tab_index();
        ?>
" type="text" value="<?php 
        echo esc_attr(bbp_get_search_terms());
        ?>
" placeholder="<?php 
        _e('Search the Forum...', 'Avada');
        ?>
" name="bbp_search" id="bbp_search" />
					</div>
					<div class="search-button">
						<input tabindex="<?php 
        bbp_tab_index();
        ?>
" class="fusion-button button submit" type="submit" id="bbp_search_submit" value="&#xf002;" />
					</div>
				</div>
			</form>
		</div>
		<?php 
    }
开发者ID:agiper,项目名称:wordpress,代码行数:48,代码来源:class-avada-layout-bbpress.php

示例7: bbp_parse_query


//.........这里部分代码省略.........
            // Editing a user
            $posts_query->bbp_is_edit = true;
            // User favorites
        } elseif (!empty($is_favs)) {
            $posts_query->bbp_is_single_user_favs = true;
            // User subscriptions
        } elseif (!empty($is_subs)) {
            $posts_query->bbp_is_single_user_subs = true;
            // User topics
        } elseif (!empty($is_topics)) {
            $posts_query->bbp_is_single_user_topics = true;
            // User topics
        } elseif (!empty($is_replies)) {
            $posts_query->bbp_is_single_user_replies = true;
            // User profile
        } else {
            $posts_query->bbp_is_single_user_profile = true;
        }
        // Looking at a single user
        $posts_query->bbp_is_single_user = true;
        // Make sure 404 is not set
        $posts_query->is_404 = false;
        // Correct is_home variable
        $posts_query->is_home = false;
        // User is looking at their own profile
        if (get_current_user_id() === $the_user->ID) {
            $posts_query->bbp_is_single_user_home = true;
        }
        // Set bbp_user_id for future reference
        $posts_query->set('bbp_user_id', $the_user->ID);
        // Set author_name as current user's nicename to get correct posts
        $posts_query->set('author_name', $the_user->user_nicename);
        // Set the displayed user global to this user
        bbpress()->displayed_user = $the_user;
        // View Page
    } elseif (!empty($bbp_view)) {
        // Check if the view exists by checking if there are query args are set
        $view_args = bbp_get_view_query_args($bbp_view);
        // Bail if view args is false (view isn't registered)
        if (false === $view_args) {
            $posts_query->set_404();
            return;
        }
        // Correct is_home variable
        $posts_query->is_home = false;
        // We are in a custom topic view
        $posts_query->bbp_is_view = true;
        // Search Page
    } elseif (isset($posts_query->query_vars[bbp_get_search_rewrite_id()])) {
        // Check if there are search query args set
        $search_terms = bbp_get_search_terms();
        if (!empty($search_terms)) {
            $posts_query->bbp_search_terms = $search_terms;
        }
        // Correct is_home variable
        $posts_query->is_home = false;
        // We are in a search query
        $posts_query->bbp_is_search = true;
        // Forum/Topic/Reply Edit Page
    } elseif (!empty($is_edit)) {
        // Get the post type from the main query loop
        $post_type = $posts_query->get('post_type');
        // Check which post_type we are editing, if any
        if (!empty($post_type)) {
            switch ($post_type) {
                // We are editing a forum
                case bbp_get_forum_post_type():
                    $posts_query->bbp_is_forum_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a topic
                // We are editing a topic
                case bbp_get_topic_post_type():
                    $posts_query->bbp_is_topic_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
                    // We are editing a reply
                // We are editing a reply
                case bbp_get_reply_post_type():
                    $posts_query->bbp_is_reply_edit = true;
                    $posts_query->bbp_is_edit = true;
                    break;
            }
            // We are editing a topic tag
        } elseif (bbp_is_topic_tag()) {
            $posts_query->bbp_is_topic_tag_edit = true;
            $posts_query->bbp_is_edit = true;
        }
        // We save post revisions on our own
        remove_action('pre_post_update', 'wp_save_post_revision');
        // Topic tag page
    } elseif (bbp_is_topic_tag()) {
        $posts_query->set('bbp_topic_tag', get_query_var('term'));
        $posts_query->set('post_type', bbp_get_topic_post_type());
        $posts_query->set('posts_per_page', bbp_get_topics_per_page());
        // Do topics on forums root
    } elseif (is_post_type_archive(array(bbp_get_forum_post_type(), bbp_get_topic_post_type())) && 'topics' === bbp_show_on_root()) {
        $posts_query->bbp_show_topics_on_root = true;
    }
}
开发者ID:donwea,项目名称:nhap.org,代码行数:101,代码来源:template-functions.php

示例8: myfossil_bbpress_highlight_search_results

function myfossil_bbpress_highlight_search_results()
{
    myfossil_highlight_search_results();
    // Get search terms
    $search_terms = bbp_get_search_terms();
    echo "<script>jQuery('#bbp-search-results').highlight('" . $search_terms . "');</script>";
}
开发者ID:par-orillonsoft,项目名称:myfossil-theme,代码行数:7,代码来源:plugins.php

示例9: display_search

 /**
  * Display the contents of search results in an output buffer and return to
  * ensure that post/page contents are displayed first.
  *
  * @since bbPress (r4579)
  *
  * @param array $attr
  * @param string $content
  * @uses bbp_search_query()
  * @uses get_template_part()
  */
 public function display_search($attr, $content = '')
 {
     // Sanity check required info
     if (!empty($content)) {
         return $content;
     }
     // Bail if search is disabled
     if (!bbp_allow_search()) {
         return;
     }
     // Trim search attribute if it's set
     if (isset($attr['search'])) {
         $attr['search'] = trim($attr['search']);
     }
     // Set passed attribute to $search_terms for clarity
     $search_terms = empty($attr['search']) ? bbp_get_search_terms() : $attr['search'];
     // Unset globals
     $this->unset_globals();
     // Set terms for query
     set_query_var(bbp_get_search_rewrite_id(), $search_terms);
     // Start output buffer
     $this->start(bbp_get_search_rewrite_id());
     // Output template
     bbp_get_template_part('content', 'search');
     // Return contents of output buffer
     return $this->end();
 }
开发者ID:danielcoats,项目名称:schoolpress,代码行数:38,代码来源:shortcodes.php

示例10: pg_has_search_results

function pg_has_search_results($args = '')
{
    global $wp_rewrite;
    //start with code as per bbp search !
    /** Defaults **************************************************************/
    $default_post_type = array(bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type());
    // Default query args
    $default = array('post_type' => $default_post_type, 'posts_per_page' => bbp_get_replies_per_page(), 'paged' => bbp_get_paged(), 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true, 's' => bbp_get_search_terms());
    // What are the default allowed statuses (based on user caps)
    if (bbp_get_view_all()) {
        // Default view=all statuses
        $post_statuses = array(bbp_get_public_status_id(), bbp_get_closed_status_id(), bbp_get_spam_status_id(), bbp_get_trash_status_id());
        // Add support for private status
        if (current_user_can('read_private_topics')) {
            $post_statuses[] = bbp_get_private_status_id();
        }
        // Join post statuses together
        $default['post_status'] = implode(',', $post_statuses);
        // Lean on the 'perm' query var value of 'readable' to provide statuses
    } else {
        $default['perm'] = 'readable';
    }
    //PG then loop to find allowable forums
    //Get an array of IDs which the current user has permissions to view
    $allowed_posts = private_groups_get_permitted_post_ids(new WP_Query($default));
    // The default forum query with allowed forum ids array added
    $default['post__in'] = $allowed_posts;
    if (empty($allowed_posts)) {
        $default['post__in'] = array(0);
    }
    //then return to bbp search code
    /** Setup *****************************************************************/
    // Parse arguments against default values
    $r = bbp_parse_args($args, $default, 'has_search_results');
    // Get bbPress
    $bbp = bbpress();
    // Call the query
    if (!empty($r['s'])) {
        $bbp->search_query = new WP_Query($r);
    }
    // Add pagination values to query object
    $bbp->search_query->posts_per_page = $r['posts_per_page'];
    $bbp->search_query->paged = $r['paged'];
    // Never home, regardless of what parse_query says
    $bbp->search_query->is_home = false;
    // Only add pagination is query returned results
    if (!empty($bbp->search_query->found_posts) && !empty($bbp->search_query->posts_per_page)) {
        // Array of arguments to add after pagination links
        $add_args = array();
        // If pretty permalinks are enabled, make our pagination pretty
        if ($wp_rewrite->using_permalinks()) {
            // Shortcode territory
            if (is_page() || is_single()) {
                $base = trailingslashit(get_permalink());
                // Default search location
            } else {
                $base = trailingslashit(bbp_get_search_results_url());
            }
            // Add pagination base
            $base = $base . user_trailingslashit($wp_rewrite->pagination_base . '/%#%/');
            // Unpretty permalinks
        } else {
            $base = add_query_arg('paged', '%#%');
        }
        // Add args
        if (bbp_get_view_all()) {
            $add_args['view'] = 'all';
        }
        // Add pagination to query object
        $bbp->search_query->pagination_links = paginate_links(apply_filters('bbp_search_results_pagination', array('base' => $base, 'format' => '', 'total' => ceil((int) $bbp->search_query->found_posts / (int) $r['posts_per_page']), 'current' => (int) $bbp->search_query->paged, 'prev_text' => is_rtl() ? '&rarr;' : '&larr;', 'next_text' => is_rtl() ? '&larr;' : '&rarr;', 'mid_size' => 1, 'add_args' => $add_args)));
        // Remove first page from pagination
        if ($wp_rewrite->using_permalinks()) {
            $bbp->search_query->pagination_links = str_replace($wp_rewrite->pagination_base . '/1/', '', $bbp->search_query->pagination_links);
        } else {
            $bbp->search_query->pagination_links = str_replace('&#038;paged=1', '', $bbp->search_query->pagination_links);
        }
    }
    //finally filter to return
    // Return object
    return apply_filters('pg_has_search_results', $bbp->search_query->have_posts(), $bbp->search_query);
}
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:81,代码来源:search.php


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