ListScreenUsers.php
799 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
<?php
namespace ACP\RequestHandler\Ajax;
use AC;
use AC\Nonce;
use AC\Request;
use ACP\Helper\Select;
use ACP\RequestAjaxHandler;
class ListScreenUsers implements RequestAjaxHandler {
public function handle(): void {
$request = new Request();
if ( ! ( new Nonce\Ajax() )->verify( $request ) ) {
wp_send_json_error();
}
$entities = new Select\Entities\User( [
'search' => $request->get( 'search' ),
'paged' => $request->get( 'page', 1 ),
'number' => 10,
] );
$options = new AC\Helper\Select\Options\Paginated(
$entities,
new Select\Group\UserRole(
new Select\Formatter\UserName( $entities )
)
);
$has_more = ! $options->is_last_page();
$response = new AC\Helper\Select\Response( $options, $has_more );
wp_send_json_success( $response() );
}
}