1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Bulk Delete Users Page. |
4
|
|
|
* Shows the list of modules that allows you to delete users. |
5
|
|
|
* |
6
|
|
|
* @since 5.5 |
7
|
|
|
* |
8
|
|
|
* @author Sudar |
9
|
|
|
* |
10
|
|
|
* @package BulkDelete\Users |
11
|
|
|
*/ |
12
|
|
|
defined( 'ABSPATH' ) || exit; // Exit if accessed directly |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Delete Users Page. |
16
|
|
|
* |
17
|
|
|
* @since 5.5 |
18
|
|
|
*/ |
19
|
|
|
class BD_Users_Page extends BD_Page { |
20
|
|
|
/** |
21
|
|
|
* Make this class a "hybrid Singleton". |
22
|
|
|
* |
23
|
|
|
* @static |
24
|
|
|
* |
25
|
|
|
* @since 5.5 |
26
|
|
|
*/ |
27
|
|
|
public static function factory() { |
28
|
|
|
static $instance = false; |
29
|
|
|
|
30
|
|
|
if ( ! $instance ) { |
31
|
|
|
$instance = new self; |
32
|
|
|
$instance->load_modules(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
return $instance; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
protected function load_modules() { |
39
|
|
|
Bulk_Delete_Users_By_User_Meta::factory(); |
40
|
|
|
Bulk_Delete_Users_By_User_Role::factory(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Initialize and setup variables. |
45
|
|
|
* |
46
|
|
|
* @since 5.5 |
47
|
|
|
*/ |
48
|
|
|
protected function initialize() { |
49
|
|
|
$this->page_slug = 'bulk-delete-users'; |
50
|
|
|
$this->item_type = 'users'; |
51
|
|
|
$this->capability = 'delete_users'; |
52
|
|
|
|
53
|
|
|
$this->label = array( |
54
|
|
|
'page_title' => __( 'Bulk Delete Users', 'bulk-delete' ), |
55
|
|
|
'menu_title' => __( 'Bulk Delete Users', 'bulk-delete' ), |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
$this->messages = array( |
59
|
|
|
'warning_message' => __( 'WARNING: Users deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ), |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
add_filter( 'plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 2 ); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Adds setting links in plugin listing page. |
67
|
|
|
* Based on http://striderweb.com/nerdaphernalia/2008/06/wp-use-action-links/. |
68
|
|
|
* |
69
|
|
|
* @param array $links List of current links |
70
|
|
|
* @param string $file Plugin filename |
71
|
|
|
* |
72
|
|
|
* @return array $links Modified list of links |
73
|
|
|
*/ |
74
|
|
|
public function add_plugin_action_links( $links, $file ) { |
75
|
|
|
$this_plugin = plugin_basename( Bulk_Delete::$PLUGIN_FILE ); |
76
|
|
|
|
77
|
|
|
if ( $file == $this_plugin ) { |
78
|
|
|
$delete_users_link = '<a href="admin.php?page=' . $this->page_slug . '">' . __( 'Bulk Delete Users', 'bulk-delete' ) . '</a>'; |
79
|
|
|
array_unshift( $links, $delete_users_link ); // before other links |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
return $links; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Add Help tabs. |
87
|
|
|
* |
88
|
|
|
* @since 5.5 |
89
|
|
|
* |
90
|
|
|
* @param mixed $help_tabs |
91
|
|
|
*/ |
92
|
|
|
protected function add_help_tab( $help_tabs ) { |
93
|
|
|
$overview_tab = array( |
94
|
|
|
'title' => __( 'Overview', 'bulk-delete' ), |
95
|
|
|
'id' => 'overview_tab', |
96
|
|
|
'content' => '<p>' . __( 'This screen contains different modules that allows you to delete users or schedule them for deletion.', 'bulk-delete' ) . '</p>', |
97
|
|
|
'callback' => false, |
98
|
|
|
); |
99
|
|
|
$help_tabs['overview_tab'] = $overview_tab; |
100
|
|
|
|
101
|
|
|
return $help_tabs; |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
|