Passed
Push — add/multiplan ( 24f151...309a59 )
by Virginia
03:35
created
classes/post-types/class-meal.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	 * Contructor
31 31
 	 */
32 32
 	public function __construct() {
33
-		add_action( 'init', array( $this, 'register_post_type' ) );
34
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
35
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
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' ) );
33
+		add_action('init', array($this, 'register_post_type'));
34
+		add_action('init', array($this, 'taxonomy_setup'));
35
+		add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1);
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
 
41 41
 	/**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public static function get_instance() {
49 49
 		// If the single instance hasn't been set, set it now.
50
-		if ( null === self::$instance ) {
50
+		if (null === self::$instance) {
51 51
 			self::$instance = new self();
52 52
 		}
53 53
 		return self::$instance;
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function register_post_type() {
59 59
 		$labels = array(
60
-			'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
61
-			'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
62
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
63
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
64
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
65
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
66
-			'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
67
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
68
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
69
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
70
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
60
+			'name'               => esc_html__('Meals', 'lsx-health-plan'),
61
+			'singular_name'      => esc_html__('Meal', 'lsx-health-plan'),
62
+			'add_new'            => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'),
63
+			'add_new_item'       => esc_html__('Add New', 'lsx-health-plan'),
64
+			'edit_item'          => esc_html__('Edit', 'lsx-health-plan'),
65
+			'new_item'           => esc_html__('New', 'lsx-health-plan'),
66
+			'all_items'          => esc_html__('All Meals', 'lsx-health-plan'),
67
+			'view_item'          => esc_html__('View', 'lsx-health-plan'),
68
+			'search_items'       => esc_html__('Search', 'lsx-health-plan'),
69
+			'not_found'          => esc_html__('None found', 'lsx-health-plan'),
70
+			'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'),
71 71
 			'parent_item_colon'  => '',
72
-			'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
72
+			'menu_name'          => esc_html__('Meals', 'lsx-health-plan'),
73 73
 		);
74
-		$args   = array(
74
+		$args = array(
75 75
 			'labels'             => $labels,
76 76
 			'public'             => true,
77 77
 			'publicly_queryable' => true,
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			'menu_icon'          => 'dashicons-carrot',
82 82
 			'query_var'          => true,
83 83
 			'rewrite'            => array(
84
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
84
+				'slug' => \lsx_health_plan\functions\get_option('meal_single_slug', 'meal'),
85 85
 			),
86 86
 			'capability_type'    => 'post',
87
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
87
+			'has_archive'        => \lsx_health_plan\functions\get_option('endpoint_meal_archive', 'meals'),
88 88
 			'hierarchical'       => true,
89 89
 			'menu_position'      => null,
90 90
 			'supports'           => array(
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 				'custom-fields',
96 96
 			),
97 97
 		);
98
-		register_post_type( 'meal', $args );
98
+		register_post_type('meal', $args);
99 99
 	}
100 100
 
101 101
 	/**
@@ -103,19 +103,19 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function taxonomy_setup() {
105 105
 		$labels = array(
106
-			'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
107
-			'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
108
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
109
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
110
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
111
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
112
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
113
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
114
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
115
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
116
-			'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
106
+			'name'              => esc_html_x('Meal Type', 'taxonomy general name', 'lsx-health-plan'),
107
+			'singular_name'     => esc_html_x('Meal Types', 'taxonomy singular name', 'lsx-health-plan'),
108
+			'search_items'      => esc_html__('Search', 'lsx-health-plan'),
109
+			'all_items'         => esc_html__('All', 'lsx-health-plan'),
110
+			'parent_item'       => esc_html__('Parent', 'lsx-health-plan'),
111
+			'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'),
112
+			'edit_item'         => esc_html__('Edit', 'lsx-health-plan'),
113
+			'update_item'       => esc_html__('Update', 'lsx-health-plan'),
114
+			'add_new_item'      => esc_html__('Add New', 'lsx-health-plan'),
115
+			'new_item_name'     => esc_html__('New Name', 'lsx-health-plan'),
116
+			'menu_name'         => esc_html__('Meal Types', 'lsx-health-plan'),
117 117
 		);
118
-		$args   = array(
118
+		$args = array(
119 119
 			'hierarchical'      => true,
120 120
 			'labels'            => $labels,
121 121
 			'show_ui'           => true,
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				'slug' => 'meal-type',
127 127
 			),
128 128
 		);
129
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
129
+		register_taxonomy('meal-type', array($this->slug), $args);
130 130
 	}
131 131
 
132 132
 	/**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @param array $post_types
136 136
 	 * @return array
137 137
 	 */
138
-	public function enable_post_type( $post_types = array() ) {
138
+	public function enable_post_type($post_types = array()) {
139 139
 		$post_types[] = $this->slug;
140 140
 		return $post_types;
141 141
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param array $connections
147 147
 	 * @return void
148 148
 	 */
149
-	public function enable_connections( $connections = array() ) {
149
+	public function enable_connections($connections = array()) {
150 150
 		$connections['meal']['connected_plans'] = 'connected_meals';
151 151
 		$connections['plan']['connected_meals'] = 'connected_plans';
152 152
 		return $connections;
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 		$cmb = new_cmb2_box(
160 160
 			array(
161 161
 				'id'           => $this->slug . '_featured_metabox_meal',
162
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
163
-				'object_types' => array( $this->slug ), // Post type
162
+				'title'        => __('Featured Meal', 'lsx-health-plan'),
163
+				'object_types' => array($this->slug), // Post type
164 164
 				'context'      => 'side',
165 165
 				'priority'     => 'high',
166 166
 				'show_names'   => true,
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 		);
169 169
 		$cmb->add_field(
170 170
 			array(
171
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
172
-				'desc'       => __( 'Enable a featured meal' ),
171
+				'name'       => __('Featured Meal', 'lsx-health-plan'),
172
+				'desc'       => __('Enable a featured meal'),
173 173
 				'id'         => $this->slug . '_featured_meal',
174 174
 				'type'       => 'checkbox',
175 175
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -181,66 +181,66 @@  discard block
 block discarded – undo
181 181
 	 * Define the metabox and field configurations.
182 182
 	 */
183 183
 	public function details_metaboxes() {
184
-		$cmb = new_cmb2_box( array(
184
+		$cmb = new_cmb2_box(array(
185 185
 			'id'           => $this->slug . '_shopping_list_metabox',
186
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
187
-			'object_types' => array( $this->slug ), // Post type
186
+			'title'        => __('Shopping List', 'lsx-health-plan'),
187
+			'object_types' => array($this->slug), // Post type
188 188
 			'context'      => 'normal',
189 189
 			'priority'     => 'high',
190 190
 			'show_names'   => true,
191
-		) );
192
-		$cmb->add_field( array(
193
-			'name'       => __( 'Shopping List', 'lsx-health-plan' ),
194
-			'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
191
+		));
192
+		$cmb->add_field(array(
193
+			'name'       => __('Shopping List', 'lsx-health-plan'),
194
+			'desc'       => __('Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.'),
195 195
 			'id'         => $this->slug . '_shopping_list',
196 196
 			'type'       => 'post_search_ajax',
197 197
 			// Optional :
198
-			'limit'      => 1,  // Limit selection to X items only (default 1)
198
+			'limit'      => 1, // Limit selection to X items only (default 1)
199 199
 			'sortable'   => true, // Allow selected items to be sortable (default false)
200 200
 			'query_args' => array(
201
-				'post_type'      => array( 'page' ),
202
-				'post_status'    => array( 'publish' ),
201
+				'post_type'      => array('page'),
202
+				'post_status'    => array('publish'),
203 203
 				'posts_per_page' => -1,
204 204
 			),
205
-		) );
206
-		$cmb = new_cmb2_box( array(
205
+		));
206
+		$cmb = new_cmb2_box(array(
207 207
 			'id'           => $this->slug . '_details_metabox',
208
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
209
-			'object_types' => array( $this->slug ), // Post type
208
+			'title'        => __('Meal Details', 'lsx-health-plan'),
209
+			'object_types' => array($this->slug), // Post type
210 210
 			'context'      => 'normal',
211 211
 			'priority'     => 'high',
212 212
 			'show_names'   => true,
213
-		) );
213
+		));
214 214
 
215
-		$cmb->add_field( array(
216
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
215
+		$cmb->add_field(array(
216
+			'name' => __('Meal Short Description', 'lsx-health-plan'),
217 217
 			'id'   => $this->slug . '_short_description',
218 218
 			'type' => 'textarea_small',
219
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
220
-		) );
219
+			'desc' => __('Add a small description for this meal (optional)', 'lsx-health-plan'),
220
+		));
221 221
 
222
-		$cmb->add_field( array(
223
-			'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
222
+		$cmb->add_field(array(
223
+			'name'       => __('Pre Breakfast Snack', 'lsx-health-plan'),
224 224
 			'id'         => $this->slug . '_pre_breakfast_snack',
225 225
 			'type'       => 'wysiwyg',
226 226
 			'show_on_cb' => 'cmb2_hide_if_no_cats',
227 227
 			'options'    => array(
228 228
 				'textarea_rows' => 5,
229 229
 			),
230
-		) );
231
-		$cmb->add_field( array(
232
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
230
+		));
231
+		$cmb->add_field(array(
232
+			'name'       => __('Breakfast', 'lsx-health-plan'),
233 233
 			'id'         => $this->slug . '_breakfast',
234 234
 			'type'       => 'wysiwyg',
235 235
 			'show_on_cb' => 'cmb2_hide_if_no_cats',
236 236
 			'options'    => array(
237 237
 				'textarea_rows' => 5,
238 238
 			),
239
-		) );
239
+		));
240 240
 
241 241
 		$cmb->add_field(
242 242
 			array(
243
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
243
+				'name'       => __('Post Breakfast Snack', 'lsx-health-plan'),
244 244
 				'id'         => $this->slug . '_breakfast_snack',
245 245
 				'type'       => 'wysiwyg',
246 246
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -250,19 +250,19 @@  discard block
 block discarded – undo
250 250
 			)
251 251
 		);
252 252
 
253
-		if ( post_type_exists( 'recipe' ) ) {
253
+		if (post_type_exists('recipe')) {
254 254
 			$cmb->add_field(
255 255
 				array(
256
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
257
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
256
+					'name'       => __('Breakfast Recipes', 'lsx-health-plan'),
257
+					'desc'       => __('Connect additional recipes options for breakfast.', 'lsx-health-plan'),
258 258
 					'id'         => 'breakfast_recipes',
259 259
 					'type'       => 'post_search_ajax',
260 260
 					// Optional :
261
-					'limit'      => 15,  // Limit selection to X items only (default 1)
261
+					'limit'      => 15, // Limit selection to X items only (default 1)
262 262
 					'sortable'   => true, // Allow selected items to be sortable (default false)
263 263
 					'query_args' => array(
264
-						'post_type'      => array( 'recipe' ),
265
-						'post_status'    => array( 'publish' ),
264
+						'post_type'      => array('recipe'),
265
+						'post_status'    => array('publish'),
266 266
 						'posts_per_page' => -1,
267 267
 					),
268 268
 				)
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
 		$cmb->add_field(
273 273
 			array(
274
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
274
+				'name'       => __('Pre Lunch Snack', 'lsx-health-plan'),
275 275
 				'id'         => $this->slug . '_pre_lunch_snack',
276 276
 				'type'       => 'wysiwyg',
277 277
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 		);
283 283
 		$cmb->add_field(
284 284
 			array(
285
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
285
+				'name'       => __('Lunch', 'lsx-health-plan'),
286 286
 				'id'         => $this->slug . '_lunch',
287 287
 				'type'       => 'wysiwyg',
288 288
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 		);
294 294
 		$cmb->add_field(
295 295
 			array(
296
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
296
+				'name'       => __('Post Lunch Snack', 'lsx-health-plan'),
297 297
 				'id'         => $this->slug . '_lunch_snack',
298 298
 				'type'       => 'wysiwyg',
299 299
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -303,19 +303,19 @@  discard block
 block discarded – undo
303 303
 			)
304 304
 		);
305 305
 
306
-		if ( post_type_exists( 'recipe' ) ) {
306
+		if (post_type_exists('recipe')) {
307 307
 			$cmb->add_field(
308 308
 				array(
309
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
310
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
309
+					'name'       => __('Lunch Recipes', 'lsx-health-plan'),
310
+					'desc'       => __('Connect additional recipes options for lunch.', 'lsx-health-plan'),
311 311
 					'id'         => 'lunch_recipes',
312 312
 					'type'       => 'post_search_ajax',
313 313
 					// Optional :
314
-					'limit'      => 15,  // Limit selection to X items only (default 1)
314
+					'limit'      => 15, // Limit selection to X items only (default 1)
315 315
 					'sortable'   => true, // Allow selected items to be sortable (default false)
316 316
 					'query_args' => array(
317
-						'post_type'      => array( 'recipe' ),
318
-						'post_status'    => array( 'publish' ),
317
+						'post_type'      => array('recipe'),
318
+						'post_status'    => array('publish'),
319 319
 						'posts_per_page' => -1,
320 320
 					),
321 321
 				)
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 
325 325
 		$cmb->add_field(
326 326
 			array(
327
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
327
+				'name'       => __('Pre Dinner Snack', 'lsx-health-plan'),
328 328
 				'id'         => $this->slug . '_pre_dinner_snack',
329 329
 				'type'       => 'wysiwyg',
330 330
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
 		);
336 336
 		$cmb->add_field(
337 337
 			array(
338
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
338
+				'name'       => __('Dinner', 'lsx-health-plan'),
339 339
 				'id'         => $this->slug . '_dinner',
340 340
 				'type'       => 'wysiwyg',
341 341
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 		);
347 347
 		$cmb->add_field(
348 348
 			array(
349
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
349
+				'name'       => __('Post Dinner Snack', 'lsx-health-plan'),
350 350
 				'id'         => $this->slug . '_dinner_snack',
351 351
 				'type'       => 'wysiwyg',
352 352
 				'show_on_cb' => 'cmb2_hide_if_no_cats',
@@ -356,19 +356,19 @@  discard block
 block discarded – undo
356 356
 			)
357 357
 		);
358 358
 
359
-		if ( post_type_exists( 'recipe' ) ) {
359
+		if (post_type_exists('recipe')) {
360 360
 			$cmb->add_field(
361 361
 				array(
362
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
363
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
362
+					'name'       => __('Dinner Recipes', 'lsx-health-plan'),
363
+					'desc'       => __('Connect additional recipes options for dinner.', 'lsx-health-plan'),
364 364
 					'id'         => 'dinner_recipes',
365 365
 					'type'       => 'post_search_ajax',
366 366
 					// Optional :
367
-					'limit'      => 15,  // Limit selection to X items only (default 1)
367
+					'limit'      => 15, // Limit selection to X items only (default 1)
368 368
 					'sortable'   => true, // Allow selected items to be sortable (default false)
369 369
 					'query_args' => array(
370
-						'post_type'      => array( 'recipe' ),
371
-						'post_status'    => array( 'publish' ),
370
+						'post_type'      => array('recipe'),
371
+						'post_status'    => array('publish'),
372 372
 						'posts_per_page' => -1,
373 373
 					),
374 374
 				)
Please login to merge, or discard this patch.