Field.php
1.97 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
<?php
namespace ACA\EC\Column\Event;
use AC;
use ACA\EC\API;
use ACA\EC\Editing;
use ACA\EC\Service\ColumnGroups;
use ACP;
/**
* @since 1.1.2
*/
class Field extends AC\Column\Meta
implements ACP\Sorting\Sortable, ACP\Filtering\Filterable, ACP\Editing\Editable, ACP\Export\Exportable, ACP\Search\Searchable, ACP\ConditionalFormat\Formattable {
use ACP\ConditionalFormat\ConditionalFormatTrait;
public function __construct() {
$this->set_label( __( 'Additional Fields', 'tribe-events-calendar-pro' ) )
->set_group( ColumnGroups::EVENTS_CALENDAR_FIELDS );
}
/**
* @param int $id
*
* @return string
*/
public function get_value( $id ) {
$fields = tribe_get_custom_fields( $id );
if ( ! is_array( $fields ) ) {
return $this->get_empty_char();
}
$label = $this->get( 'label' );
if ( ! array_key_exists( $label, $fields ) ) {
return $this->get_empty_char();
}
return $fields[ $label ];
}
/**
* @return false|array
*/
public function get_field() {
return API::get_field( $this->get_meta_key() );
}
/**
* @return string
*/
public function get_meta_key() {
return substr( $this->get_type(), strlen( 'column' ) );
}
/**
* @param string $var
*
* @return mixed
*/
public function get( $var ) {
return API::get( $this->get_meta_key(), $var );
}
public function is_valid() {
return API::is_pro();
}
public function sorting() {
return ( new ACP\Sorting\Model\MetaFactory() )->create( $this->get_meta_type(), $this->get_meta_key() );
}
public function filtering() {
return new ACP\Filtering\Model\Meta( $this );
}
public function editing() {
return new ACP\Editing\Service\Basic(
( new ACP\Editing\View\Text() )->set_clear_button( true ),
new ACP\Editing\Storage\Post\Meta( $this->get_meta_key() )
);
}
public function export() {
return new ACP\Export\Model\StrippedValue( $this );
}
public function search() {
return new ACP\Search\Comparison\Meta\Text( $this->get_meta_key(), $this->get_meta_type() );
}
}