Country.php
1.1 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
<?php
namespace ACA\EC\Column\Venue;
use ACA\EC\Column\Meta;
use ACA\EC\Search;
use ACP\ConditionalFormat;
use ACP\Editing\Service\Basic;
use ACP\Editing\Storage;
use ACP\Editing\View\Select;
use ACP\Search\Searchable;
use Tribe__View_Helpers;
class Country extends Meta
implements Searchable, ConditionalFormat\Formattable {
use ConditionalFormat\ConditionalFormatTrait;
public function __construct() {
$this->set_type( 'column-ec-venue_country' )
->set_label( __( 'Country', 'codepress-admin-columns' ) );
parent::__construct();
}
public function get_meta_key() {
return '_VenueCountry';
}
public function editing() {
return new Basic(
new Select( $this->get_countries() ),
new Storage\Post\Meta( $this->get_meta_key() )
);
}
public function search() {
return new Search\Venue\Country( $this->get_meta_key(), $this->get_meta_type(), $this->get_countries() );
}
public function get_countries() {
if ( ! class_exists( 'Tribe__View_Helpers' ) ) {
return [];
}
$countries = Tribe__View_Helpers::constructCountries();
return array_combine( $countries, $countries );
}
}