本文整理汇总了PHP中bp_get_root_blog_id函数的典型用法代码示例。如果您正苦于以下问题:PHP bp_get_root_blog_id函数的具体用法?PHP bp_get_root_blog_id怎么用?PHP bp_get_root_blog_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bp_get_root_blog_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_bp_core_ajax_url
function test_bp_core_ajax_url()
{
$forced = force_ssl_admin();
// (1) HTTPS off
force_ssl_admin(false);
$_SERVER['HTTPS'] = 'off';
// (1a) Front-end
$this->go_to('/');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http'));
// (1b) Dashboard
$this->go_to('/wp-admin');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http'));
// (2) FORCE_SSL_ADMIN
force_ssl_admin(true);
// (2a) Front-end
$this->go_to('/');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'http'));
// (2b) Dashboard
$this->go_to('/wp-admin');
$this->assertEquals(bp_core_ajax_url(), get_site_url(bp_get_root_blog_id(), '/wp-admin/admin-ajax.php', 'https'));
force_ssl_admin($forced);
// (3) Multisite, root blog other than 1
if (is_multisite()) {
$original_root_blog = bp_get_root_blog_id();
$blog_id = $this->factory->blog->create(array('path' => '/path' . rand() . time() . '/'));
buddypress()->root_blog_id = $blog_id;
$blog_url = get_blog_option($blog_id, 'siteurl');
$this->go_to(trailingslashit($blog_url));
buddypress()->root_blog_id = $original_root_blog;
$ajax_url = bp_core_ajax_url();
$this->go_to('/');
$this->assertEquals($blog_url . '/wp-admin/admin-ajax.php', $ajax_url);
}
}
示例2: friends_notification_accepted_request
function friends_notification_accepted_request($friendship_id, $initiator_id, $friend_id)
{
global $bp;
$friendship = new BP_Friends_Friendship($friendship_id, false, false);
$friend_name = bp_core_get_user_displayname($friend_id);
if ('no' == bp_get_user_meta((int) $initiator_id, 'notification_friends_friendship_accepted', true)) {
return false;
}
$ud = get_userdata($initiator_id);
$friend_link = bp_core_get_user_domain($friend_id);
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($initiator_id) . $settings_slug . '/notifications';
// Set up and send the message
$to = $ud->user_email;
$sitename = nxt_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
$subject = '[' . $sitename . '] ' . sprintf(__('%s accepted your friendship request', 'buddypress'), $friend_name);
$message = sprintf(__('%1$s accepted your friend request.
To view %2$s\'s profile: %3$s
---------------------
', 'buddypress'), $friend_name, $friend_name, $friend_link);
$message .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
/* Send the message */
$to = apply_filters('friends_notification_accepted_request_to', $to);
$subject = apply_filters('friends_notification_accepted_request_subject', $subject, $friend_name);
$message = apply_filters('friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link);
nxt_mail($to, $subject, $message);
do_action('bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id);
}
示例3: bp_adminbar_authors_menu
function bp_adminbar_authors_menu()
{
global $bp, $nxtdb;
// Only for multisite
if (!is_multisite()) {
return false;
}
// Hide on root blog
if ($nxtdb->blogid == bp_get_root_blog_id() || !bp_is_active('blogs')) {
return false;
}
$blog_prefix = $nxtdb->get_blog_prefix($nxtdb->blogid);
$authors = $nxtdb->get_results("SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM {$nxtdb->users} u, {$nxtdb->usermeta} um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id");
if (!empty($authors)) {
// This is a blog, render a menu with links to all authors
echo '<li id="bp-adminbar-authors-menu"><a href="/">';
_e('Blog Authors', 'buddypress');
echo '</a>';
echo '<ul class="author-list">';
foreach ((array) $authors as $author) {
$caps = maybe_unserialize($author->caps);
if (isset($caps['subscriber']) || isset($caps['contributor'])) {
continue;
}
echo '<li>';
echo '<a href="' . bp_core_get_user_domain($author->user_id, $author->user_nicename, $author->user_login) . '">';
echo bp_core_fetch_avatar(array('item_id' => $author->user_id, 'email' => $author->user_email, 'width' => 15, 'height' => 15));
echo ' ' . $author->display_name . '</a>';
echo '<div class="admin-bar-clear"></div>';
echo '</li>';
}
echo '</ul>';
echo '</li>';
}
}
示例4: bp_blogs_register_widgets
function bp_blogs_register_widgets()
{
global $wpdb;
if (bp_is_active('activity') && (int) $wpdb->blogid == bp_get_root_blog_id()) {
add_action('widgets_init', create_function('', 'return register_widget("BP_Blogs_Recent_Posts_Widget");'));
}
}
示例5: bp_core_allow_default_theme
/**
* bp_core_allow_default_theme()
*
* On multiblog installations you must first allow themes to be activated and show
* up on the theme selection screen. This function will let the BuddyPress bundled
* themes show up on the root blog selection screen and bypass this step. It also
* means that the themes won't show for selection on other blogs.
*
* @package BuddyPress Core
*/
function bp_core_allow_default_theme($themes)
{
global $wpdb;
if (!bp_current_user_can('bp_moderate')) {
return $themes;
}
if ($wpdb->blogid == bp_get_root_blog_id()) {
$themes['bp-default'] = 1;
}
return $themes;
}
示例6: bp_get_object_terms
/**
* Get taxonomy terms for a BuddyPress object.
*
* @since BuddyPress (2.2.0)
*
* @see wp_get_object_terms() for a full description of function and parameters.
*
* @param int|array $object_ids ID or IDs of objects.
* @param string|array $taxonomies Name or names of taxonomies to match.
* @param array $args See {@see wp_get_object_terms()}.
* @return array
*/
function bp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
if ( ! bp_is_root_blog() ) {
switch_to_blog( bp_get_root_blog_id() );
}
$retval = wp_get_object_terms( $object_ids, $taxonomies, $args );
restore_current_blog();
return $retval;
}
示例7: thatcamp_blogs_register_widgets
function thatcamp_blogs_register_widgets()
{
global $wpdb;
if (bp_is_active('activity') && bp_is_active('blogs') && class_exists('BP_Blogs_Recent_Posts_Widget') && (int) $wpdb->blogid == bp_get_root_blog_id()) {
include __DIR__ . '/includes/posts-widget.php';
add_action('widgets_init', create_function('', 'unregister_widget( "BP_Blogs_Recent_Posts_Widget" ); return register_widget("THATCamp_Blogs_Recent_Posts_Widget");'));
}
if (bp_is_active('groups') && (int) $wpdb->blogid == bp_get_root_blog_id()) {
include __DIR__ . '/includes/groups-widget.php';
add_action('widgets_init', create_function('', 'unregister_widget( "BP_Groups_Widget" ); return register_widget("THATCamp_Groups_Widget");'));
}
}
示例8: bp_get_taxonomy_term_site_id
/**
* Gets the ID of the site that BP should use for taxonomy term storage.
*
* Defaults to the root blog ID.
*
* @since 2.6.0
*
* @param string $taxonomy Taxonomy slug to check for.
* @return int
*/
function bp_get_taxonomy_term_site_id($taxonomy = '')
{
$site_id = bp_get_root_blog_id();
/**
* Filters the ID of the site where BP should store taxonomy terms.
*
* @since 2.6.0
*
* @param int $site_id Site ID to cehck for.
* @param string $taxonomy Taxonomy slug to check for.
*/
return (int) apply_filters('bp_get_taxonomy_term_site_id', $site_id, $taxonomy);
}
示例9: __construct
/**
* Constructor method
*
* @package Rendez_Vous
* @subpackage Component
*
* @since Rendez Vous (1.0.0)
*/
function __construct()
{
$bp = buddypress();
parent::start('rendez_vous', rendez_vous()->get_component_name(), rendez_vous()->includes_dir);
$this->includes();
$bp->active_components[$this->id] = '1';
/**
* Only register the post type on the blog where BuddyPress is activated.
*/
if (get_current_blog_id() == bp_get_root_blog_id()) {
add_action('init', array(&$this, 'register_post_types'));
}
}
示例10: actions
/**
* set some actions
*
*
* @package BuddyDrive
* @since 1.2.0
*/
private function actions()
{
buddypress()->active_components[$this->id] = '1';
/**
* Register the BuddyDrive custom post types
*/
if (get_current_blog_id() == bp_get_root_blog_id()) {
add_action('init', array(&$this, 'register_post_types'), 9);
// Register the BuddyDrive upload dir
add_action('bp_init', array($this, 'register_upload_dir'));
}
// register the embed handler
add_action('bp_init', array($this, 'register_embed_code'), 4);
}
示例11: bp_core_allow_default_theme
/**
* On multiblog installations you must first allow themes to be activated and
* show up on the theme selection screen. This function will let the BuddyPress
* bundled themes show up on the root blog selection screen and bypass this
* step. It also means that the themes won't show for selection on other blogs.
*
* @deprecated BuddyPress (1.7)
* @package BuddyPress Core
*/
function bp_core_allow_default_theme($themes)
{
_deprecated_function(__FUNCTION__, '1.7');
if (!bp_current_user_can('bp_moderate')) {
return $themes;
}
if (bp_get_root_blog_id() != get_current_blog_id()) {
return $themes;
}
if (isset($themes['bp-default'])) {
return $themes;
}
$themes['bp-default'] = true;
return $themes;
}
示例12: test_bp_current_user_can_should_respect_blog_id_passed_in_args_array
/**
* @ticket BP6501
*/
public function test_bp_current_user_can_should_respect_blog_id_passed_in_args_array()
{
if (!is_multisite()) {
$this->markTestSkipped(__METHOD__ . ' requires multisite.');
}
$b = $this->factory->blog->create();
$u = $this->factory->user->create();
$this->set_current_user($u);
add_filter('user_has_cap', array($this, 'grant_cap_foo'), 10, 2);
$can = bp_current_user_can('foo', array('blog_id' => bp_get_root_blog_id()));
$cant = bp_current_user_can('foo', array('blog_id' => $b));
remove_filter('user_has_cap', array($this, 'grant_cap_foo'), 10, 2);
$this->assertTrue($can);
$this->assertFalse($cant);
}
示例13: bp_forums_bbpress_install
function bp_forums_bbpress_install($location = '')
{
global $wpdb, $bbdb;
check_admin_referer('bp_forums_new_install_init');
if (empty($location)) {
$location = ABSPATH . 'bb-config.php';
}
$bp = buddypress();
// Create the bb-config.php file.
$initial_write = bp_forums_bbpress_write($bp->plugin_dir . '/bp-forums/bbpress/bb-config-sample.php', $location, array("define( 'BBDB_NAME'," => array("'bbpress'", "'" . DB_NAME . "'"), "define( 'BBDB_USER'," => array("'username'", "'" . DB_USER . "'"), "define( 'BBDB_PASSWO" => array("'password'", "'" . DB_PASSWORD . "'"), "define( 'BBDB_HOST'," => array("'localhost'", "'" . DB_HOST . "'"), "define( 'BBDB_CHARSE" => array("'utf8'", "'" . DB_CHARSET . "'"), "define( 'BBDB_COLLAT" => array("''", "'" . DB_COLLATE . "'"), "define( 'BB_AUTH_KEY" => array("'put your unique phrase here'", "'" . addslashes(AUTH_KEY) . "'"), "define( 'BB_SECURE_A" => array("'put your unique phrase here'", "'" . addslashes(SECURE_AUTH_KEY) . "'"), "define( 'BB_LOGGED_I" => array("'put your unique phrase here'", "'" . addslashes(LOGGED_IN_KEY) . "'"), "define( 'BB_NONCE_KE" => array("'put your unique phrase here'", "'" . addslashes(NONCE_KEY) . "'"), "\$bb_table_prefix = '" => array("'bb_'", "'" . $bp->table_prefix . "bb_'"), "define( 'BB_LANG', '" => array("''", "'" . get_locale() . "'")));
// Add the custom user and usermeta entries to the config file.
if ($initial_write == 1) {
$file = file_get_contents($location);
} else {
$file =& $initial_write;
}
$file = trim($file);
if ('?>' == substr($file, -2, 2)) {
$file = substr($file, 0, -2);
}
$file .= "\n" . '$bb->custom_user_table = \'' . $wpdb->users . '\';';
$file .= "\n" . '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';';
$file .= "\n\n" . '$bb->uri = \'' . $bp->plugin_url . '/bp-forums/bbpress/\';';
$file .= "\n" . '$bb->name = \'' . get_blog_option(bp_get_root_blog_id(), 'blogname') . ' ' . __('Forums', 'buddypress') . '\';';
if (is_multisite()) {
$file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . bp_get_root_blog_id() . ';';
}
if (defined('AUTH_SALT')) {
$file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes(AUTH_SALT) . '\');';
}
if (defined('LOGGED_IN_SALT')) {
$file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes(LOGGED_IN_SALT) . '\');';
}
if (defined('SECURE_AUTH_SALT')) {
$file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes(SECURE_AUTH_SALT) . '\');';
}
$file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);';
$file .= "\n\n" . '?>';
if ($initial_write == 1) {
$file_handle = fopen($location, 'w');
fwrite($file_handle, $file);
fclose($file_handle);
} else {
$initial_write = $file;
}
bp_update_option('bb-config-location', $location);
return $initial_write;
}
示例14: messages_notification_new_message
function messages_notification_new_message($args = array())
{
// These should be extracted below
$recipients = array();
$email_subject = $email_content = '';
extract($args);
$sender_name = bp_core_get_user_displayname($sender_id);
// Bail if no recipients
if (!empty($recipients)) {
foreach ($recipients as $recipient) {
if ($sender_id == $recipient->user_id || 'no' == bp_get_user_meta($recipient->user_id, 'notification_messages_new_message', true)) {
continue;
}
// User data and links
$ud = get_userdata($recipient->user_id);
$message_link = bp_core_get_user_domain($recipient->user_id) . bp_get_messages_slug() . '/';
$settings_slug = function_exists('bp_get_settings_slug') ? bp_get_settings_slug() : 'settings';
$settings_link = bp_core_get_user_domain($recipient->user_id) . $settings_slug . '/notifications/';
// Sender info
$sender_name = stripslashes($sender_name);
$subject = stripslashes(wp_filter_kses($subject));
$content = stripslashes(wp_filter_kses($content));
// Set up and send the message
$email_to = $ud->user_email;
$sitename = wp_specialchars_decode(get_blog_option(bp_get_root_blog_id(), 'blogname'), ENT_QUOTES);
$email_subject = '[' . $sitename . '] ' . sprintf(__('New message from %s', 'buddypress'), $sender_name);
$email_content = sprintf(__('%1$s sent you a new message:
Subject: %2$s
"%3$s"
To view and read your messages please log in and visit: %4$s
---------------------
', 'buddypress'), $sender_name, $subject, $content, $message_link);
$email_content .= sprintf(__('To disable these notifications please log in and go to: %s', 'buddypress'), $settings_link);
// Send the message
$email_to = apply_filters('messages_notification_new_message_to', $email_to);
$email_subject = apply_filters('messages_notification_new_message_subject', $email_subject, $sender_name);
$email_content = apply_filters('messages_notification_new_message_message', $email_content, $sender_name, $subject, $content, $message_link, $settings_link);
wp_mail($email_to, $email_subject, $email_content);
}
}
do_action('bp_messages_sent_notification_email', $recipients, $email_subject, $email_content, $args);
}
示例15: bp_admin_bar_root_site
/**
* Add a menu for the root site of this BuddyPress network
*
* @global type $nxt_admin_bar
* @return If in ajax
*/
function bp_admin_bar_root_site()
{
global $nxt_admin_bar;
// Create the root blog menu
$nxt_admin_bar->add_menu(array('id' => 'bp-root-blog', 'title' => get_blog_option(bp_get_root_blog_id(), 'blogname'), 'href' => bp_get_root_domain()));
// Logged in user
if (is_user_logged_in()) {
// Dashboard links
if (is_super_admin()) {
// Add site admin link
$nxt_admin_bar->add_menu(array('id' => 'dashboard', 'parent' => 'bp-root-blog', 'title' => __('Admin Dashboard', 'buddypress'), 'href' => get_admin_url(bp_get_root_blog_id())));
// Add network admin link
if (is_multisite()) {
// Link to the network admin dashboard
$nxt_admin_bar->add_menu(array('id' => 'network-dashboard', 'parent' => 'bp-root-blog', 'title' => __('Network Dashboard', 'buddypress'), 'href' => network_admin_url()));
}
}
}
}