Organizer.php
2.52 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
104
105
106
107
108
109
110
<?php
namespace ACA\EC\Column\Event;
use AC;
use ACA\EC\Column\Meta;
use ACA\EC\Editing;
use ACA\EC\Filtering;
use ACA\EC\Search;
use ACA\EC\Settings;
use ACP;
use ACP\ConditionalFormat;
use ACP\Sorting\Model\MetaFormatFactory;
class Organizer extends Meta
implements AC\Column\Relation, ACP\Export\Exportable, ACP\Search\Searchable, ConditionalFormat\Formattable
{
use ConditionalFormat\FilteredHtmlFormatTrait;
public function __construct()
{
$this->set_type('column-ec-event_organizer')
->set_label(__('Organizer', 'codepress-admin-columns'));
parent::__construct();
}
public function get_relation_object()
{
return new AC\Relation\Post('tribe_organizer');
}
public function get_meta_key()
{
return '_EventOrganizerID';
}
public function get_value($id)
{
$post_ids = $this->get_raw_value($id);
if ( ! $post_ids) {
return $this->get_empty_char();
}
$values = [];
foreach ($post_ids as $_id) {
$values[] = $this->get_formatted_value($_id, $_id);
}
$setting_limit = $this->get_setting('number_of_items');
return ac_helper()->html->more($values, $setting_limit ? $setting_limit->get_value() : false);
}
public function get_raw_value($id)
{
$value = $this->get_meta_value($id, $this->get_meta_key(), false);
$value = array_filter($value);
if ( ! $value) {
return false;
}
return $value;
}
public function register_settings()
{
$this->add_setting(new Settings\OrganizerDisplay($this));
$this->add_setting(new AC\Settings\Column\NumberOfItems($this));
}
public function editing()
{
return new Editing\Service\Event\Organizer();
}
public function filtering()
{
return new Filtering\RelatedPost($this);
}
public function sorting()
{
return (new MetaFormatFactory())->create(
$this->get_meta_type(),
$this->get_meta_key(),
new ACP\Sorting\FormatValue\PostTitle(),
null,
[
'taxonomy' => $this->get_taxonomy(),
'post_type' => $this->get_post_type(),
]
);
}
public function export()
{
return new ACP\Export\Model\StrippedValue($this);
}
public function search()
{
return new Search\Event\Relation($this->get_meta_key(), $this->get_meta_type(), $this->get_relation_object());
}
}