Skip to:
Content

BuddyPress.org

Changeset 10459


Ignore:
Timestamp:
01/22/2016 06:02:13 PM (5 years ago)
Author:
boonebgorges
Message:

Introduce bp_get_member_type_directory_permalink().

The new template tag is an easy way to get the URL of a member-type directory.

Props Offereins.
Fixes #6840.

Location:
trunk
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-template.php

    r10458 r10459  
    157157         */
    158158        return apply_filters( 'bp_get_members_directory_permalink', trailingslashit( bp_get_root_domain() . '/' . bp_get_members_root_slug() ) );
     159    }
     160
     161/**
     162 * Output member type directory permalink.
     163 *
     164 * @since 2.5.0
     165 *
     166 * @uses bp_get_member_type_directory_permalink()
     167 *
     168 * @param string $member_type Optional. Member type.
     169 */
     170function bp_member_type_directory_permalink( $member_type = '' ) {
     171    echo esc_url( bp_get_member_type_directory_permalink( $member_type ) );
     172}
     173    /**
     174     * Return member type directory permalink.
     175     *
     176     * @since 2.5.0
     177     *
     178     * @param string $member_type Optional. Member type. Defaults to current member type.
     179     * @return string Member type directory URL on success, an empty string on failure.
     180     */
     181    function bp_get_member_type_directory_permalink( $member_type = '' ) {
     182
     183        if ( $member_type ) {
     184            $_member_type = $member_type;
     185        } else {
     186            // Fall back on the current member type.
     187            $_member_type = bp_get_current_member_type();
     188        }
     189
     190        $type = bp_get_member_type_object( $_member_type );
     191
     192        // Bail when member type is not found or has no directory.
     193        if ( ! $type || ! $type->has_directory ) {
     194            return '';
     195        }
     196
     197        /**
     198         * Filters the member type directory permalink.
     199         *
     200         * @since 2.5.0
     201         *
     202         * @param string $value       Member type directory permalink.
     203         * @param object $type        Member type object.
     204         * @param string $member_type Member type name, as passed to the function.
     205         */
     206        return apply_filters( 'bp_get_member_type_directory_permalink', trailingslashit( bp_get_members_directory_permalink() . bp_get_members_member_type_base() . '/' . $type->directory_slug ), $type, $member_type );
    159207    }
    160208
Note: See TracChangeset for help on using the changeset viewer.