Passed
Push — add/multiplan ( 23765e...a781ed )
by Warwick
05:45 queued 11s
created
classes/post-types/class-plan.php 1 patch
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -31,34 +31,34 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public function __construct() {
33 33
 
34
-		add_action( 'init', array( $this, 'register_post_type' ) );
35
-		add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) );
36
-		add_action( 'init', array( $this, 'week_taxonomy_setup' ) );
34
+		add_action('init', array($this, 'register_post_type'));
35
+		add_action('init', array($this, 'plan_type_taxonomy_setup'));
36
+		add_action('init', array($this, 'week_taxonomy_setup'));
37 37
 
38 38
 		// Icons for the plan types.
39
-		add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 );
40
-		add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 );
39
+		add_action('create_term', array($this, 'save_meta'), 10, 2);
40
+		add_action('edit_term', array($this, 'save_meta'), 10, 2);
41 41
 		$prefix_taxonomy = 'plan-type';
42
-		add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 );
42
+		add_action(sprintf('%s_edit_form_fields', $prefix_taxonomy), array($this, 'add_thumbnail_form_field'), 3, 1);
43 43
 
44 44
 		// Register the Metaboxes.
45
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
46
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 );
47
-		add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 );
48
-		add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 );
45
+		add_action('cmb2_admin_init', array($this, 'featured_metabox'), 5);
46
+		add_action('cmb2_admin_init', array($this, 'details_metaboxes'), 5);
47
+		add_action('cmb2_admin_init', array($this, 'plan_connections'), 5);
48
+		add_action('cmb2_admin_init', array($this, 'sections_metabox_loop'), 1);
49 49
 
50
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
50
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
51 51
 		//add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 );
52 52
 
53 53
 		// Template Redirects.
54
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
55
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
54
+		add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1);
55
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
56 56
 
57 57
 		// Plan Archive Actions.
58
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
59
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
60
-		add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 );
61
-		add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 );
58
+		add_action('pre_get_posts', array($this, 'set_parent_only'), 10, 1);
59
+		add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100);
60
+		add_action('lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1);
61
+		add_filter('lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1);
62 62
 	}
63 63
 
64 64
 	/**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public static function get_instance() {
72 72
 		// If the single instance hasn't been set, set it now.
73
-		if ( null === self::$instance ) {
73
+		if (null === self::$instance) {
74 74
 			self::$instance = new self();
75 75
 		}
76 76
 		return self::$instance;
@@ -80,21 +80,21 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function register_post_type() {
82 82
 		$labels = array(
83
-			'name'               => esc_html__( 'Plans', 'lsx-health-plan' ),
84
-			'singular_name'      => esc_html__( 'Plan', 'lsx-health-plan' ),
85
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
86
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
87
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
88
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
89
-			'all_items'          => esc_html__( 'All Plans', 'lsx-health-plan' ),
90
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
91
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
92
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
93
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
83
+			'name'               => esc_html__('Plans', 'lsx-health-plan'),
84
+			'singular_name'      => esc_html__('Plan', 'lsx-health-plan'),
85
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
86
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
87
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
88
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
89
+			'all_items'          => esc_html__('All Plans', 'lsx-health-plan'),
90
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
91
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
92
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
93
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
94 94
 			'parent_item_colon'  => '',
95
-			'menu_name'          => esc_html__( 'Plans', 'lsx-health-plan' ),
95
+			'menu_name'          => esc_html__('Plans', 'lsx-health-plan'),
96 96
 		);
97
-		$args   = array(
97
+		$args = array(
98 98
 			'labels'             => $labels,
99 99
 			'public'             => true,
100 100
 			'publicly_queryable' => true,
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 			'menu_icon'          => 'dashicons-welcome-write-blog',
105 105
 			'query_var'          => true,
106 106
 			'rewrite'            => array(
107
-				'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ),
107
+				'slug' => \lsx_health_plan\functions\get_option('plan_single_slug', 'plan'),
108 108
 			),
109 109
 			'capability_type'    => 'page',
110
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ),
110
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_plan_archive', 'plans'),
111 111
 			'hierarchical'       => false,
112 112
 			'menu_position'      => null,
113 113
 			'supports'           => array(
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 				'custom-fields',
119 119
 			),
120 120
 		);
121
-		register_post_type( 'plan', $args );
121
+		register_post_type('plan', $args);
122 122
 	}
123 123
 
124 124
 	/**
@@ -126,17 +126,17 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function plan_type_taxonomy_setup() {
128 128
 		$labels = array(
129
-			'name'              => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ),
130
-			'singular_name'     => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ),
131
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
132
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
133
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
134
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
135
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
136
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
137
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
138
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
139
-			'menu_name'         => esc_html__( 'Plan Types', 'lsx-health-plan' ),
129
+			'name'              => esc_html_x('Plan Type', 'taxonomy general name', 'lsx-health-plan'),
130
+			'singular_name'     => esc_html_x('Plan Type', 'taxonomy singular name', 'lsx-health-plan'),
131
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
132
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
133
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
134
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
135
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
136
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
137
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
138
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
139
+			'menu_name'         => esc_html__('Plan Types', 'lsx-health-plan'),
140 140
 		);
141 141
 
142 142
 		$args = array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			),
151 151
 		);
152 152
 
153
-		register_taxonomy( 'plan-type', array( 'plan' ), $args );
153
+		register_taxonomy('plan-type', array('plan'), $args);
154 154
 	}
155 155
 
156 156
 	/**
@@ -158,17 +158,17 @@  discard block
 block discarded – undo
158 158
 	 */
159 159
 	public function week_taxonomy_setup() {
160 160
 		$labels = array(
161
-			'name'              => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ),
162
-			'singular_name'     => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ),
163
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
164
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
165
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
166
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
167
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
168
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
169
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
170
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
171
-			'menu_name'         => esc_html__( 'Weeks', 'lsx-health-plan' ),
161
+			'name'              => esc_html_x('Week', 'taxonomy general name', 'lsx-health-plan'),
162
+			'singular_name'     => esc_html_x('Week', 'taxonomy singular name', 'lsx-health-plan'),
163
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
164
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
165
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
166
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
167
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
168
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
169
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
170
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
171
+			'menu_name'         => esc_html__('Weeks', 'lsx-health-plan'),
172 172
 		);
173 173
 
174 174
 		$args = array(
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			),
184 184
 		);
185 185
 
186
-		register_taxonomy( 'week', array( 'plan' ), $args );
186
+		register_taxonomy('week', array('plan'), $args);
187 187
 	}
188 188
 
189 189
 	/**
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 	 *
192 192
 	 * @since 0.1.0
193 193
 	 */
194
-	public function add_thumbnail_form_field( $term = false ) {
195
-		if ( is_object( $term ) ) {
196
-			$value         = get_term_meta( $term->term_id, 'thumbnail', true );
197
-			$image_preview = wp_get_attachment_image_src( $value, 'thumbnail' );
194
+	public function add_thumbnail_form_field($term = false) {
195
+		if (is_object($term)) {
196
+			$value         = get_term_meta($term->term_id, 'thumbnail', true);
197
+			$image_preview = wp_get_attachment_image_src($value, 'thumbnail');
198 198
 
199
-			if ( is_array( $image_preview ) ) {
200
-				$image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
199
+			if (is_array($image_preview)) {
200
+				$image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url($image_preview[0]) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
201 201
 			}
202 202
 		} else {
203 203
 			$image_preview = false;
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 		}
206 206
 		?>
207 207
 		<tr class="form-field form-required term-thumbnail-wrap">
208
-			<th scope="row"><label for="thumbnail"><?php esc_html_e( 'Icon Image', 'lsx-health-plan' ); ?></label></th>
208
+			<th scope="row"><label for="thumbnail"><?php esc_html_e('Icon Image', 'lsx-health-plan'); ?></label></th>
209 209
 			<td>
210
-				<input class="input_image_id" type="hidden" name="thumbnail" value="<?php echo wp_kses_post( $value ); ?>">
210
+				<input class="input_image_id" type="hidden" name="thumbnail" value="<?php echo wp_kses_post($value); ?>">
211 211
 				<div class="thumbnail-preview">
212
-					<?php echo wp_kses_post( $image_preview ); ?>
212
+					<?php echo wp_kses_post($image_preview); ?>
213 213
 				</div>
214
-				<a style="<?php if ( '' !== $value && false !== $value ) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-add"><?php esc_html_e( 'Choose Image', 'lsx-health-plan' ); ?></a>
215
-				<a style="<?php if ( '' === $value || false === $value ) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-remove"><?php esc_html_e( 'Remove Image', 'lsx-health-plan' ); ?></a>
216
-				<?php wp_nonce_field( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ); ?>
214
+				<a style="<?php if ('' !== $value && false !== $value) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-add"><?php esc_html_e('Choose Image', 'lsx-health-plan'); ?></a>
215
+				<a style="<?php if ('' === $value || false === $value) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-remove"><?php esc_html_e('Remove Image', 'lsx-health-plan'); ?></a>
216
+				<?php wp_nonce_field('lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce'); ?>
217 217
 			</td>
218 218
 		</tr>
219 219
 		<?php
@@ -227,27 +227,27 @@  discard block
 block discarded – undo
227 227
 	 * @param  int    $term_id
228 228
 	 * @param  string $taxonomy
229 229
 	 */
230
-	public function save_meta( $term_id = 0, $taxonomy = '' ) {
231
-		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
230
+	public function save_meta($term_id = 0, $taxonomy = '') {
231
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
232 232
 			return;
233 233
 		}
234 234
 
235
-		if ( ! isset( $_POST['thumbnail'] ) ) {
235
+		if ( ! isset($_POST['thumbnail'])) {
236 236
 			return;
237 237
 		}
238 238
 
239
-		if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) {
240
-			if ( ! isset( $_POST['thumbnail'] ) ) {
239
+		if (check_admin_referer('lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce')) {
240
+			if ( ! isset($_POST['thumbnail'])) {
241 241
 				return;
242 242
 			}
243 243
 
244
-			$thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] );
245
-			$thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : '';
244
+			$thumbnail_meta = sanitize_text_field($_POST['thumbnail']);
245
+			$thumbnail_meta = ! empty($thumbnail_meta) ? $thumbnail_meta : '';
246 246
 
247
-			if ( empty( $thumbnail_meta ) ) {
248
-				delete_term_meta( $term_id, 'thumbnail' );
247
+			if (empty($thumbnail_meta)) {
248
+				delete_term_meta($term_id, 'thumbnail');
249 249
 			} else {
250
-				update_term_meta( $term_id, 'thumbnail', $thumbnail_meta );
250
+				update_term_meta($term_id, 'thumbnail', $thumbnail_meta);
251 251
 			}
252 252
 		}
253 253
 	}
@@ -256,33 +256,33 @@  discard block
 block discarded – undo
256 256
 	 * Define the metabox and field configurations.
257 257
 	 */
258 258
 	public function details_metaboxes() {
259
-		$cmb = new_cmb2_box( array(
259
+		$cmb = new_cmb2_box(array(
260 260
 			'id'           => $this->slug . '_details_metabox',
261
-			'title'        => __( 'Details', 'lsx-health-plan' ),
262
-			'object_types' => array( $this->slug ), // Post type
261
+			'title'        => __('Details', 'lsx-health-plan'),
262
+			'object_types' => array($this->slug), // Post type
263 263
 			'context'      => 'normal',
264 264
 			'priority'     => 'high',
265 265
 			'show_names'   => true,
266
-		) );
266
+		));
267 267
 
268 268
 		$warmup_type = 'page';
269
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
270
-			$warmup_type = array( 'page', 'workout' );
269
+		if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) {
270
+			$warmup_type = array('page', 'workout');
271 271
 		}
272
-		$cmb->add_field( array(
273
-			'name'       => __( 'Warmup', 'lsx-health-plan' ),
274
-			'desc'       => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ),
272
+		$cmb->add_field(array(
273
+			'name'       => __('Warmup', 'lsx-health-plan'),
274
+			'desc'       => __('Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan'),
275 275
 			'id'         => $this->slug . '_warmup',
276 276
 			'type'       => 'post_search_ajax',
277 277
 			// Optional :
278
-			'limit'      => 3,  // Limit selection to X items only (default 1)
278
+			'limit'      => 3, // Limit selection to X items only (default 1)
279 279
 			'sortable'   => true, // Allow selected items to be sortable (default false)
280 280
 			'query_args' => array(
281 281
 				'post_type'      => $warmup_type,
282
-				'post_status'    => array( 'publish' ),
282
+				'post_status'    => array('publish'),
283 283
 				'posts_per_page' => -1,
284 284
 			),
285
-		) );
285
+		));
286 286
 	}
287 287
 
288 288
 	/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @param array $post_types
292 292
 	 * @return array
293 293
 	 */
294
-	public function enable_post_type( $post_types = array() ) {
294
+	public function enable_post_type($post_types = array()) {
295 295
 		$post_types[] = $this->slug;
296 296
 		return $post_types;
297 297
 	}
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 		$cmb = new_cmb2_box(
306 306
 			array(
307 307
 				'id'           => $this->slug . '_connections_metabox',
308
-				'title'        => __( 'Plans', 'lsx-health-plan' ),
309
-				'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ),
308
+				'title'        => __('Plans', 'lsx-health-plan'),
309
+				'object_types' => array('workout', 'meal', 'tip', 'recipe'),
310 310
 				'context'      => 'normal',
311 311
 				'priority'     => 'high',
312 312
 				'show_names'   => true,
@@ -314,15 +314,15 @@  discard block
 block discarded – undo
314 314
 		);
315 315
 		$cmb->add_field(
316 316
 			array(
317
-				'name'       => __( 'Plan', 'lsx-health-plan' ),
317
+				'name'       => __('Plan', 'lsx-health-plan'),
318 318
 				'id'         => 'connected_plans',
319
-				'desc'       => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ),
319
+				'desc'       => __('Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan'),
320 320
 				'type'       => 'post_search_ajax',
321 321
 				'limit'      => 15,
322 322
 				'sortable'   => true,
323 323
 				'query_args' => array(
324
-					'post_type'      => array( 'plan' ),
325
-					'post_status'    => array( 'publish' ),
324
+					'post_type'      => array('plan'),
325
+					'post_status'    => array('publish'),
326 326
 					'posts_per_page' => -1,
327 327
 				),
328 328
 			)
@@ -335,9 +335,9 @@  discard block
 block discarded – undo
335 335
 	 * @param string $title the term title.
336 336
 	 * @return string
337 337
 	 */
338
-	public function get_the_archive_title( $title ) {
339
-		if ( is_post_type_archive( 'plan' ) ) {
340
-			$title = __( 'Our health plans', 'lsx-health-plan' );
338
+	public function get_the_archive_title($title) {
339
+		if (is_post_type_archive('plan')) {
340
+			$title = __('Our health plans', 'lsx-health-plan');
341 341
 		}
342 342
 		return $title;
343 343
 	}
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	 * @param object $wp_query
349 349
 	 * @return array
350 350
 	 */
351
-	public function set_parent_only( $wp_query ) {
352
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) {
353
-			$wp_query->set( 'post_parent', '0' );
351
+	public function set_parent_only($wp_query) {
352
+		if ( ! is_admin() && $wp_query->is_main_query() && ($wp_query->is_post_type_archive('plan') || $wp_query->is_tax('plan-type'))) {
353
+			$wp_query->set('post_parent', '0');
354 354
 		}
355 355
 	}
356 356
 
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 		$cmb = new_cmb2_box(
362 362
 			array(
363 363
 				'id'           => $this->slug . '_featured_metabox_plan',
364
-				'title'        => __( 'Featured Plan', 'lsx-health-plan' ),
365
-				'object_types' => array( $this->slug ), // Post type
364
+				'title'        => __('Featured Plan', 'lsx-health-plan'),
365
+				'object_types' => array($this->slug), // Post type
366 366
 				'context'      => 'side',
367 367
 				'priority'     => 'high',
368 368
 				'show_names'   => true,
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 		);
371 371
 		$cmb->add_field(
372 372
 			array(
373
-				'name'       => __( 'Featured Plan', 'lsx-health-plan' ),
374
-				'desc'       => __( 'Enable a featured plan' ),
373
+				'name'       => __('Featured Plan', 'lsx-health-plan'),
374
+				'desc'       => __('Enable a featured plan'),
375 375
 				'id'         => $this->slug . '_featured_plan',
376 376
 				'type'       => 'checkbox',
377 377
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 		$cmb = new_cmb2_box(
387 387
 			array(
388 388
 				'id'           => $this->slug . '_sections_metabox',
389
-				'title'        => __( 'Sections', 'lsx-health-plan' ),
390
-				'object_types' => array( $this->slug ), // Post type.
389
+				'title'        => __('Sections', 'lsx-health-plan'),
390
+				'object_types' => array($this->slug), // Post type.
391 391
 				'context'      => 'normal',
392 392
 				'priority'     => 'low',
393 393
 				'show_names'   => true,
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 				'id'      => $this->slug . '_sections',
404 404
 				'type'    => 'group',
405 405
 				'options' => array(
406
-					'group_title'   => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
407
-					'add_button'    => __( 'Add section', 'lsx-health-plan' ),
408
-					'remove_button' => __( 'Remove section', 'lsx-health-plan' ),
406
+					'group_title'   => __('Section', 'lsx-health-plan') . ' {#}', // {#} gets replaced by row number
407
+					'add_button'    => __('Add section', 'lsx-health-plan'),
408
+					'remove_button' => __('Remove section', 'lsx-health-plan'),
409 409
 					'sortable'      => true,
410 410
 					'closed'        => true, // true to have the groups closed by default
411 411
 				),
@@ -417,10 +417,10 @@  discard block
 block discarded – undo
417 417
 		$cmb->add_group_field(
418 418
 			$group,
419 419
 			array(
420
-				'name'       => __( 'Title', 'lsx-health-plan' ),
420
+				'name'       => __('Title', 'lsx-health-plan'),
421 421
 				'id'         => 'title',
422 422
 				'type'       => 'text',
423
-				'desc'       => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ),
423
+				'desc'       => __('e.g Day 1 / Week 1', 'lsx-health-plan'),
424 424
 				'classes'    => 'lsx-field-col  lsx-field-col-50',
425 425
 			)
426 426
 		);
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
 		$cmb->add_group_field(
429 429
 			$group,
430 430
 			array(
431
-				'name'       => __( 'Group', 'lsx-health-plan' ),
431
+				'name'       => __('Group', 'lsx-health-plan'),
432 432
 				'id'         => 'group',
433 433
 				'type'       => 'text',
434
-				'desc'       => __( 'e.g Week 1 / January', 'lsx-health-plan' ),
434
+				'desc'       => __('e.g Week 1 / January', 'lsx-health-plan'),
435 435
 				'classes'    => 'lsx-field-col  lsx-field-col-50',
436 436
 			)
437 437
 		);
@@ -439,25 +439,25 @@  discard block
 block discarded – undo
439 439
 		$cmb->add_group_field(
440 440
 			$group,
441 441
 			array(
442
-				'name' => __( 'Overview', 'lsx-health-plan' ),
442
+				'name' => __('Overview', 'lsx-health-plan'),
443 443
 				'id'   => 'description',
444 444
 				'type' => 'wysiwyg',
445 445
 			)
446 446
 		);
447 447
 
448
-		if ( post_type_exists( 'workout' ) ) {
448
+		if (post_type_exists('workout')) {
449 449
 			$cmb->add_group_field(
450 450
 				$group,
451 451
 				array(
452
-					'name'       => __( 'Workouts', 'lsx-health-plan' ),
452
+					'name'       => __('Workouts', 'lsx-health-plan'),
453 453
 					'id'         => 'connected_workouts',
454
-					'desc'       => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ),
454
+					'desc'       => __('Connect the workout(s) that apply to this section.', 'lsx-health-plan'),
455 455
 					'type'       => 'post_search_ajax',
456 456
 					'limit'      => 15,
457 457
 					'sortable'   => true,
458 458
 					'query_args' => array(
459
-						'post_type'      => array( 'workout' ),
460
-						'post_status'    => array( 'publish' ),
459
+						'post_type'      => array('workout'),
460
+						'post_status'    => array('publish'),
461 461
 						'posts_per_page' => -1,
462 462
 					),
463 463
 					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-33',
@@ -465,40 +465,40 @@  discard block
 block discarded – undo
465 465
 			);
466 466
 		}
467 467
 
468
-		if ( post_type_exists( 'meal' ) ) {
468
+		if (post_type_exists('meal')) {
469 469
 			$cmb->add_group_field(
470 470
 				$group,
471 471
 				array(
472
-					'name'       => __( 'Meals', 'lsx-health-plan' ),
473
-					'desc'       => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ),
472
+					'name'       => __('Meals', 'lsx-health-plan'),
473
+					'desc'       => __('Connect the meal(s) that apply to this section.', 'lsx-health-plan'),
474 474
 					'id'         => 'connected_meals',
475 475
 					'type'       => 'post_search_ajax',
476 476
 					// Optional :
477 477
 					'limit'      => 15, // Limit selection to X items only (default 1)
478 478
 					'sortable'   => true, // Allow selected items to be sortable (default false)
479 479
 					'query_args' => array(
480
-						'post_type'      => array( 'meal' ),
481
-						'post_status'    => array( 'publish' ),
480
+						'post_type'      => array('meal'),
481
+						'post_status'    => array('publish'),
482 482
 						'posts_per_page' => -1,
483 483
 					),
484 484
 					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-33',
485 485
 				)
486 486
 			);
487 487
 		}
488
-		if ( post_type_exists( 'tip' ) ) {
488
+		if (post_type_exists('tip')) {
489 489
 			$cmb->add_group_field(
490 490
 				$group,
491 491
 				array(
492
-					'name'       => __( 'Tips', 'lsx-health-plan' ),
492
+					'name'       => __('Tips', 'lsx-health-plan'),
493 493
 					'id'         => 'connected_tips',
494
-					'desc'       => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ),
494
+					'desc'       => __('Connect the tip(s) that apply to this section.', 'lsx-health-plan'),
495 495
 					'type'       => 'post_search_ajax',
496 496
 					// Optional :
497
-					'limit'      => 15,  // Limit selection to X items only (default 1)
498
-					'sortable'   => true,  // Allow selected items to be sortable (default false)
497
+					'limit'      => 15, // Limit selection to X items only (default 1)
498
+					'sortable'   => true, // Allow selected items to be sortable (default false)
499 499
 					'query_args' => array(
500
-						'post_type'      => array( 'tip' ),
501
-						'post_status'    => array( 'publish' ),
500
+						'post_type'      => array('tip'),
501
+						'post_status'    => array('publish'),
502 502
 						'posts_per_page' => -1,
503 503
 					),
504 504
 					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-33',
Please login to merge, or discard this patch.