GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#1136)
by
unknown
02:47
created

menu.php ➔ highlight_submenu()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace HM\BackUpWordPress;
4
5
/**
6
 * Add the backups menu item
7
 * to the tools menu
8
 */
9
function admin_menu() {
10
11
	if ( is_multisite() ) {
12
		add_submenu_page( 'settings.php', __( 'Manage Backups | BackUpWordPress', 'backupwordpress' ), __( 'Backups', 'backupwordpress' ), ( defined( 'HMBKP_CAPABILITY' ) && HMBKP_CAPABILITY ) ? HMBKP_CAPABILITY : 'manage_options', HMBKP_PLUGIN_SLUG, 'HM\BackUpWordPress\manage_backups' );
13
	} else {
14
		add_management_page( __( 'Manage Backups', 'backupwordpress' ), __( 'Backups', 'backupwordpress' ), ( defined( 'HMBKP_CAPABILITY' ) && HMBKP_CAPABILITY ) ? HMBKP_CAPABILITY : 'manage_options', HMBKP_PLUGIN_SLUG, 'HM\BackUpWordPress\manage_backups' );
15
	}
16
17
	add_submenu_page( null, __( 'BackUpWordPress Extensions', 'backupwordpress' ), __( 'Extensions', 'backupwordpress' ), ( defined( 'HMBKP_CAPABILITY' ) && HMBKP_CAPABILITY ) ? HMBKP_CAPABILITY : 'manage_options', HMBKP_PLUGIN_SLUG . '_extensions', 'HM\BackUpWordPress\extensions' );
18
19
}
20
add_action( 'network_admin_menu', 'HM\BackUpWordPress\admin_menu' );
21
add_action( 'admin_menu', 'HM\BackUpWordPress\admin_menu' );
22
23
/**
24
 * Load the backups admin page
25
 * when the menu option is clicked
26
 *
27
 * @return null
28
 */
29
function manage_backups() {
30
	require_once( HMBKP_PLUGIN_PATH . 'admin/page.php' );
31
}
32
33
34
/**
35
 * Load the backups admin page
36
 * when the menu option is clicked
37
 *
38
 * @return null
39
 */
40
function extensions() {
41
	require_once( HMBKP_PLUGIN_PATH . 'admin/extensions.php' );
42
}
43
44
/**
45
 * Highlights the 'Backups' submenu item when on the Extentions page
46
 *
47
 * @param string $parent_file The filename of the parent menu item
48
 * @return string $parent_file The filename of the parent menu item
49
 */
50
function highlight_submenu( $parent_file ) {
51
52
	global $submenu_file;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
53
54
	$screen = get_current_screen();
55
56
	if ( 'tools_page_' . HMBKP_PLUGIN_SLUG . '_extensions' === $screen->id ) {
57
58
		// Set the main plugin page to be the active submenu page
59
		$submenu_file = HMBKP_PLUGIN_SLUG;
60
61
	}
62
63
	return $parent_file;
64
}
65
add_filter( 'parent_file', 'HM\BackUpWordPress\highlight_submenu' );
66
67
/**
68
 * Add a link to the backups page to the plugin action links.
69
 *
70
 * @param array $links
71
 * @param string $file
72
 *
73
 * @return array $links
74
 */
75
function plugin_action_link( $links, $file ) {
76
77
	if ( false !== strpos( $file, HMBKP_PLUGIN_SLUG ) ) {
78
		array_push( $links, '<a href="' . esc_url( HMBKP_ADMIN_URL ) . '">' . __( 'Backups', 'backupwordpress' ) . '</a>' );
79
	}
80
81
	return $links;
82
83
}
84
add_filter( 'plugin_action_links', 'HM\BackUpWordPress\plugin_action_link', 10, 2 );
85
86
/**
87
 * Add Contextual Help to Backups tools page.
88
 *
89
 * Help is pulled from the readme FAQ.
90
 *
91
 * @return null
92
 */
93
function contextual_help() {
94
95
	// Pre WordPress 3.3 compat
96
	if ( ! method_exists( get_current_screen(), 'add_help_tab' ) ) {
97
		return;
98
	}
99
100
	ob_start();
101
	require_once( HMBKP_PLUGIN_PATH . 'admin/constants.php' );
102
	$constants = ob_get_clean();
103
104
	ob_start();
105
	include_once( HMBKP_PLUGIN_PATH . 'admin/faq.php' );
106
	$faq = ob_get_clean();
107
108
	get_current_screen()->add_help_tab( array(
109
		'title'   => __( 'FAQ', 'backupwordpress' ),
110
		'id'      => 'hmbkp_faq',
111
		'content' => wp_kses_post( $faq ),
112
	) );
113
114
	get_current_screen()->add_help_tab( array(
115
		'title'   => __( 'Constants', 'backupwordpress' ),
116
		'id'      => 'hmbkp_constants',
117
		'content' => wp_kses_post( $constants ),
118
	) );
119
120
	require_once( HMBKP_PLUGIN_PATH . 'classes/class-requirements.php' );
121
122
	ob_start();
123
	require_once( HMBKP_PLUGIN_PATH . 'admin/server-info.php' );
124
	$info = ob_get_clean();
125
126
	get_current_screen()->add_help_tab(
127
		array(
128
			'title'   => __( 'Server Info', 'backupwordpress' ),
129
			'id'      => 'hmbkp_server',
130
			'content' => $info,
131
		)
132
	);
133
134
	get_current_screen()->set_help_sidebar(
135
		'<p><strong>' . esc_html__( 'For more information:', 'backupwordpress' ) . '</strong></p><p><a href="https://github.com/humanmade/backupwordpress" target="_blank">GitHub</a></p><p><a href="http://wordpress.org/tags/backupwordpress?forum_id=10" target="_blank">' . esc_html__( 'Support Forums', 'backupwordpress' ) . '</a></p><p><a href="https://translate.wordpress.org/projects/wp-plugins/backupwordpress/dev/" target="_blank">' . esc_html__( 'Help with translation', 'backupwordpress' ) . '</a></p>'
136
	);
137
138
}
139
add_action( 'load-' . HMBKP_ADMIN_PAGE, 'HM\BackUpWordPress\contextual_help' );
140