Skip to:
Content

BuddyPress.org

Changeset 11110


Ignore:
Timestamp:
09/17/2016 04:54:21 PM (4 years ago)
Author:
dcavins
Message:

Member Types: Use helper function for taxonomy name.

Allows the member type taxonomy name to be filtered.

Props slaFFik, dcavins.

See #6060.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-taxonomy.php

    r11073 r11110  
    2222function bp_register_default_taxonomies() {
    2323    // Member Type.
    24     register_taxonomy( 'bp_member_type', 'user', array(
     24    register_taxonomy( bp_get_member_type_tax_name(), 'user', array(
    2525        'public' => false,
    2626    ) );
  • trunk/src/bp-core/classes/class-bp-user-query.php

    r11067 r11110  
    788788        $tax_query = new WP_Tax_Query( array(
    789789            array(
    790                 'taxonomy' => 'bp_member_type',
     790                'taxonomy' => bp_get_member_type_tax_name(),
    791791                'field'    => 'name',
    792792                'operator' => $operator,
     
    796796
    797797        // Switch to the root blog, where member type taxonomies live.
    798         $site_id  = bp_get_taxonomy_term_site_id( 'bp_member_type' );
     798        $site_id  = bp_get_taxonomy_term_site_id( bp_get_member_type_tax_name() );
    799799        $switched = false;
    800800        if ( $site_id !== get_current_blog_id() ) {
  • trunk/src/bp-members/bp-members-cache.php

    r11101 r11110  
    2121    $uncached_member_ids = bp_get_non_cached_ids( $bp_user_query->user_ids, 'bp_member_member_type' );
    2222
    23     $member_types = bp_get_object_terms( $uncached_member_ids, 'bp_member_type', array(
     23    $member_types = bp_get_object_terms( $uncached_member_ids, bp_get_member_type_tax_name(), array(
    2424        'fields' => 'all_with_object_id',
    2525    ) );
  • trunk/src/bp-members/bp-members-functions.php

    r11045 r11110  
    25072507
    25082508/**
     2509 * Output the slug of the member type taxonomy.
     2510 *
     2511 * @since 2.7.0
     2512 */
     2513function bp_member_type_tax_name() {
     2514    echo bp_get_member_type_tax_name();
     2515}
     2516
     2517    /**
     2518     * Return the slug of the member type taxonomy.
     2519     *
     2520     * @since 2.7.0
     2521     *
     2522     * @return string The unique member taxonomy slug.
     2523     */
     2524    function bp_get_member_type_tax_name() {
     2525        /**
     2526         * Filters the slug of the member type taxonomy.
     2527         *
     2528         * @since 2.7.0
     2529         *
     2530         * @param string $value Member type taxonomy slug.
     2531         */
     2532        return apply_filters( 'bp_get_member_type_tax_name', 'bp_member_type' );
     2533    }
     2534
     2535/**
    25092536 * Register a member type.
    25102537 *
     
    26772704    }
    26782705
    2679     $retval = bp_set_object_terms( $user_id, $member_type, 'bp_member_type', $append );
     2706    $retval = bp_set_object_terms( $user_id, $member_type, bp_get_member_type_tax_name(), $append );
    26802707
    26812708    // Bust the cache if the type has been updated.
     
    27132740    }
    27142741
    2715     $deleted = bp_remove_object_terms( $user_id, $member_type, 'bp_member_type' );
     2742    $deleted = bp_remove_object_terms( $user_id, $member_type, bp_get_member_type_tax_name() );
    27162743
    27172744    // Bust the cache if the type has been removed.
     
    27482775
    27492776    if ( false === $types ) {
    2750         $raw_types = bp_get_object_terms( $user_id, 'bp_member_type' );
     2777        $raw_types = bp_get_object_terms( $user_id, bp_get_member_type_tax_name() );
    27512778
    27522779        if ( ! is_wp_error( $raw_types ) ) {
  • trunk/tests/phpunit/testcases/members/types.php

    r11045 r11110  
    286286
    287287        // Fetch a term ID.
    288         $terms = get_terms( 'bp_member_type', array( 'hide_empty' => false, 'fields' => 'all' ) );
     288        $terms = get_terms( bp_get_member_type_tax_name(), array( 'hide_empty' => false, 'fields' => 'all' ) );
    289289
    290290        // Make sure the user's ID matches a term ID, to force a cache confusion.
     
    296296
    297297        // Reprime the taxonomy cache.
    298         $terms = get_terms( 'bp_member_type', array( 'hide_empty' => false, 'fields' => 'all' ) );
     298        $terms = get_terms( bp_get_member_type_tax_name(), array( 'hide_empty' => false, 'fields' => 'all' ) );
    299299
    300300        $this->assertSame( 'foo', bp_get_member_type( $new_user_id, true ) );
     
    400400
    401401        // Directly set a type that hasn't been registered.
    402         bp_set_object_terms( $u1, 'ugh', 'bp_member_type', true );
     402        bp_set_object_terms( $u1, 'ugh', bp_get_member_type_tax_name(), true );
    403403
    404404        $type = bp_get_member_type( $u1, false );
Note: See TracChangeset for help on using the changeset viewer.