TableScreen.php
1.19 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
<?php
namespace ACP\Export;
use AC;
use AC\Asset\Location;
use AC\Registrable;
use ACP\Export\Asset\Script;
class TableScreen implements Registrable {
/**
* @var Location
*/
protected $location;
public function __construct( Location $location ) {
$this->location = $location;
}
public function register() {
add_action( 'ac/table/list_screen', [ $this, 'load_list_screen' ] );
}
/**
* Load a list screen and potentially attach the proper exporting information to it
*
* @param AC\ListScreen $list_screen List screen for current table screen
*
* @since 1.0
*/
public function load_list_screen( AC\ListScreen $list_screen ) {
if ( ! $list_screen instanceof ListScreen ) {
return;
}
$list_screen->export()->attach();
add_action( 'ac/table_scripts', [ $this, 'scripts' ] );
}
public function scripts( ListScreen $list_screen ) {
$style = new AC\Asset\Style(
'acp-export-listscreen',
$this->location->with_suffix( 'assets/export/css/listscreen.css' )
);
$style->enqueue();
$script = new Script\Table(
'acp-export-listscreen',
$this->location->with_suffix( 'assets/export/js/listscreen.js' ),
$list_screen->export()
);
$script->enqueue();
}
}