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


PHP bp_core_enable_root_profiles函数代码示例

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


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

示例1: validate_url_to_item_id

 /**
  * Validates the URL to determine if the activity item is valid.
  *
  * @since 2.6.0
  *
  * @param  string   $url The URL to check.
  * @return int|bool Activity ID on success; boolean false on failure.
  */
 protected function validate_url_to_item_id($url)
 {
     if (bp_core_enable_root_profiles()) {
         $domain = bp_get_root_domain();
     } else {
         $domain = bp_get_members_directory_permalink();
     }
     // Check the URL to see if this is a single activity URL.
     if (0 !== strpos($url, $domain)) {
         return false;
     }
     // Check for activity slug.
     if (false === strpos($url, '/' . bp_get_activity_slug() . '/')) {
         return false;
     }
     // Do more checks.
     $url = trim(untrailingslashit($url));
     // Grab the activity ID.
     $activity_id = (int) substr($url, strrpos($url, '/') + 1);
     if (!empty($activity_id)) {
         // Check if activity item still exists.
         $activity = new BP_Activity_Activity($activity_id);
         // Okay, we're good to go!
         if (!empty($activity->component) && 0 === (int) $activity->is_spam) {
             return $activity_id;
         }
     }
     return false;
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:37,代码来源:class-bp-activity-oembed-extension.php

示例2: bp_members_signup_with_subdirectory_blog

/**
 * Make sure the username is not the blog slug in case of root profile & subdirectory blog
 *
 * If BP_ENABLE_ROOT_PROFILES is defined & multisite config is set to subdirectories,
 * then there is a chance site.url/username == site.url/blogslug. If so, user's profile
 * is not reachable, instead the blog is displayed. This filter makes sure the signup username
 * is not the same than the blog slug for this particular config.
 *
 * @since  BuddyPress (2.1.0)
 * @param  array $illegal_names
 * @return array $illegal_names
 */
function bp_members_signup_with_subdirectory_blog($illegal_names = array())
{
    if (!bp_core_enable_root_profiles()) {
        return $illegal_names;
    }
    if (is_network_admin() && isset($_POST['blog'])) {
        $blog = $_POST['blog'];
        $domain = '';
        if (preg_match('|^([a-zA-Z0-9-])$|', $blog['domain'])) {
            $domain = strtolower($blog['domain']);
        }
        if (username_exists($domain)) {
            $illegal_names[] = $domain;
        }
    } else {
        $illegal_names[] = buddypress()->signup->username;
    }
    return $illegal_names;
}
开发者ID:eresyyl,项目名称:mk,代码行数:31,代码来源:bp-members-filters.php

示例3: bp_core_get_user_domain

/**
 * Return the domain for the passed user: e.g. http://example.com/members/andy/.
 *
 * @since 1.0.0
 *
 * @param int         $user_id       The ID of the user.
 * @param string|bool $user_nicename Optional. user_nicename of the user.
 * @param string|bool $user_login    Optional. user_login of the user.
 * @return string
 */
function bp_core_get_user_domain($user_id = 0, $user_nicename = false, $user_login = false)
{
    if (empty($user_id)) {
        return;
    }
    $username = bp_core_get_username($user_id, $user_nicename, $user_login);
    if (bp_is_username_compatibility_mode()) {
        $username = rawurlencode($username);
    }
    $after_domain = bp_core_enable_root_profiles() ? $username : bp_get_members_root_slug() . '/' . $username;
    $domain = trailingslashit(bp_get_root_domain() . '/' . $after_domain);
    // Don't use this filter.  Subject to removal in a future release.
    // Use the 'bp_core_get_user_domain' filter instead.
    $domain = apply_filters('bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login);
    /**
     * Filters the domain for the passed user.
     *
     * @since 1.0.1
     *
     * @param string $domain        Domain for the passed user.
     * @param int    $user_id       ID of the passed user.
     * @param string $user_nicename User nicename of the passed user.
     * @param string $user_login    User login of the passed user.
     */
    return apply_filters('bp_core_get_user_domain', $domain, $user_id, $user_nicename, $user_login);
}
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:36,代码来源:bp-members-functions.php

示例4: bp_core_set_uri_globals


//.........这里部分代码省略.........
    }
    // No exact match, so look for partials.
    if (empty($match)) {
        // Loop through each page in the $bp->pages global.
        foreach ((array) $bp->pages as $page_key => $bp_page) {
            // Look for a match (check members first).
            if (in_array($bp_page->name, (array) $bp_uri)) {
                // Match found, now match the slug to make sure.
                $uri_chunks = explode('/', $bp_page->slug);
                // Loop through uri_chunks.
                foreach ((array) $uri_chunks as $key => $uri_chunk) {
                    // Make sure chunk is in the correct position.
                    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);
        }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:67,代码来源:bp-core-catchuri.php

示例5: ass_digest_get_user_domain

/**
 * Get user domain.
 *
 * Do not use this outside of digests!
 *
 * This is almost a duplicate of bp_core_get_user_domain(), but references
 * our already-fetched mass-userdata array to avoid pinging the DB over and
 * over again in a foreach loop.
 */
function ass_digest_get_user_domain($user_id)
{
    global $bp;
    if (empty($bp->ass->massdata)) {
        return false;
    }
    $mass_userdata = $bp->ass->massdata;
    $username = bp_is_username_compatibility_mode() ? $mass_userdata[$user_id]['user_login'] : $mass_userdata[$user_id]['user_nicename'];
    if (bp_core_enable_root_profiles()) {
        $after_domain = $username;
    } else {
        $after_domain = bp_get_members_root_slug() . '/';
        $after_domain .= bp_is_username_compatibility_mode() ? rawurlencode($username) : $username;
    }
    $domain = trailingslashit(bp_get_root_domain() . '/' . $after_domain);
    $domain = apply_filters('bp_core_get_user_domain_pre_cache', $domain, $user_id, $mass_userdata[$user_id]['user_nicename'], $mass_userdata[$user_id]['user_login']);
    return apply_filters('bp_core_get_user_domain', $domain, $user_id, $mass_userdata[$user_id]['user_nicename'], $mass_userdata[$user_id]['user_login']);
}
开发者ID:pausaura,项目名称:agora_nodes,代码行数:27,代码来源:bp-activity-subscription-digest.php

示例6: bp_core_get_user_domain

/**
 * Returns the domain for the passed user: e.g. http://domain.com/members/andy/
 *
 * @package BuddyPress Core
 * @global $current_user WordPress global variable containing current logged in user information
 * @param user_id The ID of the user.
 */
function bp_core_get_user_domain($user_id, $user_nicename = false, $user_login = false)
{
    if (empty($user_id)) {
        return;
    }
    if (!($domain = wp_cache_get('bp_user_domain_' . $user_id, 'bp'))) {
        $username = bp_core_get_username($user_id, $user_nicename, $user_login);
        if (bp_is_username_compatibility_mode()) {
            $username = rawurlencode($username);
        }
        $after_domain = bp_core_enable_root_profiles() ? $username : bp_get_members_root_slug() . '/' . $username;
        $domain = trailingslashit(bp_get_root_domain() . '/' . $after_domain);
        $domain = apply_filters('bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login);
        // Cache the link
        if (!empty($domain)) {
            wp_cache_set('bp_user_domain_' . $user_id, $domain, 'bp');
        }
    }
    return apply_filters('bp_core_get_user_domain', $domain, $user_id, $user_nicename, $user_login);
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:27,代码来源:bp-members-functions.php

示例7: bp_core_get_user_domain

/**
 * Return the domain for the passed user: e.g. http://domain.com/members/andy/.
 *
 * @param int $user_id The ID of the user.
 * @param string $user_nicename Optional. user_nicename of the user.
 * @param string $user_login Optional. user_login of the user.
 */
function bp_core_get_user_domain($user_id = 0, $user_nicename = false, $user_login = false)
{
    if (empty($user_id)) {
        return;
    }
    $username = bp_core_get_username($user_id, $user_nicename, $user_login);
    if (bp_is_username_compatibility_mode()) {
        $username = rawurlencode($username);
    }
    $after_domain = bp_core_enable_root_profiles() ? $username : bp_get_members_root_slug() . '/' . $username;
    $domain = trailingslashit(bp_get_root_domain() . '/' . $after_domain);
    // Don't use this filter.  Subject to removal in a future release.
    // Use the 'bp_core_get_user_domain' filter instead.
    $domain = apply_filters('bp_core_get_user_domain_pre_cache', $domain, $user_id, $user_nicename, $user_login);
    return apply_filters('bp_core_get_user_domain', $domain, $user_id, $user_nicename, $user_login);
}
开发者ID:eresyyl,项目名称:mk,代码行数:23,代码来源:bp-members-functions.php

示例8: bp_core_set_uri_globals


//.........这里部分代码省略.........
    }
    // No exact match, so look for partials
    if (empty($match)) {
        // Loop through each page in the $bp->pages global
        foreach ((array) $bp->pages as $page_key => $bp_page) {
            // Look for a match (check members first)
            if (in_array($bp_page->name, (array) $bp_uri)) {
                // Match found, now match the slug to make sure.
                $uri_chunks = explode('/', $bp_page->slug);
                // Loop through uri_chunks
                foreach ((array) $uri_chunks as $key => $uri_chunk) {
                    // Make sure chunk is in the correct position
                    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()) {
        // 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, WordPress won't know which page to load
            // This filter intercepts the WP 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
开发者ID:newington,项目名称:buddypress,代码行数:67,代码来源:bp-core-catchuri.php

示例9: geodir_buddypress_login_redirect

/**
 * Filter the login redirect URL.
 *
 * @since 1.0.2
 * @package GeoDirectory_BuddyPress_Integration
 *
 * @global object $bp BuddyPress object.
 *
 * @param string $redirect_to The redirect destination URL.
 * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter.
 * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise.
 * @return string The redirect URL.
 */
function geodir_buddypress_login_redirect($redirect_to, $requested_redirect_to, $user)
{
    // Only modify the redirect if we're on the main BP blog
    if (!bp_is_root_blog()) {
        return $redirect_to;
    }
    // Only modify the redirect once the user is logged in
    if (!is_a($user, 'WP_User')) {
        return $redirect_to;
    }
    // If a 'redirect_to' parameter has been passed that contains 'wp-admin'
    if (!empty($redirect_to) && false !== strpos($redirect_to, 'wp-admin') && user_can($user, 'edit_posts')) {
        return $redirect_to;
    }
    $login_redirect = (int) get_option('gdbuddypress_login_redirect');
    switch ($login_redirect) {
        case 1:
            // Home page
            $redirect_to = trailingslashit(home_url());
            break;
        case 2:
            // Profile page
            $members_slug = bp_get_members_root_slug();
            if ($members_slug) {
                $redirect_to = trailingslashit(bp_core_get_user_domain($user->ID));
            } else {
                $username = bp_core_get_username($user->ID, $user->data->user_nicename, $user->data->user_login);
                if (bp_core_enable_root_profiles()) {
                    $redirect_to = trailingslashit(bp_get_root_domain() . '/' . $username);
                } else {
                    $bp_pages = bp_core_get_directory_pages();
                    if (isset($bp_pages->members->slug)) {
                        $members_slug = $bp_pages->members->slug;
                    } else {
                        global $bp;
                        $members_slug = defined('BP_MEMBERS_SLUG') ? BP_MEMBERS_SLUG : $bp->members->id;
                    }
                    $redirect_to = trailingslashit(bp_get_root_domain() . '/' . $members_slug . '/' . $username);
                }
            }
            break;
        case 3:
            // Menu page
            $menu_redirect = (int) get_option('gdbuddypress_menu_redirect');
            if ($menu_redirect > 0) {
                $redirect_to = get_permalink($menu_redirect);
            }
            break;
    }
    return $redirect_to;
}
开发者ID:poweronio,项目名称:mbsite,代码行数:64,代码来源:gdbuddypress_functions.php


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