#7308 closed defect (bug) (fixed)
Make function "bp_core_menu_highlight_parent_page" multisite-aware
Reported by: | martinutopia | Owned by: | imath |
---|---|---|---|
Milestone: | 11.0.0 | Priority: | normal |
Severity: | normal | Version: | 2.7 |
Component: | Core | Keywords: | |
Cc: |
Description
In my WP-multisite I want to loop over posts in a WP-Menu of my main site that is no buddypress-Site. So I'm using switch_to_blog() to get the data from my main site.
I get an error in the file buddypress/bp-core/bp-core-filters.php on line 199 that the second parameter of in_array is not an array. (it's null because the get_post() on line 198 returns null)
My suggested fix is to test if we are in a switch_to_blogs context. For that I suggest following fix on line 171 (add a check of ms_is_switched()):
if ( ! is_buddypress() || ms_is_switched() )
Thanks,
Martin
Attachments (1)
Change History (12)
#1
@
8 years ago
- Keywords good-first-bug needs-patch added
- Milestone changed from Awaiting Review to 2.8
This ticket was mentioned in PR #22 on buddypress/buddypress by robinwpdeveloper.
2 years ago
#3
- Keywords has-patch added; needs-patch removed
bp_is_root_blog check added on bp_core_menu_highlight_parent_page function
Trac ticket: 7308
robinwpdeveloper commented on PR #22:
2 years ago
#4
@imath can you please review this pull request.
This is my first contribution to buddypress :)
#5
@
2 years ago
The PR looks good to me according to @DJPaul's suggestions. Thanks @robinwpdeveloper for your first contribution in BuddyPress
2 years ago
#6
@robinwpdeveloper Sure & with great pleasure! Thanks a lot for this first PR 😍. Don't hesitate to pull more requests 👌
#7
@
2 years ago
- Keywords needs-patch added; has-patch removed
- Milestone changed from Awaiting Contributions to 11.0.0
#8
in reply to:
↑ 6
@
2 years ago
- Keywords good-first-bug needs-patch removed
Replying to imath:
@robinwpdeveloper Sure & with great pleasure! Thanks a lot for this first PR 😍. Don't hesitate to pull more requests 👌
Yes, you are absolutely right we have to return from the function if it is not bp_is_root_blog(). I just uploaded a patch you may check it.
2 years ago
#9
FYI, a patch was added to our Trac ticket about it, so I'm going to close this PR. I hope you won't be disappointed, no worries about the credit/prop, I'll add your WordPress username to my commit.
#10
@
2 years ago
- Owner set to imath
- Resolution set to fixed
- Status changed from new to closed
In 13322:
robinwpdeveloper commented on PR #22:
2 years ago
#11
Thank you very much @imath :)
Hi @martinutopia
Thanks for the bug report (your first, I think; welcome!).
I think we'll fix this with our
bp_is_root_blog
function rather thanms_is_switched
(the latter function is only present if multisite is enabled). Alternately, BuddyPress could do its ownswitch_to_blog
inside the function. I need to spend more than 5 minutes considering the best fix to be sure, but we can definitely get this in for our next major release (2.8; early next year).For now, I'd suggest you hook a function to that action with a higher priority, and inside that function callback, unhook the BuddyPress function from that action if
ms_is_switched
since that apparently works well for you.