Skip to:
Content

BuddyPress.org

Ticket #7485: 7485.1.diff

File 7485.1.diff, 2.7 KB (added by dcavins, 8 years ago)

Add an "html_link" parameter to bp_get_group_permalink().

  • src/bp-groups/bp-groups-template.php

    diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php
    index 15eb8ca..bb33cf3 100644
    function bp_group_last_active( $group = false, $args = array() ) { 
    962962 *
    963963 * @since 1.0.0
    964964 *
    965  * @param BP_Groups_Group|null $group Optional. Group object. Default: current group in loop.
     965 * @param BP_Groups_Group|null $group     Optional. Group object.
     966 *                                        Default: current group in loop.
     967 * @param bool                 $html_link Optional. Whether to generate an html
     968 *                                        link or just return the URL.
     969 *                                        Default: false.
    966970 */
    967 function bp_group_permalink( $group = null ) {
    968         echo bp_get_group_permalink( $group );
     971function bp_group_permalink( $group = null, $html_link = false ) {
     972        echo bp_get_group_permalink( $group, $html_link );
    969973}
    970974        /**
    971975         * Return the permalink for the current group in the loop.
    972976         *
    973977         * @since 1.0.0
    974978         *
    975          * @param BP_Groups_Group|null $group Optional. Group object. Default: current group in loop.
     979         * @param BP_Groups_Group|null $group     Optional. Group object.
     980         *                                        Default: current group in loop.
     981         * @param bool                 $html_link Optional. Whether to generate an
     982         *                                        html link or just return the URL.
     983         *                                        Default: false.
    976984         * @return string
    977985         */
    978         function bp_get_group_permalink( $group = null ) {
     986        function bp_get_group_permalink( $group = null, $html_link = false ) {
    979987                global $groups_template;
    980988
    981989                if ( empty( $group ) ) {
    function bp_group_permalink( $group = null ) { 
    991999                 * @param string $value Permalink for the current group in the loop.
    9921000                 * @param object $group Group object.
    9931001                 */
    994                 return apply_filters( 'bp_get_group_permalink', trailingslashit( bp_get_groups_directory_permalink() . bp_get_group_slug( $group ) . '/' ), $group );
     1002                $permalink = apply_filters( 'bp_get_group_permalink', trailingslashit( bp_get_groups_directory_permalink() . bp_get_group_slug( $group ) . '/' ), $group );
     1003
     1004                if ( $html_link ) {
     1005                        $permalink = sprintf(
     1006                                '<a href="%s">%s</a>',
     1007                                esc_url( bp_get_group_permalink( $group ) ),
     1008                                esc_html( bp_get_group_name( $group ) )
     1009                        );
     1010
     1011                        /**
     1012                         * Filters the html version of the permalink for the current group in the loop.
     1013                         *
     1014                         * @since 2.9.0
     1015                         *
     1016                         * @param string $value HTML permalink for the current group in the loop.
     1017                         * @param object $group Group object.
     1018                         */
     1019                        $permalink = apply_filters( 'bp_get_group_permalink_html', $permalink, $group );
     1020                }
     1021
     1022                return $permalink;
    9951023        }
    9961024
    9971025/**