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


PHP bp_get_search_slug函数代码示例

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


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

示例1: bp_core_set_uri_globals


//.........这里部分代码省略.........
                    if (!empty($bp_uri[$key]) && $bp_uri[$key] == $uri_chunk) {
                        $matches[] = 1;
                        // No match.
                    } else {
                        $matches[] = 0;
                    }
                }
                // Have a match.
                if (!in_array(0, (array) $matches)) {
                    $match = $bp_page;
                    $match->key = $page_key;
                    break;
                }
                // Unset matches.
                unset($matches);
            }
            // Unset uri chunks.
            unset($uri_chunks);
        }
    }
    // URLs with BP_ENABLE_ROOT_PROFILES enabled won't be caught above.
    if (empty($matches) && bp_core_enable_root_profiles()) {
        // Switch field based on compat.
        $field = bp_is_username_compatibility_mode() ? 'login' : 'slug';
        // Make sure there's a user corresponding to $bp_uri[0].
        if (!empty($bp->pages->members) && !empty($bp_uri[0]) && ($root_profile = get_user_by($field, $bp_uri[0]))) {
            // Force BP to recognize that this is a members page.
            $matches[] = 1;
            $match = $bp->pages->members;
            $match->key = 'members';
        }
    }
    // Search doesn't have an associated page, so we check for it separately.
    if (!empty($bp_uri[0]) && bp_get_search_slug() == $bp_uri[0]) {
        $matches[] = 1;
        $match = new stdClass();
        $match->key = 'search';
        $match->slug = bp_get_search_slug();
    }
    // This is not a BuddyPress page, so just return.
    if (empty($matches)) {
        return false;
    }
    $wp_rewrite->use_verbose_page_rules = false;
    // Find the offset. With $root_profile set, we fudge the offset down so later parsing works.
    $slug = !empty($match) ? explode('/', $match->slug) : '';
    $uri_offset = empty($root_profile) ? 0 : -1;
    // Rejig the offset.
    if (!empty($slug) && 1 < count($slug)) {
        // Only offset if not on a root profile. Fixes issue when Members page is nested.
        if (false === $root_profile) {
            array_pop($slug);
            $uri_offset = count($slug);
        }
    }
    // Global the unfiltered offset to use in bp_core_load_template().
    // To avoid PHP warnings in bp_core_load_template(), it must always be >= 0.
    $bp->unfiltered_uri_offset = $uri_offset >= 0 ? $uri_offset : 0;
    // We have an exact match.
    if (isset($match->key)) {
        // Set current component to matched key.
        $bp->current_component = $match->key;
        // If members component, do more work to find the actual component.
        if ('members' == $match->key) {
            $after_member_slug = false;
            if (!empty($bp_uri[$uri_offset + 1])) {
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:67,代码来源:bp-core-catchuri.php

示例2: bp_core_action_search_site

/**
 * A javascript-free implementation of the search functions in BuddyPress.
 *
 * @param string $slug The slug to redirect to for searching.
 */
function bp_core_action_search_site($slug = '')
{
    if (!bp_is_current_component(bp_get_search_slug())) {
        return;
    }
    if (empty($_POST['search-terms'])) {
        bp_core_redirect(bp_get_root_domain());
        return;
    }
    $search_terms = stripslashes($_POST['search-terms']);
    $search_which = !empty($_POST['search-which']) ? $_POST['search-which'] : '';
    $query_string = '/?s=';
    if (empty($slug)) {
        switch ($search_which) {
            case 'posts':
                $slug = '';
                $var = '/?s=';
                // If posts aren't displayed on the front page, find the post page's slug.
                if ('page' == get_option('show_on_front')) {
                    $page = get_post(get_option('page_for_posts'));
                    if (!is_wp_error($page) && !empty($page->post_name)) {
                        $slug = $page->post_name;
                        $var = '?s=';
                    }
                }
                break;
            case 'blogs':
                $slug = bp_is_active('blogs') ? bp_get_blogs_root_slug() : '';
                break;
            case 'forums':
                $slug = bp_is_active('forums') ? bp_get_forums_root_slug() : '';
                $query_string = '/?fs=';
                break;
            case 'groups':
                $slug = bp_is_active('groups') ? bp_get_groups_root_slug() : '';
                break;
            case 'members':
            default:
                $slug = bp_get_members_root_slug();
                break;
        }
        if (empty($slug) && 'posts' != $search_which) {
            bp_core_redirect(bp_get_root_domain());
            return;
        }
    }
    bp_core_redirect(apply_filters('bp_core_search_site', home_url($slug . $query_string . urlencode($search_terms)), $search_terms));
}
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:53,代码来源:bp-core-functions.php

示例3: bp_core_set_uri_globals


//.........这里部分代码省略.........
                        $matches[] = 1;
                        // No match
                    } else {
                        $matches[] = 0;
                    }
                }
                // Have a match
                if (!in_array(0, (array) $matches)) {
                    $match = $bp_page;
                    $match->key = $page_key;
                    break;
                }
                // Unset matches
                unset($matches);
            }
            // Unset uri chunks
            unset($uri_chunks);
        }
    }
    // URLs with BP_ENABLE_ROOT_PROFILES enabled won't be caught above
    if (empty($matches) && defined('BP_ENABLE_ROOT_PROFILES') && BP_ENABLE_ROOT_PROFILES) {
        // Make sure there's a user corresponding to $bp_uri[0]
        if (!empty($bp->pages->members) && !empty($bp_uri[0]) && ($root_profile = get_user_by('login', $bp_uri[0]))) {
            // Force BP to recognize that this is a members page
            $matches[] = 1;
            $match = $bp->pages->members;
            $match->key = 'members';
            // Without the 'members' URL chunk, NXTClass won't know which page to load
            // This filter intercepts the nxt query and tells it to load the members page
            add_filter('request', create_function('$query_args', '$query_args["pagename"] = "' . $match->name . '"; return $query_args;'));
        }
    }
    // Search doesn't have an associated page, so we check for it separately
    if (!empty($bp_uri[0]) && bp_get_search_slug() == $bp_uri[0]) {
        $matches[] = 1;
        $match = new stdClass();
        $match->key = 'search';
        $match->slug = bp_get_search_slug();
    }
    // This is not a BuddyPress page, so just return.
    if (!isset($matches)) {
        return false;
    }
    // Find the offset. With $root_profile set, we fudge the offset down so later parsing works
    $slug = !empty($match) ? explode('/', $match->slug) : '';
    $uri_offset = empty($root_profile) ? 0 : -1;
    // Rejig the offset
    if (!empty($slug) && 1 < count($slug)) {
        array_pop($slug);
        $uri_offset = count($slug);
    }
    // Global the unfiltered offset to use in bp_core_load_template().
    // To avoid PHP warnings in bp_core_load_template(), it must always be >= 0
    $bp_unfiltered_uri_offset = $uri_offset >= 0 ? $uri_offset : 0;
    // We have an exact match
    if (isset($match->key)) {
        // Set current component to matched key
        $bp->current_component = $match->key;
        // If members component, do more work to find the actual component
        if ('members' == $match->key) {
            // Viewing a specific user
            if (!empty($bp_uri[$uri_offset + 1])) {
                // Switch the displayed_user based on compatbility mode
                if (bp_is_username_compatibility_mode()) {
                    $bp->displayed_user->id = (int) bp_core_get_userid(urldecode($bp_uri[$uri_offset + 1]));
                } else {
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:67,代码来源:bp-core-catchuri.php

示例4: bp_search_slug

/**
 * Output the search slug.
 *
 * @since 1.5.0
 *
 */
function bp_search_slug()
{
    echo bp_get_search_slug();
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:10,代码来源:bp-core-template.php

示例5: bp_core_action_search_site

/**
 * A javascript free implementation of the search functions in BuddyPress
 *
 * @package BuddyPress Core
 * @global object $bp Global BuddyPress settings object
 * @param string $slug The slug to redirect to for searching.
 */
function bp_core_action_search_site($slug = '')
{
    global $bp;
    if (!bp_is_current_component(bp_get_search_slug())) {
        return;
    }
    if (empty($_POST['search-terms'])) {
        bp_core_redirect(bp_get_root_domain());
        return;
    }
    $search_terms = stripslashes($_POST['search-terms']);
    $search_which = !empty($_POST['search-which']) ? $_POST['search-which'] : '';
    $query_string = '/?s=';
    if (empty($slug)) {
        switch ($search_which) {
            case 'posts':
                $slug = '';
                $var = '/?s=';
                break;
            case 'blogs':
                $slug = bp_is_active('blogs') ? bp_get_blogs_root_slug() : '';
                break;
            case 'forums':
                $slug = bp_is_active('forums') ? bp_get_forums_root_slug() : '';
                $query_string = '/?fs=';
                break;
            case 'groups':
                $slug = bp_is_active('groups') ? bp_get_groups_root_slug() : '';
                break;
            case 'members':
            default:
                $slug = bp_get_members_root_slug();
                break;
        }
        if (empty($slug) && 'posts' != $search_which) {
            bp_core_redirect(bp_get_root_domain());
            return;
        }
    }
    bp_core_redirect(apply_filters('bp_core_search_site', home_url($slug . $query_string . urlencode($search_terms)), $search_terms));
}
开发者ID:hornetalcala,项目名称:trunk,代码行数:48,代码来源:bp-core-functions.php

示例6: getPrimaryComponentName

 /**
  * Checks if a slug matches an active "primary" BuddyPress component. Primary components
  * are components which can exist as a top-level page on the site, and in some cases
  * a secondary page nested below the "members" component. Third-party components following
  * the "BuddyPress Example Component" pattern will appear in the results.
  *
  * @version 1.0
  * @since 1.0
  * @param string $slug | Name of slug to check
  * @return string $result | Exception on failure. Null on nonexistent. Name of component on success.
  */
 public function getPrimaryComponentName($slug)
 {
     if (empty($slug)) {
         throw new FOX_exception(array('numeric' => 1, 'text' => "Called with empty slug", 'file' => __FILE__, 'line' => __LINE__, 'method' => __METHOD__, 'child' => null));
     }
     // If the BP Pages object hasn't been loaded yet, try to load it
     if (empty($this->bp->pages)) {
         try {
             $this->bp->pages = self::buildDirectoryPages($this->flat_pages);
         } catch (FOX_exception $child) {
             throw new FOX_exception(array('numeric' => 2, 'text' => "Failed to load BP pages object", 'data' => array("bp_pages" => $this->bp->pages), 'file' => __FILE__, 'line' => __LINE__, 'method' => __METHOD__, 'child' => $child));
         }
     }
     foreach ($this->bp->pages as $component_name => $data) {
         // NOTE: We cannot use an algorithm that checks against $this->bp->active_components,
         // because its impossible for 3rd-party components to add themselves to this array
         // using the 'bp_active_components' filter. The filter is placed so early in the call
         // stack it runs before 3rd-party components can load any of their plugin files.
         if (!array_key_exists($component_name, $this->bp->deactivated_components) && $data->name == $slug) {
             return $component_name;
         }
     }
     unset($component_name, $data);
     // Separate check for search component (because its not a real BP component,
     // and its not included in the $bp->active_components array)
     if ($slug == bp_get_search_slug()) {
         return "search";
     }
     return null;
 }
开发者ID:alexborisov,项目名称:foxfire,代码行数:41,代码来源:class.router.php

示例7: thatcamp_action_search_site

function thatcamp_action_search_site()
{
    if (!bp_is_current_component(bp_get_search_slug())) {
        return;
    }
    if (empty($_POST['search-terms'])) {
        $redirect = wp_get_referer() ? wp_get_referer() : bp_get_root_domain();
        bp_core_redirect($redirect);
        return;
    }
    $search_terms = stripslashes($_POST['search-terms']);
    $search_which = !empty($_POST['search-which']) ? $_POST['search-which'] : '';
    $query_string = '/?s=';
    $slug = '';
    $var = '/?s=';
    // If posts aren't displayed on the front page, find the post page's slug.
    /*if ( 'page' == get_option( 'show_on_front' ) ) {
    		$page = get_post( get_option( 'page_for_posts' ) );
    
    		if ( !is_wp_error( $page ) && !empty( $page->post_name ) ) {
    			$slug = $page->post_name;
    			$var  = '?s=';
    		}
    	}*/
    $redirect = home_url($slug . $query_string . urlencode($search_terms));
    bp_core_redirect($redirect);
}
开发者ID:kosir,项目名称:thatcamp-org,代码行数:27,代码来源:functions.php


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