Completed
Push — master ( 2a5bdf...b12cef )
by Sudar
08:15 queued 04:50
created

BD_Users_Page   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 75
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add_plugin_action_links() 0 9 2
A initialize() 0 15 1
A factory() 0 8 2
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
		}
33
34
		return $instance;
35
	}
36
37
	/**
38
	 * Initialize and setup variables.
39
	 *
40
	 * @since 5.5
41
	 */
42
	protected function initialize() {
43
		$this->page_slug  = 'bulk-delete-users';
44
		$this->item_type  = 'users';
45
		$this->capability = 'delete_users';
46
47
		$this->label = array(
48
			'page_title' => __( 'Bulk Delete Users', 'bulk-delete' ),
49
			'menu_title' => __( 'Bulk Delete Users', 'bulk-delete' ),
50
		);
51
52
		$this->messages = array(
53
			'warning_message'      => __( 'WARNING: Users deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ),
54
		);
55
56
		add_filter( 'plugin_action_links', array( $this, 'add_plugin_action_links' ), 10, 2 );
57
	}
58
59
	/**
60
	 * Adds setting links in plugin listing page.
61
	 * Based on http://striderweb.com/nerdaphernalia/2008/06/wp-use-action-links/.
62
	 *
63
	 * @param array  $links List of current links
64
	 * @param string $file  Plugin filename
65
	 *
66
	 * @return array $links Modified list of links
67
	 */
68
	public function add_plugin_action_links( $links, $file ) {
69
		$this_plugin = plugin_basename( Bulk_Delete::$PLUGIN_FILE );
70
71
		if ( $file == $this_plugin ) {
72
			$delete_users_link = '<a href="admin.php?page=' . $this->page_slug . '">' . __( 'Bulk Delete Users', 'bulk-delete' ) . '</a>';
73
			array_unshift( $links, $delete_users_link ); // before other links
74
		}
75
76
		return $links;
77
	}
78
79
	/**
80
	 * Add Help tabs.
81
	 *
82
	 * @since 5.5
83
	 *
84
	 * @param mixed $help_tabs
85
	 */
86
	protected function add_help_tab( $help_tabs ) {
87
		$overview_tab = array(
88
			'title'    => __( 'Overview', 'bulk-delete' ),
89
			'id'       => 'overview_tab',
90
			'content'  => '<p>' . __( 'This screen contains different modules that allows you to delete users or schedule them for deletion.', 'bulk-delete' ) . '</p>',
91
			'callback' => false,
92
		);
93
		$help_tabs['overview_tab'] = $overview_tab;
94
95
		return $help_tabs;
96
	}
97
}
98
99
BD_Users_Page::factory();
100