@@ -463,8 +463,10 @@ protected function table_contents( $user, $tax, $terms ) {
463
463
<thead>
464
464
<tr>
465
465
<td id="cb" class="manage-column column-cb check-column">
466
- <label class="screen-reader-text" for="cb-select-all-1"><?php esc_html_e ( 'Select All ' , 'wp-user-groups ' ); ?> </label>
467
- <input id="cb-select-all-1" type="checkbox">
466
+ <?php if ( ! $ this ->is_exclusive () ) : ?>
467
+ <label class="screen-reader-text" for="cb-select-all-1"><?php esc_html_e ( 'Select All ' , 'wp-user-groups ' ); ?> </label>
468
+ <input id="cb-select-all-1" type="checkbox">
469
+ <?php endif ; ?>
468
470
</td>
469
471
<th scope="col" class="manage-column column-name column-primary"><?php esc_html_e ( 'Name ' , 'wp-user-groups ' ); ?> </th>
470
472
<th scope="col" class="manage-column column-description"><?php esc_html_e ( 'Description ' , 'wp-user-groups ' ); ?> </th>
@@ -480,7 +482,7 @@ protected function table_contents( $user, $tax, $terms ) {
480
482
481
483
<tr class="<?php echo ( true === $ active ) ? 'active ' : 'inactive ' ; ?> ">
482
484
<th scope="row" class="check-column">
483
- <input type="checkbox" name="<?php echo esc_attr ( $ this ->taxonomy ); ?> []" id="<?php echo esc_attr ( $ this ->taxonomy ); ?> -<?php echo esc_attr ( $ term ->slug ); ?> " value="<?php echo esc_attr ( $ term ->slug ); ?> " <?php checked ( $ active ); ?> />
485
+ <input type="<?php echo $ this -> is_exclusive () ? ' radio ' : ' checkbox ' ; ?> " name="<?php echo esc_attr ( $ this ->taxonomy ); ?> []" id="<?php echo esc_attr ( $ this ->taxonomy ); ?> -<?php echo esc_attr ( $ term ->slug ); ?> " value="<?php echo esc_attr ( $ term ->slug ); ?> " <?php checked ( $ active ); ?> />
484
486
<label for="<?php echo esc_attr ( $ this ->taxonomy ); ?> -<?php echo esc_attr ( $ term ->slug ); ?> "></label>
485
487
</th>
486
488
<td class="column-primary">
@@ -514,8 +516,10 @@ protected function table_contents( $user, $tax, $terms ) {
514
516
<tfoot>
515
517
<tr>
516
518
<td class="manage-column column-cb check-column">
517
- <label class="screen-reader-text" for="cb-select-all-2"><?php esc_html_e ( 'Select All ' , 'wp-user-groups ' ); ?> </label>
518
- <input id="cb-select-all-2" type="checkbox">
519
+ <?php if ( ! $ this ->is_exclusive () ) : ?>
520
+ <label class="screen-reader-text" for="cb-select-all-2"><?php esc_html_e ( 'Select All ' , 'wp-user-groups ' ); ?> </label>
521
+ <input id="cb-select-all-2" type="checkbox">
522
+ <?php endif ; ?>
519
523
</td>
520
524
<th scope="col" class="manage-column column-name column-primary"><?php esc_html_e ( 'Name ' , 'wp-user-groups ' ); ?> </th>
521
525
<th scope="col" class="manage-column column-description"><?php esc_html_e ( 'Description ' , 'wp-user-groups ' ); ?> </th>
@@ -644,7 +648,12 @@ protected function parse_labels() {
644
648
*/
645
649
protected function parse_options () {
646
650
return wp_parse_args ( $ this ->args , array (
647
- 'user_group ' => true , // Custom
651
+
652
+ // Custom
653
+ 'user_group ' => true , // Make it easy to identify user groups
654
+ 'exclusive ' => false , // Check vs. Radio
655
+
656
+ // Core
648
657
'hierarchical ' => true ,
649
658
'public ' => false ,
650
659
'show_ui ' => true ,
@@ -732,6 +741,18 @@ public function bulk_actions_sort( $actions = array() ) {
732
741
return $ new ;
733
742
}
734
743
744
+ /**
745
+ * Is this an exclusive user group type, where a user can only belong to one
746
+ * group within the taxonomy?
747
+ *
748
+ * @since 2.0.0
749
+ *
750
+ * @return bool
751
+ */
752
+ public function is_exclusive () {
753
+ return ( true === $ this ->args ['exclusive ' ] );
754
+ }
755
+
735
756
/**
736
757
* Handle bulk editing of users
737
758
*
0 commit comments