Costs.php
1.32 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
<?php
namespace ACA\EC\Column\Event;
use ACA\EC\Column\Meta;
use ACP;
use ACP\ConditionalFormat\FormattableConfig;
use ACP\ConditionalFormat\Formatter\FloatFormatter;
use ACP\ConditionalFormat\Formatter\SanitizedFormatter;
use ACP\Sorting\Type\DataType;
class Costs extends Meta
implements ACP\Search\Searchable, ACP\ConditionalFormat\Formattable {
public function __construct() {
$this->set_type( 'column-ec-event_costs' )
->set_label( __( 'Costs', 'codepress-admin-columns' ) );
parent::__construct();
}
public function get_meta_key() {
return '_EventCost';
}
public function get_value( $id ) {
$value = tribe_get_formatted_cost( $id );
if ( ! $value ) {
return $this->get_empty_char();
}
return $value;
}
public function filtering() {
$model = new ACP\Filtering\Model\Meta( $this );
$model->set_data_type( 'numeric' );
$model->set_ranged( true );
return $model;
}
public function sorting() {
return new ACP\Sorting\Model\Post\Meta( $this->get_meta_key(), new DataType( DataType::NUMERIC ) );
}
public function search() {
return new ACP\Search\Comparison\Meta\Number( $this->get_meta_key(), $this->get_meta_type() );
}
public function conditional_format(): ?FormattableConfig {
return new FormattableConfig( SanitizedFormatter::from_ignore_strings( new FloatFormatter() ) );
}
}