Passed
Push — add/multiplan ( 0816bf...806c57 )
by Virginia
04:04
created

Plan   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 126
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 74
c 1
b 0
f 1
dl 0
loc 126
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A get_instance() 0 6 2
B settings() 0 87 1
1
<?php
2
/**
3
 * Contains the settings class for LSX
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
namespace lsx_health_plan\classes\admin;
9
10
/**
11
 * Contains the settings for each post type \lsx_health_plan\classes\admin\Plan().
12
 */
13
class Plan {
14
15
	/**
16
	 * Holds class instance
17
	 *
18
	 * @since 1.0.0
19
	 *
20
	 * @var      object \lsx_health_plan\classes\admin\Plan()
21
	 */
22
	protected static $instance = null;
23
24
	/**
25
	 * Constructor
26
	 */
27
	public function __construct() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
28
		add_action( 'lsx_hp_settings_page_plan_top', array( $this, 'settings' ), 1, 1 );
29
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
30
31
	/**
32
	 * Return an instance of this class.
33
	 *
34
	 * @since 1.0.0
35
	 *
36
	 * @return    object \lsx_health_plan\classes\admin\Plan()    A single instance of this class.
37
	 */
38
	public static function get_instance() {
39
		// If the single instance hasn't been set, set it now.
40
		if ( null === self::$instance ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
41
			self::$instance = new self();
42
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
43
		return self::$instance;
44
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
45
46
	/**
47
	 * Registers the general settings.
48
	 *
49
	 * @param object $cmb new_cmb2_box().
50
	 * @return void
51
	 */
52
	public function settings( $cmb ) {
53
		$cmb->add_field(
54
			array(
55
				'name'        => __( 'Plan Filters', 'lsx-health-plan' ),
56
				'id'          => 'plan_filters_disabled',
57
				'type'        => 'checkbox',
58
				'value'       => 1,
59
				'default'     => 0,
60
				'description' => __( 'Toggle the display of the tab filters on the post type archive.', 'lsx-health-plan' ),
61
			)
62
		);
63
64
		$cmb->add_field(
65
			array(
66
				'before_row'  => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>',
67
				'name'        =>  __( 'My Plan Slug', 'lsx-health-plan' ),
0 ignored issues
show
introduced by
Expected 1 space after "=>"; 2 found
Loading history...
68
				'description' => __( 'This will be the slug url for redirecting users after login, use the login page slug.', 'lsx-health-plan' ),
69
				'id'          => 'my_plan_slug',
70
				'type'        => 'input',
71
				'value'       => '',
72
				'default'     => 'my-plan',
73
			)
74
		);
75
		$cmb->add_field(
76
			array(
77
				'name'    =>  __( 'Single Plan Slug', 'lsx-health-plan' ),
0 ignored issues
show
introduced by
Expected 1 space after "=>"; 2 found
Loading history...
78
				'id'      => 'plan_single_slug',
79
				'type'    => 'input',
80
				'value'   => '',
81
				'default' => 'plan',
82
			)
83
		);
84
		$cmb->add_field(
85
			array(
86
				'name'    =>  __( 'Plans Archive Endpoint', 'lsx-health-plan' ),
0 ignored issues
show
introduced by
Expected 1 space after "=>"; 2 found
Loading history...
87
				'id'      => 'endpoint_plan_archive',
88
				'type'    => 'input',
89
				'value'   => '',
90
				'default' => 'plans',
91
			)
92
		);
93
94
		$cmb->add_field(
95
			array(
96
				'before_row' => '<h4><b><u>My Stats Options</u></b></h4>',
97
				'name'       => __( 'Disable All Stats', 'lsx-health-plan' ),
98
				'desc'       => 'Disable All Stats',
99
				'id'         => 'disable_all_stats',
100
				'type'       => 'checkbox',
101
				'value'      => 1,
102
				'default'    => 0,
103
			)
104
		);
105
		$cmb->add_field(
106
			array(
107
				'name'    => __( 'Disable Weight', 'lsx-health-plan' ),
108
				'id'      => 'disable_weight_checkbox',
109
				'type'    => 'checkbox',
110
				'value'   => 1,
111
				'default' => 0,
112
			)
113
		);
114
		$cmb->add_field(
115
			array(
116
				'name'    => __( 'Disable Height', 'lsx-health-plan' ),
117
				'id'      => 'disable_height_checkbox',
118
				'type'    => 'checkbox',
119
				'value'   => 1,
120
				'default' => 0,
121
			)
122
		);
123
		$cmb->add_field(
124
			array(
125
				'name'    => __( 'Disable Waist', 'lsx-health-plan' ),
126
				'id'      => 'disable_waist_checkbox',
127
				'type'    => 'checkbox',
128
				'value'   => 1,
129
				'default' => 0,
130
			)
131
		);
132
		$cmb->add_field(
133
			array(
134
				'name'    => __( 'Disable BMI', 'lsx-health-plan' ),
135
				'id'      => 'disable_bmi_checkbox',
136
				'type'    => 'checkbox',
137
				'value'   => 1,
138
				'default' => 0,
139
			)
140
		);
141
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
142
}
143
Plan::get_instance();
144