Bulk_Delete_Help_Screen::get_help_tabs()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 45
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 26
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 45
ccs 0
cts 31
cp 0
crap 12
rs 9.504
1
<?php
2
/**
3
 * Bulk Delete Help Screen.
4
 *
5
 * Displays the help tab on top of Bulk Delete Admin pages
6
 *
7
 * @since      5.1
8
 *
9
 * @author     Sudar
10
 *
11
 * @package    BulkDelete\Help
12
 */
13
defined( 'ABSPATH' ) || exit; // Exit if accessed directly
14
15
class Bulk_Delete_Help_Screen {
16
	/**
17
	 * Add contextual help to admin screens.
18
	 *
19
	 * @since 5.1
20
	 * @static
21
	 *
22
	 * @param string $screen Screen name
23
	 */
24
	public static function add_contextual_help( $screen ) {
25
		$help_tabs = self::get_help_tabs( $screen );
26
27
		foreach ( $help_tabs as $help_tab ) {
28
			get_current_screen()->add_help_tab( $help_tab );
0 ignored issues
show
Bug introduced by
Are you sure the usage of get_current_screen() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
29
		}
30
31
		// Add help sidebar
32
		get_current_screen()->set_help_sidebar(
0 ignored issues
show
Bug introduced by
Are you sure the usage of get_current_screen() is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
33
			'<p><strong>' . __( 'More information', 'bulk-delete' ) . '</strong></p>' .
34
			'<p><a href = "https://bulkwp.com/support/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=helptab">' . __( 'Support Forums', 'bulk-delete' ) . '</a></p>' .
35
			'<p><a href = "https://bulkwp.com/addons/?utm_source=wpadmin&utm_campaign=BulkDelete&utm_medium=helptab">' . __( 'Buy pro addons', 'bulk-delete' ) . '</a></p>' .
36
			'<p><a href = "https://sudarmuthu.com/blog">' . __( "Plugin author's blog", 'bulk-delete' ) . '</a></p>' .
37
			'<p><a href = "https://sudarmuthu.com/wordpress/">' . __( "Other Plugin's by Author", 'bulk-delete' ) . '</a></p>'
38
		);
39
	}
40
41
	/**
42
	 * Get the list of help tabs for a given screen.
43
	 *
44
	 * @since 5.1
45
	 * @static
46
	 * @access private
47
	 *
48
	 * @param string $screen Screen name
49
	 *
50
	 * @return array $help_tabs List of tabs
51
	 */
52
	private static function get_help_tabs( $screen ) {
53
		$bd        = BULK_DELETE();
54
		$help_tabs = array();
55
56
		switch ( $screen ) {
57
			case $bd->posts_page:
58
				$overview_tab = array(
59
					'title'    => __( 'Overview', 'bulk-delete' ),
60
					'id'       => 'overview_tab',
61
					'content'  => '<p>' . __( 'This screen contains different modules that allows you to delete posts or schedule them for deletion.', 'bulk-delete' ) . '</p>',
62
					'callback' => false,
63
				);
64
65
				$help_tabs['overview_tab'] = $overview_tab;
66
				break;
67
68
			case $bd->pages_page:
69
				// Overview tab
70
				$overview_tab = array(
71
					'title'    => __( 'Overview', 'bulk-delete' ),
72
					'id'       => 'overview_tab',
73
					'content'  => '<p>' . __( 'This screen contains different modules that allows you to delete pages or schedule them for deletion.', 'bulk-delete' ) . '</p>',
74
					'callback' => false,
75
				);
76
77
				$help_tabs['overview_tab'] = $overview_tab;
78
				break;
79
		}
80
81
		// about plugin tab
82
		$about_plugin_tab = array(
83
			'title'    => __( 'About Plugin', 'bulk-delete' ),
84
			'id'       => 'about_plugin_tab',
85
			'content'  => '',
86
			'callback' => array( 'Bulk_Delete_Help_Screen', 'print_about_plugin_tab_content' ),
87
		);
88
89
		$help_tabs['about_plugin_tab'] = $about_plugin_tab;
90
91
		/**
92
		 * Filters help tab content for admin screens.
93
		 *
94
		 * @since 5.1
95
		 */
96
		return apply_filters( 'bd_admin_help_tabs', $help_tabs, $screen );
97
	}
98
99
	/**
100
	 * print the about plugin tab content.
101
	 *
102
	 * @since 5.1
103
	 * @static
104
	 */
105
	public static function print_about_plugin_tab_content() {
106
		echo '<p>' . __( 'This plugin allows you to perform bulk operations in WordPress easily.', 'bulk-delete' ) . '</p>';
107
		echo '<p>' . __( 'This plugin can be used to delete the posts, pages or users using various filters and conditions.', 'bulk-delete' ) . '</p>';
108
	}
109
}
110