Passed
Push — 218-fix/metabox-for-delete-pos... ( 76f661...4c1c9d )
by
unknown
06:21
created

DeletePostsPage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 74
ccs 0
cts 30
cp 0
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get_bulkwp_menu_position() 0 9 1
A initialize() 0 15 1
A add_help_tab() 0 11 1
A register() 0 12 1
1
<?php
2
3
namespace BulkWP\BulkDelete\Core\Posts;
4
5
use BulkWP\BulkDelete\Core\Base\MetaboxPage;
6
7 1
defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
8
9
/**
10
 * Bulk Delete Posts Page.
11
 *
12
 * Shows the list of modules that allows you to delete posts.
13
 *
14
 * @since 6.0.0
15
 */
16
class DeletePostsPage extends MetaboxPage {
17
	/**
18
	 * Position in which the Bulk WP menu should appear.
19
	 */
20
	const MENU_POSITION = '26';
21
22
	/**
23
	 * Initialize and setup variables.
24
	 */
25
	protected function initialize() {
26
		$this->page_slug  = 'bulk-delete-posts';
27
		$this->item_type  = 'posts';
28
		$this->capability = 'delete_posts';
29
30
		$this->label = array(
31
			'page_title' => __( 'Bulk Delete Posts', 'bulk-delete' ),
32
			'menu_title' => __( 'Bulk Delete Posts', 'bulk-delete' ),
33
		);
34
35
		$this->messages = array(
36
			'warning_message' => __( 'WARNING: Posts deleted once cannot be retrieved back. Use with caution.', 'bulk-delete' ),
37
		);
38
39
		$this->show_link_in_plugin_list = true;
40
	}
41
42
	public function register() {
43
		add_menu_page(
44
			__( 'Bulk WP', 'bulk-delete' ),
45
			__( 'Bulk WP', 'bulk-delete' ),
46
			$this->capability,
47
			$this->page_slug,
48
			array( $this, 'render_page' ),
49
			'dashicons-trash',
50
			$this->get_bulkwp_menu_position()
51
		);
52
53
		parent::register();
54
	}
55
56
	/**
57
	 * Get the Menu position of BulkWP menu.
58
	 *
59
	 * @return int Menu position.
60
	 */
61
	protected function get_bulkwp_menu_position() {
62
		/**
63
		 * Bulk WP Menu position.
64
		 *
65
		 * @since 6.0.0
66
		 *
67
		 * @param int Menu Position.
68
		 */
69
		return apply_filters( 'bd_bulkwp_menu_position', self::MENU_POSITION );
70
	}
71
72
	/**
73
	 * Add Help tabs.
74
	 *
75
	 * @param array $help_tabs Help tabs.
76
	 *
77
	 * @return array Modified list of tabs.
78
	 */
79
	protected function add_help_tab( $help_tabs ) {
80
		$overview_tab = array(
81
			'title'    => __( 'Overview', 'bulk-delete' ),
82
			'id'       => 'overview_tab',
83
			'content'  => '<p>' . __( 'This screen contains different modules that allows you to delete posts or schedule them for deletion.', 'bulk-delete' ) . '</p>',
84
			'callback' => false,
85
		);
86
87
		$help_tabs['overview_tab'] = $overview_tab;
88
89
		return $help_tabs;
90
	}
91
}
92