Passed
Push — master ( 903e32...f43b43 )
by Warwick
07:01
created
classes/post-types/class-meal.php 2 patches
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -8,402 +8,402 @@
 block discarded – undo
8 8
  */
9 9
 class Meal {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Meal()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Meal()
17
+      */
18
+     protected static $instance = null;
19 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 = 'meal';
20
+     /**
21
+      * Holds post_type slug used as an index
22
+      *
23
+      * @since 1.0.0
24
+      *
25
+      * @var      string
26
+      */
27
+     public $slug = 'meal';
28 28
 
29
-	/**
30
-	 * Constructor
31
-	 */
32
-	public function __construct() {
33
-		add_action( 'init', array( $this, 'register_post_type' ) );
34
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
29
+     /**
30
+      * Constructor
31
+      */
32
+     public function __construct() {
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
-		// 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 );
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 );
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 );
46
-	}
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
+     }
47 47
 
48
-	/**
49
-	 * Return an instance of this class.
50
-	 *
51
-	 * @since 1.0.0
52
-	 *
53
-	 * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
54
-	 */
55
-	public static function get_instance() {
56
-		// If the single instance hasn't been set, set it now.
57
-		if ( null === self::$instance ) {
58
-			self::$instance = new self();
59
-		}
60
-		return self::$instance;
61
-	}
62
-	/**
63
-	 * Register the post type.
64
-	 */
65
-	public function register_post_type() {
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' ),
80
-		);
81
-		$args   = array(
82
-			'labels'             => $labels,
83
-			'public'             => true,
84
-			'publicly_queryable' => true,
85
-			'show_ui'            => true,
86
-			'show_in_menu'       => true,
87
-			'show_in_rest'       => true,
88
-			'menu_icon'          => 'dashicons-carrot',
89
-			'query_var'          => true,
90
-			'rewrite'            => array(
91
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
92
-			),
93
-			'capability_type'    => 'page',
94
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
95
-			'hierarchical'       => true,
96
-			'menu_position'      => null,
97
-			'supports'           => array(
98
-				'title',
99
-				'editor',
100
-				'thumbnail',
101
-				'page-attributes',
102
-				'custom-fields',
103
-			),
104
-		);
105
-		register_post_type( 'meal', $args );
106
-	}
48
+     /**
49
+      * Return an instance of this class.
50
+      *
51
+      * @since 1.0.0
52
+      *
53
+      * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
54
+      */
55
+     public static function get_instance() {
56
+          // If the single instance hasn't been set, set it now.
57
+          if ( null === self::$instance ) {
58
+               self::$instance = new self();
59
+          }
60
+          return self::$instance;
61
+     }
62
+     /**
63
+      * Register the post type.
64
+      */
65
+     public function register_post_type() {
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' ),
80
+          );
81
+          $args   = array(
82
+               'labels'             => $labels,
83
+               'public'             => true,
84
+               'publicly_queryable' => true,
85
+               'show_ui'            => true,
86
+               'show_in_menu'       => true,
87
+               'show_in_rest'       => true,
88
+               'menu_icon'          => 'dashicons-carrot',
89
+               'query_var'          => true,
90
+               'rewrite'            => array(
91
+                    'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
92
+               ),
93
+               'capability_type'    => 'page',
94
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
95
+               'hierarchical'       => true,
96
+               'menu_position'      => null,
97
+               'supports'           => array(
98
+                    'title',
99
+                    'editor',
100
+                    'thumbnail',
101
+                    'page-attributes',
102
+                    'custom-fields',
103
+               ),
104
+          );
105
+          register_post_type( 'meal', $args );
106
+     }
107 107
 
108
-	/**
109
-	 * Register the Meal Type taxonomy.
110
-	 */
111
-	public function taxonomy_setup() {
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' ),
124
-		);
125
-		$args   = array(
126
-			'hierarchical'      => true,
127
-			'labels'            => $labels,
128
-			'show_ui'           => true,
129
-			'show_in_menu'      => 'edit.php?post_type=meal',
130
-			'show_admin_column' => true,
131
-			'query_var'         => true,
132
-			'rewrite'           => array(
133
-				'slug' => 'meal-type',
134
-			),
135
-		);
136
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
137
-	}
108
+     /**
109
+      * Register the Meal Type taxonomy.
110
+      */
111
+     public function taxonomy_setup() {
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' ),
124
+          );
125
+          $args   = array(
126
+               'hierarchical'      => true,
127
+               'labels'            => $labels,
128
+               'show_ui'           => true,
129
+               'show_in_menu'      => 'edit.php?post_type=meal',
130
+               'show_admin_column' => true,
131
+               'query_var'         => true,
132
+               'rewrite'           => array(
133
+                    'slug' => 'meal-type',
134
+               ),
135
+          );
136
+          register_taxonomy( 'meal-type', array( $this->slug ), $args );
137
+     }
138 138
 
139
-	/**
140
-	 * Adds the post type to the different arrays.
141
-	 *
142
-	 * @param array $post_types
143
-	 * @return array
144
-	 */
145
-	public function enable_post_type( $post_types = array() ) {
146
-		$post_types[] = $this->slug;
147
-		return $post_types;
148
-	}
139
+     /**
140
+      * Adds the post type to the different arrays.
141
+      *
142
+      * @param array $post_types
143
+      * @return array
144
+      */
145
+     public function enable_post_type( $post_types = array() ) {
146
+          $post_types[] = $this->slug;
147
+          return $post_types;
148
+     }
149 149
 
150
-	/**
151
-	 * Enables the Bi Directional relationships
152
-	 *
153
-	 * @param array $connections
154
-	 * @return void
155
-	 */
156
-	public function enable_connections( $connections = array() ) {
157
-		$connections['meal']['connected_plans'] = 'connected_meals';
158
-		$connections['plan']['connected_meals'] = 'connected_plans';
159
-		return $connections;
160
-	}
150
+     /**
151
+      * Enables the Bi Directional relationships
152
+      *
153
+      * @param array $connections
154
+      * @return void
155
+      */
156
+     public function enable_connections( $connections = array() ) {
157
+          $connections['meal']['connected_plans'] = 'connected_meals';
158
+          $connections['plan']['connected_meals'] = 'connected_plans';
159
+          return $connections;
160
+     }
161 161
 
162
-	/**
163
-	 * Remove the "Archives:" from the post type meal.
164
-	 *
165
-	 * @param string $title the term title.
166
-	 * @return string
167
-	 */
168
-	public function get_the_archive_title( $title ) {
169
-		if ( is_post_type_archive( 'meal' ) ) {
170
-			$title = __( 'Meals', 'lsx-health-plan' );
171
-		}
172
-		return $title;
173
-	}
162
+     /**
163
+      * Remove the "Archives:" from the post type meal.
164
+      *
165
+      * @param string $title the term title.
166
+      * @return string
167
+      */
168
+     public function get_the_archive_title( $title ) {
169
+          if ( is_post_type_archive( 'meal' ) ) {
170
+               $title = __( 'Meals', 'lsx-health-plan' );
171
+          }
172
+          return $title;
173
+     }
174 174
 
175
-	/**
176
-	 * Define the metabox and field configurations.
177
-	 */
178
-	public function featured_metabox() {
179
-		$cmb = new_cmb2_box(
180
-			array(
181
-				'id'           => $this->slug . '_featured_metabox_meal',
182
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
183
-				'object_types' => array( $this->slug ), // Post type
184
-				'context'      => 'side',
185
-				'priority'     => 'high',
186
-				'show_names'   => true,
187
-			)
188
-		);
189
-		$cmb->add_field(
190
-			array(
191
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
192
-				'desc'       => __( 'Enable a featured meal' ),
193
-				'id'         => $this->slug . '_featured_meal',
194
-				'type'       => 'checkbox',
195
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
196
-			)
197
-		);
198
-	}
175
+     /**
176
+      * Define the metabox and field configurations.
177
+      */
178
+     public function featured_metabox() {
179
+          $cmb = new_cmb2_box(
180
+               array(
181
+                    'id'           => $this->slug . '_featured_metabox_meal',
182
+                    'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
183
+                    'object_types' => array( $this->slug ), // Post type
184
+                    'context'      => 'side',
185
+                    'priority'     => 'high',
186
+                    'show_names'   => true,
187
+               )
188
+          );
189
+          $cmb->add_field(
190
+               array(
191
+                    'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
192
+                    'desc'       => __( 'Enable a featured meal' ),
193
+                    'id'         => $this->slug . '_featured_meal',
194
+                    'type'       => 'checkbox',
195
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
196
+               )
197
+          );
198
+     }
199 199
 
200
-	/**
201
-	 * Define the metabox and field configurations.
202
-	 */
203
-	public function details_metaboxes() {
204
-		$cmb = new_cmb2_box( array(
205
-			'id'           => $this->slug . '_shopping_list_metabox',
206
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
207
-			'object_types' => array( $this->slug ), // Post type
208
-			'context'      => 'normal',
209
-			'priority'     => 'high',
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.' ),
215
-			'id'         => $this->slug . '_shopping_list',
216
-			'type'       => 'post_search_ajax',
217
-			// Optional :
218
-			'limit'      => 1,  // Limit selection to X items only (default 1)
219
-			'sortable'   => true, // Allow selected items to be sortable (default false)
220
-			'query_args' => array(
221
-				'post_type'      => array( 'page' ),
222
-				'post_status'    => array( 'publish' ),
223
-				'posts_per_page' => -1,
224
-			),
225
-		) );
226
-		$cmb = new_cmb2_box( array(
227
-			'id'           => $this->slug . '_details_metabox',
228
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
229
-			'object_types' => array( $this->slug ), // Post type
230
-			'context'      => 'normal',
231
-			'priority'     => 'high',
232
-			'show_names'   => true,
233
-		) );
200
+     /**
201
+      * Define the metabox and field configurations.
202
+      */
203
+     public function details_metaboxes() {
204
+          $cmb = new_cmb2_box( array(
205
+               'id'           => $this->slug . '_shopping_list_metabox',
206
+               'title'        => __( 'Shopping List', 'lsx-health-plan' ),
207
+               'object_types' => array( $this->slug ), // Post type
208
+               'context'      => 'normal',
209
+               'priority'     => 'high',
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.' ),
215
+               'id'         => $this->slug . '_shopping_list',
216
+               'type'       => 'post_search_ajax',
217
+               // Optional :
218
+               'limit'      => 1,  // Limit selection to X items only (default 1)
219
+               'sortable'   => true, // Allow selected items to be sortable (default false)
220
+               'query_args' => array(
221
+                    'post_type'      => array( 'page' ),
222
+                    'post_status'    => array( 'publish' ),
223
+                    'posts_per_page' => -1,
224
+               ),
225
+          ) );
226
+          $cmb = new_cmb2_box( array(
227
+               'id'           => $this->slug . '_details_metabox',
228
+               'title'        => __( 'Meal Details', 'lsx-health-plan' ),
229
+               'object_types' => array( $this->slug ), // Post type
230
+               'context'      => 'normal',
231
+               'priority'     => 'high',
232
+               'show_names'   => true,
233
+          ) );
234 234
 
235
-		$cmb->add_field( array(
236
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
237
-			'id'   => $this->slug . '_short_description',
238
-			'type' => 'textarea_small',
239
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
240
-		) );
235
+          $cmb->add_field( array(
236
+               'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
237
+               'id'   => $this->slug . '_short_description',
238
+               'type' => 'textarea_small',
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' ),
244
-			'id'         => $this->slug . '_pre_breakfast_snack',
245
-			'type'       => 'wysiwyg',
246
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
247
-			'options'    => array(
248
-				'textarea_rows' => 5,
249
-			),
250
-		) );
251
-		$cmb->add_field( array(
252
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
253
-			'id'         => $this->slug . '_breakfast',
254
-			'type'       => 'wysiwyg',
255
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
256
-			'options'    => array(
257
-				'textarea_rows' => 5,
258
-			),
259
-		) );
242
+          $cmb->add_field( array(
243
+               'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
244
+               'id'         => $this->slug . '_pre_breakfast_snack',
245
+               'type'       => 'wysiwyg',
246
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
247
+               'options'    => array(
248
+                    'textarea_rows' => 5,
249
+               ),
250
+          ) );
251
+          $cmb->add_field( array(
252
+               'name'       => __( 'Breakfast', 'lsx-health-plan' ),
253
+               'id'         => $this->slug . '_breakfast',
254
+               'type'       => 'wysiwyg',
255
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
256
+               'options'    => array(
257
+                    'textarea_rows' => 5,
258
+               ),
259
+          ) );
260 260
 
261
-		$cmb->add_field(
262
-			array(
263
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
264
-				'id'         => $this->slug . '_breakfast_snack',
265
-				'type'       => 'wysiwyg',
266
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
267
-				'options'    => array(
268
-					'textarea_rows' => 5,
269
-				),
270
-			)
271
-		);
261
+          $cmb->add_field(
262
+               array(
263
+                    'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
264
+                    'id'         => $this->slug . '_breakfast_snack',
265
+                    'type'       => 'wysiwyg',
266
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
267
+                    'options'    => array(
268
+                         'textarea_rows' => 5,
269
+                    ),
270
+               )
271
+          );
272 272
 
273
-		if ( post_type_exists( 'recipe' ) ) {
274
-			$cmb->add_field(
275
-				array(
276
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
277
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
278
-					'id'         => 'breakfast_recipes',
279
-					'type'       => 'post_search_ajax',
280
-					// Optional :
281
-					'limit'      => 15,  // Limit selection to X items only (default 1)
282
-					'sortable'   => true, // Allow selected items to be sortable (default false)
283
-					'query_args' => array(
284
-						'post_type'      => array( 'recipe' ),
285
-						'post_status'    => array( 'publish' ),
286
-						'posts_per_page' => -1,
287
-					),
288
-				)
289
-			);
290
-		}
273
+          if ( post_type_exists( 'recipe' ) ) {
274
+               $cmb->add_field(
275
+                    array(
276
+                         'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
277
+                         'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
278
+                         'id'         => 'breakfast_recipes',
279
+                         'type'       => 'post_search_ajax',
280
+                         // Optional :
281
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
282
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
283
+                         'query_args' => array(
284
+                              'post_type'      => array( 'recipe' ),
285
+                              'post_status'    => array( 'publish' ),
286
+                              'posts_per_page' => -1,
287
+                         ),
288
+                    )
289
+               );
290
+          }
291 291
 
292
-		$cmb->add_field(
293
-			array(
294
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
295
-				'id'         => $this->slug . '_pre_lunch_snack',
296
-				'type'       => 'wysiwyg',
297
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
298
-				'options'    => array(
299
-					'textarea_rows' => 5,
300
-				),
301
-			)
302
-		);
303
-		$cmb->add_field(
304
-			array(
305
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
306
-				'id'         => $this->slug . '_lunch',
307
-				'type'       => 'wysiwyg',
308
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
309
-				'options'    => array(
310
-					'textarea_rows' => 5,
311
-				),
312
-			)
313
-		);
314
-		$cmb->add_field(
315
-			array(
316
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
317
-				'id'         => $this->slug . '_lunch_snack',
318
-				'type'       => 'wysiwyg',
319
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
320
-				'options'    => array(
321
-					'textarea_rows' => 5,
322
-				),
323
-			)
324
-		);
292
+          $cmb->add_field(
293
+               array(
294
+                    'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
295
+                    'id'         => $this->slug . '_pre_lunch_snack',
296
+                    'type'       => 'wysiwyg',
297
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
298
+                    'options'    => array(
299
+                         'textarea_rows' => 5,
300
+                    ),
301
+               )
302
+          );
303
+          $cmb->add_field(
304
+               array(
305
+                    'name'       => __( 'Lunch', 'lsx-health-plan' ),
306
+                    'id'         => $this->slug . '_lunch',
307
+                    'type'       => 'wysiwyg',
308
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
309
+                    'options'    => array(
310
+                         'textarea_rows' => 5,
311
+                    ),
312
+               )
313
+          );
314
+          $cmb->add_field(
315
+               array(
316
+                    'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
317
+                    'id'         => $this->slug . '_lunch_snack',
318
+                    'type'       => 'wysiwyg',
319
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
320
+                    'options'    => array(
321
+                         'textarea_rows' => 5,
322
+                    ),
323
+               )
324
+          );
325 325
 
326
-		if ( post_type_exists( 'recipe' ) ) {
327
-			$cmb->add_field(
328
-				array(
329
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
330
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
331
-					'id'         => 'lunch_recipes',
332
-					'type'       => 'post_search_ajax',
333
-					// Optional :
334
-					'limit'      => 15,  // Limit selection to X items only (default 1)
335
-					'sortable'   => true, // Allow selected items to be sortable (default false)
336
-					'query_args' => array(
337
-						'post_type'      => array( 'recipe' ),
338
-						'post_status'    => array( 'publish' ),
339
-						'posts_per_page' => -1,
340
-					),
341
-				)
342
-			);
343
-		}
326
+          if ( post_type_exists( 'recipe' ) ) {
327
+               $cmb->add_field(
328
+                    array(
329
+                         'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
330
+                         'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
331
+                         'id'         => 'lunch_recipes',
332
+                         'type'       => 'post_search_ajax',
333
+                         // Optional :
334
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
335
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
336
+                         'query_args' => array(
337
+                              'post_type'      => array( 'recipe' ),
338
+                              'post_status'    => array( 'publish' ),
339
+                              'posts_per_page' => -1,
340
+                         ),
341
+                    )
342
+               );
343
+          }
344 344
 
345
-		$cmb->add_field(
346
-			array(
347
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
348
-				'id'         => $this->slug . '_pre_dinner_snack',
349
-				'type'       => 'wysiwyg',
350
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
351
-				'options'    => array(
352
-					'textarea_rows' => 5,
353
-				),
354
-			)
355
-		);
356
-		$cmb->add_field(
357
-			array(
358
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
359
-				'id'         => $this->slug . '_dinner',
360
-				'type'       => 'wysiwyg',
361
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
362
-				'options'    => array(
363
-					'textarea_rows' => 5,
364
-				),
365
-			)
366
-		);
367
-		$cmb->add_field(
368
-			array(
369
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
370
-				'id'         => $this->slug . '_dinner_snack',
371
-				'type'       => 'wysiwyg',
372
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
373
-				'options'    => array(
374
-					'textarea_rows' => 5,
375
-				),
376
-			)
377
-		);
345
+          $cmb->add_field(
346
+               array(
347
+                    'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
348
+                    'id'         => $this->slug . '_pre_dinner_snack',
349
+                    'type'       => 'wysiwyg',
350
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
351
+                    'options'    => array(
352
+                         'textarea_rows' => 5,
353
+                    ),
354
+               )
355
+          );
356
+          $cmb->add_field(
357
+               array(
358
+                    'name'       => __( 'Dinner', 'lsx-health-plan' ),
359
+                    'id'         => $this->slug . '_dinner',
360
+                    'type'       => 'wysiwyg',
361
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
362
+                    'options'    => array(
363
+                         'textarea_rows' => 5,
364
+                    ),
365
+               )
366
+          );
367
+          $cmb->add_field(
368
+               array(
369
+                    'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
370
+                    'id'         => $this->slug . '_dinner_snack',
371
+                    'type'       => 'wysiwyg',
372
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
373
+                    'options'    => array(
374
+                         'textarea_rows' => 5,
375
+                    ),
376
+               )
377
+          );
378 378
 
379
-		if ( post_type_exists( 'recipe' ) ) {
380
-			$cmb->add_field(
381
-				array(
382
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
383
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
384
-					'id'         => 'dinner_recipes',
385
-					'type'       => 'post_search_ajax',
386
-					// Optional :
387
-					'limit'      => 15,  // Limit selection to X items only (default 1)
388
-					'sortable'   => true, // Allow selected items to be sortable (default false)
389
-					'query_args' => array(
390
-						'post_type'      => array( 'recipe' ),
391
-						'post_status'    => array( 'publish' ),
392
-						'posts_per_page' => -1,
393
-					),
394
-				)
395
-			);
396
-		}
397
-	}
398
-	/**
399
-	 * Set the post type archive to show the parent plans only.
400
-	 *
401
-	 * @param object $wp_query
402
-	 * @return array
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' );
407
-		}
408
-	}
379
+          if ( post_type_exists( 'recipe' ) ) {
380
+               $cmb->add_field(
381
+                    array(
382
+                         'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
383
+                         'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
384
+                         'id'         => 'dinner_recipes',
385
+                         'type'       => 'post_search_ajax',
386
+                         // Optional :
387
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
388
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
389
+                         'query_args' => array(
390
+                              'post_type'      => array( 'recipe' ),
391
+                              'post_status'    => array( 'publish' ),
392
+                              'posts_per_page' => -1,
393
+                         ),
394
+                    )
395
+               );
396
+          }
397
+     }
398
+     /**
399
+      * Set the post type archive to show the parent plans only.
400
+      *
401
+      * @param object $wp_query
402
+      * @return array
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' );
407
+          }
408
+     }
409 409
 }
Please login to merge, or discard this 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.