Profile.php
2.08 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
92
93
94
95
96
97
98
99
100
101
102
103
<?php
namespace ACA\BP\Column;
use AC;
use ACA\BP\Field;
use ACA\BP\Settings;
use ACP;
use BP_XProfile_Field;
class Profile extends AC\Column
implements ACP\Editing\Editable, ACP\Filtering\Filterable, ACP\Sorting\Sortable, ACP\Export\Exportable, ACP\Search\Searchable, ACP\ConditionalFormat\Formattable {
use ACP\ConditionalFormat\ConditionalFormatTrait;
public function __construct() {
$this->set_type( 'column-buddypress' )
->set_label( __( 'Profile Fields', 'buddypress' ) )
->set_group( 'buddypress' );
}
public function get_value( $id ) {
$value = $this->get_field()->get_value( $id );
if ( ! $value ) {
$value = $this->get_empty_char();
}
return $value;
}
public function is_valid() {
return bp_is_active( 'xprofile' );
}
public function editing() {
return $this->get_field()->editing();
}
public function filtering() {
return $this->get_field()->filtering();
}
public function sorting() {
return $this->get_field()->sorting();
}
public function export() {
return $this->get_field()->export();
}
public function search() {
return $this->get_field()->search();
}
protected function register_settings() {
$this->add_setting( new Settings\Profile( $this ) );
}
public function get_raw_value( $id ) {
return $this->get_field()->get_raw_value( $id );
}
/**
* @return false|Field\Profile
*/
public function get_field() {
$class = Field\Profile::class;
$type = $class . '\\' . ucfirst( $this->get_buddypress_field_option( 'type' ) );
// Single fields
if ( class_exists( $type ) ) {
$class = $type;
}
return new $class( $this );
}
public function get_buddypress_field() {
return new BP_XProfile_Field( $this->get_buddypress_field_id() );
}
public function get_buddypress_field_id() {
return (string) $this->get_setting( 'profile_field' )->get_value();
}
/**
* @param string $property
*
* @return mixed
*/
public function get_buddypress_field_option( $property ) {
$field = $this->get_buddypress_field();
if ( ! isset( $field->$property ) ) {
return false;
}
return $field->$property;
}
}