Group.php
2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace ACA\BP\ListScreen;
use AC;
use ACA\BP\Column;
use ACA\BP\Editing;
use ACP;
use BP_Groups_List_Table;
use ReflectionException;
class Group extends AC\ListScreenWP
implements ACP\Editing\ListScreen {
public function __construct() {
$this->set_key( 'bp-groups' )
->set_screen_id( 'toplevel_page_bp-groups' )
->set_screen_base( 'admin' )
->set_page( 'bp-groups' )
->set_label( __( 'Groups', 'codepress-admin-columns' ) )
->set_group( 'buddypress' );
}
public function get_heading_hookname() {
return 'bp_groups_list_table_get_columns';
}
/**
* @param string $value
* @param string $column_name
* @param array $group
*
* @return string
*/
public function manage_value( $value, $column_name, $group ) {
return $this->get_display_value_by_column_name( $column_name, $group['id'], $value );
}
/**
* @param int $id
*
* @return array
*/
protected function get_object( $id ) {
return (array) groups_get_group( $id );
}
public function set_manage_value_callback() {
add_action( 'bp_groups_admin_get_group_custom_column', [ $this, 'manage_value' ], 100, 3 );
}
public function get_screen_link() {
return add_query_arg( [ 'page' => $this->get_page(), 'layout' => $this->get_layout_id() ], $this->get_admin_url() );
}
/**
* @return BP_Groups_List_Table
*/
public function get_list_table() {
// Hook suffix is required when using the list screen, mainly in Ajax
if ( ! isset( $GLOBALS['hook_suffix'] ) ) {
$GLOBALS['hook_suffix'] = $this->get_screen_id();
}
return new BP_Groups_List_Table();
}
/**
* @throws ReflectionException
*/
protected function register_column_types() {
$this->register_column_types_from_list( [
Column\Group\Avatar::class,
Column\Group\Creator::class,
Column\Group\Description::class,
Column\Group\Id::class,
Column\Group\Name::class,
Column\Group\NameOnly::class,
Column\Group\Status::class,
] );
}
public function get_table_attr_id() {
return '#bp-groups-form';
}
public function editing() {
return new Editing\Strategy\Group();
}
}