Ticket #8401: 8401.patch
File 8401.patch, 6.9 KB (added by , 4 years ago) |
---|
-
src/bp-groups/bp-groups-template.php
diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php index d0be0cc70..2b3fe0475 100644
function bp_group_type_directory_link( $group_type = '' ) { 190 190 return ''; 191 191 } 192 192 193 return sprintf( '<a href="%s">%s</a>', esc_url( bp_get_group_type_directory_permalink( $group_type ) ), bp_groups_get_group_type_object( $group_type )->labels['name'] ); 193 $group_type_object = bp_groups_get_group_type_object( $group_type ); 194 195 if ( ! isset( $group_type_object->labels['name'] ) ) { 196 return ''; 197 } 198 199 $group_type_text = $group_type_object->labels['name']; 200 if ( isset( $group_type_object->labels['singular_name'] ) && $group_type_object->labels['singular_name'] ) { 201 $group_type_text = $group_type_object->labels['singular_name']; 202 } 203 204 if ( empty( $group_type_object->has_directory ) ) { 205 return esc_html( $group_type_text ); 206 } 207 208 return sprintf( 209 '<a href="%s">%s</a>', 210 esc_url( bp_get_group_type_directory_permalink( $group_type ) ), 211 esc_html( $group_type_text ) 212 ); 194 213 } 195 214 196 215 /** … … function bp_group_type_list( $group_id = 0, $r = array() ) { 206 225 * Return a comma-delimited list of group types. 207 226 * 208 227 * @since 2.7.0 228 * @since 7.0.0 The `$r['label']` arguments now also accept an array containing the 229 * plural & singular labels to use according to the Group's number of 230 * group types it assigned to. 209 231 * 210 232 * @param int $group_id Group ID. Defaults to current group ID if on a group page. 211 233 * @param array|string $r { 212 234 * Array of parameters. All items are optional. 213 * @type string $parent_element Element to wrap around the list. Defaults to 'p'. 214 * @type array $parent_attr Element attributes for parent element. Defaults to 215 * array( 'class' => 'bp-group-type-list' ). 216 * @type string $label Label to add before the list. Defaults to 'Group Types:'. 217 * @type string $label_element Element to wrap around the label. Defaults to 'strong'. 218 * @type array $label_attr Element attributes for label element. Defaults to array(). 219 * @type bool $show_all Whether to show all registered group types. Defaults to 'false'. If 220 * 'false', only shows group types with the 'show_in_list' parameter set to 221 * true. See bp_groups_register_group_type() for more info. 235 * @type string $parent_element Element to wrap around the list. Defaults to 'p'. 236 * @type array $parent_attr Element attributes for parent element. Defaults to 237 * array( 'class' => 'bp-group-type-list' ). 238 * @type string|array $label Plural and singular labels to add before the list. Defaults to 239 * array( 'plural' => 'Group Types:', 'singular' => 'Group Type:' ). 240 * @type string $label_element Element to wrap around the label. Defaults to 'strong'. 241 * @type array $label_attr Element attributes for label element. Defaults to array(). 242 * @type bool $show_all Whether to show all registered group types. Defaults to 'false'. If 243 * 'false', only shows group types with the 'show_in_list' parameter set to 244 * true. See bp_groups_register_group_type() for more info. 222 245 * } 223 246 * @return string 224 247 */ … … function bp_group_type_list( $group_id = 0, $r = array() ) { 234 257 'parent_attr' => array( 235 258 'class' => 'bp-group-type-list', 236 259 ), 237 'label' => __( 'Group Types:', 'buddypress'),260 'label' => array(), 238 261 'label_element' => 'strong', 239 262 'label_attr' => array(), 240 263 'show_all' => false, … … function bp_group_type_list( $group_id = 0, $r = array() ) { 244 267 'group_type_list' 245 268 ); 246 269 270 // Should the label be output? 271 $has_label = ! empty( $r['label'] ); 272 273 // Ensure Backcompatibilty in case devalopers are still using a string. 274 if ( ! is_array( $r['label'] ) ) { 275 $r['label'] = array( 276 'plural' => __( 'Group Types:', 'buddypress' ), 277 ); 278 } 279 280 $labels = wp_parse_args( 281 $r['label'], 282 array( 283 'plural' => __( 'Group Types:', 'buddypress' ), 284 'singular' => __( 'Group Type:', 'buddypress' ), 285 ) 286 ); 287 247 288 $retval = ''; 248 289 249 290 if ( $types = bp_groups_get_group_type( $group_id, false ) ) { … … function bp_group_type_list( $group_id = 0, $r = array() ) { 256 297 } 257 298 258 299 $before = $after = $label = ''; 300 $count = count( $types ); 301 302 if ( 1 === $count ) { 303 $label_text = $labels['singular']; 304 } else { 305 $label_text = $labels['plural']; 306 } 259 307 260 308 // Render parent element. 261 309 if ( ! empty( $r['parent_element'] ) ) { 262 310 $parent_elem = new BP_Core_HTML_Element( array( 263 311 'element' => $r['parent_element'], 264 'attr' => $r['parent_attr'] 312 'attr' => $r['parent_attr'], 265 313 ) ); 266 314 267 315 // Set before and after. … … function bp_group_type_list( $group_id = 0, $r = array() ) { 274 322 $label = new BP_Core_HTML_Element( array( 275 323 'element' => $r['label_element'], 276 324 'attr' => $r['label_attr'], 277 'inner_html' => esc_html( $ r['label'] )325 'inner_html' => esc_html( $label_text ), 278 326 ) ); 279 327 $label = $label->contents() . ' '; 280 328 281 329 // No element, just the label. 282 } else {283 $label = esc_html( $ r['label']);330 } elseif ( $has_label ) { 331 $label = esc_html( $label_text ); 284 332 } 285 333 286 334 // The list of types. -
src/bp-templates/bp-nouveau/buddypress/groups/single/cover-image-header.php
diff --git src/bp-templates/bp-nouveau/buddypress/groups/single/cover-image-header.php src/bp-templates/bp-nouveau/buddypress/groups/single/cover-image-header.php index 07439f2f8..df18e2119 100644
46 46 bp_group_type_list( 47 47 bp_get_group_id(), 48 48 array( 49 'label' => __( 'Group Types', 'buddypress' ), 49 'label' => array( 50 'plural' => __( 'Group Types', 'buddypress' ), 51 'singular' => __( 'Group Type', 'buddypress' ), 52 ), 50 53 'list_element' => 'span', 51 54 ) 52 55 ); -
src/bp-templates/bp-nouveau/buddypress/groups/single/group-header.php
diff --git src/bp-templates/bp-nouveau/buddypress/groups/single/group-header.php src/bp-templates/bp-nouveau/buddypress/groups/single/group-header.php index 92c18c48d..ffa9f447f 100644
43 43 bp_group_type_list( 44 44 bp_get_group_id(), 45 45 array( 46 'label' => __( 'Group Types', 'buddypress' ), 46 'label' => array( 47 'plural' => __( 'Group Types', 'buddypress' ), 48 'singular' => __( 'Group Type', 'buddypress' ), 49 ), 47 50 'list_element' => 'span', 48 51 ) 49 52 );