1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MslsCustomColumnTaxonomy |
4
|
|
|
* @author Dennis Ploetner <[email protected]> |
5
|
|
|
* @since 0.9.8 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace lloc\Msls; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Handling of existing/not existing translations in the backend |
12
|
|
|
* listings of various taxonomies |
13
|
|
|
* @package Msls |
14
|
|
|
*/ |
15
|
|
|
class MslsCustomColumnTaxonomy extends MslsCustomColumn { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Factory |
19
|
|
|
* |
20
|
|
|
* @codeCoverageIgnore |
21
|
|
|
* |
22
|
|
|
* @return MslsCustomColumnTaxonomy |
23
|
|
|
*/ |
24
|
|
|
public static function init() { |
25
|
|
|
$options = MslsOptions::instance(); |
26
|
|
|
$collection = MslsBlogCollection::instance(); |
27
|
|
|
$obj = new static( $options, $collection ); |
28
|
|
|
|
29
|
|
|
if ( ! $options->is_excluded() ) { |
30
|
|
|
$taxonomy = MslsTaxonomy::instance()->get_request(); |
31
|
|
|
|
32
|
|
|
if ( ! empty( $taxonomy ) ) { |
33
|
|
|
add_filter( "manage_edit-{$taxonomy}_columns" , [ $obj, 'th' ] ); |
34
|
|
|
add_action( "manage_{$taxonomy}_custom_column" , [ $obj, 'column_default' ], -100, 3 ); |
35
|
|
|
add_action( "delete_{$taxonomy}", [ $obj, 'delete' ] ); |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
return $obj; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Table body |
44
|
|
|
* |
45
|
|
|
* @param string $deprecated |
46
|
|
|
* @param string $column_name |
47
|
|
|
* @param int $item_id |
48
|
|
|
*/ |
49
|
|
|
public function column_default( $deprecated, $column_name, $item_id ) { |
50
|
|
|
$this->td( $column_name, $item_id ); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Delete |
55
|
|
|
* |
56
|
|
|
* @codeCoverageIgnore |
57
|
|
|
* |
58
|
|
|
* @param int $object_id |
59
|
|
|
*/ |
60
|
|
|
public function delete( $object_id ) { |
61
|
|
|
$this->save( $object_id, MslsOptionsTax::class ); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
} |
65
|
|
|
|