TableFormView.php
959 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
56
57
58
59
<?php
namespace AC\Table;
use AC\Registerable;
final class TableFormView implements Registerable {
const PARAM_ACTION = 'ac-actions-form';
/**
* @var string
*/
private $type;
/**
* @var string
*/
private $html;
/**
* @var int
*/
private $priority;
public function __construct( $type, $html, $priority = null ) {
if ( null === $priority ) {
$priority = 10;
}
$this->type = (string) $type;
$this->html = (string) $html;
$this->priority = (int) $priority;
}
public function register(): void
{
switch ( $this->type ) {
case 'post':
add_action( 'restrict_manage_posts', [ $this, 'render' ], $this->priority );
break;
case'user':
add_action( 'restrict_manage_users', [ $this, 'render' ], $this->priority );
break;
case 'comment':
add_action( 'restrict_manage_comment', [ $this, 'render' ], $this->priority );
break;
}
}
public function render() {
echo $this->html;
}
}