UpcomingEvent.php
1.18 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
<?php
namespace ACA\EC\Column;
use ACA\EC\Export;
use ACA\EC\Settings;
use ACP;
abstract class UpcomingEvent extends Events
implements ACP\Export\Exportable {
public function __construct() {
parent::__construct();
$this->set_label( __( 'Upcoming Event', 'codepress-admin-columns' ) );
}
public function get_value( $id ) {
$raw_value = $this->get_raw_value( $id );
if ( ! $raw_value ) {
return $this->get_empty_char();
}
$values = [
$this->get_formatted_value( ac_helper()->post->get_title( $raw_value ), $raw_value ),
];
$setting = $this->get_setting( 'show_event_date' );
if ( $setting && 'on' === $setting->get_value() ) {
$values[] = tribe_events_event_schedule_details( $raw_value );
}
return implode( '<br>', $values );
}
public function get_raw_value( $id ) {
$event = $this->get_events_by_id( $id, [
'posts_per_page' => 1,
] );
if ( ! $event ) {
return false;
}
return $event[0]->ID;
}
public function register_settings() {
$this->add_setting( new Settings\EventLink( $this ) );
$this->add_setting( new Settings\ShowEventDate( $this ) );
}
public function export() {
return new Export\Model\UpcomingEvent( $this );
}
}