• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP bp_core_get_directory_pages函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: infinity_register_bp_menu

/**
 * Register and create a custom BuddyPress menu
 */
function infinity_register_bp_menu($menu_name)
{
    global $blog_id;
    // check BP reqs and if our custom default menu already exists
    if (function_exists('bp_core_get_directory_pages') && BP_ROOT_BLOG == $blog_id && !is_nav_menu($menu_name)) {
        // doesn't exist, create it
        $menu_id = wp_create_nav_menu($menu_name);
        // get bp pages
        $pages = bp_core_get_directory_pages();
        // allowed pages
        $pages_ok = array('activity' => true, 'blogs' => true, 'forums' => true, 'groups' => true, 'links' => true, 'members' => true);
        // loop all pages
        foreach ($pages as $config) {
            // make sure we support this page
            if (array_key_exists($config->name, $pages_ok)) {
                // yep, add page as a nav item
                wp_update_nav_menu_item($menu_id, 0, array('menu-item-type' => 'post_type', 'menu-item-status' => 'publish', 'menu-item-object' => 'page', 'menu-item-object-id' => $config->id, 'menu-item-title' => $config->title, 'menu-item-attr-title' => $config->title, 'menu-item-classes' => 'icon-' . $config->name));
            }
        }
        // get location settings
        $locations = get_theme_mod('nav_menu_locations');
        // is main menu location set yet?
        if (empty($locations['main-menu'])) {
            // nope, set it
            $locations['main-menu'] = $menu_id;
            // update theme mode
            set_theme_mod('nav_menu_locations', $locations);
        }
    }
}
开发者ID:shads196770,项目名称:cbox-theme,代码行数:33,代码来源:menus.php


示例2: cbox_theme_register_default_menu

/**
 * Register and create a default menu in CBOX.
 *
 * @param array $args Arguments to register the default menu:
 *  'menu_name' - The internal menu name we should give our new menu.
 *  'location' - The nav menu location we want our new menu to reside.
 *  'pages' - Associative array of pages. Sample looks like this:
 *       array(
 *            array(
 *                 'title'    => 'Home',
 *                 'position' => 0,
 *                 'url'      => home_url( '/' ) // custom url
 *            ),
 *            array(
 *                 'title'        => 'Members',
 *                 'position'     => 10,
 *                 'bp_directory' => 'members'   // match bp component
 *            ),
 *       )
 */
function cbox_theme_register_default_menu($args = array())
{
    global $blog_id;
    if (empty($args['menu_name']) || empty($args['location']) || empty($args['pages'])) {
        return false;
    }
    if (!is_array($args['pages'])) {
        return false;
    }
    // check BP reqs and if our custom default menu already exists
    if (function_exists('bp_core_get_directory_pages') && BP_ROOT_BLOG == $blog_id && !is_nav_menu($args['menu_name'])) {
        // menu doesn't exist, so create it
        $menu_id = wp_create_nav_menu($args['menu_name']);
        // get bp pages
        $bp_pages = bp_core_get_directory_pages();
        // now, add the pages to our menu
        foreach ($args['pages'] as $page) {
            // default args
            $params = array('menu-item-status' => 'publish', 'menu-item-title' => $page['title'], 'menu-item-classes' => 'icon-' . !empty($page['bp_directory']) ? $page['bp_directory'] : sanitize_title($page['title']), 'menu-item-position' => $page['position']);
            // support custom menu type
            if (!empty($page['type'])) {
                $params['menu-item-type'] = $page['type'];
            }
            // support custom url
            if (!empty($page['url'])) {
                $params['menu-item-url'] = $page['url'];
            }
            // add additional args for bp directories
            if (!empty($page['bp_directory'])) {
                // bp directory page doesn't exist, so stop!
                if (!array_key_exists($page['bp_directory'], get_object_vars($bp_pages))) {
                    continue;
                }
                // yep, add page as a nav item
                $params['menu-item-type'] = 'post_type';
                $params['menu-item-object'] = 'page';
                $params['menu-item-object-id'] = $bp_pages->{$page['bp_directory']}->id;
            }
            wp_update_nav_menu_item($menu_id, 0, $params);
            $params = array();
        }
        // get location settings
        $locations = get_theme_mod('nav_menu_locations');
        // is our menu location set yet?
        if (empty($locations[$args['location']])) {
            // nope, set it
            $locations[$args['location']] = $menu_id;
            // update theme mode
            set_theme_mod('nav_menu_locations', $locations);
        }
        return true;
    }
}
开发者ID:shads196770,项目名称:cbox-theme,代码行数:73,代码来源:bp-menus.php


示例3: test_bp_core_get_user_domain_after_directory_page_update

 /**
  * @group object_cache
  * @group bp_core_get_directory_pages
  */
 public function test_bp_core_get_user_domain_after_directory_page_update()
 {
     // Generate user
     $user_id = $this->factory->user->create(array('role' => 'subscriber'));
     // Set object cache first for user domain
     $user_domain = bp_core_get_user_domain($user_id);
     // Now change the members directory slug
     $pages = bp_core_get_directory_pages();
     $members_page = get_post($pages->members->id);
     $members_page->post_name = 'new-members-slug';
     wp_update_post($members_page);
     // Go back to members directory page and recheck user domain
     $this->go_to(trailingslashit(home_url('new-members-slug')));
     $user = new WP_User($user_id);
     $this->assertSame(home_url('new-members-slug') . '/' . $user->user_nicename . '/', bp_core_get_user_domain($user_id));
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:20,代码来源:functions.php


示例4: setup_globals

 /**
  * Set up bp-core global settings.
  *
  * Sets up a majority of the BuddyPress globals that require a minimal
  * amount of processing, meaning they cannot be set in the BuddyPress class.
  *
  * @since BuddyPress (1.5.0)
  *
  * @see BP_Component::setup_globals() for description of parameters.
  *
  * @param array $args See {@link BP_Component::setup_globals()}.
  */
 public function setup_globals($args = array())
 {
     $bp = buddypress();
     /** Database **********************************************************/
     // Get the base database prefix
     if (empty($bp->table_prefix)) {
         $bp->table_prefix = bp_core_get_table_prefix();
     }
     // The domain for the root of the site where the main blog resides
     if (empty($bp->root_domain)) {
         $bp->root_domain = bp_core_get_root_domain();
     }
     // Fetches all of the core BuddyPress settings in one fell swoop
     if (empty($bp->site_options)) {
         $bp->site_options = bp_core_get_root_options();
     }
     // The names of the core WordPress pages used to display BuddyPress content
     if (empty($bp->pages)) {
         $bp->pages = bp_core_get_directory_pages();
     }
     /** Basic current user data *******************************************/
     // Logged in user is the 'current_user'
     $current_user = wp_get_current_user();
     // The user ID of the user who is currently logged in.
     $bp->loggedin_user = new stdClass();
     $bp->loggedin_user->id = isset($current_user->ID) ? $current_user->ID : 0;
     /** Avatars ***********************************************************/
     // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
     $bp->grav_default = new stdClass();
     $bp->grav_default->user = apply_filters('bp_user_gravatar_default', $bp->site_options['avatar_default']);
     $bp->grav_default->group = apply_filters('bp_group_gravatar_default', $bp->grav_default->user);
     $bp->grav_default->blog = apply_filters('bp_blog_gravatar_default', $bp->grav_default->user);
     // Notifications table. Included here for legacy purposes. Use
     // bp-notifications instead.
     $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
     /**
      * Used to determine if user has admin rights on current content. If the
      * logged in user is viewing their own profile and wants to delete
      * something, is_item_admin is used. This is a generic variable so it
      * can be used by other components. It can also be modified, so when
      * viewing a group 'is_item_admin' would be 'true' if they are a group
      * admin, and 'false' if they are not.
      */
     bp_update_is_item_admin(bp_user_has_access(), 'core');
     // Is the logged in user is a mod for the current item?
     bp_update_is_item_mod(false, 'core');
     do_action('bp_core_setup_globals');
 }
开发者ID:danielcoats,项目名称:schoolpress,代码行数:60,代码来源:bp-core-loader.php


示例5: test_bp_core_activation_notice_register_activate_pages_created_signup_allowed

 /**
  * @group bp_core_activation_notice
  */
 public function test_bp_core_activation_notice_register_activate_pages_created_signup_allowed()
 {
     $bp = buddypress();
     $reset_bp_pages = $bp->pages;
     $reset_admin_notices = $bp->admin->notices;
     add_filter('bp_get_signup_allowed', '__return_true', 999);
     $ac = buddypress()->active_components;
     bp_core_add_page_mappings(array_keys($ac));
     // Reset pages
     $bp->pages = bp_core_get_directory_pages();
     bp_core_activation_notice();
     remove_filter('bp_get_signup_allowed', '__return_true', 999);
     $missing_pages = array();
     foreach (buddypress()->admin->notices as $notice) {
         preg_match_all('/<strong>(.+?)<\\/strong>/', $notice['message'], $missing_pages);
     }
     $this->assertNotContains('Register', $missing_pages[1]);
     $this->assertNotContains('Activate', $missing_pages[1]);
     // Reset buddypress() vars
     $bp->pages = $reset_bp_pages;
     $bp->admin->notices = $reset_admin_notices;
 }
开发者ID:dcavins,项目名称:buddypress-svn,代码行数:25,代码来源:functions.php


示例6: test_bp_core_get_directory_pages_autocreate_register_pages_multisite

 /**
  * @ticket BP7193
  */
 public function test_bp_core_get_directory_pages_autocreate_register_pages_multisite()
 {
     if (!is_multisite()) {
         return;
     }
     // Emulate being in the network admin area.
     if (!class_exists('BP_Members_Admin', false)) {
         require BP_PLUGIN_DIR . 'bp-members/classes/class-bp-members-admin.php';
     }
     $admin = new BP_Members_Admin();
     add_action('update_site_option_registration', array($admin, 'multisite_registration_on'), 10, 2);
     // Emulate turning registration on.
     update_site_option('registration', 'user');
     // Now check directory pages.
     $pages = bp_core_get_directory_pages();
     $this->assertNotEmpty($pages->register);
     $this->assertNotEmpty($pages->activate);
     remove_action('update_site_option_registration', array($admin, 'multisite_registration_on'), 10);
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:22,代码来源:bpCoreGetDirectoryPageIds.php


示例7: test_bp_core_get_directory_pages_multisite_delete_post_with_same_bp_page_id

 public function test_bp_core_get_directory_pages_multisite_delete_post_with_same_bp_page_id()
 {
     if (!is_multisite()) {
         return;
     }
     $dir_pages = bp_core_get_directory_pages();
     // create a blog
     $u = $this->factory->user->create();
     $b1 = $this->factory->blog->create(array('user_id' => $u));
     // switch to blog and create some dummy posts until we reach a post ID that
     // matches our BP activity page ID
     switch_to_blog($b1);
     $p = $this->factory->post->create();
     while ($p <= $dir_pages->activity->id) {
         $p = $this->factory->post->create();
     }
     // delete the post that matches the BP activity page ID on this sub-site
     wp_delete_post($dir_pages->activity->id, true);
     // restore blog
     restore_current_blog();
     // refetch BP directory pages
     $dir_pages = bp_core_get_directory_pages();
     // Now verify that our BP activity page was not wiped out
     $this->assertNotEmpty($dir_pages->activity);
 }
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:25,代码来源:bpCoreGetDirectoryPageIds.php


示例8: 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.
//.........这里部分代码省略.........
开发者ID:JeroenNouws,项目名称:BuddyPress,代码行数:101,代码来源:bp-core-catchuri.php


示例9: 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)) {
//.........这里部分代码省略.........
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:101,代码来源:bp-core-catchuri.php


示例10: go_to

 function go_to($url)
 {
     $GLOBALS['bp']->loggedin_user = NULL;
     $GLOBALS['bp']->pages = bp_core_get_directory_pages();
     parent::go_to($url);
     do_action('bp_init');
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:7,代码来源:testcase.php


示例11: test_bp_core_get_directory_pages_after_page_edit

 /**
  * @group bp_core_get_directory_pages
  */
 public function test_bp_core_get_directory_pages_after_page_edit()
 {
     // Set the cache
     $pages = bp_core_get_directory_pages();
     // Update one of the posts
     switch_to_blog(bp_get_root_blog_id());
     // grab the first one
     foreach ($pages as $page) {
         $p = $page;
         break;
     }
     $post = get_post($p->id);
     $post->post_title .= ' Foo';
     wp_update_post($post);
     restore_current_blog();
     $this->assertFalse(wp_cache_get('directory_pages', 'bp'));
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:20,代码来源:functions.php


示例12: 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


示例13: setup_globals

 function setup_globals()
 {
     global $bp;
     /** Database **********************************************************/
     // Get the base database prefix
     if (empty($bp->table_prefix)) {
         $bp->table_prefix = bp_core_get_table_prefix();
     }
     // The domain for the root of the site where the main blog resides
     if (empty($bp->root_domain)) {
         $bp->root_domain = bp_core_get_root_domain();
     }
     // Fetches all of the core BuddyPress settings in one fell swoop
     if (empty($bp->site_options)) {
         $bp->site_options = bp_core_get_root_options();
     }
     // The names of the core NXTClass pages used to display BuddyPress content
     if (empty($bp->pages)) {
         $bp->pages = bp_core_get_directory_pages();
     }
     /** Admin Bar *********************************************************/
     // Set the 'My Account' global to prevent debug notices
     $bp->my_account_menu_id = false;
     /** Component and Action **********************************************/
     // Used for overriding the 2nd level navigation menu so it can be used to
     // display custom navigation for an item (for example a group)
     $bp->is_single_item = false;
     // Sets up the array container for the component navigation rendered
     // by bp_get_nav()
     $bp->bp_nav = array();
     // Sets up the array container for the component options navigation
     // rendered by bp_get_options_nav()
     $bp->bp_options_nav = array();
     // Contains an array of all the active components. The key is the slug,
     // value the internal ID of the component.
     //$bp->active_components = array();
     /** Basic current user data *******************************************/
     // Logged in user is the 'current_user'
     $current_user = nxt_get_current_user();
     // The user ID of the user who is currently logged in.
     $bp->loggedin_user->id = $current_user->ID;
     /** Avatars ***********************************************************/
     // Fetches the default Gravatar image to use if the user/group/blog has no avatar or gravatar
     $bp->grav_default->user = apply_filters('bp_user_gravatar_default', $bp->site_options['avatar_default']);
     $bp->grav_default->group = apply_filters('bp_group_gravatar_default', $bp->grav_default->user);
     $bp->grav_default->blog = apply_filters('bp_blog_gravatar_default', $bp->grav_default->user);
     // Notifications Table
     $bp->core->table_name_notifications = $bp->table_prefix . 'bp_notifications';
     /**
      * Used to determine if user has admin rights on current content. If the
      * logged in user is viewing their own profile and wants to delete
      * something, is_item_admin is used. This is a generic variable so it
      * can be used by other components. It can also be modified, so when
      * viewing a group 'is_item_admin' would be 'true' if they are a group
      * admin, and 'false' if they are not.
      */
     bp_update_is_item_admin(bp_user_has_access(), 'core');
     // Is the logged in user is a mod for the current item?
     bp_update_is_item_mod(false, 'core');
     do_action('bp_core_setup_globals');
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:61,代码来源:bp-core-loader.php


示例14: bp_core_activation_notice

/**
 * Verify that some BP prerequisites are set up properly, and notify the admin if not.
 *
 * On every Dashboard page, this function checks the following:
 *   - that pretty permalinks are enabled.
 *   - that every BP component that needs a WP page for a directory has one.
 *   - that no WP page has multiple BP components associated with it.
 * The administrator will be shown a notice for each check that fails.
 *
 * @global WPDB $wpdb WordPress DB object
 * @global WP_Rewrite $wp_rewrite
 *
 * @since 1.2.0
 */
function bp_core_activation_notice()
{
    global $wp_rewrite, $wpdb;
    // Only the super admin gets warnings.
    if (!bp_current_user_can('bp_moderate')) {
        return;
    }
    // Bail in user admin.
    if (is_user_admin()) {
        return;
    }
    // On multisite installs, don't load on a non-root blog, unless do_network_admin is overridden.
    if (is_multisite() && bp_core_do_network_admin() && !bp_is_root_blog()) {
        return;
    }
    // Bail if in network admin, and BuddyPress is not network activated.
    if (is_network_admin() && !bp_is_network_activated()) {
        return;
    }
    /**
     * Check to make sure that the blog setup routine has run. This can't
     * happen during the wizard because of the order which the components
     * are loaded.
     */
    if (bp_is_active('blogs')) {
        $bp = buddypress();
        $count = $wpdb->get_var("SELECT COUNT(*) FROM {$bp->blogs->table_name}");
        if (empty($count)) {
            bp_blogs_record_existing_blogs();
        }
    }
    // Add notice if no rewrite rules are enabled.
    if (empty($wp_rewrite->permalink_structure)) {
        bp_core_add_admin_notice(sprintf(__('<strong>BuddyPress is almost ready</strong>. You must <a href="%s">update your permalink structure</a> to something other than the default for it to work.', 'buddypress'), admin_url('options-permalink.php')), 'error');
    }
    // Get BuddyPress instance.
    $bp = buddypress();
    /**
     * Check for orphaned BP components (BP component is enabled, no WP page exists).
     */
    $orphaned_components = array();
    $wp_page_components = array();
    // Only components with 'has_directory' require a WP page to function.
    foreach (array_keys($bp->loaded_components) as $component_id) {
        if (!empty($bp->{$component_id}->has_directory)) {
            $wp_page_components[] = array('id' => $component_id, 'name' => isset($bp->{$component_id}->name) ? $bp->{$component_id}->name : ucwords($bp->{$component_id}->id));
        }
    }
    // Activate and Register are special cases. They are not components but they need WP pages.
    // If user registration is disabled, we can skip this step.
    if (bp_get_signup_allowed()) {
        $wp_page_components[] = array('id' => 'activate', 'name' => __('Activate', 'buddypress'));
        $wp_page_components[] = array('id' => 'register', 'name' => __('Register', 'buddypress'));
    }
    // On the first admin screen after a new installation, this isn't set, so grab it to suppress
    // a misleading error message.
    if (empty($bp->pages->members)) {
        $bp->pages = bp_core_get_directory_pages();
    }
    foreach ($wp_page_components as $component) {
        if (!isset($bp->pages->{$component['id']})) {
            $orphaned_components[] = $component['name'];
        }
    }
    // Special case: If the Forums component is orphaned, but the bbPress 1.x installation is
    // not correctly set up, don't show a nag. (In these cases, it's probably the case that the
    // user is using bbPress 2.x; see https://buddypress.trac.wordpress.org/ticket/4292.
    if (isset($bp->forums->name) && in_array($bp->forums->name, $orphaned_components) && !bp_forums_is_installed_correctly()) {
        $forum_key = array_search($bp->forums->name, $orphaned_components);
        unset($orphaned_components[$forum_key]);
        $orphaned_components = array_values($orphaned_components);
    }
    if (!empty($orphaned_components)) {
        $admin_url = bp_get_admin_url(add_query_arg(array('page' => 'bp-page-settings'), 'admin.php'));
        $notice = sprintf(__('The following active BuddyPress Components do not have associated WordPress Pages: %2$s. <a href="%1$s">Repair</a>', 'buddypress'), esc_url($admin_url), '<strong>' . implode('</strong>, <strong>', $orphaned_components) . '</strong>');
        bp_core_add_admin_notice($notice);
    }
    // BP components cannot share a single WP page. Check for duplicate assignments, and post a message if found.
    $dupe_names = array();
    $page_ids = (array) bp_core_get_directory_page_ids();
    $dupes = array_diff_assoc($page_ids, array_unique($page_ids));
    if (!empty($dupes)) {
        foreach (array_keys($dupes) as $dupe_component) {
            $dupe_names[] = $bp->pages->{$dupe_component}->title;
        }
        // Make sure that there are no duplicate duplicates :).
//.........这里部分代码省略.........
开发者ID:igniterealtime,项目名称:community-plugins,代码行数:101,代码来源:bp-core-admin-functions.php


示例15: go_to


//.........这里部分代码省略.........
                 // Search the network path + one more path segment (on top of the network path).
                 $current_blog = get_site_by_path($domain, $path, substr_count($current_site->path, '/'));
             }
             // The network declared by the site trumps any constants.
             if ($current_blog && $current_blog->site_id != $current_site->id) {
                 $current_site = wp_get_network($current_blog->site_id);
             }
             // If we don't have a network by now, we have a problem.
             if (empty($current_site)) {
                 ms_not_installed();
             }
             // @todo What if the domain of the network doesn't match the current site?
             $current_site->cookie_domain = $current_site->domain;
             if ('www.' === substr($current_site->cookie_domain, 0, 4)) {
                 $current_site->cookie_domain = substr($current_site->cookie_domain, 4);
             }
             // Figure out the current network's main site.
             if (!isset($current_site->blog_id)) {
                 if ($current_blog && $current_blog->domain === $current_site->domain && $current_blog->path === $current_site->path) {
                     $current_site->blog_id = $current_blog->blog_id;
                 } else {
                     // @todo we should be able to cache the blog ID of a network's main site easily.
                     $current_site->blog_id = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path));
                 }
             }
             $blog_id = $current_blog->blog_id;
             $public = $current_blog->public;
             if (empty($current_blog->site_id)) {
                 // This dates to [MU134] and shouldn't be relevant anymore,
                 // but it could be possible for arguments passed to insert_blog() etc.
                 $current_blog->site_id = 1;
             }
             $site_id = $current_blog->site_id;
             wp_load_core_site_options($site_id);
             // Pre WP 3.9
         } else {
             $domain = rtrim($domain, '.');
             $cookie_domain = $domain;
             if (substr($cookie_domain, 0, 4) == 'www.') {
                 $cookie_domain = substr($cookie_domain, 4);
             }
             $path = preg_replace('|([a-z0-9-]+.php.*)|', '', $GLOBALS['_SERVER']['REQUEST_URI']);
             $path = str_replace('/wp-admin/', '/', $path);
             $path = preg_replace('|(/[a-z0-9-]+?/).*|', '$1', $path);
             $GLOBALS['current_site'] = wpmu_current_site();
             if (!isset($GLOBALS['current_site']->blog_id) && !empty($GLOBALS['current_site'])) {
                 $GLOBALS['current_site']->blog_id = $wpdb->get_var($wpdb->prepare("SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $GLOBALS['current_site']->domain, $GLOBALS['current_site']->path));
             }
             $blogname = htmlspecialchars(substr($GLOBALS['_SERVER']['REQUEST_URI'], strlen($path)));
             if (false !== strpos($blogname, '/')) {
                 $blogname = substr($blogname, 0, strpos($blogname, '/'));
             }
             if (false !== strpos($blogname, '?')) {
                 $blogname = substr($blogname, 0, strpos($blogname, '?'));
             }
             $reserved_blognames = array('page', 'comments', 'blog', 'wp-admin', 'wp-includes', 'wp-content', 'files', 'feed');
             if ($blogname != '' && !in_array($blogname, $reserved_blognames) && !is_file($blogname)) {
                 $path .= $blogname . '/';
             }
             $GLOBALS['current_blog'] = get_blog_details(array('domain' => $domain, 'path' => $path), false);
             unset($reserved_blognames);
             if ($GLOBALS['current_site'] && !$GLOBALS['current_blog']) {
                 $GLOBALS['current_blog'] = get_blog_details(array('domain' => $GLOBALS['current_site']->domain, 'path' => $GLOBALS['current_site']->path), false);
             }
             $GLOBALS['blog_id'] = $GLOBALS['current_blog']->blog_id;
         }
         // Emulate a switch_to_blog()
         $table_prefix = $wpdb->get_blog_prefix($current_blog->blog_id);
         $wpdb->set_blog_id($current_blog->blog_id, $current_blog->site_id);
         $_wp_switched_stack = array();
         $switched = false;
         if (!isset($current_site->site_name)) {
             $current_site->site_name = get_site_option('site_name');
             if (!$current_site->site_name) {
                 $current_site->site_name = ucfirst($current_site->domain);
             }
         }
     }
     $this->flush_cache();
     unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
     $GLOBALS['wp_the_query'] = new WP_Query();
     $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];
     $GLOBALS['wp'] = new WP();
     // clean out globals to stop them polluting wp and wp_query
     foreach ($GLOBALS['wp']->public_query_vars as $v) {
         unset($GLOBALS[$v]);
     }
     foreach ($GLOBALS['wp']->private_query_vars as $v) {
         unset($GLOBALS[$v]);
     }
     $GLOBALS['wp']->main($parts['query']);
     $wp_roles->reinit();
     $current_user = wp_get_current_user();
     $current_user->for_blog($blog_id);
     // For BuddyPress, James.
     $this->clean_up_global_scope();
     $GLOBALS['bp']->loggedin_user = NULL;
     $GLOBALS['bp']->pages = bp_core_get_directory_pages();
     do_action('bp_init');
 }
开发者ID:jasonmcalpin,项目名称:BuddyPress,代码行数:101,代码来源:testcase.php


示例16: bp_core_add_root_component

/**
 * Add support for a top-level ("root") component.
 *
 * This function originally (pre-1.5) let plugins add support for pages in the
 * root of the install. These root level pages are now handled by actual
 * WordPress pages and this function is now a convenience for compatibility
 * with the new method.
 *
 * @param string $slug The slug of the component being added to the root list.
 */
function bp_core_add_root_component($slug)
{
    $bp = buddypress();
    if (empty($bp->pages)) {
        $bp->pages = bp_core_get_directory_pages();
    }
    $match = false;
    // Check if the slug is registered in the $bp->pages global
    foreach ((array) $bp->pages as $key => $page) {
        if ($key == $slug || $page->slug == $slug) {
            $match = true;
        }
    }
    // Maybe create the add_root array
    if (empty($bp->add_root)) {
        $bp->add_root = array();
    }
    // If there was no match, add a page for this root component
    if (empty($match)) {
        $add_root_items = $bp->add_root();
        $add_root_items[] = $slug;
        $bp->add_root = $add_root_items;
    }
    // Make sure that this component is registered as requiring a top-level directory
    if (isset($bp->{$slug})) {
        $bp->loaded_components[$bp->{$slug}->slug] = $bp->{$slug}->id;
        $bp->{$slug}->has_directory = true;
    }
}
开发者ID:antares-ff,项目名称:ANTARES-Test,代码行数:39,代码来源:bp-core-functions.php


示例17: test_bp_core_activation_notice_register_activate_pages_created_signup_allowed

 /**
  * @group bp_core_activation_notice
  */
 public function test_bp_core_activation_notice_register_activate_pages_created_signup_allowed()
 {
     $bp = buddypress();
     $reset_bp_pages = $bp->pages;
     $reset_admin_notices = $bp->admin->notices;
     add_filter('bp_get_signup_allowed', '__return_true', 999);
     $ac = buddypress()->active_components;
     bp_core_add_page_mappings(array_keys($ac));
     // Reset pages
     $bp->pages = bp_core_get_directory_pages();
     bp_core_activation_notice();
     remove_filter('bp_get_signup_allowed', '__return_true', 999);
     $missing_pages = array();
     foreach (buddypress()->admin->notices as $notice) {
         if (false !== strpos($notice['message'], 'BuddyPress is almost ready')) {
             continue;
         }
         preg_match_all('/<strong>(.+?)<\\/strong>/', $notice['message'], $missing_pages);
     }
     $this->assertEmpty($missing_pages);
     // Reset buddypress() vars
     $bp->pages = $reset_bp_pages;
     $bp->admin->notices = $reset_admin_notices;
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:27,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP bp_core_get_last_activity函数代码示例发布时间:2022-05-24
下一篇:
PHP bp_core_get_directory_page_ids函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap