1 | <?php |
||
20 | abstract class BD_Page extends BD_Base_Page { |
||
21 | /** |
||
22 | * @var string Item Type. Possible values 'posts', 'pages', 'users' etc. |
||
23 | */ |
||
24 | protected $item_type; |
||
25 | |||
26 | /** |
||
27 | * Setup hooks. |
||
28 | * |
||
29 | * @since 5.5 |
||
30 | */ |
||
31 | protected function setup_hooks() { |
||
32 | parent::setup_hooks(); |
||
33 | |||
34 | add_action( "bd_admin_footer_for_{$this->item_type}", array( $this, 'modify_admin_footer' ) ); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Check for nonce before executing the action. |
||
39 | * |
||
40 | * @since 5.5 |
||
41 | * |
||
42 | * @param bool $result The current result. |
||
43 | * @param string $action Action name. |
||
44 | */ |
||
45 | public function nonce_check( $result, $action ) { |
||
46 | $action_prefix = "delete_{$this->item_type}_"; |
||
47 | |||
48 | if ( $action_prefix === substr( $action, 0, strlen( $action_prefix ) ) |
||
49 | && check_admin_referer( "bd-{$this->page_slug}", "bd-{$this->page_slug}-nonce" ) ) { |
||
50 | return true; |
||
51 | } else { |
||
52 | return $result; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | /** |
||
57 | * Add menu. |
||
58 | * |
||
59 | * @since 5.5 |
||
60 | */ |
||
61 | public function add_menu() { |
||
62 | parent::add_menu(); |
||
63 | |||
64 | $bd = BULK_DELETE(); |
||
65 | |||
66 | add_action( "admin_print_scripts-{$this->screen}", array( $bd, 'add_script' ) ); |
||
67 | |||
68 | add_action( "load-{$this->screen}", array( $this, 'add_settings_panel' ) ); |
||
69 | add_action( "add_meta_boxes_{$this->screen}", array( $this, 'add_meta_boxes' ) ); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * Add settings Panel. |
||
74 | * |
||
75 | * @since 5.5 |
||
76 | */ |
||
77 | public function add_settings_panel() { |
||
78 | /** |
||
79 | * Add contextual help for admin screens. |
||
80 | * |
||
81 | * @since 5.1 |
||
82 | */ |
||
83 | do_action( 'bd_add_contextual_help', $this->screen ); |
||
84 | |||
85 | // Trigger the add_meta_boxes hooks to allow meta boxes to be added |
||
86 | do_action( 'add_meta_boxes_' . $this->screen, null ); |
||
87 | |||
88 | // Enqueue WordPress' script for handling the meta boxes |
||
89 | wp_enqueue_script( 'postbox' ); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Register meta boxes. |
||
94 | * |
||
95 | * @since 5.5 |
||
96 | */ |
||
97 | public function add_meta_boxes() { |
||
98 | /** |
||
99 | * Add meta box in delete users page. |
||
100 | * This hook can be used for adding additional meta boxes in delete users page. |
||
101 | * |
||
102 | * @since 5.3 |
||
103 | */ |
||
104 | do_action( "bd_add_meta_box_for_{$this->item_type}", $this->screen, $this->page_slug ); |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Add additional nonce fields. |
||
109 | * |
||
110 | * @since 5.5.4 |
||
111 | */ |
||
112 | protected function render_nonce_fields() { |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Render meta boxes in body. |
||
122 | * |
||
123 | * @since 5.5.4 |
||
124 | */ |
||
125 | protected function render_body() { |
||
126 | do_meta_boxes( '', 'advanced', null ); |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * Render footer. |
||
131 | * |
||
132 | * @since 5.5.4 |
||
133 | */ |
||
134 | protected function render_footer() { |
||
145 | } |
||
146 | } |
||
147 |