Skip to:
Content

BuddyPress.org

Opened 13 years ago

Closed 13 years ago

#3132 closed enhancement (fixed)

Wrapper function for BP_ROOT_BLOG checks

Reported by: boonebgorges's profile boonebgorges Owned by: boonebgorges's profile boonebgorges
Milestone: 1.5 Priority: minor
Severity: Version: 1.2.8
Component: Core Keywords: has-patch needs-testing
Cc:

Description

There are a bunch of places where we check to see whether the current blog is BP_ROOT_BLOG. These should be handled by a wrapper function, so that it's easier to debug in the future, and so that plugins can take better advantage of the check.

Patch attached. Can I have a second set of eyes on it before I put it in?

Attachments (1)

3132.patch (934 bytes) - added by boonebgorges 13 years ago.

Download all attachments as: .zip

Change History (11)

@boonebgorges
13 years ago

#1 @r-a-y
13 years ago

I haven't tested it, but it looks okay to me.

Could be overkill, but maybe pass $wpdb->blogid as an additional parameter as well?

#2 @boonebgorges
13 years ago

I assume you mean, pass $blog_id, and then set it to $wpdb->blogid if no value is passed? I suppose that might be useful - essentially the same thing as checking $blog_id == $wpdb->blogid, without having to instantiate the global.

#3 @r-a-y
13 years ago

I meant in the filter, but what you propose sounds even better ;)

#4 @boonebgorges
13 years ago

Ah, I see what you mean :) Yeah, it doesn't hurt to pass $wpdb->blogid in the filter, but I tend not to do that when it's a value that's available in the global (just because it gets messy).

I'll repatch and commit tomorrow unless someone has objections. Then I can go back and refactor the BP_ROOT_BLOG/current blog checks throughout BP to make them use the new function.

#5 @ptahdunbar
13 years ago

seems fine, but perhaps use get_current_blog_id() instead.

#6 @boonebgorges
13 years ago

Ah, I didn't know about get_current_blog_id(). Does that get switched with switch_to_blog() (too lazy to look for myself at the moment)?

#7 @DJPaul
13 years ago

I believe so, I think it was introduced with WP 3.1. #WP15233

#8 @boonebgorges
13 years ago

Thanks for the pointer, DJPaul. It is indeed switched: http://core.trac.wordpress.org/browser/branches/3.1/wp-includes/ms-blogs.php#L480 I'll update the patch and put it in soon.

#9 @DJPaul
13 years ago

Looks fine (when updated to use get_current_blog_id)

#10 @boonebgorges
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [4174]) Introduces bp_is_root_blog() function. Fixes #3132

Note: See TracTickets for help on using tickets.