本文整理汇总了PHP中bp_core_get_site_path函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_core_get_site_path函数的具体用法?PHP bp_core_get_site_path怎么用?PHP bp_core_get_site_path使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_core_get_site_path函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_core_set_uri_globals
/**
* Analyze the URI and break it down into BuddyPress-usable chunks.
*
* BuddyPress can use complete custom friendly URIs without the user having to
* add new rewrite rules. Custom components are able to use their own custom
* URI structures with very little work.
*
* The URIs are broken down as follows:
* - http:// example.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
* - OUTSIDE ROOT: http:// example.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
*
* Example:
* - http://example.com/members/andy/profile/edit/group/5/
* - $bp->current_component: string 'xprofile'
* - $bp->current_action: string 'edit'
* - $bp->action_variables: array ['group', 5]
*
* @since 1.0.0
*/
function bp_core_set_uri_globals()
{
global $current_blog, $wp_rewrite;
// Don't catch URIs on non-root blogs unless multiblog mode is on.
if (!bp_is_root_blog() && !bp_is_multiblog_mode()) {
return false;
}
$bp = buddypress();
// Define local variables.
$root_profile = $match = false;
$key_slugs = $matches = $uri_chunks = array();
// Fetch all the WP page names for each component.
if (empty($bp->pages)) {
$bp->pages = bp_core_get_directory_pages();
}
// Ajax or not?
if (defined('DOING_AJAX') && DOING_AJAX || strpos($_SERVER['REQUEST_URI'], 'wp-load.php')) {
$path = bp_get_referer_path();
} else {
$path = esc_url($_SERVER['REQUEST_URI']);
}
/**
* Filters the BuddyPress global URI path.
*
* @since 1.0.0
*
* @param string $path Path to set.
*/
$path = apply_filters('bp_uri', $path);
// Take GET variables off the URL to avoid problems.
$path = strtok($path, '?');
// Fetch current URI and explode each part separated by '/' into an array.
$bp_uri = explode('/', $path);
// Loop and remove empties.
foreach ((array) $bp_uri as $key => $uri_chunk) {
if (empty($bp_uri[$key])) {
unset($bp_uri[$key]);
}
}
// If running off blog other than root, any subdirectory names must be
// removed from $bp_uri. This includes two cases:
//
// 1. when WP is installed in a subdirectory,
// 2. when BP is running on secondary blog of a subdirectory
// multisite installation. Phew!
if (is_multisite() && !is_subdomain_install() && (bp_is_multiblog_mode() || 1 != bp_get_root_blog_id())) {
// Blow chunks.
$chunks = explode('/', $current_blog->path);
// If chunks exist...
if (!empty($chunks)) {
// ...loop through them...
foreach ($chunks as $key => $chunk) {
$bkey = array_search($chunk, $bp_uri);
// ...and unset offending keys
if (false !== $bkey) {
unset($bp_uri[$bkey]);
}
$bp_uri = array_values($bp_uri);
}
}
}
// Get site path items.
$paths = explode('/', bp_core_get_site_path());
// Take empties off the end of path.
if (empty($paths[count($paths) - 1])) {
array_pop($paths);
}
// Take empties off the start of path.
if (empty($paths[0])) {
array_shift($paths);
}
// Reset indexes.
$bp_uri = array_values($bp_uri);
$paths = array_values($paths);
// Unset URI indices if they intersect with the paths.
foreach ((array) $bp_uri as $key => $uri_chunk) {
if (isset($paths[$key]) && $uri_chunk == $paths[$key]) {
unset($bp_uri[$key]);
}
}
// Reset the keys by merging with an empty array.
//.........这里部分代码省略.........
示例2: bp_is_component_front_page
/**
* Check if the specified BuddyPress component directory is set to be the front page.
*
* Corresponds to the setting in wp-admin's Settings > Reading screen.
*
* @since 1.5.0
*
* @global int $current_blog WordPress global for the current blog.
*
* @param string $component Optional. Name of the component to check for.
* Default: current component.
* @return bool True if the specified component is set to be the site's front
* page, otherwise false.
*/
function bp_is_component_front_page($component = '')
{
global $current_blog;
$bp = buddypress();
// Default to the current component if none is passed.
if (empty($component)) {
$component = bp_current_component();
}
// Get the path for the current blog/site.
$path = is_main_site() ? bp_core_get_site_path() : $current_blog->path;
// Get the front page variables.
$show_on_front = get_option('show_on_front');
$page_on_front = get_option('page_on_front');
if ('page' !== $show_on_front || empty($component) || empty($bp->pages->{$component}) || $_SERVER['REQUEST_URI'] !== $path) {
return false;
}
/**
* Filters whether or not the specified BuddyPress component directory is set to be the front page.
*
* @since 1.5.0
*
* @param bool $value Whether or not the specified component directory is set as front page.
* @param string $component Current component being checked.
*/
return (bool) apply_filters('bp_is_component_front_page', $bp->pages->{$component}->id == $page_on_front, $component);
}
示例3: bp_core_set_uri_globals
/**
* Analyzes the URI structure and breaks it down into parts for use in code.
* The idea is that BuddyPress can use complete custom friendly URI's without the
* user having to add new re-write rules.
*
* Future custom components would then be able to use their own custom URI structure.
*
* @package BuddyPress Core
* @since BuddyPress (r100)
*
* The URI's are broken down as follows:
* - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
* - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
*
* Example:
* - http://domain.com/members/andy/profile/edit/group/5/
* - $bp->current_component: string 'xprofile'
* - $bp->current_action: string 'edit'
* - $bp->action_variables: array ['group', 5]
*
*/
function bp_core_set_uri_globals()
{
global $bp, $bp_unfiltered_uri, $bp_unfiltered_uri_offset;
global $current_blog, $nxtdb;
// Create global component, action, and item variables
$bp->current_component = $bp->current_action = $bp->current_item = '';
$bp->action_variables = $bp->displayed_user->id = '';
// Don't catch URIs on non-root blogs unless multiblog mode is on
if (!bp_is_root_blog() && !bp_is_multiblog_mode()) {
return false;
}
// Fetch all the nxt page names for each component
if (empty($bp->pages)) {
$bp->pages = bp_core_get_directory_pages();
}
// Ajax or not?
if (strpos($_SERVER['REQUEST_URI'], 'nxt-load.php')) {
$path = bp_core_referrer();
} else {
$path = esc_url($_SERVER['REQUEST_URI']);
}
// Filter the path
$path = apply_filters('bp_uri', $path);
// Take GET variables off the URL to avoid problems,
// they are still registered in the global $_GET variable
if ($noget = substr($path, 0, strpos($path, '?'))) {
$path = $noget;
}
// Fetch the current URI and explode each part separated by '/' into an array
$bp_uri = explode('/', $path);
// Loop and remove empties
foreach ((array) $bp_uri as $key => $uri_chunk) {
if (empty($bp_uri[$key])) {
unset($bp_uri[$key]);
}
}
// Running off blog other than root
if (is_multisite() && !is_subdomain_install() && (bp_is_multiblog_mode() || 1 != bp_get_root_blog_id())) {
// Any subdirectory names must be removed from $bp_uri.
// This includes two cases: (1) when nxt is installed in a subdirectory,
// and (2) when BP is running on secondary blog of a subdirectory
// multisite installation. Phew!
if ($chunks = explode('/', $current_blog->path)) {
foreach ($chunks as $key => $chunk) {
$bkey = array_search($chunk, $bp_uri);
if ($bkey !== false) {
unset($bp_uri[$bkey]);
}
$bp_uri = array_values($bp_uri);
}
}
}
// Set the indexes, these are incresed by one if we are not on a VHOST install
$component_index = 0;
$action_index = $component_index + 1;
// Get site path items
$paths = explode('/', bp_core_get_site_path());
// Take empties off the end of path
if (empty($paths[count($paths) - 1])) {
array_pop($paths);
}
// Take empties off the start of path
if (empty($paths[0])) {
array_shift($paths);
}
// Unset URI indices if they intersect with the paths
foreach ((array) $bp_uri as $key => $uri_chunk) {
if (in_array($uri_chunk, $paths)) {
unset($bp_uri[$key]);
}
}
// Reset the keys by merging with an empty array
$bp_uri = array_merge(array(), $bp_uri);
// If a component is set to the front page, force its name into $bp_uri
// so that $current_component is populated (unless a specific nxt post is being requested
// via a URL parameter, usually signifying Preview mode)
if ('page' == get_option('show_on_front') && get_option('page_on_front') && empty($bp_uri) && empty($_GET['p']) && empty($_GET['page_id'])) {
$post = get_post(get_option('page_on_front'));
if (!empty($post)) {
//.........这里部分代码省略.........
示例4: bp_is_component_front_page
/**
* Checks if the site's front page is set to the specified BuddyPress component
* page in nxt-admin's Settings > Reading screen.
*
* @global object $bp Global BuddyPress settings object
* @global $current_blog NXTClass global for the current blog
* @param string $component Optional; Name of the component to check for.
* @return bool True If the specified component is set to be the site's front page.
* @since 1.5
*/
function bp_is_component_front_page($component = '')
{
global $bp, $current_blog;
if (!$component && !empty($bp->current_component)) {
$component = $bp->current_component;
}
$path = is_main_site() ? bp_core_get_site_path() : $current_blog->path;
if ('page' != get_option('show_on_front') || !$component || empty($bp->pages->{$component}) || $_SERVER['REQUEST_URI'] != $path) {
return false;
}
return apply_filters('bp_is_component_front_page', $bp->pages->{$component}->id == get_option('page_on_front'), $component);
}
示例5: bp_core_set_uri_globals
/**
* bp_core_set_uri_globals()
*
* Analyzes the URI structure and breaks it down into parts for use in code.
* The idea is that BuddyPress can use complete custom friendly URI's without the
* user having to add new re-write rules.
*
* Future custom components would then be able to use their own custom URI structure.
*
* The URI's are broken down as follows:
* - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
* - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
*
* Example:
* - http://domain.com/members/andy/profile/edit/group/5/
* - $current_component: string 'profile'
* - $current_action: string 'edit'
* - $action_variables: array ['group', 5]
*
* @package BuddyPress Core
*/
function bp_core_set_uri_globals()
{
global $current_component, $current_action, $action_variables;
global $displayed_user_id;
global $is_member_page, $is_new_friend;
global $bp_unfiltered_uri;
global $bp, $current_blog;
/* Only catch URI's on the root blog */
if (BP_ROOT_BLOG != (int) $current_blog->blog_id) {
return false;
}
if (strpos($_SERVER['REQUEST_URI'], 'bp-core-ajax-handler.php')) {
$path = bp_core_referrer();
} else {
$path = clean_url($_SERVER['REQUEST_URI']);
}
$path = apply_filters('bp_uri', $path);
// Firstly, take GET variables off the URL to avoid problems,
// they are still registered in the global $_GET variable */
$noget = substr($path, 0, strpos($path, '?'));
if ($noget != '') {
$path = $noget;
}
/* Fetch the current URI and explode each part seperated by '/' into an array */
$bp_uri = explode("/", $path);
/* Take empties off the end of complete URI */
if (empty($bp_uri[count($bp_uri) - 1])) {
array_pop($bp_uri);
}
/* Take empties off the start of complete URI */
if (empty($bp_uri[0])) {
array_shift($bp_uri);
}
/* Get total URI segment count */
$bp_uri_count = count($bp_uri) - 1;
$is_member_page = false;
/* Set the indexes, these are incresed by one if we are not on a VHOST install */
$component_index = 0;
$action_index = $component_index + 1;
// If this is a WordPress page, return from the function.
if (is_page($bp_uri[$component_index])) {
return false;
}
/* Get site path items */
$paths = explode('/', bp_core_get_site_path());
/* Take empties off the end of path */
if (empty($paths[count($paths) - 1])) {
array_pop($paths);
}
/* Take empties off the start of path */
if (empty($paths[0])) {
array_shift($paths);
}
for ($i = 0; $i < $bp_uri_count; $i++) {
if (in_array($bp_uri[$i], $paths)) {
unset($bp_uri[$i]);
}
}
/* Reset the keys by merging with an empty array */
$bp_uri = array_merge(array(), $bp_uri);
$bp_unfiltered_uri = $bp_uri;
/* Catch a member page and set the current member ID */
if ($bp_uri[0] == BP_MEMBERS_SLUG || in_array('bp-core-ajax-handler.php', $bp_uri)) {
$is_member_page = true;
$is_root_component = true;
// We are within a member page, set up user id globals
$displayed_user_id = bp_core_get_displayed_userid($bp_uri[1]);
unset($bp_uri[0]);
unset($bp_uri[1]);
// if the get variable 'new' is set this the first visit to a new friends profile.
// this means we need to delete friend acceptance notifications, so we set a flag of is_new_friend.
if (isset($_GET['new'])) {
$is_new_friend = 1;
unset($bp_uri[2]);
}
/* Reset the keys by merging with an empty array */
$bp_uri = array_merge(array(), $bp_uri);
}
if (!isset($is_root_component)) {
//.........这里部分代码省略.........
示例6: bp_is_component_front_page
/**
* Check if the specified BuddyPress component directory is set to be the front page.
*
* Corresponds to the setting in wp-admin's Settings > Reading screen.
*
* @since BuddyPress (1.5.0)
*
* @global $current_blog WordPress global for the current blog.
*
* @param string $component Optional. Name of the component to check for.
* Default: current component.
* @return bool True if the specified component is set to be the site's front
* page, otherwise false.
*/
function bp_is_component_front_page($component = '')
{
global $current_blog;
$bp = buddypress();
// Default to the current component if none is passed
if (empty($component)) {
$component = bp_current_component();
}
// Get the path for the current blog/site
$path = is_main_site() ? bp_core_get_site_path() : $current_blog->path;
// Get the front page variables
$show_on_front = get_option('show_on_front');
$page_on_front = get_option('page_on_front');
if ('page' !== $show_on_front || empty($component) || empty($bp->pages->{$component}) || $_SERVER['REQUEST_URI'] !== $path) {
return false;
}
return (bool) apply_filters('bp_is_component_front_page', $bp->pages->{$component}->id == $page_on_front, $component);
}
示例7: bp_core_set_uri_globals
/**
* bp_core_set_uri_globals()
*
* Analyzes the URI structure and breaks it down into parts for use in code.
* The idea is that BuddyPress can use complete custom friendly URI's without the
* user having to add new re-write rules.
*
* Future custom components would then be able to use their own custom URI structure.
*
* The URI's are broken down as follows:
* - http:// domain.com / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
* - OUTSIDE ROOT: http:// domain.com / sites / buddypress / members / andy / [current_component] / [current_action] / [action_variables] / [action_variables] / ...
*
* Example:
* - http://domain.com/members/andy/profile/edit/group/5/
* - $bp->current_component: string 'profile'
* - $bp->current_action: string 'edit'
* - $bp->action_variables: array ['group', 5]
*
* @package BuddyPress Core
*/
function bp_core_set_uri_globals()
{
global $current_component, $current_action, $action_variables;
global $displayed_user_id;
global $is_member_page;
global $bp_unfiltered_uri;
global $bp, $current_blog;
// Only catch URI's on the root blog if we are not running BP on multiple blogs
if (!defined('BP_ENABLE_MULTIBLOG') && bp_core_is_multisite()) {
if (BP_ROOT_BLOG != (int) $current_blog->blog_id) {
return false;
}
}
// Ajax or not?
if (strpos($_SERVER['REQUEST_URI'], 'wp-load.php')) {
$path = bp_core_referrer();
} else {
$path = esc_url($_SERVER['REQUEST_URI']);
}
$path = apply_filters('bp_uri', $path);
// Take GET variables off the URL to avoid problems,
// they are still registered in the global $_GET variable
$noget = substr($path, 0, strpos($path, '?'));
if ($noget != '') {
$path = $noget;
}
// Fetch the current URI and explode each part separated by '/' into an array
$bp_uri = explode('/', $path);
// Loop and remove empties
foreach ((array) $bp_uri as $key => $uri_chunk) {
if (empty($bp_uri[$key])) {
unset($bp_uri[$key]);
}
}
// Running off blog other than root
if (defined('BP_ENABLE_MULTIBLOG') || 1 != BP_ROOT_BLOG) {
// Any subdirectory names must be removed from $bp_uri.
// This includes two cases: (1) when WP is installed in a subdirectory,
// and (2) when BP is running on secondary blog of a subdirectory
// multisite installation. Phew!
if ($chunks = explode('/', $current_blog->path)) {
foreach ($chunks as $key => $chunk) {
$bkey = array_search($chunk, $bp_uri);
if ($bkey !== false) {
unset($bp_uri[$bkey]);
}
$bp_uri = array_values($bp_uri);
}
}
}
// Set the indexes, these are incresed by one if we are not on a VHOST install
$component_index = 0;
$action_index = $component_index + 1;
// If this is a WordPress page, return from the function.
if (is_page($bp_uri[$component_index])) {
return false;
}
// Get site path items
$paths = explode('/', bp_core_get_site_path());
// Take empties off the end of path
if (empty($paths[count($paths) - 1])) {
array_pop($paths);
}
// Take empties off the start of path
if (empty($paths[0])) {
array_shift($paths);
}
foreach ((array) $bp_uri as $key => $uri_chunk) {
if (in_array($uri_chunk, $paths)) {
unset($bp_uri[$key]);
}
}
// Reset the keys by merging with an empty array
$bp_uri = array_merge(array(), $bp_uri);
$bp_unfiltered_uri = $bp_uri;
// If we are under anything with a members slug, set the correct globals
if ($bp_uri[0] == BP_MEMBERS_SLUG) {
$is_member_page = true;
$is_root_component = true;
//.........这里部分代码省略.........
示例8: bp_is_activity_front_page
function bp_is_activity_front_page() {
global $current_blog;
if ( bp_core_is_main_site() )
$path = bp_core_get_site_path();
else
$path = $current_blog->path;
return ( 'page' == get_option('show_on_front') && 'activity' == get_option('page_on_front') && $_SERVER['REQUEST_URI'] == $path );
}