Taxonomy.php
1.33 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
<?php
namespace AC\Settings\Column;
use AC;
use AC\Settings;
use AC\View;
class Taxonomy extends Settings\Column {
/**
* @var string
*/
private $taxonomy;
/**
* @var string
*/
private $post_type;
public function __construct( AC\Column $column, $post_type = null ) {
$this->post_type = $post_type;
parent::__construct( $column );
}
/**
* @return string
*/
protected function get_post_type() {
return $this->post_type
?: $this->column->get_post_type();
}
protected function define_options() {
return [ 'taxonomy' ];
}
/**
* @return View
*/
public function create_view() {
$taxonomy = $this->create_element( 'select', 'taxonomy' );
$taxonomy->set_no_result( __( 'No taxonomies available.', 'codepress-admin-columns' ) )
->set_options( ac_helper()->taxonomy->get_taxonomy_selection_options( $this->get_post_type() ) )
->set_attribute( 'data-label', 'update' )
->set_attribute( 'data-refresh', 'column' );
return new View( [
'setting' => $taxonomy,
'label' => __( 'Taxonomy', 'codepress-admin-columns' ),
] );
}
/**
* @return string
*/
public function get_taxonomy() {
return $this->taxonomy;
}
/**
* @param string $taxonomy
*
* @return bool
*/
public function set_taxonomy( $taxonomy ) {
$this->taxonomy = $taxonomy;
return true;
}
}