Changeset 11176
- Timestamp:
- 10/06/2016 07:55:32 AM (8 years ago)
- Location:
- trunk/src/bp-groups
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-admin.php
r11139 r11176 1047 1047 } 1048 1048 1049 $types = bp_groups_get_group_types( array(), 'objects' ); 1050 $current_type = bp_groups_get_group_type( $group->id ); 1049 $types = bp_groups_get_group_types( array(), 'objects' ); 1050 $current_types = bp_groups_get_group_type( $group->id, false ); 1051 $backend_only = bp_groups_get_group_types( array( 'show_in_create_screen' => false ) ); 1051 1052 ?> 1052 1053 … … 1055 1056 esc_html_e( 'Select group type', 'buddypress' ); 1056 1057 ?></label> 1057 <select name="bp-groups-group-type" id="bp-groups-group-type"> 1058 <option value="" <?php selected( '', $current_type ); ?>><?php /* translators: no option picked in select box */ esc_attr_e( '----', 'buddypress' ) ?></option>1058 1059 <ul class="categorychecklist form-no-clear"> 1059 1060 <?php foreach ( $types as $type ) : ?> 1060 <option value="<?php echo esc_attr( $type->name ) ?>" <?php selected( $type->name, $current_type ) ?>><?php echo esc_html( $type->labels['singular_name'] ) ?></option> 1061 <li> 1062 <label class="selectit"><input value="<?php echo esc_attr( $type->name ) ?>" name="bp-groups-group-type[]" type="checkbox" <?php checked( true, in_array( $type->name, $current_types ) ); ?>> 1063 <?php 1064 echo esc_html( $type->labels['singular_name'] ); 1065 if ( in_array( $type->name, $backend_only ) ) { 1066 printf( ' <span class="description">%s</span>', esc_html__( '(Not available on the frontend)', 'buddypress' ) ); 1067 } 1068 ?> 1069 1070 </label> 1071 </li> 1072 1061 1073 <?php endforeach; ?> 1062 </select> 1074 1075 </ul> 1063 1076 1064 1077 <?php … … 1073 1086 */ 1074 1087 function bp_groups_process_group_type_update( $group_id ) { 1075 if ( ! isset( $_POST['bp-group-type-nonce'] ) || ! isset( $_POST['bp-groups-group-type'] )) {1088 if ( ! isset( $_POST['bp-group-type-nonce'] ) ) { 1076 1089 return; 1077 1090 } … … 1084 1097 } 1085 1098 1086 // Group type string must either reference a valid group type, or be empty. 1087 $group_type = wp_unslash( $_POST['bp-groups-group-type'] ); 1088 if ( $group_type && ! bp_groups_get_group_type_object( $group_type ) ) { 1089 return; 1090 } 1099 $group_types = ! empty( $_POST['bp-groups-group-type'] ) ? wp_unslash( $_POST['bp-groups-group-type'] ) : array(); 1091 1100 1092 1101 /* … … 1094 1103 * fishy with the POST request, so we can fail silently. 1095 1104 */ 1096 if ( bp_groups_set_group_type( $group_id, $group_type ) ) {1105 if ( bp_groups_set_group_type( $group_id, $group_types ) ) { 1097 1106 // @todo Success messages can't be posted because other stuff happens on the page load. 1098 1107 } -
trunk/src/bp-groups/bp-groups-template.php
r11166 r11176 224 224 * @type string $label_element Element to wrap around the label. Defaults to 'strong'. 225 225 * @type array $label_attr Element attributes for label element. Defaults to array(). 226 * @type bool $show_all Whether to show all registered group types. Defaults to 'false'. If 227 * 'false', only shows group types with the 'show_in_list' parameter set to 228 * true. See bp_groups_register_group_type() for more info. 226 229 * } 227 230 * @return string … … 239 242 'label' => __( 'Group Types:', 'buddypress' ), 240 243 'label_element' => 'strong', 241 'label_attr' => array() 244 'label_attr' => array(), 245 'show_all' => false, 242 246 ), 'group_type_list' ); 243 247 … … 246 250 if ( $types = bp_groups_get_group_type( $group_id, false ) ) { 247 251 // Make sure we can show the type in the list. 248 $types = array_intersect( bp_groups_get_group_types( array( 'show_in_list' => true ) ), $types ); 249 if ( empty( $types ) ) { 250 return $retval; 252 if ( false === $show_all ) { 253 $types = array_intersect( bp_groups_get_group_types( array( 'show_in_list' => true ) ), $types ); 254 if ( empty( $types ) ) { 255 return $retval; 256 } 251 257 } 252 258 -
trunk/src/bp-groups/classes/class-bp-groups-list-table.php
r11162 r11176 716 716 } 717 717 718 // Get the group type.719 $ type = bp_groups_get_group_type( $item['id'] );720 721 // Output the722 if ( $type_obj = bp_groups_get_group_type_object( $type ) ) {723 $url = add_query_arg( array( 'bp-group-type' => urlencode( $type ) ) );724 $retval = '<a href="' . esc_url( $url ) . '">' . esc_html( $type_obj->labels['singular_name'] ) . '</a>';725 }718 add_filter( 'bp_get_group_type_directory_permalink', array( $this, 'group_type_permalink_use_admin_filter' ), 10, 2 ); 719 $retval = bp_get_group_type_list( $item['id'], array( 720 'parent_element' => '', 721 'label_element' => '', 722 'label' => '', 723 'show_all' => true 724 ) ); 725 remove_filter( 'bp_get_group_type_directory_permalink', array( $this, 'group_type_permalink_use_admin_filter' ), 10, 2 ); 726 726 727 727 /** … … 734 734 */ 735 735 echo apply_filters_ref_array( 'bp_groups_admin_get_group_type_column', array( $retval, $item ) ); 736 } 737 738 /** 739 * Filters the group type list permalink in the Group Type column. 740 * 741 * Changes the group type permalink to use the admin URL. 742 * 743 * @since 2.7.0 744 * 745 * @param string $retval Current group type permalink. 746 * @param object $type Group type object. 747 * @return string 748 */ 749 public function group_type_permalink_use_admin_filter( $retval, $type ) { 750 return add_query_arg( array( 'bp-group-type' => urlencode( $type->name ) ) ); 736 751 } 737 752
Note: See TracChangeset
for help on using the changeset viewer.