I've added a list of all blogs to my admin bar, but how do i move it out of bb-core.

http://pastor2pastor.org.au/

I have added a drop down menu with a list of the latest 20 blogs into the admin bar at the top of the buddypress site so that it appears on every single blog.

The problem is, I had to modify bp-core-adminbar.php to do it.

That doesn’t seem right to me.

Is there a way I can somehow move these modifications to my theme file?

I didn’t have to modify much I just added in some extra lines.

Wayne

  • wayneconnor
    • WPMU DEV Initiate

    <?php

    /*

    Plugin Name: Adminbar BLog Menu

    Plugin URI:

    Description: Display recent blogs on Buddypress admin bar

    Author: W Connor

    Version: 1.0

    Author URI: http://pastor2pastor.org.au

    This program is free software; you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation; either version 2 of the License, or

    (at your option) any later version.

    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

    GNU General Public License for more details.

    Adds an extra adminbar menu to list all blogs (up to 20)

    Install: copy to mu plugins.

    */

    function bp_adminbar_blog_menu() {

    global $bp; ?>

    <li id=”bp-adminbar-blogs-menu”>

    <?php _e( ‘Visit a Blog’, ‘buddypress’ ) ?>

    <ul class=”random-list”>

    <?php my_show_recent_blogs(20); ?>

    <?php

    }

    function my_get_recent_blogs($number_blogs=5)

    {

    global $wpdb;

    $blog_table=$wpdb->blogs;

    /*fetch blog_id,domain,path from wp_blogs table ,where the blog is not spam,deleted or archived order by the date and time of registration */

    $query=”select blog_id,domain,path from $blog_table where public=’1′ and archived=’0′ and spam=’0′ and deleted=’0′ order by registered desc limit 0,$number_blogs”;

    $recent_blogs=$wpdb->get_results($wpdb->prepare($query));

    return $recent_blogs;

    }

    /*Show a bulleted list of recently created blogs */

    function my_show_recent_blogs($number_blogs=5,$description=true)

    {

    $recent_blogs=bpdev_get_recent_blogs($number_blogs);

    foreach($recent_blogs as $recent_blog):

    $blog_url=””;

    if( defined( “VHOST” ) && constant( “VHOST” ) == ‘yes’ )

    $blog_url=”http://&#8221;.$recent_blog->domain.$recent_blog->path;

    else

    $blog_url=”http://&#8221;.$recent_blog->domain.$recent_blog->path;

    $blog_name=get_blog_option($recent_blog->blog_id,”blogname”:wink:;

    ?>

  • “><?php _e( $blog_name)?>
  • <?php endforeach;?>

    <?php

    }

    add_action( ‘bp_adminbar_menus’, ‘bp_adminbar_blog_menu’, 14 );

    ?>