BP_Groups_List_Table

List table class for the Groups component admin page.

Defined (1)

The class is defined in the following location(s).

/bp-groups/classes/class-bp-groups-list-table.php  
  1. class BP_Groups_List_Table extends WP_List_Table { 
  2.  
  3. /** 
  4. * The type of view currently being displayed. 
  5. * E.g. "All", "Pending", "Approved", "Spam"... 
  6. * @since 1.7.0 
  7. * @var string 
  8. */ 
  9. public $view = 'all'; 
  10.  
  11. /** 
  12. * Group counts for each group type. 
  13. * @since 1.7.0 
  14. * @var int 
  15. */ 
  16. public $group_counts = 0; 
  17.  
  18. /** 
  19. * Multidimensional array of group visibility (status) types and their groups. 
  20. * @link https://buddypress.trac.wordpress.org/ticket/6277 
  21. * @var array 
  22. */ 
  23. public $group_type_ids = array(); 
  24.  
  25. /** 
  26. * Constructor 
  27. * @since 1.7.0 
  28. */ 
  29. public function __construct() { 
  30.  
  31. // Define singular and plural labels, as well as whether we support AJAX. 
  32. parent::__construct( array( 
  33. 'ajax' => false,  
  34. 'plural' => 'groups',  
  35. 'singular' => 'group',  
  36. ) ); 
  37.  
  38. // Add Group Type column and bulk change controls. 
  39. if ( bp_groups_get_group_types() ) { 
  40. // Add Group Type column. 
  41. add_filter( 'bp_groups_list_table_get_columns', array( $this, 'add_type_column' ) ); 
  42. add_filter( 'bp_groups_admin_get_group_custom_column', array( $this, 'column_content_group_type' ), 10, 3 ); 
  43. // Add the bulk change select. 
  44. add_action( 'bp_groups_list_table_after_bulk_actions', array( $this, 'add_group_type_bulk_change_select' ) ); 
  45.  
  46. /** 
  47. * Set up items for display in the list table. 
  48. * Handles filtering of data, sorting, pagination, and any other data 
  49. * manipulation required prior to rendering. 
  50. * @since 1.7.0 
  51. */ 
  52. public function prepare_items() { 
  53. global $groups_template; 
  54.  
  55. $screen = get_current_screen(); 
  56.  
  57. // Option defaults. 
  58. $include_id = false; 
  59. $search_terms = false; 
  60.  
  61. // Set current page. 
  62. $page = $this->get_pagenum(); 
  63.  
  64. // Set per page from the screen options. 
  65. $per_page = $this->get_items_per_page( str_replace( '-', '_', "{$screen->id}_per_page" ) ); 
  66.  
  67. // Sort order. 
  68. $order = 'DESC'; 
  69. if ( !empty( $_REQUEST['order'] ) ) { 
  70. $order = ( 'desc' == strtolower( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC'; 
  71.  
  72. // Order by - default to newest. 
  73. $orderby = 'last_activity'; 
  74. if ( ! empty( $_REQUEST['orderby'] ) ) { 
  75. switch ( $_REQUEST['orderby'] ) { 
  76. case 'name' : 
  77. $orderby = 'name'; 
  78. break; 
  79. case 'id' : 
  80. $orderby = 'date_created'; 
  81. break; 
  82. case 'members' : 
  83. $orderby = 'total_member_count'; 
  84. break; 
  85. case 'last_active' : 
  86. $orderby = 'last_activity'; 
  87. break; 
  88.  
  89. // Are we doing a search? 
  90. if ( !empty( $_REQUEST['s'] ) ) 
  91. $search_terms = $_REQUEST['s']; 
  92.  
  93. // Check if user has clicked on a specific group (if so, fetch only that group). 
  94. if ( !empty( $_REQUEST['gid'] ) ) 
  95. $include_id = (int) $_REQUEST['gid']; 
  96.  
  97. // Set the current view. 
  98. if ( isset( $_GET['group_status'] ) && in_array( $_GET['group_status'], array( 'public', 'private', 'hidden' ) ) ) { 
  99. $this->view = $_GET['group_status']; 
  100.  
  101. // We'll use the ids of group status types for the 'include' param. 
  102. $this->group_type_ids = BP_Groups_Group::get_group_type_ids(); 
  103.  
  104. // Pass a dummy array if there are no groups of this type. 
  105. $include = false; 
  106. if ( 'all' != $this->view && isset( $this->group_type_ids[ $this->view ] ) ) { 
  107. $include = ! empty( $this->group_type_ids[ $this->view ] ) ? $this->group_type_ids[ $this->view ] : array( 0 ); 
  108.  
  109. // Get group type counts for display in the filter tabs. 
  110. $this->group_counts = array(); 
  111. foreach ( $this->group_type_ids as $group_type => $group_ids ) { 
  112. $this->group_counts[ $group_type ] = count( $group_ids ); 
  113.  
  114. // Group types 
  115. $group_type = false; 
  116. if ( isset( $_GET['bp-group-type'] ) && null !== bp_groups_get_group_type_object( $_GET['bp-group-type'] ) ) { 
  117. $group_type = $_GET['bp-group-type']; 
  118.  
  119. // If we're viewing a specific group, flatten all activities into a single array. 
  120. if ( $include_id ) { 
  121. $groups = array( (array) groups_get_group( $include_id ) ); 
  122. } else { 
  123. $groups_args = array( 
  124. 'include' => $include,  
  125. 'per_page' => $per_page,  
  126. 'page' => $page,  
  127. 'orderby' => $orderby,  
  128. 'order' => $order 
  129. ); 
  130.  
  131. if ( $group_type ) { 
  132. $groups_args['group_type'] = $group_type; 
  133.  
  134. $groups = array(); 
  135. if ( bp_has_groups( $groups_args ) ) { 
  136. while ( bp_groups() ) { 
  137. bp_the_group(); 
  138. $groups[] = (array) $groups_template->group; 
  139.  
  140. // Set raw data to display. 
  141. $this->items = $groups; 
  142.  
  143. // Store information needed for handling table pagination. 
  144. $this->set_pagination_args( array( 
  145. 'per_page' => $per_page,  
  146. 'total_items' => $groups_template->total_group_count,  
  147. 'total_pages' => ceil( $groups_template->total_group_count / $per_page ) 
  148. ) ); 
  149.  
  150. /** 
  151. * Get an array of all the columns on the page. 
  152. * @since 1.7.0 
  153. * @return array Array of column headers. 
  154. */ 
  155. public function get_column_info() { 
  156. $this->_column_headers = array( 
  157. $this->get_columns(),  
  158. array(),  
  159. $this->get_sortable_columns(),  
  160. $this->get_default_primary_column_name(),  
  161. ); 
  162.  
  163. return $this->_column_headers; 
  164.  
  165. /** 
  166. * Get name of default primary column 
  167. * @since 2.3.3 
  168. * @return string 
  169. */ 
  170. protected function get_default_primary_column_name() { 
  171. // Comment column is mapped to Group's name. 
  172. return 'comment'; 
  173.  
  174. /** 
  175. * Display a message on screen when no items are found ("No groups found"). 
  176. * @since 1.7.0 
  177. */ 
  178. public function no_items() { 
  179. _e( 'No groups found.', 'buddypress' ); 
  180.  
  181. /** 
  182. * Output the Groups data table. 
  183. * @since 1.7.0 
  184. */ 
  185. public function display() { 
  186. $this->display_tablenav( 'top' ); ?> 
  187.  
  188. <h2 class="screen-reader-text"><?php 
  189. /** translators: accessibility text */ 
  190. _e( 'Groups list', 'buddypress' ); 
  191. ?></h2> 
  192.  
  193. <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0"> 
  194. <thead> 
  195. <tr> 
  196. <?php $this->print_column_headers(); ?> 
  197. </tr> 
  198. </thead> 
  199.  
  200. <tbody id="the-comment-list"> 
  201. <?php $this->display_rows_or_placeholder(); ?> 
  202. </tbody> 
  203.  
  204. <tfoot> 
  205. <tr> 
  206. <?php $this->print_column_headers( false ); ?> 
  207. </tr> 
  208. </tfoot> 
  209. </table> 
  210. <?php 
  211.  
  212. $this->display_tablenav( 'bottom' ); 
  213.  
  214. /** 
  215. * Extra controls to be displayed between bulk actions and pagination 
  216. * @since 2.7.0 
  217. * @access protected 
  218. * @param string $which 
  219. */ 
  220. protected function extra_tablenav( $which ) { 
  221. /** 
  222. * Fires just after the bulk action controls in the WP Admin groups list table. 
  223. * @since 2.7.0 
  224. * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. 
  225. */ 
  226. do_action( 'bp_groups_list_table_after_bulk_actions', $which ); 
  227.  
  228. /** 
  229. * Generate content for a single row of the table. 
  230. * @since 1.7.0 
  231. * @param object|array $item The current group item in the loop. 
  232. */ 
  233. public function single_row( $item = array() ) { 
  234. static $even = false; 
  235.  
  236. $row_classes = array(); 
  237.  
  238. if ( $even ) { 
  239. $row_classes = array( 'even' ); 
  240. } else { 
  241. $row_classes = array( 'alternate', 'odd' ); 
  242.  
  243. /** 
  244. * Filters the classes applied to a single row in the groups list table. 
  245. * @since 1.9.0 
  246. * @param array $row_classes Array of classes to apply to the row. 
  247. * @param string $value ID of the current group being displayed. 
  248. */ 
  249. $row_classes = apply_filters( 'bp_groups_admin_row_class', $row_classes, $item['id'] ); 
  250. $row_class = ' class="' . implode( ' ', $row_classes ) . '"'; 
  251.  
  252. echo '<tr' . $row_class . ' id="group-' . esc_attr( $item['id'] ) . '" data-parent_id="' . esc_attr( $item['id'] ) . '" data-root_id="' . esc_attr( $item['id'] ) . '">'; 
  253. echo $this->single_row_columns( $item ); 
  254. echo '</tr>'; 
  255.  
  256. $even = ! $even; 
  257.  
  258. /** 
  259. * Get the list of views available on this table (e.g. "all", "public"). 
  260. * @since 1.7.0 
  261. */ 
  262. public function get_views() { 
  263. $url_base = bp_get_admin_url( 'admin.php?page=bp-groups' ); ?> 
  264.  
  265. <h2 class="screen-reader-text"><?php 
  266. /** translators: accessibility text */ 
  267. _e( 'Filter groups list', 'buddypress' ); 
  268. ?></h2> 
  269.  
  270. <ul class="subsubsub"> 
  271. <li class="all"><a href="<?php echo esc_url( $url_base ); ?>" class="<?php if ( 'all' == $this->view ) echo 'current'; ?>"><?php _e( 'All', 'buddypress' ); ?></a> |</li> 
  272. <li class="public"><a href="<?php echo esc_url( add_query_arg( 'group_status', 'public', $url_base ) ); ?>" class="<?php if ( 'public' == $this->view ) echo 'current'; ?>"><?php printf( _n( 'Public <span class="count">(%s)</span>', 'Public <span class="count">(%s)</span>', $this->group_counts['public'], 'buddypress' ), number_format_i18n( $this->group_counts['public'] ) ); ?></a> |</li> 
  273. <li class="private"><a href="<?php echo esc_url( add_query_arg( 'group_status', 'private', $url_base ) ); ?>" class="<?php if ( 'private' == $this->view ) echo 'current'; ?>"><?php printf( _n( 'Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', $this->group_counts['private'], 'buddypress' ), number_format_i18n( $this->group_counts['private'] ) ); ?></a> |</li> 
  274. <li class="hidden"><a href="<?php echo esc_url( add_query_arg( 'group_status', 'hidden', $url_base ) ); ?>" class="<?php if ( 'hidden' == $this->view ) echo 'current'; ?>"><?php printf( _n( 'Hidden <span class="count">(%s)</span>', 'Hidden <span class="count">(%s)</span>', $this->group_counts['hidden'], 'buddypress' ), number_format_i18n( $this->group_counts['hidden'] ) ); ?></a></li> 
  275.  
  276. <?php 
  277.  
  278. /** 
  279. * Fires inside listing of views so plugins can add their own. 
  280. * @since 1.7.0 
  281. * @param string $url_base Current URL base for view. 
  282. * @param string $view Current view being displayed. 
  283. */ 
  284. do_action( 'bp_groups_list_table_get_views', $url_base, $this->view ); ?> 
  285. </ul> 
  286. <?php 
  287.  
  288. /** 
  289. * Get bulk actions for single group row. 
  290. * @since 1.7.0 
  291. * @return array Key/value pairs for the bulk actions dropdown. 
  292. */ 
  293. public function get_bulk_actions() { 
  294.  
  295. /** 
  296. * Filters the list of bulk actions to display on a single group row. 
  297. * @since 1.7.0 
  298. * @param array $value Array of bulk actions to display. 
  299. */ 
  300. return apply_filters( 'bp_groups_list_table_get_bulk_actions', array( 
  301. 'delete' => __( 'Delete', 'buddypress' ) 
  302. ) ); 
  303.  
  304. /** 
  305. * Get the table column titles. 
  306. * @since 1.7.0 
  307. * @see WP_List_Table::single_row_columns() 
  308. * @return array Array of column titles. 
  309. */ 
  310. public function get_columns() { 
  311.  
  312. /** 
  313. * Filters the titles for the columns for the groups list table. 
  314. * @since 2.0.0 
  315. * @param array $value Array of slugs and titles for the columns. 
  316. */ 
  317. return apply_filters( 'bp_groups_list_table_get_columns', array( 
  318. 'cb' => '<input name type="checkbox" />',  
  319. 'comment' => _x( 'Name', 'Groups admin Group Name column header', 'buddypress' ),  
  320. 'description' => _x( 'Description', 'Groups admin Group Description column header', 'buddypress' ),  
  321. 'status' => _x( 'Status', 'Groups admin Privacy Status column header', 'buddypress' ),  
  322. 'members' => _x( 'Members', 'Groups admin Members column header', 'buddypress' ),  
  323. 'last_active' => _x( 'Last Active', 'Groups admin Last Active column header', 'buddypress' ) 
  324. ) ); 
  325.  
  326. /** 
  327. * Get the column names for sortable columns. 
  328. * Note: It's not documented in WP, but the second item in the 
  329. * nested arrays below is $desc_first. Normally, we would set 
  330. * last_active to be desc_first (since you're generally interested in 
  331. * the *most* recently active group, not the *least*). But because 
  332. * the default sort for the Groups admin screen is DESC by last_active,  
  333. * we want the first click on the Last Active column header to switch 
  334. * the sort order - ie, to make it ASC. Thus last_active is set to 
  335. * $desc_first = false. 
  336. * @since 1.7.0 
  337. * @return array Array of sortable column names. 
  338. */ 
  339. public function get_sortable_columns() { 
  340. return array( 
  341. 'gid' => array( 'gid', false ),  
  342. 'comment' => array( 'name', false ),  
  343. 'members' => array( 'members', false ),  
  344. 'last_active' => array( 'last_active', false ),  
  345. ); 
  346.  
  347. /** 
  348. * Override WP_List_Table::row_actions(). 
  349. * Basically a duplicate of the row_actions() method, but removes the 
  350. * unnecessary <button> addition. 
  351. * @since 2.3.3 
  352. * @since 2.3.4 Visibility set to public for compatibility with WP < 4.0.0. 
  353. * @param array $actions The list of actions. 
  354. * @param bool $always_visible Whether the actions should be always visible. 
  355. * @return string 
  356. */ 
  357. public function row_actions( $actions, $always_visible = false ) { 
  358. $action_count = count( $actions ); 
  359. $i = 0; 
  360.  
  361. if ( !$action_count ) 
  362. return ''; 
  363.  
  364. $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; 
  365. foreach ( $actions as $action => $link ) { 
  366. ++$i; 
  367. ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 
  368. $out .= "<span class='$action'>$link$sep</span>"; 
  369. $out .= '</div>'; 
  370.  
  371. return $out; 
  372.  
  373. /** 
  374. * Markup for the Checkbox column. 
  375. * @since 1.7.0 
  376. * @see WP_List_Table::single_row_columns() 
  377. * @param array $item A singular item (one full row). 
  378. */ 
  379. public function column_cb( $item = array() ) { 
  380. /** translators: accessibility text */ 
  381. printf( '<label class="screen-reader-text" for="gid-%1$d">' . __( 'Select group %1$d', 'buddypress' ) . '</label><input type="checkbox" name="gid[]" value="%1$d" id="gid-%1$d" />', $item['id'] ); 
  382.  
  383. /** 
  384. * Markup for the Group ID column. 
  385. * @since 1.7.0 
  386. * @see WP_List_Table::single_row_columns() 
  387. * @param array $item A singular item (one full row). 
  388. */ 
  389. public function column_gid( $item = array() ) { 
  390. echo '<strong>' . absint( $item['id'] ) . '</strong>'; 
  391.  
  392. /** 
  393. * Name column, and "quick admin" rollover actions. 
  394. * Called "comment" in the CSS so we can re-use some WP core CSS. 
  395. * @since 1.7.0 
  396. * @see WP_List_Table::single_row_columns() 
  397. * @param array $item A singular item (one full row). 
  398. */ 
  399. public function column_comment( $item = array() ) { 
  400.  
  401. // Preorder items: Edit | Delete | View. 
  402. $actions = array( 
  403. 'edit' => '',  
  404. 'delete' => '',  
  405. 'view' => '',  
  406. ); 
  407.  
  408. // We need the group object for some BP functions. 
  409. $item_obj = (object) $item; 
  410.  
  411. // Build actions URLs. 
  412. $base_url = bp_get_admin_url( 'admin.php?page=bp-groups&gid=' . $item['id'] ); 
  413. $delete_url = wp_nonce_url( $base_url . "&action=delete", 'bp-groups-delete' ); 
  414. $edit_url = $base_url . '&action=edit'; 
  415. $view_url = bp_get_group_permalink( $item_obj ); 
  416.  
  417. /** 
  418. * Filters the group name for a group's column content. 
  419. * @since 1.7.0 
  420. * @param string $value Name of the group being rendered. 
  421. * @param array $item Array for the current group item. 
  422. */ 
  423. $group_name = apply_filters_ref_array( 'bp_get_group_name', array( $item['name'], $item ) ); 
  424.  
  425. // Rollover actions. 
  426. // Edit. 
  427. $actions['edit'] = sprintf( '<a href="%s">%s</a>', esc_url( $edit_url ), __( 'Edit', 'buddypress' ) ); 
  428.  
  429. // Delete. 
  430. $actions['delete'] = sprintf( '<a href="%s">%s</a>', esc_url( $delete_url ), __( 'Delete', 'buddypress' ) ); 
  431.  
  432. // Visit. 
  433. $actions['view'] = sprintf( '<a href="%s">%s</a>', esc_url( $view_url ), __( 'View', 'buddypress' ) ); 
  434.  
  435. /** 
  436. * Filters the actions that will be shown for the column content. 
  437. * @since 1.7.0 
  438. * @param array $value Array of actions to be displayed for the column content. 
  439. * @param array $item The current group item in the loop. 
  440. */ 
  441. $actions = apply_filters( 'bp_groups_admin_comment_row_actions', array_filter( $actions ), $item ); 
  442.  
  443. // Get group name and avatar. 
  444. $avatar = ''; 
  445.  
  446. if ( buddypress()->avatar->show_avatars ) { 
  447. $avatar = bp_core_fetch_avatar( array( 
  448. 'item_id' => $item['id'],  
  449. 'object' => 'group',  
  450. 'type' => 'thumb',  
  451. 'avatar_dir' => 'group-avatars',  
  452. 'alt' => sprintf( __( 'Group logo of %s', 'buddypress' ), $group_name ),  
  453. 'width' => '32',  
  454. 'height' => '32',  
  455. 'title' => $group_name 
  456. ) ); 
  457.  
  458. $content = sprintf( '<strong><a href="%s">%s</a></strong>', esc_url( $edit_url ), $group_name ); 
  459.  
  460. echo $avatar . ' ' . $content . ' ' . $this->row_actions( $actions ); 
  461.  
  462. /** 
  463. * Markup for the Description column. 
  464. * @since 1.7.0 
  465. * @param array $item Information about the current row. 
  466. */ 
  467. public function column_description( $item = array() ) { 
  468.  
  469. /** 
  470. * Filters the markup for the Description column. 
  471. * @since 1.0.0 
  472. * @param string $value Markup for the Description column. 
  473. * @param array $item The current group item in the loop. 
  474. */ 
  475. echo apply_filters_ref_array( 'bp_get_group_description', array( $item['description'], $item ) ); 
  476.  
  477. /** 
  478. * Markup for the Status column. 
  479. * @since 1.7.0 
  480. * @param array $item Information about the current row. 
  481. */ 
  482. public function column_status( $item = array() ) { 
  483. $status = $item['status']; 
  484. $status_desc = ''; 
  485.  
  486. // @todo This should be abstracted out somewhere for the whole 
  487. // Groups component. 
  488. switch ( $status ) { 
  489. case 'public' : 
  490. $status_desc = __( 'Public', 'buddypress' ); 
  491. break; 
  492. case 'private' : 
  493. $status_desc = __( 'Private', 'buddypress' ); 
  494. break; 
  495. case 'hidden' : 
  496. $status_desc = __( 'Hidden', 'buddypress' ); 
  497. break; 
  498.  
  499. /** 
  500. * Filters the markup for the Status column. 
  501. * @since 1.7.0 
  502. * @param string $status_desc Markup for the Status column. 
  503. * @parma array $item The current group item in the loop. 
  504. */ 
  505. echo apply_filters_ref_array( 'bp_groups_admin_get_group_status', array( $status_desc, $item ) ); 
  506.  
  507. /** 
  508. * Markup for the Number of Members column. 
  509. * @since 1.7.0 
  510. * @param array $item Information about the current row. 
  511. */ 
  512. public function column_members( $item = array() ) { 
  513. $count = groups_get_groupmeta( $item['id'], 'total_member_count' ); 
  514.  
  515. /** 
  516. * Filters the markup for the number of Members column. 
  517. * @since 1.7.0 
  518. * @param int $count Markup for the number of Members column. 
  519. * @parma array $item The current group item in the loop. 
  520. */ 
  521. echo apply_filters_ref_array( 'bp_groups_admin_get_group_member_count', array( (int) $count, $item ) ); 
  522.  
  523. /** 
  524. * Markup for the Last Active column. 
  525. * @since 1.7.0 
  526. * @param array $item Information about the current row. 
  527. */ 
  528. public function column_last_active( $item = array() ) { 
  529. $last_active = groups_get_groupmeta( $item['id'], 'last_activity' ); 
  530.  
  531. /** 
  532. * Filters the markup for the Last Active column. 
  533. * @since 1.7.0 
  534. * @param string $last_active Markup for the Last Active column. 
  535. * @parma array $item The current group item in the loop. 
  536. */ 
  537. echo apply_filters_ref_array( 'bp_groups_admin_get_group_last_active', array( $last_active, $item ) ); 
  538.  
  539. /** 
  540. * Allow plugins to add their custom column. 
  541. * @since 2.0.0 
  542. * @param array $item Information about the current row. 
  543. * @param string $column_name The column name. 
  544. * @return string 
  545. */ 
  546. public function column_default( $item = array(), $column_name = '' ) { 
  547.  
  548. /** 
  549. * Filters a string to allow plugins to add custom column content. 
  550. * @since 2.0.0 
  551. * @param string $value Empty string. 
  552. * @param string $column_name Name of the column being rendered. 
  553. * @param array $item The current group item in the loop. 
  554. */ 
  555. return apply_filters( 'bp_groups_admin_get_group_custom_column', '', $column_name, $item ); 
  556.  
  557. // Group Types 
  558.  
  559. /** 
  560. * Add group type column to the WordPress admin groups list table. 
  561. * @since 2.7.0 
  562. * @param array $columns Groups table columns. 
  563. * @return array $columns 
  564. */ 
  565. public function add_type_column( $columns = array() ) { 
  566. $columns['bp_group_type'] = _x( 'Group Type', 'Label for the WP groups table group type column', 'buddypress' ); 
  567.  
  568. return $columns; 
  569.  
  570. /** 
  571. * Markup for the Group Type column. 
  572. * @since 2.7.0 
  573. * @param string $value Empty string. 
  574. * @param string $column_name Name of the column being rendered. 
  575. * @param array $item The current group item in the loop. 
  576. */ 
  577. public function column_content_group_type( $retval = '', $column_name, $item ) { 
  578. if ( 'bp_group_type' !== $column_name ) { 
  579. return $retval; 
  580.  
  581. add_filter( 'bp_get_group_type_directory_permalink', array( $this, 'group_type_permalink_use_admin_filter' ), 10, 2 ); 
  582. $retval = bp_get_group_type_list( $item['id'], array( 
  583. 'parent_element' => '',  
  584. 'label_element' => '',  
  585. 'label' => '',  
  586. 'show_all' => true 
  587. ) ); 
  588. remove_filter( 'bp_get_group_type_directory_permalink', array( $this, 'group_type_permalink_use_admin_filter' ), 10 ); 
  589.  
  590. /** 
  591. * Filters the markup for the Group Type column. 
  592. * @since 2.7.0 
  593. * @param string $retval Markup for the Group Type column. 
  594. * @parma array $item The current group item in the loop. 
  595. */ 
  596. echo apply_filters_ref_array( 'bp_groups_admin_get_group_type_column', array( $retval, $item ) ); 
  597.  
  598. /** 
  599. * Filters the group type list permalink in the Group Type column. 
  600. * Changes the group type permalink to use the admin URL. 
  601. * @since 2.7.0 
  602. * @param string $retval Current group type permalink. 
  603. * @param object $type Group type object. 
  604. * @return string 
  605. */ 
  606. public function group_type_permalink_use_admin_filter( $retval, $type ) { 
  607. return add_query_arg( array( 'bp-group-type' => urlencode( $type->name ) ) ); 
  608.  
  609. /** 
  610. * Markup for the Group Type bulk change select. 
  611. * @since 2.7.0 
  612. * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. 
  613. */ 
  614. public function add_group_type_bulk_change_select( $which ) { 
  615. // `$which` is only passed in WordPress 4.6+. Avoid duplicating controls in earlier versions. 
  616. static $displayed = false; 
  617. if ( version_compare( bp_get_major_wp_version(), '4.6', '<' ) && $displayed ) { 
  618. return; 
  619. $displayed = true; 
  620. $id_name = 'bottom' === $which ? 'bp_change_type2' : 'bp_change_type'; 
  621.  
  622. $types = bp_groups_get_group_types( array(), 'objects' ); 
  623. ?> 
  624. <div class="alignleft actions"> 
  625. <label class="screen-reader-text" for="<?php echo $id_name; ?>"><?php _e( 'Change group type to…', 'buddypress' ) ?></label> 
  626. <select name="<?php echo $id_name; ?>" id="<?php echo $id_name; ?>" style="display:inline-block;float:none;"> 
  627. <option value=""><?php _e( 'Change group type to…', 'buddypress' ) ?></option> 
  628.  
  629. <?php foreach( $types as $type ) : ?> 
  630.  
  631. <option value="<?php echo esc_attr( $type->name ); ?>"><?php echo esc_html( $type->labels['singular_name'] ); ?></option> 
  632.  
  633. <?php endforeach; ?> 
  634.  
  635. <option value="remove_group_type"><?php _e( 'No Group Type', 'buddypress' ) ?></option> 
  636.  
  637. </select> 
  638. <?php 
  639. wp_nonce_field( 'bp-bulk-groups-change-type-' . bp_loggedin_user_id(), 'bp-bulk-groups-change-type-nonce' ); 
  640. submit_button( __( 'Change', 'buddypress' ), 'button', 'bp_change_group_type', false ); 
  641. ?> 
  642. </div> 
  643. <?php