Taxonomy.php
960 Bytes
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
<?php
namespace ACA\MetaBox\Editing\Service;
use ACA;
use ACP;
use ACP\Editing\View;
class Taxonomy implements ACP\Editing\Service, ACP\Editing\PaginatedOptions {
/**
* @var string|array
*/
protected $taxonomy;
/**
* @var ACP\Editing\Storage
*/
private $storage;
public function __construct( ACP\Editing\Storage $storage, $taxonomy ) {
$this->storage = $storage;
$this->taxonomy = $taxonomy;
}
public function get_view( string $context ): ?View {
return new ACP\Editing\View\AjaxSelect();
}
public function update( int $id, $data ): void {
$this->storage->update( $id, $data );
}
public function get_value( $id ) {
$value = $this->storage->get( $id );
return $value
? [ $value => ac_helper()->taxonomy->get_term_display_name( get_term( $value ) ) ]
: false;
}
public function get_paginated_options( $s, $paged, $id = null ) {
return new ACP\Helper\Select\Paginated\Terms( $s, $paged, $this->taxonomy );
}
}