Passed
Push — master ( 43702f...903e32 )
by Warwick
04:44 queued 10s
created
classes/post-types/class-workout.php 1 patch
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
 	 * Constructor
33 33
 	 */
34 34
 	public function __construct() {
35
-		add_action( 'init', array( $this, 'register_post_type' ) );
36
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
37
-		add_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) );
38
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
39
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
40
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
41
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
35
+		add_action('init', array($this, 'register_post_type'));
36
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
37
+		add_action('init', array($this, 'workout_type_taxonomy_setup'));
38
+		add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1);
39
+		add_action('cmb2_admin_init', array($this, 'featured_metabox'), 5);
40
+		add_action('cmb2_admin_init', array($this, 'details_metaboxes'));
41
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
42 42
 
43 43
 		// Template Redirects.
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
44
+		add_action('pre_get_posts', array($this, 'set_parent_only'), 10, 1);
45
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
46 46
 	}
47 47
 
48 48
 	/**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public static function get_instance() {
56 56
 		// If the single instance hasn't been set, set it now.
57
-		if ( null === self::$instance ) {
57
+		if (null === self::$instance) {
58 58
 			self::$instance = new self();
59 59
 		}
60 60
 		return self::$instance;
@@ -64,19 +64,19 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function register_post_type() {
66 66
 		$labels = array(
67
-			'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
68
-			'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
69
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
70
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
71
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
72
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
73
-			'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
74
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
75
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
76
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
77
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
78
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
79
-			'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
67
+			'name'               => esc_html__('Workouts', 'lsx-health-plan'),
68
+			'singular_name'      => esc_html__('Workout', 'lsx-health-plan'),
69
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
70
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
71
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
72
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
73
+			'all_items'          => esc_html__('All Workouts', 'lsx-health-plan'),
74
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
75
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
76
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
77
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
78
+			'parent_item_colon'  => esc_html__('Parent:', 'lsx-health-plan'),
79
+			'menu_name'          => esc_html__('Workouts', 'lsx-health-plan'),
80 80
 		);
81 81
 		$args = array(
82 82
 			'labels'             => $labels,
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 			'menu_icon'          => 'dashicons-universal-access',
89 89
 			'query_var'          => true,
90 90
 			'rewrite'            => array(
91
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
91
+				'slug' => \lsx_health_plan\functions\get_option('endpoint_workout', 'workout'),
92 92
 			),
93 93
 			'capability_type'    => 'page',
94
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
94
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_workout_archive', 'workouts'),
95 95
 			'hierarchical'       => true,
96 96
 			'menu_position'      => null,
97 97
 			'supports'           => array(
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 				'custom-fields',
104 104
 			),
105 105
 		);
106
-		register_post_type( 'workout', $args );
106
+		register_post_type('workout', $args);
107 107
 	}
108 108
 
109 109
 	/**
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	public function workout_type_taxonomy_setup() {
113 113
 		$labels = array(
114
-			'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
115
-			'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
116
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
117
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
118
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
119
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
120
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
121
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
122
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
123
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
124
-			'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
114
+			'name'              => esc_html_x('Workout Type', 'taxonomy general name', 'lsx-health-plan'),
115
+			'singular_name'     => esc_html_x('Workout Type', 'taxonomy singular name', 'lsx-health-plan'),
116
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
117
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
118
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
119
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
120
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
121
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
122
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
123
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
124
+			'menu_name'         => esc_html__('Workout Types', 'lsx-health-plan'),
125 125
 		);
126 126
 
127 127
 		$args = array(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 			),
136 136
 		);
137 137
 
138
-		register_taxonomy( 'workout-type', array( 'workout' ), $args );
138
+		register_taxonomy('workout-type', array('workout'), $args);
139 139
 	}
140 140
 
141 141
 	/**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @param array $post_types
145 145
 	 * @return array
146 146
 	 */
147
-	public function enable_post_type( $post_types = array() ) {
147
+	public function enable_post_type($post_types = array()) {
148 148
 		$post_types[] = $this->slug;
149 149
 		return $post_types;
150 150
 	}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @param array $connections
156 156
 	 * @return void
157 157
 	 */
158
-	public function enable_connections( $connections = array() ) {
158
+	public function enable_connections($connections = array()) {
159 159
 		$connections['workout']['connected_plans'] = 'connected_workouts';
160 160
 		$connections['plan']['connected_workouts'] = 'connected_plans';
161 161
 
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
 	 * @param string $title the term title.
174 174
 	 * @return string
175 175
 	 */
176
-	public function get_the_archive_title( $title ) {
177
-		if ( is_post_type_archive( 'workout' ) ) {
178
-			$title = __( 'Workouts', 'lsx-health-plan' );
176
+	public function get_the_archive_title($title) {
177
+		if (is_post_type_archive('workout')) {
178
+			$title = __('Workouts', 'lsx-health-plan');
179 179
 		}
180 180
 		return $title;
181 181
 	}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 		$cmb = new_cmb2_box(
188 188
 			array(
189 189
 				'id'           => $this->slug . '_featured_metabox_workout',
190
-				'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
191
-				'object_types' => array( $this->slug ), // Post type
190
+				'title'        => __('Featured Workout', 'lsx-health-plan'),
191
+				'object_types' => array($this->slug), // Post type
192 192
 				'context'      => 'side',
193 193
 				'priority'     => 'high',
194 194
 				'show_names'   => true,
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 		);
197 197
 		$cmb->add_field(
198 198
 			array(
199
-				'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
200
-				'desc'       => __( 'Enable a featured workout' ),
199
+				'name'       => __('Featured Workout', 'lsx-health-plan'),
200
+				'desc'       => __('Enable a featured workout'),
201 201
 				'id'         => $this->slug . '_featured_workout',
202 202
 				'type'       => 'checkbox',
203 203
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -210,43 +210,43 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function details_metaboxes() {
212 212
 
213
-		$cmb = new_cmb2_box( array(
213
+		$cmb = new_cmb2_box(array(
214 214
 			'id'           => $this->slug . '_details_metabox',
215
-			'title'        => __( 'Workout Details', 'lsx-health-plan' ),
216
-			'object_types' => array( $this->slug ), // Post type
215
+			'title'        => __('Workout Details', 'lsx-health-plan'),
216
+			'object_types' => array($this->slug), // Post type
217 217
 			'context'      => 'normal',
218 218
 			'priority'     => 'high',
219 219
 			'show_names'   => true,
220
-		) );
220
+		));
221 221
 
222
-		$cmb->add_field( array(
223
-			'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
222
+		$cmb->add_field(array(
223
+			'name' => __('Workout Short Description', 'lsx-health-plan'),
224 224
 			'id'   => $this->slug . '_short_description',
225 225
 			'type' => 'textarea_small',
226
-			'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
227
-		) );
226
+			'desc' => __('Add a small description for this workout (optional)', 'lsx-health-plan'),
227
+		));
228 228
 
229
-		$workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
230
-		if ( false !== $workout_sections && null !== $workout_sections ) {
229
+		$workout_sections = apply_filters('lsx_health_plan_workout_sections_amount', 6);
230
+		if (false !== $workout_sections && null !== $workout_sections) {
231 231
 			$i = 1;
232
-			while ( $i <= $workout_sections ) {
232
+			while ($i <= $workout_sections) {
233 233
 
234
-				$cmb_group = new_cmb2_box( array(
234
+				$cmb_group = new_cmb2_box(array(
235 235
 					'id'           => $this->slug . '_section_' . $i . '_metabox',
236
-					'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
237
-					'object_types' => array( $this->slug ),
238
-				) );
236
+					'title'        => esc_html__('Exercise Group ', 'lsx-health-plan') . $i,
237
+					'object_types' => array($this->slug),
238
+				));
239 239
 
240
-				$cmb_group->add_field( array(
241
-					'name'       => __( 'Title', 'lsx-health-plan' ),
240
+				$cmb_group->add_field(array(
241
+					'name'       => __('Title', 'lsx-health-plan'),
242 242
 					'id'         => $this->slug . '_section_' . $i . '_title',
243 243
 					'type'       => 'text',
244 244
 					'show_on_cb' => 'cmb2_hide_if_no_cats',
245
-				) );
245
+				));
246 246
 
247 247
 				$cmb_group->add_field(
248 248
 					array(
249
-						'name'       => __( 'Description', 'lsx-health-plan' ),
249
+						'name'       => __('Description', 'lsx-health-plan'),
250 250
 						'id'         => $this->slug . '_section_' . $i . '_description',
251 251
 						'type'       => 'wysiwyg',
252 252
 						'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -265,28 +265,28 @@  discard block
 block discarded – undo
265 265
 						'id'      => $this->slug . '_section_' . $i,
266 266
 						'type'    => 'group',
267 267
 						'options' => array(
268
-							'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
269
-							'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
270
-							'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
268
+							'group_title'   => esc_html__('Exercise {#}', 'lsx-health-plan'), // {#} gets replaced by row number
269
+							'add_button'    => esc_html__('Add New', 'lsx-health-plan'),
270
+							'remove_button' => esc_html__('Delete', 'lsx-health-plan'),
271 271
 							'sortable'      => true,
272 272
 							'closed'        => true, // true to have the groups closed by default
273 273
 						),
274 274
 					)
275 275
 				);
276 276
 
277
-				if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
277
+				if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
278 278
 					$cmb_group->add_group_field(
279 279
 						$group_field_id,
280 280
 						array(
281
-							'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
281
+							'name'       => __('Exercise related to this workout', 'lsx-health-plan'),
282 282
 							'id'         => 'connected_exercises',
283 283
 							'type'       => 'post_search_ajax',
284 284
 							// Optional :
285 285
 							'limit'      => 1, // Limit selection to X items only (default 1)
286
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
286
+							'sortable'   => true, // Allow selected items to be sortable (default false)
287 287
 							'query_args' => array(
288
-								'post_type'      => array( 'exercise' ),
289
-								'post_status'    => array( 'publish' ),
288
+								'post_type'      => array('exercise'),
289
+								'post_status'    => array('publish'),
290 290
 								'posts_per_page' => -1,
291 291
 							),
292 292
 						)
@@ -295,15 +295,15 @@  discard block
 block discarded – undo
295 295
 					$cmb_group->add_group_field(
296 296
 						$group_field_id,
297 297
 						array(
298
-							'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
298
+							'name'       => __('Video related to this workout', 'lsx-health-plan'),
299 299
 							'id'         => 'connected_videos',
300 300
 							'type'       => 'post_search_ajax',
301 301
 							// Optional :
302 302
 							'limit'      => 1, // Limit selection to X items only (default 1)
303
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
303
+							'sortable'   => true, // Allow selected items to be sortable (default false)
304 304
 							'query_args' => array(
305
-								'post_type'      => array( 'video' ),
306
-								'post_status'    => array( 'publish' ),
305
+								'post_type'      => array('video'),
306
+								'post_status'    => array('publish'),
307 307
 								'posts_per_page' => -1,
308 308
 							),
309 309
 						)
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 					$cmb_group->add_group_field(
312 312
 						$group_field_id,
313 313
 						array(
314
-							'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
314
+							'name' => esc_html__('Workout Name', 'lsx-health-plan'),
315 315
 							'id'   => 'name',
316 316
 							'type' => 'text',
317 317
 							// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 					$cmb_group->add_group_field(
322 322
 						$group_field_id,
323 323
 						array(
324
-							'name'    => __( 'Description', 'lsx-health-plan' ),
324
+							'name'    => __('Description', 'lsx-health-plan'),
325 325
 							'id'      => 'description',
326 326
 							'type'    => 'wysiwyg',
327 327
 							'options' => array(
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 				$cmb_group->add_group_field(
335 335
 					$group_field_id,
336 336
 					array(
337
-						'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
337
+						'name' => esc_html__('Exercise title (Optional)', 'lsx-health-plan'),
338 338
 						'id'   => 'alt_title',
339 339
 						'type' => 'text',
340 340
 					)
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				$cmb_group->add_group_field(
343 343
 					$group_field_id,
344 344
 					array(
345
-						'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
345
+						'name' => esc_html__('Exercise Description (Optional)', 'lsx-health-plan'),
346 346
 						'id'   => 'alt_description',
347 347
 						'type' => 'textarea_small',
348 348
 					)
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 				$cmb_group->add_group_field(
351 351
 					$group_field_id,
352 352
 					array(
353
-						'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
353
+						'name' => esc_html__('Reps / Time / Distance', 'lsx-health-plan'),
354 354
 						'id'   => 'reps',
355 355
 						'type' => 'text',
356 356
 						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
@@ -359,13 +359,13 @@  discard block
 block discarded – undo
359 359
 				$cmb_group->add_group_field(
360 360
 					$group_field_id,
361 361
 					array(
362
-						'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
362
+						'name'         => __('Exercise Image (Optional)', 'lsx-health-plan'),
363 363
 						'id'           => 'exercise_alt_thumbnail',
364 364
 						'type'         => 'file',
365 365
 						'text'         => array(
366
-							'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
366
+							'add_upload_file_text' => __('Add File', 'lsx-health-plan'),
367 367
 						),
368
-						'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
368
+						'desc'         => __('Upload an image 300px x 300px in size.', 'lsx-health-plan'),
369 369
 						'query_args'   => array(
370 370
 							'type' => array(
371 371
 								'image/gif',
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
 	 * @param object $wp_query
389 389
 	 * @return array
390 390
 	 */
391
-	public function set_parent_only( $wp_query ) {
392
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) {
393
-			$wp_query->set( 'post_parent', '0' );
391
+	public function set_parent_only($wp_query) {
392
+		if ( ! is_admin() && $wp_query->is_main_query() && ($wp_query->is_post_type_archive('workout') || $wp_query->is_tax(array('workout-type')))) {
393
+			$wp_query->set('post_parent', '0');
394 394
 		}
395 395
 	}
396 396
 }
Please login to merge, or discard this patch.
classes/post-types/class-meal.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 * Constructor
31 31
 	 */
32 32
 	public function __construct() {
33
-		add_action( 'init', array( $this, 'register_post_type' ) );
34
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
33
+		add_action('init', array($this, 'register_post_type'));
34
+		add_action('init', array($this, 'taxonomy_setup'));
35 35
 		
36
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
36
+		add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1);
37
+		add_action('cmb2_admin_init', array($this, 'featured_metabox'), 5);
38
+		add_action('cmb2_admin_init', array($this, 'details_metaboxes'));
39 39
 
40 40
 		// Template Redirects.
41
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
42
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
41
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
42
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
43 43
 
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
44
+		add_action('pre_get_posts', array($this, 'set_parent_only'), 10, 1);
45
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
46 46
 	}
47 47
 
48 48
 	/**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public static function get_instance() {
56 56
 		// If the single instance hasn't been set, set it now.
57
-		if ( null === self::$instance ) {
57
+		if (null === self::$instance) {
58 58
 			self::$instance = new self();
59 59
 		}
60 60
 		return self::$instance;
@@ -64,21 +64,21 @@  discard block
 block discarded – undo
64 64
 	 */
65 65
 	public function register_post_type() {
66 66
 		$labels = array(
67
-			'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
68
-			'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
69
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
70
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
71
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
72
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
73
-			'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
74
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
75
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
76
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
77
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
78
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
79
-			'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
67
+			'name'               => esc_html__('Meals', 'lsx-health-plan'),
68
+			'singular_name'      => esc_html__('Meal', 'lsx-health-plan'),
69
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
70
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
71
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
72
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
73
+			'all_items'          => esc_html__('All Meals', 'lsx-health-plan'),
74
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
75
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
76
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
77
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
78
+			'parent_item_colon'  => esc_html__('Parent:', 'lsx-health-plan'),
79
+			'menu_name'          => esc_html__('Meals', 'lsx-health-plan'),
80 80
 		);
81
-		$args   = array(
81
+		$args = array(
82 82
 			'labels'             => $labels,
83 83
 			'public'             => true,
84 84
 			'publicly_queryable' => true,
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 			'menu_icon'          => 'dashicons-carrot',
89 89
 			'query_var'          => true,
90 90
 			'rewrite'            => array(
91
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
91
+				'slug' => \lsx_health_plan\functions\get_option('meal_single_slug', 'meal'),
92 92
 			),
93 93
 			'capability_type'    => 'page',
94
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
94
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_meal_archive', 'meals'),
95 95
 			'hierarchical'       => true,
96 96
 			'menu_position'      => null,
97 97
 			'supports'           => array(
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 				'custom-fields',
103 103
 			),
104 104
 		);
105
-		register_post_type( 'meal', $args );
105
+		register_post_type('meal', $args);
106 106
 	}
107 107
 
108 108
 	/**
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
 	 */
111 111
 	public function taxonomy_setup() {
112 112
 		$labels = array(
113
-			'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
114
-			'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
115
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
116
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
117
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
118
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
119
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
120
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
121
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
122
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
123
-			'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
113
+			'name'              => esc_html_x('Meal Type', 'taxonomy general name', 'lsx-health-plan'),
114
+			'singular_name'     => esc_html_x('Meal Types', 'taxonomy singular name', 'lsx-health-plan'),
115
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
116
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
117
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
118
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
119
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
120
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
121
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
122
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
123
+			'menu_name'         => esc_html__('Meal Types', 'lsx-health-plan'),
124 124
 		);
125
-		$args   = array(
125
+		$args = array(
126 126
 			'hierarchical'      => true,
127 127
 			'labels'            => $labels,
128 128
 			'show_ui'           => true,
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 				'slug' => 'meal-type',
134 134
 			),
135 135
 		);
136
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
136
+		register_taxonomy('meal-type', array($this->slug), $args);
137 137
 	}
138 138
 
139 139
 	/**
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param array $post_types
143 143
 	 * @return array
144 144
 	 */
145
-	public function enable_post_type( $post_types = array() ) {
145
+	public function enable_post_type($post_types = array()) {
146 146
 		$post_types[] = $this->slug;
147 147
 		return $post_types;
148 148
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param array $connections
154 154
 	 * @return void
155 155
 	 */
156
-	public function enable_connections( $connections = array() ) {
156
+	public function enable_connections($connections = array()) {
157 157
 		$connections['meal']['connected_plans'] = 'connected_meals';
158 158
 		$connections['plan']['connected_meals'] = 'connected_plans';
159 159
 		return $connections;
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 * @param string $title the term title.
166 166
 	 * @return string
167 167
 	 */
168
-	public function get_the_archive_title( $title ) {
169
-		if ( is_post_type_archive( 'meal' ) ) {
170
-			$title = __( 'Meals', 'lsx-health-plan' );
168
+	public function get_the_archive_title($title) {
169
+		if (is_post_type_archive('meal')) {
170
+			$title = __('Meals', 'lsx-health-plan');
171 171
 		}
172 172
 		return $title;
173 173
 	}
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 		$cmb = new_cmb2_box(
180 180
 			array(
181 181
 				'id'           => $this->slug . '_featured_metabox_meal',
182
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
183
-				'object_types' => array( $this->slug ), // Post type
182
+				'title'        => __('Featured Meal', 'lsx-health-plan'),
183
+				'object_types' => array($this->slug), // Post type
184 184
 				'context'      => 'side',
185 185
 				'priority'     => 'high',
186 186
 				'show_names'   => true,
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 		);
189 189
 		$cmb->add_field(
190 190
 			array(
191
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
192
-				'desc'       => __( 'Enable a featured meal' ),
191
+				'name'       => __('Featured Meal', 'lsx-health-plan'),
192
+				'desc'       => __('Enable a featured meal'),
193 193
 				'id'         => $this->slug . '_featured_meal',
194 194
 				'type'       => 'checkbox',
195 195
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -201,66 +201,66 @@  discard block
 block discarded – undo
201 201
 	 * Define the metabox and field configurations.
202 202
 	 */
203 203
 	public function details_metaboxes() {
204
-		$cmb = new_cmb2_box( array(
204
+		$cmb = new_cmb2_box(array(
205 205
 			'id'           => $this->slug . '_shopping_list_metabox',
206
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
207
-			'object_types' => array( $this->slug ), // Post type
206
+			'title'        => __('Shopping List', 'lsx-health-plan'),
207
+			'object_types' => array($this->slug), // Post type
208 208
 			'context'      => 'normal',
209 209
 			'priority'     => 'high',
210 210
 			'show_names'   => true,
211
-		) );
212
-		$cmb->add_field( array(
213
-			'name'       => __( 'Shopping List', 'lsx-health-plan' ),
214
-			'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
211
+		));
212
+		$cmb->add_field(array(
213
+			'name'       => __('Shopping List', 'lsx-health-plan'),
214
+			'desc'       => __('Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.'),
215 215
 			'id'         => $this->slug . '_shopping_list',
216 216
 			'type'       => 'post_search_ajax',
217 217
 			// Optional :
218
-			'limit'      => 1,  // Limit selection to X items only (default 1)
218
+			'limit'      => 1, // Limit selection to X items only (default 1)
219 219
 			'sortable'   => true, // Allow selected items to be sortable (default false)
220 220
 			'query_args' => array(
221
-				'post_type'      => array( 'page' ),
222
-				'post_status'    => array( 'publish' ),
221
+				'post_type'      => array('page'),
222
+				'post_status'    => array('publish'),
223 223
 				'posts_per_page' => -1,
224 224
 			),
225
-		) );
226
-		$cmb = new_cmb2_box( array(
225
+		));
226
+		$cmb = new_cmb2_box(array(
227 227
 			'id'           => $this->slug . '_details_metabox',
228
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
229
-			'object_types' => array( $this->slug ), // Post type
228
+			'title'        => __('Meal Details', 'lsx-health-plan'),
229
+			'object_types' => array($this->slug), // Post type
230 230
 			'context'      => 'normal',
231 231
 			'priority'     => 'high',
232 232
 			'show_names'   => true,
233
-		) );
233
+		));
234 234
 
235
-		$cmb->add_field( array(
236
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
235
+		$cmb->add_field(array(
236
+			'name' => __('Meal Short Description', 'lsx-health-plan'),
237 237
 			'id'   => $this->slug . '_short_description',
238 238
 			'type' => 'textarea_small',
239
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
240
-		) );
239
+			'desc' => __('Add a small description for this meal (optional)', 'lsx-health-plan'),
240
+		));
241 241
 
242
-		$cmb->add_field( array(
243
-			'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
242
+		$cmb->add_field(array(
243
+			'name'       => __('Pre Breakfast Snack', 'lsx-health-plan'),
244 244
 			'id'         => $this->slug . '_pre_breakfast_snack',
245 245
 			'type'       => 'wysiwyg',
246 246
 			'show_on_cb' => 'cmb2_hide_if_no_cats',
247 247
 			'options'    => array(
248 248
 				'textarea_rows' => 5,
249 249
 			),
250
-		) );
251
-		$cmb->add_field( array(
252
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
250
+		));
251
+		$cmb->add_field(array(
252
+			'name'       => __('Breakfast', 'lsx-health-plan'),
253 253
 			'id'         => $this->slug . '_breakfast',
254 254
 			'type'       => 'wysiwyg',
255 255
 			'show_on_cb' => 'cmb2_hide_if_no_cats',
256 256
 			'options'    => array(
257 257
 				'textarea_rows' => 5,
258 258
 			),
259
-		) );
259
+		));
260 260
 
261 261
 		$cmb->add_field(
262 262
 			array(
263
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
263
+				'name'       => __('Post Breakfast Snack', 'lsx-health-plan'),
264 264
 				'id'         => $this->slug . '_breakfast_snack',
265 265
 				'type'       => 'wysiwyg',
266 266
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
 			)
271 271
 		);
272 272
 
273
-		if ( post_type_exists( 'recipe' ) ) {
273
+		if (post_type_exists('recipe')) {
274 274
 			$cmb->add_field(
275 275
 				array(
276
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
277
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
276
+					'name'       => __('Breakfast Recipes', 'lsx-health-plan'),
277
+					'desc'       => __('Connect additional recipes options for breakfast.', 'lsx-health-plan'),
278 278
 					'id'         => 'breakfast_recipes',
279 279
 					'type'       => 'post_search_ajax',
280 280
 					// Optional :
281
-					'limit'      => 15,  // Limit selection to X items only (default 1)
281
+					'limit'      => 15, // Limit selection to X items only (default 1)
282 282
 					'sortable'   => true, // Allow selected items to be sortable (default false)
283 283
 					'query_args' => array(
284
-						'post_type'      => array( 'recipe' ),
285
-						'post_status'    => array( 'publish' ),
284
+						'post_type'      => array('recipe'),
285
+						'post_status'    => array('publish'),
286 286
 						'posts_per_page' => -1,
287 287
 					),
288 288
 				)
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$cmb->add_field(
293 293
 			array(
294
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
294
+				'name'       => __('Pre Lunch Snack', 'lsx-health-plan'),
295 295
 				'id'         => $this->slug . '_pre_lunch_snack',
296 296
 				'type'       => 'wysiwyg',
297 297
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 		);
303 303
 		$cmb->add_field(
304 304
 			array(
305
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
305
+				'name'       => __('Lunch', 'lsx-health-plan'),
306 306
 				'id'         => $this->slug . '_lunch',
307 307
 				'type'       => 'wysiwyg',
308 308
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		);
314 314
 		$cmb->add_field(
315 315
 			array(
316
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
316
+				'name'       => __('Post Lunch Snack', 'lsx-health-plan'),
317 317
 				'id'         => $this->slug . '_lunch_snack',
318 318
 				'type'       => 'wysiwyg',
319 319
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -323,19 +323,19 @@  discard block
 block discarded – undo
323 323
 			)
324 324
 		);
325 325
 
326
-		if ( post_type_exists( 'recipe' ) ) {
326
+		if (post_type_exists('recipe')) {
327 327
 			$cmb->add_field(
328 328
 				array(
329
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
330
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
329
+					'name'       => __('Lunch Recipes', 'lsx-health-plan'),
330
+					'desc'       => __('Connect additional recipes options for lunch.', 'lsx-health-plan'),
331 331
 					'id'         => 'lunch_recipes',
332 332
 					'type'       => 'post_search_ajax',
333 333
 					// Optional :
334
-					'limit'      => 15,  // Limit selection to X items only (default 1)
334
+					'limit'      => 15, // Limit selection to X items only (default 1)
335 335
 					'sortable'   => true, // Allow selected items to be sortable (default false)
336 336
 					'query_args' => array(
337
-						'post_type'      => array( 'recipe' ),
338
-						'post_status'    => array( 'publish' ),
337
+						'post_type'      => array('recipe'),
338
+						'post_status'    => array('publish'),
339 339
 						'posts_per_page' => -1,
340 340
 					),
341 341
 				)
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 
345 345
 		$cmb->add_field(
346 346
 			array(
347
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
347
+				'name'       => __('Pre Dinner Snack', 'lsx-health-plan'),
348 348
 				'id'         => $this->slug . '_pre_dinner_snack',
349 349
 				'type'       => 'wysiwyg',
350 350
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		);
356 356
 		$cmb->add_field(
357 357
 			array(
358
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
358
+				'name'       => __('Dinner', 'lsx-health-plan'),
359 359
 				'id'         => $this->slug . '_dinner',
360 360
 				'type'       => 'wysiwyg',
361 361
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 		);
367 367
 		$cmb->add_field(
368 368
 			array(
369
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
369
+				'name'       => __('Post Dinner Snack', 'lsx-health-plan'),
370 370
 				'id'         => $this->slug . '_dinner_snack',
371 371
 				'type'       => 'wysiwyg',
372 372
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -376,19 +376,19 @@  discard block
 block discarded – undo
376 376
 			)
377 377
 		);
378 378
 
379
-		if ( post_type_exists( 'recipe' ) ) {
379
+		if (post_type_exists('recipe')) {
380 380
 			$cmb->add_field(
381 381
 				array(
382
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
383
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
382
+					'name'       => __('Dinner Recipes', 'lsx-health-plan'),
383
+					'desc'       => __('Connect additional recipes options for dinner.', 'lsx-health-plan'),
384 384
 					'id'         => 'dinner_recipes',
385 385
 					'type'       => 'post_search_ajax',
386 386
 					// Optional :
387
-					'limit'      => 15,  // Limit selection to X items only (default 1)
387
+					'limit'      => 15, // Limit selection to X items only (default 1)
388 388
 					'sortable'   => true, // Allow selected items to be sortable (default false)
389 389
 					'query_args' => array(
390
-						'post_type'      => array( 'recipe' ),
391
-						'post_status'    => array( 'publish' ),
390
+						'post_type'      => array('recipe'),
391
+						'post_status'    => array('publish'),
392 392
 						'posts_per_page' => -1,
393 393
 					),
394 394
 				)
@@ -401,9 +401,9 @@  discard block
 block discarded – undo
401 401
 	 * @param object $wp_query
402 402
 	 * @return array
403 403
 	 */
404
-	public function set_parent_only( $wp_query ) {
405
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'meal' ) || $wp_query->is_tax( array( 'meal-type' ) ) ) ) {
406
-			$wp_query->set( 'post_parent', '0' );
404
+	public function set_parent_only($wp_query) {
405
+		if ( ! is_admin() && $wp_query->is_main_query() && ($wp_query->is_post_type_archive('meal') || $wp_query->is_tax(array('meal-type')))) {
406
+			$wp_query->set('post_parent', '0');
407 407
 		}
408 408
 	}
409 409
 }
Please login to merge, or discard this patch.