Opened 13 years ago
Closed 13 years ago
#3132 closed enhancement (fixed)
Wrapper function for BP_ROOT_BLOG checks
Reported by: | boonebgorges | Owned by: | 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)
Change History (11)
#2
@
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.
#4
@
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.
#6
@
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)?
#8
@
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.
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?