コード例 #1
0
 /**
  * Setup BuddyBar navigation
  *
  * @global BuddyPress $bp The one true BuddyPress instance
  */
 public function setup_nav($main_nav = array(), $sub_nav = array())
 {
     global $bp;
     /**
      * Blog/post/comment menus should not appear on single WordPress setups.
      * Although comments and posts made by users will still show on their
      * activity stream.
      */
     if (!is_multisite()) {
         return false;
     }
     $sub_nav = array();
     // Add 'Sites' to the main navigation
     $main_nav = array('name' => sprintf(__('Sites <span>%d</span>', 'buddypress'), bp_blogs_total_blogs_for_user()), 'slug' => $this->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-sites', 'item_css_id' => $this->id);
     // Determine user to use
     if (bp_displayed_user_domain()) {
         $user_domain = bp_displayed_user_domain();
     } elseif (bp_loggedin_user_domain()) {
         $user_domain = bp_loggedin_user_domain();
     } else {
         return;
     }
     $parent_url = trailingslashit($user_domain . bp_get_blogs_slug());
     $sub_nav[] = array('name' => __('My Sites', 'buddypress'), 'slug' => 'my-sites', 'parent_url' => $parent_url, 'parent_slug' => $bp->blogs->slug, 'screen_function' => 'bp_blogs_screen_my_blogs', 'position' => 10);
     // Setup navigation
     parent::setup_nav($main_nav, $sub_nav);
 }
コード例 #2
0
 /**
  * Setup BuddyBar navigation
  *
  * @global obj $bp
  */
 function setup_nav()
 {
     global $bp;
     /**
      * Blog/post/comment menus should not appear on single WordPress setups.
      * Although comments and posts made by users will still show on their
      * activity stream.
      */
     if (!is_multisite()) {
         return false;
     }
     // Add 'Sites' to the main navigation
     $main_nav = array('name' => sprintf(__('Sites <span>%d</span>', 'buddypress'), bp_blogs_total_blogs_for_user()), 'slug' => $this->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $this->id);
     // Setup navigation
     parent::setup_nav($main_nav);
 }
コード例 #3
0
/**
 * Return the number of blogs in user's profile.
 *
 * @since BuddyPress (2.0.0)
 *
 * @param array|string $args before|after|user_id
 *
 * @return string HTML for stats output.
 */
function bp_blogs_get_profile_stats($args = '')
{
    // Parse the args
    $r = bp_parse_args($args, array('before' => '<li class="bp-blogs-profile-stats">', 'after' => '</li>', 'user_id' => bp_displayed_user_id(), 'blogs' => 0, 'output' => ''), 'blogs_get_profile_stats');
    // Allow completely overloaded output
    if (is_multisite() && empty($r['output'])) {
        // Only proceed if a user ID was passed
        if (!empty($r['user_id'])) {
            // Get the user's blogs
            if (empty($r['blogs'])) {
                $r['blogs'] = absint(bp_blogs_total_blogs_for_user($r['user_id']));
            }
            // If blogs exist, show some formatted output
            $r['output'] = $r['before'] . sprintf(_n('%s site', '%s sites', $r['blogs'], 'buddypress'), '<strong>' . $r['blogs'] . '</strong>') . $r['after'];
        }
    }
    /**
     * Filters the number of blogs in user's profile.
     *
     * @since BuddyPress (2.0.0)
     *
     * @param string $value Output determined for the profile stats.
     * @param array  $r     Array of arguments used for default output if none provided.
     */
    return apply_filters('bp_blogs_get_profile_stats', $r['output'], $r);
}
コード例 #4
0
ファイル: bp-blogs.php プロジェクト: n-sane/zaroka
/**
 * bp_blogs_setup_nav()
 *
 * Adds "Blog" to the navigation arrays for the current and logged in user.
 *
 * @package BuddyPress Blogs
 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
 * @uses bp_is_my_profile() Checks to see if the current user being viewed is the logged in user
 */
function bp_blogs_setup_nav() {
	global $bp;

	/* Blog/post/comment menus should not appear on single WordPress setups. Although comments
	   and posts made by users will still show on their activity stream .*/
	if ( !bp_core_is_multisite() )
		return false;

	/* Add 'Blogs' to the main navigation */
	bp_core_new_nav_item( array( 'name' => sprintf( __( 'Blogs <span>(%d)</span>', 'buddypress' ), bp_blogs_total_blogs_for_user() ), 'slug' => $bp->blogs->slug, 'position' => 30, 'screen_function' => 'bp_blogs_screen_my_blogs', 'default_subnav_slug' => 'my-blogs', 'item_css_id' => $bp->blogs->id ) );

	$blogs_link = $bp->loggedin_user->domain . $bp->blogs->slug . '/';

	/* Set up the component options navigation for Blog */
	if ( 'blogs' == $bp->current_component ) {
		if ( bp_is_my_profile() ) {
			if ( function_exists('xprofile_setup_nav') ) {
				$bp->bp_options_title = __('My Blogs', 'buddypress');
			}
		} else {
			/* If we are not viewing the logged in user, set up the current users avatar and name */
			$bp->bp_options_avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => 'thumb' ) );
			$bp->bp_options_title = $bp->displayed_user->fullname;
		}
	}

	do_action( 'bp_blogs_setup_nav' );
}
コード例 #5
0
	function bp_get_total_blog_count_for_user( $user_id = false ) {
		return apply_filters( 'bp_get_total_blog_count_for_user', bp_blogs_total_blogs_for_user( $user_id ) );
	}
コード例 #6
0
/**
 * Return the number of blogs in user's profile.
 *
 * @since BuddyPress (2.0.0)
 *
 * @param array $args before|after|user_id
 * @return string HTML for stats output.
 */
function bp_blogs_get_profile_stats($args = '')
{
    // Parse the args
    $r = bp_parse_args($args, array('before' => '<li class="bp-blogs-profile-stats">', 'after' => '</li>', 'user_id' => bp_displayed_user_id(), 'blogs' => 0, 'output' => ''), 'blogs_get_profile_stats');
    // Allow completely overloaded output
    if (is_multisite() && empty($r['output'])) {
        // Only proceed if a user ID was passed
        if (!empty($r['user_id'])) {
            // Get the user's blogs
            if (empty($r['blogs'])) {
                $r['blogs'] = absint(bp_blogs_total_blogs_for_user($r['user_id']));
            }
            // If blogs exist, show some formatted output
            $r['output'] = $r['before'] . sprintf(_n('%s site', '%s sites', $r['blogs'], 'buddypress'), '<strong>' . $r['blogs'] . '</strong>') . $r['after'];
        }
    }
    // Filter and return
    return apply_filters('bp_blogs_get_profile_stats', $r['output'], $r);
}