Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/07/2017 07:05:55 PM (9 years ago)
Author:
dcavins
Message:

Introduce new template function bp_group_link().

This new template function outputs a group’s name as a text hyperlink
to a group’s home page.

Props hnla, dcavins.

Fixes #7485.

File:
1 edited

Legend:

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

    r11447 r11527  
    996996
    997997/**
     998 * Output an HTML-formatted link for the current group in the loop.
     999 *
     1000 * @since 2.9.0
     1001 *
     1002 * @param BP_Groups_Group|null $group Optional. Group object.
     1003 *                                    Default: current group in loop.
     1004 */
     1005function bp_group_link( $group = null ) {
     1006        echo bp_get_group_link( $group );
     1007}
     1008        /**
     1009         * Return an HTML-formatted link for the current group in the loop.
     1010         *
     1011         * @since 2.9.0
     1012         *
     1013         * @param BP_Groups_Group|null $group Optional. Group object.
     1014         *                                    Default: current group in loop.
     1015         * @return string
     1016         */
     1017        function bp_get_group_link( $group = null ) {
     1018                global $groups_template;
     1019
     1020                if ( empty( $group ) ) {
     1021                        $group =& $groups_template->group;
     1022                }
     1023
     1024                $link = sprintf(
     1025                        '<a href="%s" class="bp-group-home-link %s-home-link">%s</a>',
     1026                        esc_url( bp_get_group_permalink( $group ) ),
     1027                        esc_attr( bp_get_group_slug( $group ) ),
     1028                        esc_html( bp_get_group_name( $group ) )
     1029                );
     1030
     1031                /**
     1032                 * Filters the HTML-formatted link for the current group in the loop.
     1033                 *
     1034                 * @since 2.9.0
     1035                 *
     1036                 * @param string          $value HTML-formatted link for the
     1037                 *                               current group in the loop.
     1038                 * @param BP_Groups_Group $group The current group object.
     1039                 */
     1040                return apply_filters( 'bp_get_group_link', $link, $group );
     1041        }
     1042
     1043/**
    9981044 * Output the permalink for the admin section of the current group in the loop.
    9991045 *
Note: See TracChangeset for help on using the changeset viewer.