1 | <?php |
||
18 | class Bulk_Delete_Users_By_User_Role extends BD_User_Meta_Box_Module { |
||
19 | /** |
||
20 | * Make this class a "hybrid Singleton". |
||
21 | * |
||
22 | * @static |
||
23 | * |
||
24 | * @since 5.5 |
||
25 | */ |
||
26 | 1 | public static function factory() { |
|
27 | 1 | static $instance = false; |
|
28 | |||
29 | 1 | if ( ! $instance ) { |
|
30 | 1 | $instance = new self; |
|
31 | } |
||
32 | |||
33 | 1 | return $instance; |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * Initialize and setup variables. |
||
38 | * |
||
39 | * @since 5.5 |
||
40 | */ |
||
41 | 1 | protected function initialize() { |
|
42 | 1 | $this->item_type = 'users'; |
|
43 | 1 | $this->field_slug = 'u_role'; |
|
44 | 1 | $this->meta_box_slug = 'bd_users_by_role'; |
|
45 | 1 | $this->meta_box_hook = "bd_add_meta_box_for_{$this->item_type}"; |
|
46 | 1 | $this->delete_action = 'delete_users_by_role'; |
|
47 | 1 | $this->cron_hook = 'do-bulk-delete-users-by-role'; |
|
48 | 1 | $this->scheduler_url = 'http://bulkwp.com/addons/scheduler-for-deleting-users-by-role/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=buynow&utm_content=bd-u-ur'; |
|
49 | 1 | $this->messages = array( |
|
50 | 1 | 'box_label' => __( 'By User Role', 'bulk-delete' ), |
|
51 | 1 | 'scheduled' => __( 'Users from the selected userrole are scheduled for deletion.', 'bulk-delete' ), |
|
52 | 1 | 'deleted_single' => __( 'Deleted %d user from the selected roles', 'bulk-delete' ), |
|
53 | 1 | 'deleted_plural' => __( 'Deleted %d users from the selected roles', 'bulk-delete' ), |
|
54 | ); |
||
55 | 1 | } |
|
56 | |||
57 | /** |
||
58 | * Render delete users box. |
||
59 | * |
||
60 | * @since 5.5 |
||
61 | */ |
||
62 | public function render() { |
||
63 | ?> |
||
64 | <!-- Users Start--> |
||
65 | <h4><?php _e( 'Select the user roles from which you want to delete users', 'bulk-delete' ); ?></h4> |
||
66 | |||
67 | <fieldset class="options"> |
||
68 | <table class="optiontable"> |
||
69 | <?php |
||
70 | $users_count = count_users(); |
||
71 | foreach ( $users_count['avail_roles'] as $role => $count ) { |
||
72 | ?> |
||
73 | <tr> |
||
74 | <td scope="row" > |
||
75 | <input name="smbd_u_roles[]" value = "<?php echo $role; ?>" type = "checkbox"> |
||
76 | <label for="smbd_u_roles"><?php echo $role; ?> (<?php echo $count . ' '; _e( 'Users', 'bulk-delete' ); ?>)</label> |
||
77 | </td> |
||
78 | </tr> |
||
79 | <?php |
||
80 | } |
||
81 | ?> |
||
82 | </table> |
||
83 | |||
84 | <table class="optiontable"> |
||
85 | <?php |
||
86 | $this->render_filtering_table_header(); |
||
87 | $this->render_user_login_restrict_settings(); |
||
88 | $this->render_user_with_no_posts_settings(); |
||
89 | $this->render_limit_settings(); |
||
90 | $this->render_cron_settings(); |
||
91 | ?> |
||
92 | </table> |
||
93 | </fieldset> |
||
94 | <!-- Users end--> |
||
95 | <?php |
||
96 | $this->render_submit_button(); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Process the request for deleting users by role. |
||
101 | * |
||
102 | * @since 5.5 |
||
103 | */ |
||
104 | public function process() { |
||
105 | $delete_options = array(); |
||
106 | |||
107 | // Nonce verification is handled in `request_handler()`. |
||
108 | $delete_options['selected_roles'] = bd_array_get( $_POST, 'smbd_u_roles' ); // WPCS: XSS ok. |
||
109 | |||
110 | $this->process_user_delete( $delete_options ); |
||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Delete users by user role. |
||
115 | * |
||
116 | * @since 5.5 |
||
117 | * |
||
118 | * @param array $delete_options Delete Options |
||
119 | * |
||
120 | * @return int Number of users deleted |
||
121 | */ |
||
122 | public function delete( $delete_options ) { |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * Filter JS Array and add validation hooks. |
||
143 | * |
||
144 | * @since 5.5 |
||
145 | * |
||
146 | * @param array $js_array JavaScript Array |
||
147 | * |
||
148 | * @return array Modified JavaScript Array |
||
149 | */ |
||
150 | public function filter_js_array( $js_array ) { |
||
160 | } |
||
161 | } |
||
162 | |||
163 | 1 | Bulk_Delete_Users_By_User_Role::factory(); |
|
164 | ?> |
||
165 |