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
Push — feature/gallery-template-clien... ( 140c9b...ced802 )
by Brad
03:04
created

FooGallery_Admin_Menu::foogallery_settings()   B

Complexity

Conditions 6
Paths 12

Size

Total Lines 32
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 21
nc 12
nop 0
dl 0
loc 32
rs 8.439
c 0
b 0
f 0
1
<?php
2
/*
3
 * FooGallery Admin Menu class
4
 */
5
6
if ( ! class_exists( 'FooGallery_Admin_Menu' ) ) {
7
8
9
10
	class FooGallery_Admin_Menu {
11
12
		function __construct() {
13
			add_action( 'admin_menu', array( $this, 'register_menu_items' ) );
14
		}
15
16
		/**
17
		 * @todo add context to the translations
18
		 */
19
		function register_menu_items() {
20
			//we rely on the register_post_type call to add our main menu items
21
			$parent_slug = foogallery_admin_menu_parent_slug();
22
23
			//allow extensions to add their own menu items beforehand
24
			do_action( 'foogallery_admin_menu_before' );
25
26
			$menu_labels = apply_filters( 'foogallery_admin_menu_labels',
27
				array(
28
					array(
29
						'page_title' => sprintf( __( '%s Settings', 'foogallery' ), foogallery_plugin_name() ),
30
						'menu_title' => __( 'Settings', 'foogallery' ),
31
					),
32
					array(
33
						'page_title' => sprintf( __( '%s Extensions', 'foogallery' ), foogallery_plugin_name() ),
34
						'menu_title' => __( 'Extensions', 'foogallery' ),
35
					),
36
					array(
37
						'page_title' => sprintf( __( '%s Help', 'foogallery' ), foogallery_plugin_name() ),
38
						'menu_title' => __( 'Help', 'foogallery' ),
39
					),
40
					array(
41
						'page_title' => sprintf( __( '%s System Information', 'foogallery' ), foogallery_plugin_name() ),
42
						'menu_title' => __( 'System Info', 'foogallery' ),
43
					),
44
				)
45
			);
46
47
			$capability = apply_filters( 'foogallery_admin_menu_capability', 'manage_options' );
48
49
			add_submenu_page( $parent_slug, $menu_labels[0]['page_title'], $menu_labels[0]['menu_title'], $capability, 'foogallery-settings', array( $this, 'foogallery_settings' ) );
50
			add_submenu_page( $parent_slug, $menu_labels[1]['page_title'], $menu_labels[1]['menu_title'], $capability, 'foogallery-extensions', array( $this, 'foogallery_extensions' ) );
51
			add_submenu_page( $parent_slug, $menu_labels[2]['page_title'], $menu_labels[2]['menu_title'], $capability, 'foogallery-help', array( $this, 'foogallery_help' ) );
52
53
			if ( current_user_can( 'activate_plugins' ) ) {
54
				add_submenu_page( $parent_slug, $menu_labels[3]['page_title'], $menu_labels[3]['menu_title'], $capability, 'foogallery-systeminfo', array( $this, 'foogallery_systeminfo' ) );
55
			}
56
57
			//allow extensions to add their own menu items afterwards
58
			do_action( 'foogallery_admin_menu_after' );
59
		}
60
61
		function foogallery_settings() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Coding Style introduced by
foogallery_settings uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
62
63
			$admin_errors = get_transient( 'settings_errors' );
64
			$show_reset_message = false;
65
66
			if ( is_array( $admin_errors ) ) {
67
				//try to find a reset 'error'
68
				foreach ( $admin_errors as $error ) {
69
					if ( 'reset' === $error['setting'] ) {
70
						$show_reset_message = true;
71
						break;
72
					}
73
				}
74
			}
75
76
			if ( $show_reset_message ) {
77
				do_action( 'foogallery_settings_reset' );
78
				?>
79
				<div id="message" class="updated">
80
					<p><strong><?php printf( __( '%s settings reset to defaults.', 'foogallery' ), foogallery_plugin_name() ); ?></strong></p>
81
				</div>
82
			<?php } else if ( isset($_GET['settings-updated']) ) {
83
				do_action( 'foogallery_settings_updated' );
84
				?>
85
				<div id="message" class="updated">
86
					<p><strong><?php printf( __( '%s settings updated.', 'foogallery' ), foogallery_plugin_name() ); ?></strong></p>
87
				</div>
88
			<?php }
89
90
			$instance = FooGallery_Plugin::get_instance();
91
			$instance->admin_settings_render_page();
92
		}
93
94
		function foogallery_extensions() {
95
			require_once FOOGALLERY_PATH . 'includes/admin/view-extensions.php';
96
		}
97
98
		function foogallery_help() {
99
			require_once FOOGALLERY_PATH . 'includes/admin/view-help.php';
100
		}
101
102
		function foogallery_systeminfo() {
103
			require_once FOOGALLERY_PATH . 'includes/admin/view-system-info.php';
104
		}
105
	}
106
}
107