|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
namespace lsx_health_plan\classes; |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* Contains the exercise post type |
|
6
|
|
|
* |
|
7
|
|
|
* @package lsx-health-plan |
|
8
|
|
|
*/ |
|
9
|
|
|
class Exercise { |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Holds class instance |
|
13
|
|
|
* |
|
14
|
|
|
* @since 1.0.0 |
|
15
|
|
|
* |
|
16
|
|
|
* @var object \lsx_health_plan\classes\Exercise() |
|
17
|
|
|
*/ |
|
18
|
|
|
protected static $instance = null; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Holds post_type slug used as an index |
|
22
|
|
|
* |
|
23
|
|
|
* @since 1.0.0 |
|
24
|
|
|
* |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
public $slug = 'exercise'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Constructor |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct() { |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
|
|
|
|
|
35
|
|
|
// Post Type and Taxonomies. |
|
36
|
|
|
add_action( 'init', array( $this, 'register_post_type' ) ); |
|
37
|
|
|
add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) ); |
|
38
|
|
|
add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) ); |
|
39
|
|
|
add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) ); |
|
40
|
|
|
add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
41
|
|
|
|
|
42
|
|
|
// Custom Fields. |
|
43
|
|
|
add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 ); |
|
44
|
|
|
add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 ); |
|
45
|
|
|
add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
46
|
|
|
|
|
47
|
|
|
// Template Redirects. |
|
48
|
|
|
add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
49
|
|
|
add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
50
|
|
|
|
|
51
|
|
|
//Breadcrumbs |
|
|
|
|
|
|
52
|
|
|
add_filter( 'wpseo_breadcrumb_links', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 ); |
|
53
|
|
|
add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 ); |
|
54
|
|
|
|
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Return an instance of this class. |
|
62
|
|
|
* |
|
63
|
|
|
* @since 1.0.0 |
|
64
|
|
|
* |
|
65
|
|
|
* @return object \lsx_health_plan\classes\Exercise() A single instance of this class. |
|
66
|
|
|
*/ |
|
67
|
|
|
public static function get_instance() { |
|
68
|
|
|
// If the single instance hasn't been set, set it now. |
|
69
|
|
|
if ( null === self::$instance ) { |
|
|
|
|
|
|
70
|
|
|
self::$instance = new self(); |
|
71
|
|
|
} |
|
|
|
|
|
|
72
|
|
|
return self::$instance; |
|
73
|
|
|
} |
|
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Register the post type. |
|
76
|
|
|
*/ |
|
77
|
|
|
public function register_post_type() { |
|
78
|
|
|
$labels = array( |
|
79
|
|
|
'name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
80
|
|
|
'singular_name' => esc_html__( 'Exercise', 'lsx-health-plan' ), |
|
81
|
|
|
'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
82
|
|
|
'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
83
|
|
|
'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
84
|
|
|
'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
85
|
|
|
'all_items' => esc_html__( 'All Exercises', 'lsx-health-plan' ), |
|
86
|
|
|
'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
87
|
|
|
'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
88
|
|
|
'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
89
|
|
|
'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
90
|
|
|
'parent_item_colon' => '', |
|
91
|
|
|
'menu_name' => esc_html__( 'Exercises', 'lsx-health-plan' ), |
|
92
|
|
|
); |
|
93
|
|
|
$args = array( |
|
94
|
|
|
'labels' => $labels, |
|
95
|
|
|
'public' => true, |
|
96
|
|
|
'publicly_queryable' => true, |
|
97
|
|
|
'show_ui' => true, |
|
98
|
|
|
'show_in_menu' => 'edit.php?post_type=workout-pseudo', |
|
99
|
|
|
'show_in_rest' => true, |
|
100
|
|
|
'menu_icon' => 'dashicons-universal-access', |
|
101
|
|
|
'query_var' => true, |
|
102
|
|
|
'rewrite' => array( |
|
103
|
|
|
'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
104
|
|
|
), |
|
105
|
|
|
'capability_type' => 'page', |
|
106
|
|
|
'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ), |
|
107
|
|
|
'hierarchical' => false, |
|
108
|
|
|
'menu_position' => null, |
|
109
|
|
|
'supports' => array( |
|
110
|
|
|
'title', |
|
111
|
|
|
'thumbnail', |
|
112
|
|
|
'editor', |
|
113
|
|
|
'excerpt', |
|
114
|
|
|
'custom-fields', |
|
115
|
|
|
), |
|
116
|
|
|
); |
|
117
|
|
|
register_post_type( 'exercise', $args ); |
|
118
|
|
|
} |
|
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Register the Exercise taxonomy. |
|
122
|
|
|
* |
|
123
|
|
|
* @return void |
|
124
|
|
|
*/ |
|
125
|
|
|
public function exercise_type_taxonomy_setup() { |
|
126
|
|
|
$labels = array( |
|
127
|
|
|
'name' => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
128
|
|
|
'singular_name' => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
129
|
|
|
'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
130
|
|
|
'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
131
|
|
|
'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
132
|
|
|
'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
133
|
|
|
'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
134
|
|
|
'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
135
|
|
|
'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
136
|
|
|
'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
137
|
|
|
'menu_name' => esc_html__( 'Exercise Types', 'lsx-health-plan' ), |
|
138
|
|
|
); |
|
139
|
|
|
|
|
140
|
|
|
$args = array( |
|
141
|
|
|
'hierarchical' => true, |
|
142
|
|
|
'labels' => $labels, |
|
143
|
|
|
'show_ui' => true, |
|
144
|
|
|
'show_admin_column' => true, |
|
145
|
|
|
'query_var' => true, |
|
146
|
|
|
'rewrite' => array( |
|
147
|
|
|
'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ), |
|
148
|
|
|
), |
|
149
|
|
|
'show_in_rest' => true, |
|
150
|
|
|
); |
|
151
|
|
|
|
|
152
|
|
|
register_taxonomy( 'exercise-type', array( 'exercise' ), $args ); |
|
153
|
|
|
} |
|
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Register the Exercise taxonomy. |
|
157
|
|
|
* |
|
158
|
|
|
* @return void |
|
159
|
|
|
*/ |
|
160
|
|
|
public function equipment_taxonomy_setup() { |
|
161
|
|
|
$labels = array( |
|
162
|
|
|
'name' => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ), |
|
163
|
|
|
'singular_name' => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ), |
|
164
|
|
|
'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
165
|
|
|
'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
166
|
|
|
'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
167
|
|
|
'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
168
|
|
|
'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
169
|
|
|
'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
170
|
|
|
'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
171
|
|
|
'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
172
|
|
|
'menu_name' => esc_html__( 'Equipment', 'lsx-health-plan' ), |
|
173
|
|
|
); |
|
174
|
|
|
|
|
175
|
|
|
$args = array( |
|
176
|
|
|
'hierarchical' => true, |
|
177
|
|
|
'labels' => $labels, |
|
178
|
|
|
'show_ui' => true, |
|
179
|
|
|
'show_admin_column' => true, |
|
180
|
|
|
'query_var' => true, |
|
181
|
|
|
'rewrite' => array( |
|
182
|
|
|
'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ), |
|
183
|
|
|
), |
|
184
|
|
|
'show_in_rest' => true, |
|
185
|
|
|
); |
|
186
|
|
|
|
|
187
|
|
|
register_taxonomy( 'equipment', array( 'exercise' ), $args ); |
|
188
|
|
|
} |
|
|
|
|
|
|
189
|
|
|
|
|
190
|
|
|
/** |
|
191
|
|
|
* Register the Muscle Group taxonomy. |
|
192
|
|
|
* |
|
193
|
|
|
* @return void |
|
194
|
|
|
*/ |
|
195
|
|
|
public function muscle_group_taxonomy_setup() { |
|
196
|
|
|
$labels = array( |
|
197
|
|
|
'name' => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ), |
|
198
|
|
|
'singular_name' => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ), |
|
199
|
|
|
'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
200
|
|
|
'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
201
|
|
|
'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
202
|
|
|
'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
203
|
|
|
'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
204
|
|
|
'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
205
|
|
|
'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
206
|
|
|
'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
207
|
|
|
'menu_name' => esc_html__( 'Muscle Groups', 'lsx-health-plan' ), |
|
208
|
|
|
); |
|
209
|
|
|
|
|
210
|
|
|
$args = array( |
|
211
|
|
|
'hierarchical' => true, |
|
212
|
|
|
'labels' => $labels, |
|
213
|
|
|
'show_ui' => true, |
|
214
|
|
|
'show_admin_column' => true, |
|
215
|
|
|
'query_var' => true, |
|
216
|
|
|
'rewrite' => array( |
|
217
|
|
|
'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ), |
|
218
|
|
|
), |
|
219
|
|
|
'show_in_rest' => true, |
|
220
|
|
|
); |
|
221
|
|
|
|
|
222
|
|
|
register_taxonomy( 'muscle-group', array( 'exercise' ), $args ); |
|
223
|
|
|
} |
|
|
|
|
|
|
224
|
|
|
|
|
225
|
|
|
/** |
|
226
|
|
|
* Registers the Recipes under the Meals Post type menu. |
|
227
|
|
|
* |
|
228
|
|
|
* @return void |
|
229
|
|
|
*/ |
|
230
|
|
|
public function register_menus() { |
|
231
|
|
|
add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' ); |
|
232
|
|
|
add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' ); |
|
233
|
|
|
add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' ); |
|
234
|
|
|
add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' ); |
|
235
|
|
|
} |
|
|
|
|
|
|
236
|
|
|
|
|
237
|
|
|
/** |
|
238
|
|
|
* Adds the post type to the different arrays. |
|
239
|
|
|
* |
|
240
|
|
|
* @param array $post_types |
|
|
|
|
|
|
241
|
|
|
* @return array |
|
242
|
|
|
*/ |
|
243
|
|
|
public function enable_post_type( $post_types = array() ) { |
|
244
|
|
|
$post_types[] = $this->slug; |
|
245
|
|
|
return $post_types; |
|
246
|
|
|
} |
|
|
|
|
|
|
247
|
|
|
|
|
248
|
|
|
/** |
|
249
|
|
|
* Enables the Bi Directional relationships |
|
250
|
|
|
* |
|
251
|
|
|
* @param array $connections |
|
|
|
|
|
|
252
|
|
|
* @return void |
|
|
|
|
|
|
253
|
|
|
*/ |
|
254
|
|
|
public function enable_connections( $connections = array() ) { |
|
255
|
|
|
$connections['exercise']['connected_workouts'] = 'connected_exercises'; |
|
256
|
|
|
$connections['workout']['connected_exercises'] = 'connected_workouts'; |
|
257
|
|
|
return $connections; |
|
258
|
|
|
} |
|
|
|
|
|
|
259
|
|
|
|
|
260
|
|
|
/** |
|
261
|
|
|
* Define the metabox and field configurations. |
|
262
|
|
|
*/ |
|
263
|
|
|
public function gallery_metabox() { |
|
264
|
|
|
$cmb = new_cmb2_box( |
|
265
|
|
|
array( |
|
266
|
|
|
'id' => $this->slug . '_gallery_details_metabox', |
|
267
|
|
|
'title' => __( 'Exercise Gallery', 'lsx-health-plan' ), |
|
268
|
|
|
'object_types' => array( $this->slug ), |
|
269
|
|
|
'context' => 'normal', |
|
270
|
|
|
'priority' => 'low', |
|
271
|
|
|
'show_names' => true, |
|
272
|
|
|
) |
|
273
|
|
|
); |
|
274
|
|
|
|
|
275
|
|
|
$cmb->add_field( |
|
276
|
|
|
array( |
|
277
|
|
|
'name' => __( 'Layout', 'lsx-health-plan' ), |
|
278
|
|
|
'id' => $this->slug . '_gallery_layout', |
|
279
|
|
|
'type' => 'radio', |
|
280
|
|
|
'options' => array( |
|
281
|
|
|
'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
282
|
|
|
'grid' => __( 'Grid', 'lsx-health-plan' ), |
|
283
|
|
|
), |
|
284
|
|
|
'default' => 'grid', |
|
285
|
|
|
) |
|
286
|
|
|
); |
|
287
|
|
|
|
|
288
|
|
|
$cmb->add_field( |
|
289
|
|
|
array( |
|
290
|
|
|
'name' => __( 'Grid Columns', 'lsx-health-plan' ), |
|
291
|
|
|
'id' => $this->slug . '_gallery_columns', |
|
292
|
|
|
'type' => 'select', |
|
293
|
|
|
'options' => array( |
|
294
|
|
|
'3' => __( '2 Columns', 'lsx-health-plan' ), |
|
295
|
|
|
'4' => __( '3 Columns', 'lsx-health-plan' ), |
|
296
|
|
|
), |
|
297
|
|
|
'default' => '1', |
|
298
|
|
|
) |
|
299
|
|
|
); |
|
300
|
|
|
|
|
301
|
|
|
// Repeatable group. |
|
302
|
|
|
$gallery_group = $cmb->add_field( |
|
303
|
|
|
array( |
|
304
|
|
|
'id' => $this->slug . '_gallery', |
|
305
|
|
|
'type' => 'group', |
|
306
|
|
|
'options' => array( |
|
307
|
|
|
'group_title' => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
308
|
|
|
'add_button' => __( 'Add Item', 'lsx-health-plan' ), |
|
309
|
|
|
'remove_button' => __( 'Remove Item', 'lsx-health-plan' ), |
|
310
|
|
|
'sortable' => true, |
|
311
|
|
|
), |
|
312
|
|
|
'desc' => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ), |
|
313
|
|
|
'classes' => 'lsx-admin-row', |
|
314
|
|
|
) |
|
315
|
|
|
); |
|
316
|
|
|
|
|
317
|
|
|
// Title. |
|
318
|
|
|
$cmb->add_group_field( |
|
319
|
|
|
$gallery_group, |
|
|
|
|
|
|
320
|
|
|
array( |
|
321
|
|
|
'name' => __( 'Image', 'lsx-health-plan' ), |
|
|
|
|
|
|
322
|
|
|
'id' => $this->slug . '_gallery_image', |
|
|
|
|
|
|
323
|
|
|
'type' => 'file', |
|
|
|
|
|
|
324
|
|
|
'text' => array( |
|
|
|
|
|
|
325
|
|
|
'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ), |
|
326
|
|
|
), |
|
327
|
|
|
'desc' => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ), |
|
|
|
|
|
|
328
|
|
|
'query_args' => array( |
|
|
|
|
|
|
329
|
|
|
'type' => array( |
|
330
|
|
|
'image/gif', |
|
331
|
|
|
'image/jpeg', |
|
332
|
|
|
'image/png', |
|
333
|
|
|
), |
|
334
|
|
|
), |
|
335
|
|
|
'preview_size' => 'lsx-thumbnail-wide', |
|
336
|
|
|
'classes' => 'lsx-field-col lsx-field-col-80', |
|
|
|
|
|
|
337
|
|
|
) |
|
338
|
|
|
); |
|
339
|
|
|
|
|
340
|
|
|
// Title. |
|
341
|
|
|
$cmb->add_group_field( |
|
342
|
|
|
$gallery_group, |
|
343
|
|
|
array( |
|
344
|
|
|
'name' => __( 'oEmbed', 'lsx-health-plan' ), |
|
345
|
|
|
'id' => $this->slug . '_gallery_embed', |
|
346
|
|
|
'type' => 'text', |
|
347
|
|
|
'desc' => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ), |
|
348
|
|
|
'classes' => 'test-apply-form lsx-field-col lsx-field-col-50', |
|
349
|
|
|
) |
|
350
|
|
|
); |
|
351
|
|
|
|
|
352
|
|
|
$cmb->add_group_field( |
|
353
|
|
|
$gallery_group, |
|
354
|
|
|
array( |
|
355
|
|
|
'name' => __( 'External Media', 'lsx-health-plan' ), |
|
356
|
|
|
'id' => $this->slug . '_gallery_external', |
|
357
|
|
|
'type' => 'textarea_code', |
|
358
|
|
|
'desc' => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: <iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen></iframe>', 'lsx-health-plan' ), |
|
359
|
|
|
'classes' => 'lsx-field-col lsx-field-col-50', |
|
360
|
|
|
) |
|
361
|
|
|
); |
|
362
|
|
|
} |
|
|
|
|
|
|
363
|
|
|
|
|
364
|
|
|
/** |
|
365
|
|
|
* Registers the general settings for the exercise. |
|
366
|
|
|
* |
|
367
|
|
|
* @return void |
|
368
|
|
|
*/ |
|
369
|
|
|
public function exercise_details() { |
|
370
|
|
|
$cmb = new_cmb2_box( |
|
371
|
|
|
array( |
|
372
|
|
|
'id' => $this->slug . '_general_details_metabox', |
|
373
|
|
|
'title' => __( 'Details', 'lsx-health-plan' ), |
|
374
|
|
|
'object_types' => array( $this->slug ), |
|
375
|
|
|
'context' => 'normal', |
|
376
|
|
|
'priority' => 'high', |
|
377
|
|
|
'show_names' => true, |
|
378
|
|
|
) |
|
379
|
|
|
); |
|
380
|
|
|
|
|
381
|
|
|
$cmb->add_field( |
|
382
|
|
|
array( |
|
383
|
|
|
'name' => __( 'Side', 'lsx-health-plan' ), |
|
384
|
|
|
'id' => $this->slug . '_side', |
|
385
|
|
|
'type' => 'select', |
|
386
|
|
|
'options' => array( |
|
387
|
|
|
'' => __( 'Select', 'lsx-health-plan' ), |
|
388
|
|
|
'left' => __( 'Left', 'lsx-health-plan' ), |
|
389
|
|
|
'right' => __( 'Right', 'lsx-health-plan' ), |
|
390
|
|
|
), |
|
391
|
|
|
'desc' => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ), |
|
392
|
|
|
) |
|
393
|
|
|
); |
|
394
|
|
|
} |
|
|
|
|
|
|
395
|
|
|
|
|
396
|
|
|
/** |
|
|
|
|
|
|
397
|
|
|
* Holds the array for the single exercise breadcrumbs. |
|
398
|
|
|
* |
|
399
|
|
|
* @var array $crumbs |
|
400
|
|
|
* @return array |
|
401
|
|
|
*/ |
|
402
|
|
|
public function exercise_breadcrumb_filter( $crumbs ) { |
|
403
|
|
|
$exercise = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' ); |
|
404
|
|
|
$exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' ); |
|
405
|
|
|
$url = get_post_type_archive_link( $exercise ); |
|
|
|
|
|
|
406
|
|
|
|
|
407
|
|
|
if ( is_singular( 'exercise' ) ) { |
|
|
|
|
|
|
408
|
|
|
$exercise_name = get_the_title(); |
|
|
|
|
|
|
409
|
|
|
$term_obj_list = get_the_terms( get_the_ID(), 'exercise-type' ); |
|
|
|
|
|
|
410
|
|
|
$exercise_type = $term_obj_list[0]->name; |
|
411
|
|
|
$exercise_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
412
|
|
|
|
|
413
|
|
|
$new_crumbs = array(); |
|
414
|
|
|
$new_crumbs[0] = $crumbs[0]; |
|
415
|
|
|
|
|
416
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
|
|
|
|
|
417
|
|
|
$new_crumbs[1] = array( |
|
418
|
|
|
0 => $exercises, |
|
419
|
|
|
1 => $url, |
|
420
|
|
|
); |
|
421
|
|
|
$new_crumbs[2] = array( |
|
422
|
|
|
0 => $exercise_type, |
|
423
|
|
|
1 => $exercise_type_url, |
|
424
|
|
|
); |
|
425
|
|
|
$new_crumbs[3] = array( |
|
426
|
|
|
0 => $exercise_name, |
|
427
|
|
|
); |
|
428
|
|
|
} else { |
|
429
|
|
|
$new_crumbs[1] = array( |
|
430
|
|
|
'text' => $exercises, |
|
431
|
|
|
'url' => $url, |
|
432
|
|
|
); |
|
433
|
|
|
$new_crumbs[2] = array( |
|
434
|
|
|
'text' => $exercise_type, |
|
435
|
|
|
'url' => $exercise_type_url, |
|
436
|
|
|
); |
|
437
|
|
|
$new_crumbs[3] = array( |
|
438
|
|
|
'text' => $exercise_name, |
|
439
|
|
|
); |
|
440
|
|
|
} |
|
|
|
|
|
|
441
|
|
|
$crumbs = $new_crumbs; |
|
442
|
|
|
|
|
|
|
|
|
|
443
|
|
|
} |
|
|
|
|
|
|
444
|
|
|
if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) { |
|
|
|
|
|
|
445
|
|
|
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
446
|
|
|
|
|
447
|
|
|
$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
448
|
|
|
|
|
449
|
|
|
$new_crumbs = array(); |
|
450
|
|
|
$new_crumbs[0] = $crumbs[0]; |
|
451
|
|
|
|
|
452
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
|
|
|
|
|
453
|
|
|
$new_crumbs[1] = array( |
|
454
|
|
|
0 => $exercises, |
|
455
|
|
|
1 => $url, |
|
456
|
|
|
); |
|
457
|
|
|
$new_crumbs[2] = array( |
|
458
|
|
|
0 => $single_term_title, |
|
459
|
|
|
); |
|
460
|
|
|
} else { |
|
461
|
|
|
$new_crumbs[1] = array( |
|
462
|
|
|
'text' => $exercises, |
|
463
|
|
|
'url' => $url, |
|
464
|
|
|
); |
|
465
|
|
|
$new_crumbs[2] = array( |
|
466
|
|
|
'text' => $single_term_title, |
|
467
|
|
|
); |
|
468
|
|
|
} |
|
|
|
|
|
|
469
|
|
|
$crumbs = $new_crumbs; |
|
470
|
|
|
|
|
|
|
|
|
|
471
|
|
|
} |
|
|
|
|
|
|
472
|
|
|
if ( is_post_type_archive( 'exercise' ) ) { |
|
|
|
|
|
|
473
|
|
|
|
|
474
|
|
|
$new_crumbs = array(); |
|
475
|
|
|
$new_crumbs[0] = $crumbs[0]; |
|
476
|
|
|
|
|
477
|
|
|
if ( function_exists( 'woocommerce_breadcrumb' ) ) { |
|
|
|
|
|
|
478
|
|
|
$new_crumbs[1] = array( |
|
479
|
|
|
0 => $exercises, |
|
480
|
|
|
); |
|
481
|
|
|
} else { |
|
482
|
|
|
$new_crumbs[1] = array( |
|
483
|
|
|
'text' => $exercises, |
|
484
|
|
|
); |
|
485
|
|
|
} |
|
|
|
|
|
|
486
|
|
|
$crumbs = $new_crumbs; |
|
487
|
|
|
} |
|
|
|
|
|
|
488
|
|
|
return $crumbs; |
|
489
|
|
|
} |
|
|
|
|
|
|
490
|
|
|
} |
|
491
|
|
|
|