#6615 closed defect (bug) (fixed)
bp_get_the_post_class() mistakenly removes classes
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 2.4 | Priority: | normal |
| Severity: | normal | Version: | 2.1 |
| Component: | Core | Keywords: | has-patch commit |
| Cc: | dcavins |
Description
bp_get_the_post_class() tries to unset the classes page and type-page on BuddyPress pages. However, it uses array_search() to find the key to unset and doesn't check for strict falsey-ness (array_search returns the found key--including 0-- or false if nothing is found).
In our function, if the targeted class isn't found, the zeroth element of the array is accidentally unset. I've added a strict check on the result of array_search() before unsetting anything.
This also could be done using array_diff(), if you have some idea that that would be more efficient/less klutzy, please let me know. :)
Attachments (1)
Change History (5)
#2
@
10 years ago
- Keywords commit added
- Version changed from 2.3.3 to 2.1
Fix looks good. You can blame me for this one!
I'm guessing that a plugin or theme might have removed the 'page' or 'type-page' CSS classes, which is why this is necessary.
Add strict check on result of array_search() in bp_get_the_post_class().