Changeset 13097
- Timestamp:
- 08/26/2021 01:29:03 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r13085 r13097 897 897 // translators: %1$s is the name of the group. 898 898 'alt' => sprintf( __( 'Group logo of %1$s', 'buddypress' ), $group->name ), 899 ) 899 ), 900 'get_group_avatar' 900 901 ); 901 902 … … 1018 1019 * 1019 1020 * @since 5.0.0 1020 * @since 10.0.0 Updated to use `bp_get_group_avatar` 1021 * @since 10.0.0 Updated to use `bp_get_group_avatar`. 1021 1022 * 1022 1023 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. … … 1112 1113 } 1113 1114 1114 $r = bp_parse_args( $args, array( 1115 'relative' => true, 1116 ), 'group_last_active' ); 1115 $r = bp_parse_args( 1116 $args, 1117 array( 1118 'relative' => true, 1119 ), 1120 'group_last_active' 1121 ); 1117 1122 1118 1123 $last_active = $group->last_activity; … … 1137 1142 * @since 2.5.0 Added the `$group` parameter. 1138 1143 * 1139 * @param string 1140 * @param BP_Groups_Group |null$group The group object.1144 * @param string $value Determined last active value for the current group. 1145 * @param BP_Groups_Group $group The group object. 1141 1146 */ 1142 1147 return apply_filters( 'bp_get_group_last_active', bp_core_time_since( $last_active ), $group ); … … 1648 1653 1649 1654 /** 1650 * Output the avatar of the creator of the current group in the loop.1655 * Output the avatar of the creator of the group. 1651 1656 * 1652 1657 * @since 1.7.0 1653 1658 * 1654 * @param object|bool $group Optional.Group object.1655 * Default: current group in loop.1656 * @param array $args{1659 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1660 * Default: false. 1661 * @param array $args { 1657 1662 * Array of optional arguments. See {@link bp_get_group_creator_avatar()} 1658 1663 * for description. … … 1663 1668 } 1664 1669 /** 1665 * Return the avatar of the creator of the current group in the loop.1670 * Return the avatar of the creator of the group. 1666 1671 * 1667 1672 * @since 1.7.0 1668 * 1669 * @param object|bool $group Optional. Group object. 1670 * Default: current group in loop. 1671 * @param array $args { 1673 * @since 10.0.0 Updated to use `bp_get_group`. 1674 * 1675 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1676 * Default: false. 1677 * @param array $args { 1672 1678 * Array of optional arguments. See {@link bp_core_fetch_avatar()} 1673 1679 * for detailed description of arguments. … … 1683 1689 */ 1684 1690 function bp_get_group_creator_avatar( $group = false, $args = array() ) { 1685 global $groups_template; 1686 1687 if ( empty( $group ) ) { 1688 $group =& $groups_template->group; 1689 } 1690 1691 $r = bp_parse_args( $args, array( 1692 'type' => 'full', 1693 'width' => false, 1694 'height' => false, 1695 'class' => 'avatar', 1696 'id' => false, 1697 'alt' => sprintf( 1698 /* translators: %s: group creator name */ 1699 __( 'Group creator profile photo of %s', 'buddypress' ), 1700 bp_core_get_user_displayname( $group->creator_id ) 1691 $group = bp_get_group( $group ); 1692 1693 if ( empty( $group->id ) ) { 1694 return ''; 1695 } 1696 1697 $r = bp_parse_args( 1698 $args, 1699 array( 1700 'type' => 'full', 1701 'width' => false, 1702 'height' => false, 1703 'class' => 'avatar', 1704 'id' => false, 1705 'alt' => sprintf( 1706 /* translators: %s: group creator name */ 1707 __( 'Group creator profile photo of %s', 'buddypress' ), 1708 bp_core_get_user_displayname( $group->creator_id ) 1709 ), 1701 1710 ), 1702 ), 'group_creator_avatar' ); 1703 extract( $r, EXTR_SKIP ); 1704 1705 $avatar = bp_core_fetch_avatar( array( 'item_id' => $group->creator_id, 'type' => $type, 'css_id' => $id, 'class' => $class, 'width' => $width, 'height' => $height, 'alt' => $alt ) ); 1706 1707 /** 1708 * Filters the avatar of the creator of the current group in the loop. 1711 'group_creator_avatar' 1712 ); 1713 1714 $avatar = bp_core_fetch_avatar( 1715 array( 1716 'item_id' => $group->creator_id, 1717 'type' => $r['type'], 1718 'css_id' => $r['id'], 1719 'class' => $r['class'], 1720 'width' => $r['width'], 1721 'height' => $r['height'], 1722 'alt' => $r['alt'], 1723 ) 1724 ); 1725 1726 /** 1727 * Filters the avatar of the creator of the group. 1709 1728 * 1710 1729 * @since 1.7.0 1711 * @since 2.5.0 Added the `$group` parameter. 1712 * 1713 * @param string $avatar Avatar of the group creator. 1714 * @param object $group Group object. 1715 */ 1716 return apply_filters( 'bp_get_group_creator_avatar', $avatar, $group ); 1730 * @since 2.5.0 Added the `$group` parameter. 1731 * @since 10.0.0 Added the `$r` parameter. 1732 * 1733 * @param string $avatar Avatar of the group creator. 1734 * @param BP_Groups_Group $group The group object. 1735 * @param array $r Array of parsed arguments for the group creator avatar. 1736 */ 1737 return apply_filters( 'bp_get_group_creator_avatar', $avatar, $group, $r ); 1717 1738 } 1718 1739 … … 1747 1768 * 1748 1769 * @since 1.0.0 1749 * 1750 * @param object|bool $group Optional. Group object. 1751 * Default: current group in loop. 1770 * @since 10.0.0 Updated to use `bp_get_group`. 1771 * 1772 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1773 * Default: false. 1752 1774 */ 1753 1775 function bp_group_list_admins( $group = false ) { 1754 global $groups_template; 1755 1756 if ( empty( $group ) ) { 1757 $group =& $groups_template->group; 1758 } 1776 $group = bp_get_group( $group ); 1759 1777 1760 1778 if ( ! empty( $group->admins ) ) { ?> 1761 1779 <ul id="group-admins"> 1762 <?php foreach ( (array) $group->admins as $admin ) { ?>1780 <?php foreach ( (array) $group->admins as $admin ) { ?> 1763 1781 <li> 1764 <a href="<?php echo bp_core_get_user_domain( $admin->user_id, $admin->user_nicename, $admin->user_login ) ?>" class="bp-tooltip" data-bp-tooltip="<?php printf( ('%s'), bp_core_get_user_displayname( $admin->user_id ) ); ?>"> 1782 <a 1783 href="<?php echo esc_url( bp_core_get_user_domain( $admin->user_id, $admin->user_nicename, $admin->user_login ) ); ?>" 1784 class="bp-tooltip" 1785 data-bp-tooltip="<?php printf( ( '%s' ), bp_core_get_user_displayname( $admin->user_id ) ); ?>" 1786 > 1765 1787 <?php 1766 1788 echo bp_core_fetch_avatar( … … 1781 1803 </ul> 1782 1804 <?php } else { ?> 1783 <span class="activity"><?php _e( 'No Admins', 'buddypress' ) ?></span> 1805 <span class="activity"> 1806 <?php esc_html_e( 'No Admins', 'buddypress' ); ?> 1807 </span> 1784 1808 <?php } ?> 1785 <?php1809 <?php 1786 1810 } 1787 1811 … … 1790 1814 * 1791 1815 * @since 1.0.0 1792 * 1793 * @param object|bool $group Optional. Group object. 1794 * Default: current group in loop. 1816 * @since 10.0.0 Updated to use `bp_get_group`. 1817 * 1818 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1819 * Default: false. 1795 1820 */ 1796 1821 function bp_group_list_mods( $group = false ) { 1797 global $groups_template; 1798 1799 if ( empty( $group ) ) { 1800 $group =& $groups_template->group; 1801 } 1802 1803 if ( ! empty( $group->mods ) ) : ?> 1804 1822 $group = bp_get_group( $group ); 1823 1824 if ( ! empty( $group->mods ) ) : 1825 ?> 1805 1826 <ul id="group-mods"> 1806 1807 <?php foreach( (array) $group->mods as $mod ) { ?> 1808 1827 <?php foreach ( (array) $group->mods as $mod ) { ?> 1809 1828 <li> 1810 <a href="<?php echo bp_core_get_user_domain( $mod->user_id, $mod->user_nicename, $mod->user_login ) ?>" class="bp-tooltip" data-bp-tooltip="<?php printf( ('%s'), bp_core_get_user_displayname( $mod->user_id ) ); ?>"> 1829 <a 1830 href="<?php echo esc_url( bp_core_get_user_domain( $mod->user_id, $mod->user_nicename, $mod->user_login ) ); ?>" 1831 class="bp-tooltip" 1832 data-bp-tooltip="<?php printf( ( '%s' ), bp_core_get_user_displayname( $mod->user_id ) ); ?>"> 1811 1833 <?php 1812 1834 echo bp_core_fetch_avatar( … … 1820 1842 ), 1821 1843 ) 1822 ); ?> 1844 ); 1845 ?> 1823 1846 </a> 1824 1847 </li> 1825 1826 1848 <?php } ?> 1827 1828 1849 </ul> 1829 1830 <?php else : ?> 1831 1832 <span class="activity"><?php _e( 'No Mods', 'buddypress' ) ?></span> 1833 1834 <?php endif; 1835 1850 <?php else : ?> 1851 <span class="activity"> 1852 <?php esc_html_e( 'No Mods', 'buddypress' ); ?> 1853 </span> 1854 <?php 1855 endif; 1836 1856 } 1837 1857 … … 1840 1860 * 1841 1861 * @since 1.5.0 1842 * 1843 * @param BP_Groups_Group|bool $group Optional. The group being queried. Defaults 1844 * to the current group in the loop. 1845 * @param string $format Optional. 'string' to get a comma-separated string, 1846 * 'array' to get an array. 1847 * @return mixed $admin_ids A string or array of user IDs. 1862 * @since 10.0.0 Updated to use `bp_get_group`. 1863 * 1864 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1865 * Default: false. 1866 * @param string $format (Optional) 'string' to get a comma-separated string, 1867 * 'array' to get an array. 1868 * @return string|array|false A string or an array of user IDs, false if group does not exist. 1848 1869 */ 1849 1870 function bp_group_admin_ids( $group = false, $format = 'string' ) { 1850 global $groups_template;1851 1852 if ( empty( $group ) ) {1853 $group =& $groups_template->group;1871 $group = bp_get_group( $group ); 1872 1873 if ( empty( $group->id ) ) { 1874 return false; 1854 1875 } 1855 1876 1856 1877 $admin_ids = array(); 1857 1878 1858 if ( $group->admins) {1859 foreach ( $group->admins as $admin ) {1879 if ( ! empty( $group->admins ) ) { 1880 foreach ( $group->admins as $admin ) { 1860 1881 $admin_ids[] = $admin->user_id; 1861 1882 } 1862 1883 } 1863 1884 1864 if ( 'string' == $format ) {1885 if ( 'string' == $format && ! empty( $admin_ids ) ) { 1865 1886 $admin_ids = implode( ',', $admin_ids ); 1866 1887 } … … 1872 1893 * 1873 1894 * @since 1.5.0 1874 * @since 2.5.0 Added the `$group` parameter. 1875 * 1876 * @param array|string $admin_ids List of user IDs for a group's admins. 1877 * @param object $group Group object. 1878 */ 1879 return apply_filters( 'bp_group_admin_ids', $admin_ids, $group ); 1895 * @since 2.5.0 Added the `$group` parameter. 1896 * @since 10.0.0 Added the `$format` parameter. 1897 * 1898 * @param array|string $admin_ids List of user IDs for a group's admins. 1899 * @param BP_Groups_Group $group The group object. 1900 * @param string $format The filter used to format the results. 1901 */ 1902 return apply_filters( 'bp_group_admin_ids', $admin_ids, $group, $format ); 1880 1903 } 1881 1904 … … 1884 1907 * 1885 1908 * @since 1.5.0 1886 * 1887 * @param BP_Groups_Group|bool $group Optional. The group being queried. 1888 * Defaults to the current group in the loop. 1889 * @param string $format Optional. 'string' to get a comma-separated string, 1890 * 'array' to get an array. 1891 * @return mixed $mod_ids A string or array of user IDs. 1909 * @since 10.0.0 Updated to use `bp_get_group`. 1910 * 1911 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1912 * Default: false. 1913 * @param string $format (Optional) 'string' to get a comma-separated string, 1914 * 'array' to get an array. 1915 * @return string|array|false A string or an array of user IDs, false if group does not exist. 1892 1916 */ 1893 1917 function bp_group_mod_ids( $group = false, $format = 'string' ) { 1894 global $groups_template;1895 1896 if ( empty( $group ) ) {1897 $group =& $groups_template->group;1918 $group = bp_get_group( $group ); 1919 1920 if ( empty( $group->id ) ) { 1921 return false; 1898 1922 } 1899 1923 1900 1924 $mod_ids = array(); 1901 1925 1902 if ( $group->mods) {1903 foreach ( $group->mods as $mod ) {1926 if ( ! empty( $group->mods ) ) { 1927 foreach ( $group->mods as $mod ) { 1904 1928 $mod_ids[] = $mod->user_id; 1905 1929 } 1906 1930 } 1907 1931 1908 if ( 'string' == $format ) {1932 if ( 'string' == $format && ! empty( $mod_ids ) ) { 1909 1933 $mod_ids = implode( ',', $mod_ids ); 1910 1934 } … … 1916 1940 * 1917 1941 * @since 1.5.0 1918 * @since 2.5.0 Added the `$group` parameter. 1919 * 1920 * @param array|string $admin_ids List of user IDs for a group's moderators. 1921 * @param object $group Group object. 1922 */ 1923 return apply_filters( 'bp_group_mod_ids', $mod_ids, $group ); 1924 } 1925 1926 /** 1927 * Output the permalink of the current group's Members page. 1928 * 1929 * @since 1.0.0 1930 */ 1931 function bp_group_all_members_permalink() { 1932 echo bp_get_group_all_members_permalink(); 1933 } 1934 /** 1935 * Return the permalink of the Members page of the current group in the loop. 1942 * @since 2.5.0 Added the `$group` parameter. 1943 * @since 10.0.0 Added the `$format` parameter. 1944 * 1945 * @param array|string $mod_ids List of user IDs for a group's moderators. 1946 * @param BP_Groups_Group $group The group object. 1947 * @param string $format The filter used to format the results. 1948 */ 1949 return apply_filters( 'bp_group_mod_ids', $mod_ids, $group, $format ); 1950 } 1951 1952 /** 1953 * Output the permalink of a group's Members page. 1954 * 1955 * @since 1.0.0 1956 * @since 10.0.0 Added the `$group` parameter. 1957 * 1958 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1959 * Default: false. 1960 */ 1961 function bp_group_all_members_permalink( $group = false ) { 1962 echo bp_get_group_all_members_permalink( $group ); 1963 } 1964 /** 1965 * Return the permalink of the Members page of a group. 1936 1966 * 1937 1967 * @since 1.0.0 1938 * 1939 * @param object|bool $group Optional. Group object. 1940 * Default: current group in loop. 1968 * @since 10.0.0 Updated to use `bp_get_group`. 1969 * 1970 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 1971 * Default: false. 1941 1972 * @return string 1942 1973 */ 1943 1974 function bp_get_group_all_members_permalink( $group = false ) { 1944 global $groups_template;1945 1946 if ( empty( $group ) ) {1947 $group =& $groups_template->group;1948 } 1949 1950 /** 1951 * Filters the permalink of the Members page for the current group in the loop.1975 $group = bp_get_group( $group ); 1976 1977 if ( empty( $group->id ) ) { 1978 return ''; 1979 } 1980 1981 /** 1982 * Filters the permalink of the Members page for a group. 1952 1983 * 1953 1984 * @since 1.0.0 1954 1985 * @since 2.5.0 Added the `$group` parameter. 1955 1986 * 1956 * @param string $value Permalink of the Members page for the currentgroup.1957 * @param object $group Group object.1987 * @param string $value Permalink of the Members page for a group. 1988 * @param BP_Groups_Group $group The group object. 1958 1989 */ 1959 1990 return apply_filters( 'bp_get_group_all_members_permalink', trailingslashit( bp_get_group_permalink( $group ) . 'members' ), $group ); … … 2116 2147 * @since 1.0.0 2117 2148 * 2118 * @param object|bool $group Optional. Group object. Default: current group in loop. 2149 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2150 * Default: false. 2119 2151 */ 2120 2152 function bp_group_total_members( $group = false ) { … … 2126 2158 * @since 1.0.0 2127 2159 * 2128 * @param object|bool $group Optional.Group object.2129 * Default: current group in loop.2160 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2161 * Default: false. 2130 2162 * @return int 2131 2163 */ 2132 2164 function bp_get_group_total_members( $group = false ) { 2133 global $groups_template;2134 2135 if ( empty( $group ) ) {2136 $group =& $groups_template->group;2165 $group = bp_get_group( $group ); 2166 2167 if ( empty( $group->id ) ) { 2168 return 0; 2137 2169 } 2138 2170 … … 2143 2175 * @since 2.5.0 Added the `$group` parameter. 2144 2176 * 2145 * @param int $total_member_count Total member count for a group.2146 * @param object $group Group object.2147 */ 2148 return apply_filters( 'bp_get_group_total_members', $group->total_member_count, $group );2177 * @param int $total_member_count Total member count for a group. 2178 * @param BP_Groups_Group $group The group object. 2179 */ 2180 return apply_filters( 'bp_get_group_total_members', (int) $group->total_member_count, $group ); 2149 2181 } 2150 2182 … … 2155 2187 * @since 7.0.0 Adds the `$group` optional parameter. 2156 2188 * 2157 * @param object|bool $group Optional. Group object. Default: current group in loop. 2189 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2190 * Default: false. 2158 2191 */ 2159 2192 function bp_group_member_count( $group = false ) { … … 2164 2197 * 2165 2198 * @since 1.2.0 2166 * 2167 * @since 7.0.0 Adds the `$group` optional parameter. 2168 * 2169 * @param object|bool $group Optional. Group object. Default: current group in loop. 2199 * @since 7.0.0 Adds the `$group` optional parameter. 2200 * @since 10.0.0 Updated to use `bp_get_group`. 2201 * 2202 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2203 * Default: false. 2170 2204 * @return string 2171 2205 */ 2172 2206 function bp_get_group_member_count( $group = false ) { 2173 global $groups_template; 2174 2175 if ( isset( $group->total_member_count ) ) { 2176 $count = (int) $group->total_member_count; 2177 } elseif ( isset( $groups_template->group->total_member_count ) ) { 2178 $count = (int) $groups_template->group->total_member_count; 2179 } else { 2180 $count = 0; 2181 } 2182 2183 $count_string = sprintf( _n( '%s member', '%s members', $count, 'buddypress' ), bp_core_number_format( $count ) ); 2207 $group = bp_get_group( $group ); 2208 2209 if ( empty( $group->id ) ) { 2210 return ''; 2211 } 2212 2213 $count = (int) $group->total_member_count; 2214 $count_string = sprintf( 2215 // translators: %s: total member count for the group. 2216 _n( '%s member', '%s members', $count, 'buddypress' ), 2217 bp_core_number_format( $count ) 2218 ); 2184 2219 2185 2220 /** … … 2187 2222 * 2188 2223 * @since 1.2.0 2189 * 2190 * @param string $count_string The "x members" count string for a group. 2191 */ 2192 return apply_filters( 'bp_get_group_member_count', $count_string ); 2193 } 2194 2195 /** 2196 * Output the URL of the Forum page of the current group in the loop. 2197 * 2198 * @since 1.0.0 2199 */ 2200 function bp_group_forum_permalink() { 2201 echo bp_get_group_forum_permalink(); 2224 * @since 10.0.0 Added the `$group` paremeter. 2225 * 2226 * @param string $count_string The "x members" count string for a group. 2227 * @param BP_Groups_Group $group The group object. 2228 */ 2229 return apply_filters( 'bp_get_group_member_count', $count_string, $group ); 2230 } 2231 2232 /** 2233 * Output the URL of the Forum page of a group. 2234 * 2235 * @since 1.0.0 2236 * @since 10.0.0 Adds the `$group` optional parameter. 2237 * 2238 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2239 * Default: false. 2240 */ 2241 function bp_group_forum_permalink( $group = false ) { 2242 echo bp_get_group_forum_permalink( $group ); 2202 2243 } 2203 2244 /** … … 2205 2246 * 2206 2247 * @since 1.0.0 2207 * 2208 * @param object|bool $group Optional. Group object. 2209 * Default: current group in loop. 2248 * @since 10.0.0 Updated to use `bp_get_group`. 2249 * 2250 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2251 * Default: false. 2210 2252 * @return string 2211 2253 */ 2212 2254 function bp_get_group_forum_permalink( $group = false ) { 2213 global $groups_template;2214 2215 if ( empty( $group ) ) {2216 $group =& $groups_template->group;2255 $group = bp_get_group( $group ); 2256 2257 if ( empty( $group->id ) ) { 2258 return ''; 2217 2259 } 2218 2260 … … 2223 2265 * @since 2.5.0 Added the `$group` parameter. 2224 2266 * 2225 * @param string $value URL permalink for the Forum Page.2226 * @param object $group Group object.2267 * @param string $value URL permalink for the Forum Page. 2268 * @param BP_Groups_Group $group The group object. 2227 2269 */ 2228 2270 return apply_filters( 'bp_get_group_forum_permalink', trailingslashit( bp_get_group_permalink( $group ) . 'forum' ), $group ); … … 2233 2275 * 2234 2276 * @since 1.0.0 2235 * 2236 * @param object|bool $group Optional. Group object. Default: current group in loop. 2277 * @since 10.0.0 Updated to use `bp_get_group`. 2278 * 2279 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2280 * Default: false. 2237 2281 * @return bool 2238 2282 */ 2239 2283 function bp_group_is_forum_enabled( $group = false ) { 2240 global $groups_template; 2241 2242 if ( empty( $group ) ) { 2243 $group =& $groups_template->group; 2244 } 2245 2246 if ( ! empty( $group->enable_forum ) ) { 2247 return true; 2248 } 2249 2250 return false; 2284 $group = bp_get_group( $group ); 2285 2286 return ! empty( $group->enable_forum ); 2251 2287 } 2252 2288 … … 2255 2291 * 2256 2292 * @since 1.0.0 2257 * 2258 * @param object|bool $group Optional. Group object. Default: current group in loop. 2293 * @since 10.0.0 Updated to use `bp_group_is_forum_enabled`. 2294 * 2295 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2296 * Default: false. 2259 2297 */ 2260 2298 function bp_group_show_forum_setting( $group = false ) { 2261 global $groups_template; 2262 2263 if ( empty( $group ) ) { 2264 $group =& $groups_template->group; 2265 } 2266 2267 if ( $group->enable_forum ) { 2299 if ( bp_group_is_forum_enabled( $group ) ) { 2268 2300 echo ' checked="checked"'; 2269 2301 } … … 2274 2306 * 2275 2307 * @since 1.0.0 2276 * 2277 * @param string $setting Group status. 'public', 'private', 'hidden'. 2278 * @param object|bool $group Optional. Group object. Default: current group in loop. 2308 * @since 10.0.0 Updated to use `bp_get_group`. 2309 * 2310 * @param string $setting Group status: 'public', 'private', 'hidden'. 2311 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2312 * Default: false. 2279 2313 */ 2280 2314 function bp_group_show_status_setting( $setting, $group = false ) { 2281 global $groups_template; 2282 2283 if ( empty( $group ) ) { 2284 $group =& $groups_template->group; 2285 } 2286 2287 if ( $setting == $group->status ) { 2315 $group = bp_get_group( $group ); 2316 2317 if ( ! empty( $group->status ) && $setting === $group->status ) { 2288 2318 echo ' checked="checked"'; 2289 2319 } … … 2295 2325 * @since 1.5.0 2296 2326 * 2297 * @param string $setting The setting you want to check against ('members',2298 * 'mods', or 'admins').2299 * @param object|bool $group Optional. Group object. Default: current group in loop.2327 * @param string $setting The setting you want to check against ('members', 'mods', or 'admins'). 2328 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2329 * Default: false. 2300 2330 */ 2301 2331 function bp_group_show_invite_status_setting( $setting, $group = false ) { 2302 $group_id = isset( $group->id ) ? $group->id : false; 2303 2304 $invite_status = bp_group_get_invite_status( $group_id ); 2305 2306 if ( $setting == $invite_status ) { 2332 $invite_status = bp_group_get_invite_status( $group ); 2333 2334 if ( ! empty( $invite_status ) && $setting === $invite_status ) { 2307 2335 echo ' checked="checked"'; 2308 2336 } … … 2321 2349 * 2322 2350 * @since 1.5.0 2323 * 2324 * @param int|bool $group_id Optional. The ID of the group whose status you want to2325 * check. Default: the displayed group, or the current group2326 * in the loop.2351 * @since 10.0.0 Updated to use `bp_get_group`. 2352 * 2353 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2354 * Default: false. 2327 2355 * @return bool|string Returns false when no group can be found. Otherwise 2328 2356 * returns the group invite status, from among 'members', 2329 2357 * 'mods', and 'admins'. 2330 2358 */ 2331 function bp_group_get_invite_status( $group _id= false ) {2332 global $groups_template;2333 2334 if ( !$group_id) {2359 function bp_group_get_invite_status( $group = false ) { 2360 $group = bp_get_group( $group ); 2361 2362 if ( empty( $group->id ) ) { 2335 2363 $bp = buddypress(); 2336 2364 2337 if ( isset( $bp->groups->current_group->id ) ) { 2338 // Default to the current group first. 2339 $group_id = $bp->groups->current_group->id; 2340 } elseif ( isset( $groups_template->group->id ) ) { 2341 // Then see if we're in the loop. 2342 $group_id = $groups_template->group->id; 2365 // Default to the current group first. 2366 if ( ! empty( $bp->groups->current_group->id ) ) { 2367 $group = $bp->groups->current_group; 2343 2368 } else { 2344 2369 return false; … … 2346 2371 } 2347 2372 2348 $invite_status = groups_get_groupmeta( $group _id, 'invite_status' );2373 $invite_status = groups_get_groupmeta( $group->id, 'invite_status' ); 2349 2374 2350 2375 // Backward compatibility. When 'invite_status' is not set, fall back to a default value. 2351 if ( ! $invite_status ) {2376 if ( ! $invite_status ) { 2352 2377 $invite_status = apply_filters( 'bp_group_invite_status_fallback', 'members' ); 2353 2378 } … … 2359 2384 * 2360 2385 * @since 1.5.0 2361 * 2362 * @param string $invite_status Membership level needed to send an invite. 2363 * @param int $group_id ID of the group whose status is being checked. 2364 */ 2365 return apply_filters( 'bp_group_get_invite_status', $invite_status, $group_id ); 2386 * @since 10.0.0 Added the `$group` paremeter. 2387 * 2388 * @param string $invite_status Membership level needed to send an invite. 2389 * @param int $group_id ID of the group whose status is being checked. 2390 * @param BP_Groups_Group $group The group object. 2391 */ 2392 return apply_filters( 'bp_group_get_invite_status', $invite_status, $group->id, $group ); 2366 2393 } 2367 2394 … … 2627 2654 * 2628 2655 * @since 1.0.0 2629 * 2630 * @param object|bool $group Optional. Group object. Default: current group in loop. 2656 * @since 10.0.0 Updated to use `bp_get_group`. 2657 * 2658 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2659 * Default: false. 2631 2660 * @return array Info about group admins (user_id + date_modified). 2632 2661 */ 2633 2662 function bp_group_has_moderators( $group = false ) { 2634 global $groups_template;2635 2636 if ( empty( $group ) ) {2637 $group =& $groups_template->group;2663 $group = bp_get_group( $group ); 2664 2665 if ( empty( $group->id ) ) { 2666 return array(); 2638 2667 } 2639 2668 … … 2644 2673 * @since 2.5.0 Added the `$group` parameter. 2645 2674 * 2646 * @param array $value Array of user IDs who are a moderator of the provided group.2647 * @param object $group Group object.2675 * @param array $value Array of user IDs who are a moderator of the provided group. 2676 * @param BP_Groups_Group $group The group object. 2648 2677 */ 2649 2678 return apply_filters( 'bp_group_has_moderators', groups_get_group_mods( $group->id ), $group ); … … 2736 2765 * 2737 2766 * @since 1.0.0 2738 * 2739 * @param int $user_id ID of the member to demote. Default: current member in 2740 * a member loop. 2741 */ 2742 function bp_group_member_demote_link( $user_id = 0 ) { 2743 global $members_template; 2744 2745 if ( !$user_id ) { 2746 $user_id = $members_template->member->user_id; 2747 } 2748 2749 echo bp_get_group_member_demote_link( $user_id ); 2767 * @since 10.0.0 Added the `$group` paremeter. 2768 * 2769 * @param int $user_id ID of the member to demote. Default: 0. 2770 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2771 * Default: false. 2772 */ 2773 function bp_group_member_demote_link( $user_id = 0, $group = false ) { 2774 echo bp_get_group_member_demote_link( $user_id, $group ); 2750 2775 } 2751 2776 /** … … 2753 2778 * 2754 2779 * @since 1.0.0 2755 * 2756 * @param int $user_id ID of the member to demote. Default: current 2757 * member in a member loop. 2758 * @param object|bool $group Optional. Group object. Default: current group. 2780 * @since 10.0.0 Updated to use `bp_get_group`. 2781 * 2782 * @param int $user_id ID of the member to demote. Default: 0. 2783 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2784 * Default: false. 2759 2785 * @return string 2760 2786 */ 2761 2787 function bp_get_group_member_demote_link( $user_id = 0, $group = false ) { 2762 global $members_template, $groups_template; 2763 2764 if ( empty( $group ) ) { 2765 $group =& $groups_template->group; 2766 } 2767 2768 if ( !$user_id ) { 2788 global $members_template; 2789 2790 $group = bp_get_group( $group ); 2791 2792 if ( empty( $group->id ) ) { 2793 return ''; 2794 } 2795 2796 if ( ! $user_id ) { 2769 2797 $user_id = $members_template->member->user_id; 2770 2798 } … … 2774 2802 * 2775 2803 * @since 1.0.0 2776 * @since 2.5.0 Added the `$group` parameter. 2777 * 2778 * @param string $value URL to use for demoting a user to member. 2779 * @param object $group Group object. 2780 */ 2781 return apply_filters( 'bp_get_group_member_demote_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/demote/' . $user_id ), 'groups_demote_member' ), $group ); 2804 * @since 2.5.0 Added the `$group` parameter. 2805 * @since 10.0.0 Added the `$user_id` parameter. 2806 * 2807 * @param string $value URL to use for demoting a user to member. 2808 * @param BP_Groups_Group $group The group object. 2809 * @param int $user_id The user ID. 2810 */ 2811 return apply_filters( 2812 'bp_get_group_member_demote_link', 2813 wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/demote/' . $user_id ), 'groups_demote_member' ), 2814 $group, 2815 $user_id 2816 ); 2782 2817 } 2783 2818 … … 2786 2821 * 2787 2822 * @since 1.0.0 2788 * 2789 * @param int $user_id ID of the member to ban. 2790 * Default: current member in a member loop. 2791 */ 2792 function bp_group_member_ban_link( $user_id = 0 ) { 2793 global $members_template; 2794 2795 if ( !$user_id ) { 2796 $user_id = $members_template->member->user_id; 2797 } 2798 2799 echo bp_get_group_member_ban_link( $user_id ); 2823 * @since 10.0.0 Added the `$group` paremeter. 2824 * 2825 * @param int $user_id ID of the member. Default: 0. 2826 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2827 * Default: false. 2828 */ 2829 function bp_group_member_ban_link( $user_id = 0, $group = false ) { 2830 echo bp_get_group_member_ban_link( $user_id, $group ); 2800 2831 } 2801 2832 /** … … 2803 2834 * 2804 2835 * @since 1.0.0 2805 * 2806 * @param int $user_id ID of the member to ban. 2807 * Default: current member in a member loop. 2808 * @param object|bool $group Optional. Group object. Default: current group. 2836 * @since 10.0.0 Updated to use `bp_get_group`. 2837 * 2838 * @param int $user_id ID of the member to ban. Default: 0. 2839 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2840 * Default: false. 2809 2841 * @return string 2810 2842 */ 2811 2843 function bp_get_group_member_ban_link( $user_id = 0, $group = false ) { 2812 global $groups_template; 2813 2814 if ( empty( $group ) ) { 2815 $group =& $groups_template->group; 2844 global $members_template; 2845 2846 $group = bp_get_group( $group ); 2847 2848 if ( empty( $group->id ) ) { 2849 return ''; 2850 } 2851 2852 if ( ! $user_id ) { 2853 $user_id = $members_template->member->user_id; 2816 2854 } 2817 2855 … … 2820 2858 * 2821 2859 * @since 1.0.0 2822 * 2823 * @param string $value URL to use for banning a member. 2824 */ 2825 return apply_filters( 'bp_get_group_member_ban_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/ban/' . $user_id ), 'groups_ban_member' ) ); 2860 * @since 10.0.0 Added the `$group`and `$user_id` parameter. 2861 * 2862 * @param string $value URL to use for banning a member. 2863 * @param BP_Groups_Group $group The group object. 2864 * @param int $user_id The user ID. 2865 */ 2866 return apply_filters( 2867 'bp_get_group_member_ban_link', 2868 wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/ban/' . $user_id ), 'groups_ban_member' ), 2869 $group, 2870 $user_id 2871 ); 2826 2872 } 2827 2873 … … 2830 2876 * 2831 2877 * @since 1.0.0 2832 * 2833 * @param int $user_id ID of the member to unban. 2834 * Default: current member in a member loop. 2835 */ 2836 function bp_group_member_unban_link( $user_id = 0 ) { 2837 global $members_template; 2838 2839 if ( !$user_id ) { 2840 $user_id = $members_template->member->user_id; 2841 } 2842 2843 echo bp_get_group_member_unban_link( $user_id ); 2878 * @since 10.0.0 Added the `$group` paremeter. 2879 * 2880 * @param int $user_id ID of the member to unban. Default: 0. 2881 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2882 * Default: false. 2883 */ 2884 function bp_group_member_unban_link( $user_id = 0, $group = false ) { 2885 echo bp_get_group_member_unban_link( $user_id, $group ); 2844 2886 } 2845 2887 /** … … 2847 2889 * 2848 2890 * @since 1.0.0 2849 * 2850 * @param int $user_id ID of the member to unban. 2851 * Default: current member in a member loop. 2852 * @param object|bool $group Optional. Group object. Default: current group. 2891 * @since 10.0.0 Updated to use `bp_get_group`. 2892 * 2893 * @param int $user_id ID of the member to unban. Default: 0. 2894 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2895 * Default: false. 2853 2896 * @return string 2854 2897 */ 2855 2898 function bp_get_group_member_unban_link( $user_id = 0, $group = false ) { 2856 global $members_template, $groups_template; 2857 2858 if ( !$user_id ) { 2899 global $members_template; 2900 2901 $group = bp_get_group( $group ); 2902 2903 if ( empty( $group->id ) ) { 2904 return ''; 2905 } 2906 2907 if ( ! $user_id ) { 2859 2908 $user_id = $members_template->member->user_id; 2860 2909 } 2861 2910 2862 if ( empty( $group ) ) {2863 $group =& $groups_template->group;2864 }2865 2866 2911 /** 2867 2912 * Filters a URL for unbanning a member from a group. 2868 2913 * 2869 2914 * @since 1.0.0 2870 * 2871 * @param string $value URL to use for unbanning a member. 2872 */ 2873 return apply_filters( 'bp_get_group_member_unban_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id ), 'groups_unban_member' ) ); 2915 * @since 10.0.0 Added the `$group`and `$user_id` parameter. 2916 * 2917 * @param string $value URL to use for unbanning a member. 2918 * @param BP_Groups_Group $group The group object. 2919 * @param int $user_id The user ID. 2920 */ 2921 return apply_filters( 2922 'bp_get_group_member_unban_link', 2923 wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/unban/' . $user_id ), 'groups_unban_member' ), 2924 $group, 2925 $user_id 2926 ); 2874 2927 } 2875 2928 … … 2878 2931 * 2879 2932 * @since 1.2.6 2880 * 2881 * @param int $user_id ID of the member to remove. 2882 * Default: current member in a member loop. 2883 */ 2884 function bp_group_member_remove_link( $user_id = 0 ) { 2885 global $members_template; 2886 2887 if ( !$user_id ) { 2888 $user_id = $members_template->member->user_id; 2889 } 2890 2891 echo bp_get_group_member_remove_link( $user_id ); 2933 * @since 10.0.0 Added the `$group` paremeter. 2934 * 2935 * @param int $user_id ID of the member to remove. Default: 0. 2936 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2937 * Default: false. 2938 */ 2939 function bp_group_member_remove_link( $user_id = 0, $group = false ) { 2940 echo bp_get_group_member_remove_link( $user_id, $group ); 2892 2941 } 2893 2942 /** … … 2895 2944 * 2896 2945 * @since 1.2.6 2897 * 2898 * @param int $user_id ID of the member to remove. 2899 * Default: current member in a member loop. 2900 * @param object|bool $group Optional. Group object. Default: current group. 2946 * @since 10.0.0 Updated to use `bp_get_group`. 2947 * 2948 * @param int $user_id ID of the member to remove. Default: 0. 2949 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 2950 * Default: false. 2901 2951 * @return string 2902 2952 */ 2903 2953 function bp_get_group_member_remove_link( $user_id = 0, $group = false ) { 2904 global $groups_template; 2905 2906 if ( empty( $group ) ) { 2907 $group =& $groups_template->group; 2954 global $members_template; 2955 2956 $group = bp_get_group( $group ); 2957 2958 if ( empty( $group->id ) ) { 2959 return ''; 2960 } 2961 2962 if ( ! $user_id ) { 2963 $user_id = $members_template->member->user_id; 2908 2964 } 2909 2965 … … 2912 2968 * 2913 2969 * @since 1.2.6 2914 * @since 2.5.0 Added the `$group` parameter. 2915 * 2916 * @param string $value URL to use for removing a member. 2917 * @param object $group Group object. 2918 */ 2919 return apply_filters( 'bp_get_group_member_remove_link', wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id ), 'groups_remove_member' ), $group ); 2970 * @since 2.5.0 Added the `$group` parameter. 2971 * @since 10.0.0 Added the `$user_id` parameter. 2972 * 2973 * @param string $value URL to use for removing a member. 2974 * @param BP_Groups_Group $group The group object. 2975 * @param int $user_id The user ID. 2976 */ 2977 return apply_filters( 2978 'bp_get_group_member_remove_link', 2979 wp_nonce_url( trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members/remove/' . $user_id ), 'groups_remove_member' ), 2980 $group, 2981 $user_id 2982 ); 2920 2983 } 2921 2984 … … 3012 3075 * 3013 3076 * @since 1.0.0 3014 * 3015 * @param string $page Page slug. 3016 */ 3017 function bp_group_form_action( $page ) { 3018 echo bp_get_group_form_action( $page ); 3077 * @since 10.0.0 Added the `$group` paremeter. 3078 * 3079 * @param string $page Page slug. 3080 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 3081 * Default: false. 3082 */ 3083 function bp_group_form_action( $page, $group = false ) { 3084 echo bp_get_group_form_action( $page, $group ); 3019 3085 } 3020 3086 /** … … 3022 3088 * 3023 3089 * @since 1.0.0 3024 * 3025 * @param string $page Page slug. 3026 * @param object|bool $group Optional. Group object. 3027 * Default: current group in the loop. 3090 * @since 10.0.0 Updated to use `bp_get_group`. 3091 * 3092 * @param string $page Page slug. 3093 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 3094 * Default: false. 3028 3095 * @return string 3029 3096 */ 3030 3097 function bp_get_group_form_action( $page, $group = false ) { 3031 global $groups_template;3032 3033 if ( empty( $group ) ) {3034 $group =& $groups_template->group;3098 $group = bp_get_group( $group ); 3099 3100 if ( empty( $group->id ) || empty( $page ) ) { 3101 return ''; 3035 3102 } 3036 3103 … … 3041 3108 * @since 2.5.0 Added the `$group` parameter. 3042 3109 * 3043 * @param string $value Action attribute for a group form. 3044 * @param object $group Group object. 3045 */ 3046 return apply_filters( 'bp_group_form_action', trailingslashit( bp_get_group_permalink( $group ) . $page ), $group ); 3110 * @param string $value Action attribute for a group form. 3111 * @param BP_Groups_Group $group The group object. 3112 * @param int|string|bool $page Page slug. 3113 */ 3114 return apply_filters( 'bp_group_form_action', trailingslashit( bp_get_group_permalink( $group ) . $page ), $group, $page ); 3047 3115 } 3048 3116 … … 3051 3119 * 3052 3120 * @since 1.0.0 3053 * 3054 * @param string|bool $page Optional. Page slug. 3055 */ 3056 function bp_group_admin_form_action( $page = false ) { 3057 echo bp_get_group_admin_form_action( $page ); 3121 * @since 10.0.0 Added the `$group` paremeter. 3122 * 3123 * @param false|string|bool $page (Optional). Page slug. Default: false. 3124 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 3125 * Default: false. 3126 */ 3127 function bp_group_admin_form_action( $page = false, $group = false ) { 3128 echo bp_get_group_admin_form_action( $page, $group ); 3058 3129 } 3059 3130 /** … … 3061 3132 * 3062 3133 * @since 1.0.0 3063 * 3064 * @param string|bool $page Optional. Page slug. 3065 * @param object|bool $group Optional. Group object. 3066 * Default: current group in the loop. 3134 * @since 10.0.0 Updated to use `bp_get_group`. 3135 * 3136 * @param false|string|bool $page (Optional). Page slug. Default: false. 3137 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 3138 * Default: false. 3067 3139 * @return string 3068 3140 */ 3069 3141 function bp_get_group_admin_form_action( $page = false, $group = false ) { 3070 global $groups_template;3071 3072 if ( empty( $group ) ) {3073 $group =& $groups_template->group;3142 $group = bp_get_group( $group ); 3143 3144 if ( empty( $group->id ) ) { 3145 return ''; 3074 3146 } 3075 3147 … … 3082 3154 * 3083 3155 * @since 1.0.0 3084 * @since 2.5.0 Added the `$group` parameter. 3085 * 3086 * @param string $value Action attribute for a group admin form. 3087 * @param object $group Group object. 3088 */ 3089 return apply_filters( 'bp_group_admin_form_action', trailingslashit( bp_get_group_permalink( $group ) . 'admin/' . $page ), $group ); 3156 * @since 2.5.0 Added the `$group` parameter. 3157 * @since 10.0.0 Added the `$page` parameter. 3158 * 3159 * @param string $value Action attribute for a group admin form. 3160 * @param BP_Groups_Group $group The group object. 3161 * @param int|string|bool $page Page slug. 3162 */ 3163 return apply_filters( 'bp_group_admin_form_action', trailingslashit( bp_get_group_permalink( $group ) . 'admin/' . $page ), $group, $page ); 3090 3164 } 3091 3165 … … 3094 3168 * 3095 3169 * @since 1.0.0 3096 * 3097 * @param object|bool $group Optional. Group object. 3098 * Default: current group in the loop. 3170 * @since 10.0.0 Updated to use `bp_get_group`. 3171 * 3172 * @param false|int|string|BP_Groups_Group $group (Optional) The Group ID, the Group Slug or the Group object. 3173 * Default: false. 3099 3174 * @return bool 3100 3175 */ 3101 3176 function bp_group_has_requested_membership( $group = false ) { 3102 global $groups_template; 3103 3104 if ( empty( $group ) ) { 3105 $group =& $groups_template->group; 3106 } 3107 3108 if ( groups_check_for_membership_request( bp_loggedin_user_id(), $group->id ) ) { 3109 return true; 3110 } 3111 3112 return false; 3177 $group = bp_get_group( $group ); 3178 3179 if ( empty( $group->id ) ) { 3180 return false; 3181 } 3182 3183 return ( groups_check_for_membership_request( bp_loggedin_user_id(), $group->id ) ); 3113 3184 } 3114 3185 … … 3634 3705 * @since 2.0.0 3635 3706 * 3636 * @param string $button HTML button for creating a group. 3637 */ 3638 return bp_get_button( apply_filters( 'bp_get_group_create_button', $button_args ) ); 3707 * @param array $button_args HTML button for creating a group. 3708 */ 3709 $button_args = apply_filters( 'bp_get_group_create_button', $button_args ); 3710 3711 return bp_get_button( $button_args ); 3639 3712 } 3640 3713 … … 3647 3720 echo bp_get_group_create_nav_item(); 3648 3721 } 3649 3650 3722 /** 3651 3723 * Get the Create a Group nav item. … … 3811 3883 * @param int $value Total number of groups found. 3812 3884 */ 3813 return apply_filters( 'bp_get_total_group_count', groups_get_total_group_count() );3885 return apply_filters( 'bp_get_total_group_count', (int) groups_get_total_group_count() ); 3814 3886 } 3815 3887 … … 4084 4156 echo bp_get_group_member_name(); 4085 4157 } 4086 4087 4158 /** 4088 4159 * @since 1.0.0 … … 4109 4180 echo bp_get_group_member_url(); 4110 4181 } 4111 4112 4182 /** 4113 4183 * @since 1.0.0 … … 4134 4204 echo bp_get_group_member_link(); 4135 4205 } 4136 4137 4206 /** 4138 4207 * @since 1.0.0 … … 4159 4228 echo bp_get_group_member_domain(); 4160 4229 } 4161 4162 4230 /** 4163 4231 * @since 1.2.0 … … 4184 4252 echo bp_get_group_member_is_friend(); 4185 4253 } 4186 4187 4254 /** 4188 4255 * @since 1.2.0 … … 4212 4279 4213 4280 /** 4281 * Check whether the member is banned from the current group. 4282 * 4214 4283 * @since 1.0.0 4215 4284 */ … … 4217 4286 echo bp_get_group_member_is_banned(); 4218 4287 } 4219 4220 /** 4288 /** 4289 * Check whether the member is banned from the current group. 4290 * 4221 4291 * @since 1.0.0 4222 4292 * 4223 * @return mixed|void4293 * @return bool 4224 4294 */ 4225 4295 function bp_get_group_member_is_banned() { 4226 4296 global $members_template; 4227 4297 4298 if ( ! isset( $members_template->member->is_banned ) ) { 4299 return false; 4300 } 4301 4228 4302 /** 4229 4303 * Filters whether the member is banned from the current group. … … 4233 4307 * @param bool $is_banned Whether or not the member is banned. 4234 4308 */ 4235 return apply_filters( 'bp_get_group_member_is_banned', $members_template->member->is_banned ); 4236 } 4237 4238 /** 4309 return apply_filters( 'bp_get_group_member_is_banned', (bool) $members_template->member->is_banned ); 4310 } 4311 4312 /** 4313 * Output CSS if group member is banned. 4314 * 4239 4315 * @since 1.2.6 4316 * @since 10.0.0 Updated to use `bp_get_group_member_is_banned`. 4240 4317 */ 4241 4318 function bp_group_member_css_class() { 4242 global $members_template; 4243 4244 if ( $members_template->member->is_banned ) { 4319 if ( bp_get_group_member_is_banned() ) { 4245 4320 4246 4321 /** … … 4312 4387 4313 4388 /** 4389 * Get group member from current group. 4390 * 4314 4391 * @since 1.0.0 4315 4392 */ … … 4317 4394 echo bp_get_group_member_id(); 4318 4395 } 4319 4320 /** 4396 /** 4397 * Get group member from current group. 4398 * 4321 4399 * @since 1.0.0 4322 4400 * 4323 * @return mixed|void4401 * @return int 4324 4402 */ 4325 4403 function bp_get_group_member_id() { 4326 4404 global $members_template; 4327 4405 4406 if ( ! isset( $members_template->member->user_id ) ) { 4407 return 0; 4408 } 4409 4328 4410 /** 4329 4411 * Filters the member's user ID for group members loop. … … 4333 4415 * @param int $user_id User ID of the member. 4334 4416 */ 4335 return apply_filters( 'bp_get_group_member_id', $members_template->member->user_id );4417 return apply_filters( 'bp_get_group_member_id', (int) $members_template->member->user_id ); 4336 4418 } 4337 4419 … … 4344 4426 global $members_template; 4345 4427 4346 if ( $members_template->total_member_count > $members_template->pag_num ) { 4347 return true; 4348 } 4349 4350 return false; 4428 return ( $members_template->total_member_count > $members_template->pag_num ); 4351 4429 } 4352 4430 … … 4357 4435 echo bp_get_group_pag_id(); 4358 4436 } 4359 4360 4437 /** 4361 4438 * @since 1.0.0 … … 4382 4459 wp_nonce_field( 'bp_groups_member_list', '_member_pag_nonce' ); 4383 4460 } 4384 4385 4461 /** 4386 4462 * @since 1.0.0 … … 4407 4483 echo bp_get_group_member_pagination_count(); 4408 4484 } 4409 4410 4485 /** 4411 4486 * @since 1.0.0 … … 4448 4523 wp_nonce_field( 'bp_groups_member_admin_list', '_member_admin_pag_nonce' ); 4449 4524 } 4450 4451 4525 /** 4452 4526 * @since 1.0.0 -
trunk/src/bp-groups/classes/class-bp-groups-member.php
r12431 r13097 1189 1189 */ 1190 1190 public static function get_group_moderator_ids( $group_id ) { 1191 global $wpdb;1192 1191 1193 1192 if ( empty( $group_id ) ) { -
trunk/tests/phpunit/testcases/groups/template.php
r12744 r13097 5 5 */ 6 6 class BP_Tests_Groups_Template extends BP_UnitTestCase { 7 8 public function setUp() { 9 parent::setUp(); 10 11 if ( isset( $GLOBALS['groups_template'] ) ) { 12 $this->groups_template = $GLOBALS['groups_template']; 13 } 14 } 15 16 public function tearDown() { 17 if ( $this->groups_template ) { 18 $GLOBALS['groups_template'] = $this->groups_template; 19 } 20 21 parent::tearDown(); 22 } 23 7 24 /** 8 25 * Integration test to make sure meta_query is getting passed through … … 951 968 952 969 /** 970 * @group bp_group_is_forum_enabled 971 */ 972 public function test_bp_group_is_forum_enabled() { 973 $g1 = $this->factory->group->create( array( 'enable_forum' => 0 ) ); 974 $g2 = $this->factory->group->create( array( 'enable_forum' => 1 ) ); 975 976 $this->assertFalse( bp_group_is_forum_enabled( $g1 ) ); 977 $this->assertTrue( bp_group_is_forum_enabled( $g2 ) ); 978 } 979 980 /** 981 * @group bp_get_group_member_is_banned 982 */ 983 public function test_bp_group_member_is_banned() { 984 $this->assertFalse( bp_get_group_member_is_banned() ); 985 } 986 987 /** 988 * @group bp_get_group_member_id 989 */ 990 public function test_bp_get_group_member_id() { 991 $this->assertFalse( (bool) bp_get_group_member_id() ); 992 } 993 994 /** 995 * @group bp_get_group_form_action 996 */ 997 public function test_bp_bp_get_group_form_action_when_empty() { 998 $this->assertEmpty( bp_get_group_form_action( '' ) ); 999 } 1000 1001 /** 1002 * @group bp_get_group_form_action 1003 */ 1004 public function test_bp_bp_get_group_form_action() { 1005 $g = $this->factory->group->create(); 1006 $p = 2; 1007 $url = trailingslashit( bp_get_group_permalink( $g ) . $p ); 1008 1009 $this->assertSame( bp_get_group_form_action( $p, $g ), $url ); 1010 } 1011 1012 /** 953 1013 * @group bp_get_group_member_count 954 1014 */ 955 1015 public function test_bp_get_group_member_count_0_members() { 956 global $groups_template;957 $g t = $groups_template;958 $groups_template = new stdClass; 959 $groups_template->group = new stdClass;960 $ groups_template->group->total_member_count = 0;961 962 $found = bp_get_group_member_count(); 963 964 $groups_template = $gt;965 966 $this->assert Same( '0 members', $found);1016 $u = $this->factory->user->create(); 1017 $g = $this->factory->group->create( array( 'creator_id' => $u ) ); 1018 1019 // Fake the current group. 1020 $GLOBALS['groups_template'] = new stdClass; 1021 $GLOBALS['groups_template']->group = groups_get_group( $g ); 1022 1023 // Kick group creator. 1024 wp_delete_user( $u ); 1025 1026 $this->assertNotSame( '0 member', bp_get_group_member_count() ); 967 1027 } 968 1028 … … 971 1031 */ 972 1032 public function test_bp_get_group_member_count_1_member() { 973 global $groups_template; 974 $gt = $groups_template; 975 $groups_template = new stdClass; 976 $groups_template->group = new stdClass; 977 $groups_template->group->total_member_count = 1; 978 979 $found = bp_get_group_member_count(); 980 981 $groups_template = $gt; 982 983 $this->assertSame( '1 member', $found ); 1033 $g = $this->factory->group->create(); 1034 1035 // Fake the current group. 1036 $GLOBALS['groups_template'] = new stdClass; 1037 $GLOBALS['groups_template']->group = groups_get_group( $g ); 1038 1039 $this->assertSame( '1 member', bp_get_group_member_count() ); 984 1040 } 985 1041 … … 988 1044 */ 989 1045 public function test_bp_get_group_member_count_2_members() { 990 global $groups_template;991 $ gt = $groups_template;992 $g roups_template = new stdClass;993 $groups_template->group = new stdClass; 994 $ groups_template->group->total_member_count = 2;995 996 $found = bp_get_group_member_count();997 998 $ groups_template = $gt;999 1000 $this->assertSame( '2 members', $found);1046 $u1 = $this->factory->user->create(); 1047 $u2 = $this->factory->user->create(); 1048 $g = $this->factory->group->create( array( 'creator_id' => $u1 ) ); 1049 1050 $this->add_user_to_group( $u2, $g ); 1051 1052 // Fake the current group. 1053 $GLOBALS['groups_template'] = new stdClass; 1054 $GLOBALS['groups_template']->group = groups_get_group( $g ); 1055 1056 $this->assertSame( '2 members', bp_get_group_member_count() ); 1001 1057 } 1002 1058
Note: See TracChangeset
for help on using the changeset viewer.