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\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() { |
|
|
|
|
28
|
|
|
add_action( 'lsx_hp_settings_page_my-plans_top', array( $this, 'settings' ), 1, 1 ); |
29
|
|
|
} |
|
|
|
|
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 ) { |
|
|
|
|
41
|
|
|
self::$instance = new self(); |
42
|
|
|
} |
|
|
|
|
43
|
|
|
return self::$instance; |
44
|
|
|
} |
|
|
|
|
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' ), |
|
|
|
|
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' ), |
|
|
|
|
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' ), |
|
|
|
|
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
|
|
|
} |
|
|
|
|
155
|
|
|
|
156
|
|
|
public function get_page_options() { |
|
|
|
|
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( |
|
|
|
|
165
|
|
|
'' => __( 'Select a page', 'lsx-health-plan' ), |
166
|
|
|
); |
167
|
|
|
$page_query = new \WP_Query( $query_args ); |
168
|
|
|
if ( $page_query->have_posts() ) { |
|
|
|
|
169
|
|
|
foreach ( $page_query->posts as $pid ) { |
|
|
|
|
170
|
|
|
$title = get_the_title( $pid ); |
|
|
|
|
171
|
|
|
$key = sanitize_title( $title ); |
|
|
|
|
172
|
|
|
$options[ $key ] = $title; |
173
|
|
|
} |
174
|
|
|
} |
|
|
|
|
175
|
|
|
return $options; |
176
|
|
|
} |
|
|
|
|
177
|
|
|
} |
178
|
|
|
Plan::get_instance(); |
179
|
|
|
|