Changeset 12801
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-template.php
r12789 r12801 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 … … 207 226 * 208 227 * @since 2.7.0 228 * @since 7.0.0 The `$r['label']` argument now also accept an array containing the 229 * plural & singular labels to use according to the Group's number of 230 * group types it is 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 … … 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(), … … 245 268 ); 246 269 270 // Should the label be output? 271 $has_label = ! empty( $r['label'] ); 272 273 // Ensure backward compatibility in case developers 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 … … 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. … … 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 … … 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 -
trunk/src/bp-templates/bp-nouveau/buddypress/groups/single/cover-image-header.php
r12791 r12801 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 ) -
trunk/src/bp-templates/bp-nouveau/buddypress/groups/single/group-header.php
r12791 r12801 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 )
Note: See TracChangeset
for help on using the changeset viewer.