Settings.php
1.11 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
<?php
namespace ACP\Export;
use AC;
use AC\Asset\Style;
use AC\Registrable;
class Settings implements Registrable {
/**
* @var AC\Asset\Location
*/
protected $location;
public function __construct( AC\Asset\Location $location ) {
$this->location = $location;
}
public function register() {
add_action( 'ac/column/settings', [ $this, 'column_settings' ], 9 );
add_action( 'ac/admin_scripts/columns', [ $this, 'admin_scripts' ] );
}
/**
* @param AC\Column $column
*
* @return bool
*/
private function is_exportable( AC\Column $column ) {
$list_screen = $column->get_list_screen();
if ( ! $list_screen instanceof ListScreen ) {
return false;
}
if ( $column instanceof Exportable && ! $column->export()->is_active() ) {
return false;
}
return true;
}
public function column_settings( AC\Column $column ) {
if ( $this->is_exportable( $column ) ) {
$column->add_setting( new Settings\Column( $column ) );
}
}
public function admin_scripts() {
$style = new Style( 'acp-search-admin', $this->location->with_suffix( 'assets/search/css/admin.css' ) );
$style->enqueue();
}
}