Skip to:

Opened 10 years ago

Closed 9 years ago

#6028 closed enhancement (fixed)

BP taxonomy wrapper functions

Reported by: boonebgorges's profile boonebgorges Owned by:
Milestone: 2.2 Priority: normal
Severity: normal Version:
Component: Core Keywords:


See #4017, #6006

We're currently planning a number of features that should take advantage of WP's taxonomy API. But the various ways that BuddyPress interacts with Multisite mean that we need wrappers for WP's functions, so that taxonomy data can always be stored in and read from the proper site's tables.

In #4017, imath has suggested a framework for doing this. IMO, it adds a little bit more overhead than necessary. He has suggested procedural wrappers for static methods on a class loaded into the global object. But I don't think this provides any benefit over simple procedural wrapper, which would look like this:

function bp_get_terms( $taxonomies, $args = '' ) {
    switch_to_blog( bp_get_root_blog_id() );
    $retval = get_terms( $taxonomies, $args );

    return $retval;

I also don't see a pressing reason to provide wrappers for every single function in WP's taxonomy API right off the bat. Instead, I think we can go the more conservative route of adding the wrappers as we need them for BP core functionality, or as requested by plugin authors.

I suggest using the bp_ function prefix, and putting everything in bp-core/bp-core-taxonomy.php. What do others think?

Change History (3)

#1 in reply to: ↑ description @imath
10 years ago

Replying to boonebgorges:

In #4017, imath has suggested a framework for doing this. IMO, it adds a little bit more overhead than necessary.

Yes, actually my initial thought in the first patch was to do it once per load to avoid switching blogs each time a "BP_Term" static function was used. Then r-a-y recommanded to use switch_to_blog().

So a big +1 for your plan about the BP Taxonomies :)

Last edited 10 years ago by imath (previous) (diff)

This ticket was mentioned in Slack in #buddypress by boone. View the logs.

10 years ago

#3 @boonebgorges
9 years ago

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

bp-core-taxonomy.php and a few initial wrappers were introduced in [9210]. I'm going to mark this ticket resolved, but we should continue to add functions to that file as we need them. I suggest that we try to keep the order of wrappers in bp-core-taxonomy.php roughly the same as in wp-includes/taxonomy.php, just to make it a bit easier to follow.

Note: See TracTickets for help on using tickets.