Skip to:

Opened 10 years ago

Closed 10 years ago

#5660 closed enhancement (fixed)

add parameter to bp_has_blogs filter

Reported by: needle's profile needle Owned by: boonebgorges's profile boonebgorges
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Blogs Keywords: needs-patch good-first-bug


My delight at seeing that #8042 adds the capability to filter fetched blogs with a list of IDs to include is tempered by the fact that bp_has_blogs filter does not pass the current query arguments as a parameter to the filter. This means that I cannot amend the existing query when I add a filter. The following would (almost) solve this:

return apply_filters( 'bp_has_blogs', $blogs_template->has_blogs(), $blogs_template, $r );

I say "almost", because $r is not fully populated in that it does not include the search string if it comes from $_GET. In my opinion, bp_has_groups() is exemplary in this respect.

Change History (4)

#1 @boonebgorges
10 years ago

  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to 2.1

I don't have a problem making these adjustments to the filter, but I should note that probably the best way to do what you're suggesting is by using the bp_parse_args() filters introduced to template functions in BP 2.0. This will help you to avoid double queries. See for more details.

#2 @needle
10 years ago

That's totally and utterly splendid Boone, thanks for the heads-up. I noticed bp_parse_args() in the function but had no idea that it was such an improvement over wp_parse_args(). Makes adding the param to the filter pretty redundant. I'd be happy if you want to close this.

needle now goes off to re-write all his plugins...

#3 @boonebgorges
10 years ago

In 8447:

Set default search terms before function params are parsed in bp_has_blogs()

By getting the default value of the search_terms parameter from $_REQUEST
before parameters are parsed, we ensure that 'search_terms' is passed to the
bp_parse_args() filter in the same way as the rest of the function params.

See #5456 and r8116 for a similar change in bp_has_groups()

See #5660

#4 @boonebgorges
10 years ago

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

In 8450:

Pass parsed params to 'bp_has_blogs' filter

This makes for better parity with other template loop functions.

Fixes #5660

Props needle

Note: See TracTickets for help on using tickets.