TableRows.php
998 Bytes
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\Editing\Ajax;
use AC;
use AC\Response;
abstract class TableRows extends Request {
/**
* @var AC\ListScreenWP
*/
protected $list_screen;
/**
* @param AC\Request $request
* @param AC\ListScreenWP $list_screen
*/
public function __construct( AC\Request $request, AC\ListScreenWP $list_screen ) {
parent::__construct( $request );
$this->list_screen = $list_screen;
}
/**
* @return string
*/
protected function get_action() {
return 'get_table_rows';
}
public function handle_request() {
remove_action( 'parse_term_query', [ $this, __FUNCTION__ ] );
$this->check_nonce();
$ids = $this->request->filter( 'ac_ids', [], FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY );
$response = new Response\Json();
if ( ! $ids ) {
$response->error();
}
$rows = [];
foreach ( $ids as $id ) {
$rows[ $id ] = $this->list_screen->get_single_row( $id );
}
$response->set_parameter( 'table_rows', $rows )
->success();
}
}