WPMLColumn.php
1.04 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
<?php
namespace AC\ThirdParty;
/**
* WPML: display correct flags on the overview screens
*/
class WPMLColumn
{
const COLUMN_NAME = 'icl_translations';
private $column;
function __construct(string $post_type)
{
add_filter(
"manage_{$post_type}_posts_columns",
[$this, 'store_wpml_column'],
11 // priority just after WPML set's it's column
);
add_filter(
"manage_edit-{$post_type}_columns",
[$this, 'replace_wpml_column'],
201 // priority just after AC overwrite all columns
);
}
public function store_wpml_column($columns)
{
if (empty($this->column) && isset($columns[self::COLUMN_NAME])) {
$this->column = $columns[self::COLUMN_NAME];
}
return $columns;
}
public function replace_wpml_column($columns)
{
if ($this->column && isset($columns[self::COLUMN_NAME])) {
$columns[self::COLUMN_NAME] = $this->column;
}
return $columns;
}
}