1 | <?php |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
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\My_Plans(). |
||
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\My_Plans() |
||
21 | */ |
||
22 | protected static $instance = null; |
||
23 | |||
24 | /** |
||
25 | * Constructor |
||
26 | */ |
||
27 | public function __construct() { |
||
0 ignored issues
–
show
|
|||
28 | add_action( 'lsx_hp_settings_page_my-plans_top', array( $this, 'settings' ), 1, 1 ); |
||
29 | } |
||
0 ignored issues
–
show
|
|||
30 | |||
31 | /** |
||
32 | * Return an instance of this class. |
||
33 | * |
||
34 | * @since 1.0.0 |
||
35 | * |
||
36 | * @return object \lsx_health_plan\classes\admin\My_Plans() 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
|
|||
41 | self::$instance = new self(); |
||
42 | } |
||
0 ignored issues
–
show
|
|||
43 | return self::$instance; |
||
44 | } |
||
0 ignored issues
–
show
|
|||
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
|
|||
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' => 'select', |
||
71 | 'default' => 'my-plan', |
||
72 | 'options' => $this->get_page_options(), |
||
73 | ) |
||
74 | ); |
||
75 | |||
76 | $cmb->add_field( |
||
77 | array( |
||
78 | 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
||
79 | 'name' => __( 'Recipe', 'lsx-health-plan' ), |
||
80 | 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
||
81 | 'limit' => 1, |
||
82 | 'id' => 'connected_recipes', |
||
83 | 'type' => 'post_search_ajax', |
||
84 | ) |
||
85 | ); |
||
86 | |||
87 | $cmb->add_field( |
||
88 | array( |
||
89 | 'name' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
||
0 ignored issues
–
show
|
|||
90 | 'id' => 'plan_single_slug', |
||
91 | 'type' => 'input', |
||
92 | 'value' => '', |
||
93 | 'default' => 'plan', |
||
94 | ) |
||
95 | ); |
||
96 | $cmb->add_field( |
||
97 | array( |
||
98 | 'name' => __( 'Plans Archive Slug', 'lsx-health-plan' ), |
||
0 ignored issues
–
show
|
|||
99 | 'id' => 'endpoint_plan_archive', |
||
100 | 'type' => 'input', |
||
101 | 'value' => '', |
||
102 | 'default' => 'plans', |
||
103 | ) |
||
104 | ); |
||
105 | |||
106 | $cmb->add_field( |
||
107 | array( |
||
108 | 'before_row' => '<h4><b><u>My Stats Options</u></b></h4>', |
||
109 | 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
||
110 | 'desc' => 'Disable All Stats', |
||
111 | 'id' => 'disable_all_stats', |
||
112 | 'type' => 'checkbox', |
||
113 | 'value' => 1, |
||
114 | 'default' => 0, |
||
115 | ) |
||
116 | ); |
||
117 | $cmb->add_field( |
||
118 | array( |
||
119 | 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
||
120 | 'id' => 'disable_weight_checkbox', |
||
121 | 'type' => 'checkbox', |
||
122 | 'value' => 1, |
||
123 | 'default' => 0, |
||
124 | ) |
||
125 | ); |
||
126 | $cmb->add_field( |
||
127 | array( |
||
128 | 'name' => __( 'Disable Height', 'lsx-health-plan' ), |
||
129 | 'id' => 'disable_height_checkbox', |
||
130 | 'type' => 'checkbox', |
||
131 | 'value' => 1, |
||
132 | 'default' => 0, |
||
133 | ) |
||
134 | ); |
||
135 | $cmb->add_field( |
||
136 | array( |
||
137 | 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
||
138 | 'id' => 'disable_waist_checkbox', |
||
139 | 'type' => 'checkbox', |
||
140 | 'value' => 1, |
||
141 | 'default' => 0, |
||
142 | ) |
||
143 | ); |
||
144 | $cmb->add_field( |
||
145 | array( |
||
146 | 'name' => __( 'Disable BMI', 'lsx-health-plan' ), |
||
147 | 'id' => 'disable_bmi_checkbox', |
||
148 | 'type' => 'checkbox', |
||
149 | 'value' => 1, |
||
150 | 'default' => 0, |
||
151 | 'after_row' => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ), |
||
152 | ) |
||
153 | ); |
||
154 | } |
||
0 ignored issues
–
show
|
|||
155 | |||
156 | public function get_page_options() { |
||
0 ignored issues
–
show
|
|||
157 | $query_args = array( |
||
158 | 'post_type' => 'page', |
||
159 | 'post_status' => array( 'publish' ), |
||
160 | 'posts_per_page' => -1, |
||
161 | 'orderby' => 'title', |
||
162 | 'fields' => array( 'ids' ), |
||
163 | ); |
||
164 | $options = array( |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
165 | '' => __( 'Select a page', 'lsx-health-plan' ), |
||
166 | ); |
||
167 | $page_query = new \WP_Query( $query_args ); |
||
168 | if ( $page_query->have_posts() ) { |
||
0 ignored issues
–
show
|
|||
169 | foreach ( $page_query->posts as $pid ) { |
||
0 ignored issues
–
show
|
|||
170 | $title = get_the_title( $pid ); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 7 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
171 | $key = sanitize_title( $title ); |
||
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 13 spaces but found 9 spaces
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. ![]() |
|||
172 | $options[ $key ] = $title; |
||
173 | } |
||
174 | } |
||
0 ignored issues
–
show
|
|||
175 | return $options; |
||
176 | } |
||
0 ignored issues
–
show
|
|||
177 | } |
||
178 | Plan::get_instance(); |
||
179 |