Test Failed
Push — develop ( b72058...5cbfdc )
by Reüel
04:45
created

Admin::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 17
rs 10
1
<?php
2
/**
3
 * Mollie admin.
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2020 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Mollie;
12
13
/**
14
 * Title: Mollie admin
15
 * Description:
16
 * Copyright: 2005-2020 Pronamic
17
 * Company: Pronamic
18
 *
19
 * @author  Remco Tolsma
20
 * @version 2.0.9
21
 * @since   1.0.0
22
 */
23
class Admin {
24
	/**
25
	 * Construct and intialize Mollie admin.
26
	 */
27
	public function __construct() {
28
		$function = array( __CLASS__, 'user_profile' );
29
30
		if ( ! has_action( 'show_user_profile', $function ) ) {
31
			add_action( 'show_user_profile', $function );
32
		}
33
34
		if ( ! has_action( 'edit_user_profile', $function ) ) {
35
			add_action( 'edit_user_profile', $function );
36
		}
37
38
		/**
39
		 * Menu.
40
		 *
41
		 * @link https://metabox.io/create-hidden-admin-page/
42
		 */
43
		add_action( 'admin_menu', array( $this, 'admin_menu' ) );
44
	}
45
46
	/**
47
	 * Admin menu.
48
	 */
49
	public function admin_menu() {
50
		add_menu_page(
51
			__( 'Mollie', 'pronamic_ideal' ),
52
			__( 'Mollie', 'pronamic_ideal' ),
53
			'manage_options',
54
			'pronamic_pay_mollie',
55
			array( $this, 'page_mollie' )
56
		);
57
58
		add_submenu_page(
59
			'pronamic_pay_mollie',
60
			__( 'Mollie Customers', 'pronamic_ideal' ),
61
			__( 'Customers', 'pronamic_ideal' ),
62
			'manage_options',
63
			'pronamic_pay_mollie_customers',
64
			array( $this, 'page_mollie_customers' )
65
		);
66
	}
67
68
	/**
69
	 * Page Mollie.
70
	 */
71
	public function page_mollie() {
72
73
	}
74
75
	/**
76
	 * Page Mollie customers.
77
	 */
78
	public function page_mollie_customers() {
79
		if ( filter_has_var( INPUT_GET, 'id' ) ) {
80
			include __DIR__ . '/../views/page-customer.php';
81
82
			return;
83
		}
84
85
		include __DIR__ . '/../views/page-customers.php';
86
	}
87
88
	/**
89
	 * User profile.
90
	 *
91
	 * @since 1.1.6
92
	 * @link https://github.com/WordPress/WordPress/blob/4.5.2/wp-admin/user-edit.php#L578-L600
93
	 * @param WP_User $user WordPress user.
0 ignored issues
show
Bug introduced by
The type Pronamic\WordPress\Pay\Gateways\Mollie\WP_User was not found. Did you mean WP_User? If so, make sure to prefix the type with \.
Loading history...
94
	 * @return void
95
	 */
96
	public static function user_profile( $user ) {
97
		include __DIR__ . '/../views/html-admin-user-profile.php';
98
	}
99
}
100