Passed
Push — add/multiplan ( 80880c...7ffec7 )
by Virginia
04:38
created

Recipe::remove_archive_original_header()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 4
c 0
b 0
f 0
nc 4
nop 0
dl 0
loc 6
rs 10
1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
2
namespace lsx_health_plan\classes;
3
4
/**
5
 * Contains the recipe post type
6
 *
7
 * @package lsx-health-plan
8
 */
9
class Recipe {
10
11
	/**
12
	 * Holds class instance
13
	 *
14
	 * @since 1.0.0
15
	 *
16
	 * @var      object \lsx_health_plan\classes\Recipe()
17
	 */
18
	protected static $instance = null;
19
20
	/**
21
	 * Holds post_type slug used as an index
22
	 *
23
	 * @since 1.0.0
24
	 *
25
	 * @var      string
26
	 */
27
	public $slug = 'recipe';
28
29
	/**
30
	 * Holds post_type labels
31
	 *
32
	 * @since 1.0.0
33
	 *
34
	 * @var      string
35
	 */
36
	public $labels = array();
37
38
	/**
39
	 * Constructor
40
	 */
41
	public function __construct() {
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
42
		add_action( 'init', array( $this, 'register_post_type' ) );
43
		add_action( 'init', array( $this, 'taxonomy_setup' ) );
44
		add_action( 'admin_menu', array( $this, 'register_menus' ) );
45
46
		// Frontend Actions and Filters.
47
		add_action( 'wp_head', array( $this, 'remove_archive_original_header' ), 99 );
48
		add_action( 'lsx_content_wrap_before', array( $this, 'hp_lsx_archive_header' ) );
49
50
		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
51
		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
52
		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
53
		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
54
		add_filter( 'lsx_display_global_header_description', array( $this, 'disable_global_header_description' ), 100 );
55
		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
56
57
		// Backend Actions and Filters.
58
		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ) );
59
		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
60
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
61
62
	/**
63
	 * Return an instance of this class.
64
	 *
65
	 * @since 1.0.0
66
	 *
67
	 * @return    object \lsx_health_plan\classes\Recipe()    A single instance of this class.
68
	 */
69
	public static function get_instance() {
0 ignored issues
show
Coding Style introduced by
Expected 0 blank lines after opening function brace; 1 found
Loading history...
70
71
		// If the single instance hasn't been set, set it now.
72
		if ( null === self::$instance ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
73
			self::$instance = new self();
74
		}
75
76
		return self::$instance;
77
78
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
79
80
	/**
81
	 * Register the post type.
82
	 */
83
	public function register_post_type() {
84
		$this->labels = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array('name' => esc_html...s', 'lsx-health-plan')) of type array<string,string> is incompatible with the declared type string of property $labels.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
85
			'name'               => esc_html__( 'Recipes', 'lsx-health-plan' ),
86
			'singular_name'      => esc_html__( 'Recipe', 'lsx-health-plan' ),
87
			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
88
			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
89
			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
90
			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
91
			'all_items'          => esc_html__( 'All Recipes', 'lsx-health-plan' ),
92
			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
93
			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
94
			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
95
			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
96
			'parent_item_colon'  => '',
97
			'menu_name'          => esc_html__( 'Recipes', 'lsx-health-plan' ),
98
		);
99
		$args         = array(
100
			'labels'             => $this->labels,
101
			'public'             => true,
102
			'publicly_queryable' => true,
103
			'show_ui'            => true,
104
			'show_in_menu'       => false,
105
			'show_in_rest'       => true,
106
			'menu_icon'          => 'dashicons-editor-ul',
107
			'query_var'          => true,
108
			'rewrite'            => array(
109
				'slug' => 'recipe',
110
			),
111
			'capability_type'    => 'post',
112
			'has_archive'        => 'recipes',
113
			'hierarchical'       => false,
114
			'menu_position'      => null,
115
			'supports'           => array(
116
				'title',
117
				'editor',
118
				'thumbnail',
119
				'custom-fields',
120
			),
121
		);
122
		register_post_type( 'recipe', $args );
123
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
124
125
	/**
126
	 * Registers the Recipes under the Meals Post type menu.
127
	 *
128
	 * @return void
129
	 */
130
	public function register_menus() {
131
		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipes', 'lsx-health-plan' ), esc_html__( 'Recipes', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=recipe' );
132
		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipe Types', 'lsx-health-plan' ), esc_html__( 'Recipe Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-type&post_type=recipe' );
133
		add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Cuisines', 'lsx-health-plan' ), esc_html__( 'Cuisines', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-cuisine&post_type=recipe' );
134
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
135
136
	/**
137
	 * Register the Week taxonomy.
138
	 */
139
	public function taxonomy_setup() {
140
		$labels = array(
141
			'name'              => esc_html_x( 'Cuisine', 'taxonomy general name', 'lsx-health-plan' ),
142
			'singular_name'     => esc_html_x( 'Cuisines', 'taxonomy singular name', 'lsx-health-plan' ),
143
			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
144
			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
145
			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
146
			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
147
			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
148
			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
149
			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
150
			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
151
			'menu_name'         => esc_html__( 'Cuisines', 'lsx-health-plan' ),
152
		);
153
		$args   = array(
154
			'hierarchical'      => true,
155
			'labels'            => $labels,
156
			'show_ui'           => true,
157
			'show_admin_column' => true,
158
			'show_in_menu'      => 'edit.php?post_type=meal',
159
			'query_var'         => true,
160
			'rewrite'           => array(
161
				'slug' => 'recipe-cuisine',
162
			),
163
		);
164
		register_taxonomy( 'recipe-cuisine', array( $this->slug ), $args );
165
166
		$labels = array(
167
			'name'              => esc_html_x( 'Recipe Type', 'taxonomy general name', 'lsx-health-plan' ),
168
			'singular_name'     => esc_html_x( 'Recipe Types', 'taxonomy singular name', 'lsx-health-plan' ),
169
			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
170
			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
171
			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
172
			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
173
			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
174
			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
175
			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
176
			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
177
			'menu_name'         => esc_html__( 'Types', 'lsx-health-plan' ),
178
		);
179
		$args   = array(
180
			'hierarchical'      => true,
181
			'labels'            => $labels,
182
			'show_ui'           => true,
183
			'show_in_menu'      => 'edit.php?post_type=meal',
184
			'show_admin_column' => true,
185
			'query_var'         => true,
186
			'rewrite'           => array(
187
				'slug' => 'recipe-type',
188
			),
189
		);
190
		register_taxonomy( 'recipe-type', array( $this->slug ), $args );
191
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
192
193
	/**
194
	 * Adds the post type to the different arrays.
195
	 *
196
	 * @param array $post_types
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
197
	 * @return array
198
	 */
199
	public function enable_post_type( $post_types = array() ) {
200
		$post_types[] = $this->slug;
201
		return $post_types;
202
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
203
204
	/**
205
	 * Enables the Bi Directional relationships
206
	 *
207
	 * @param array $connections
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
208
	 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
209
	 */
210
	public function enable_connections( $connections = array() ) {
211
		$connections['recipe']['connected_plans'] = 'connected_recipes';
212
		$connections['plan']['connected_recipes'] = 'connected_plans';
213
		return $connections;
214
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
215
216
	/**
217
	 * Remove the "Archives:" from the post type recipes.
218
	 *
219
	 * @param string $title the term title.
220
	 * @return string
221
	 */
222
	public function get_the_archive_title( $title ) {
223
		if ( is_post_type_archive( 'recipe' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
224
			$title = __( 'Recipes', 'lsx-health-plan' );
225
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
226
		if ( is_post_type_archive( 'exercise' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
227
			$title = __( 'Exercises', 'lsx-health-plan' );
228
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
229
		if ( is_tax( 'recipe-type' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
230
			$queried_object = get_queried_object();
231
			if ( isset( $queried_object->name ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
232
				$title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' );
233
			}
234
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
235
		return $title;
236
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
237
238
	public function remove_archive_original_header() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function remove_archive_original_header()
Loading history...
239
		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
240
			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
241
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
242
		if ( ! is_post_type_archive() ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
243
			add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 );
244
		}
245
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
246
247
	public function hp_lsx_archive_header() {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function hp_lsx_archive_header()
Loading history...
248
		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
249
		?>
250
			<div class="archive-header-wrapper banner-archive col-<?php echo esc_attr( $size ); ?>-12">
251
				<?php lsx_global_header_inner_bottom(); ?>
252
				<header class="archive-header">
253
					<h1 class="archive-title">
254
						<?php if ( has_post_format() && ! is_category() && ! is_tag() && ! is_date() && ! is_tax( 'post_format' ) ) { ?>
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
255
							<?php the_archive_title( esc_html__( 'Type:', 'lsx' ) ); ?>
256
						<?php } else { ?>
257
							<?php echo wp_kses_post( apply_filters( 'lsx_global_header_title', get_the_archive_title() ) ); ?>
258
						<?php } ?>
259
					</h1>
260
261
					<?php
262
					lsx_health_plan_recipe_archive_description();
263
					?>
264
				</header>
265
			</div>
266
		<?php
267
		}
268
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
269
270
	/**
271
	 * Disables the global header description
272
	 *
273
	 * @param boolean $disable
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
274
	 * @return boolean
275
	 */
276
	public function disable_global_header_description( $disable ) {
277
		if ( is_tax( 'recipe-type' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
278
			$disable = true;
279
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
280
		return $disable;
281
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
282
283
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$crumbs" missing
Loading history...
284
	 * Holds the array for the breadcrumbs.
285
	 *
286
	 * @var array $crumbs
287
	 * @return array
288
	 */
289
	public function recipes_breadcrumb_filter( $crumbs ) {
290
		if ( is_tax( 'recipe-type' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
291
			$text = $this->labels['singular_name'];
292
			$url  = get_post_type_archive_link( 'recipe' );
293
			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
0 ignored issues
show
Coding Style introduced by
Expected 0 spaces after opening bracket; 1 found
Loading history...
Coding Style introduced by
Expected 0 spaces before closing bracket; 1 found
Loading history...
294
				$crumbs[1] = array(
295
					0 => $text,
296
					1 => $url,
297
				);
298
			} else {
299
				$crumbs[1] = array(
300
					'text' => $text,
301
					'url'  => $url,
302
				);
303
			}
304
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
305
		return $crumbs;
306
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
307
308
	/**
309
	 * Define the metabox and field configurations.
310
	 */
311
	public function featured_metabox() {
312
		$cmb = new_cmb2_box(
313
			array(
314
				'id'           => $this->slug . '_featured_metabox',
315
				'title'        => __( 'Featured', 'lsx-health-plan' ),
316
				'object_types' => array( $this->slug ),
317
				'context'      => 'side',
318
				'priority'     => 'high',
319
				'show_names'   => true,
320
			)
321
		);
322
		$cmb->add_field(
323
			array(
324
				'name'       => __( 'Featured', 'lsx-health-plan' ),
325
				'desc'       => __( 'Enable the checkbox to feature this recipe, featured recipes display in any page that has the recipe shortcode: [lsx_health_plan_featured_recipes_block]', 'lsx-health-plan' ),
326
				'id'         => $this->slug . '_featured',
327
				'type'       => 'checkbox',
328
				'show_on_cb' => 'cmb2_hide_if_no_cats',
329
			)
330
		);
331
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
332
333
	/**
334
	 * Define the metabox and field configurations.
335
	 */
336
	public function details_metaboxes() {
337
		$cmb = new_cmb2_box(
338
			array(
339
				'id'           => $this->slug . '_details_metabox',
340
				'title'        => __( 'Cooking Info', 'lsx-health-plan' ),
341
				'object_types' => array( $this->slug ), // Post type
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
342
				'context'      => 'normal',
343
				'priority'     => 'high',
344
				'show_names'   => true,
345
			)
346
		);
347
		$cmb->add_field(
348
			array(
349
				'name'       => __( 'Prep Time', 'lsx-health-plan' ),
350
				'id'         => $this->slug . '_prep_time',
351
				'desc'       => __( 'Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan' ),
352
				'type'       => 'text',
353
				'show_on_cb' => 'cmb2_hide_if_no_cats',
354
			)
355
		);
356
		$cmb->add_field(
357
			array(
358
				'name'       => __( 'Cooking Time', 'lsx-health-plan' ),
359
				'id'         => $this->slug . '_cooking_time',
360
				'desc'       => __( 'Add the cooking time i.e: 15 mins', 'lsx-health-plan' ),
361
				'type'       => 'text',
362
				'show_on_cb' => 'cmb2_hide_if_no_cats',
363
			)
364
		);
365
		$cmb->add_field(
366
			array(
367
				'name'       => __( 'Serves', 'lsx-health-plan' ),
368
				'id'         => $this->slug . '_serves',
369
				'desc'       => __( 'Add the recommended serving size i.e: 6', 'lsx-health-plan' ),
370
				'type'       => 'text',
371
				'show_on_cb' => 'cmb2_hide_if_no_cats',
372
				'attributes' => array(
373
					'type'    => 'number',
374
					'pattern' => '\d*',
375
				),
376
			)
377
		);
378
		$cmb->add_field(
379
			array(
380
				'name'       => __( 'Portion', 'lsx-health-plan' ),
381
				'desc'       => __( 'Add the recommended portion size i.e: 200mg', 'lsx-health-plan' ),
382
				'id'         => $this->slug . '_portion',
383
				'type'       => 'text',
384
				'show_on_cb' => 'cmb2_hide_if_no_cats',
385
			)
386
		);
387
		$cmb = new_cmb2_box(
388
			array(
389
				'id'           => $this->slug . '_nutritional_metabox',
390
				'title'        => __( 'Nutritional Info', 'lsx-health-plan' ),
391
				'object_types' => array( $this->slug ), // Post type
0 ignored issues
show
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
392
				'context'      => 'normal',
393
				'priority'     => 'high',
394
				'show_names'   => true,
395
			)
396
		);
397
		$cmb->add_field(
398
			array(
399
				'name'       => __( 'Energy', 'lsx-health-plan' ),
400
				'id'         => $this->slug . '_energy',
401
				'desc'       => __( 'Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan' ),
402
				'type'       => 'text',
403
				'show_on_cb' => 'cmb2_hide_if_no_cats',
404
			)
405
		);
406
		$cmb->add_field(
407
			array(
408
				'name'       => __( 'Protein', 'lsx-health-plan' ),
409
				'id'         => $this->slug . '_protein',
410
				'desc'       => __( 'Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan' ),
411
				'type'       => 'text',
412
				'show_on_cb' => 'cmb2_hide_if_no_cats',
413
			)
414
		);
415
		$cmb->add_field(
416
			array(
417
				'name'       => __( 'Carbohydrates', 'lsx-health-plan' ),
418
				'id'         => $this->slug . '_carbohydrates',
419
				'desc'       => __( 'Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
420
				'type'       => 'text',
421
				'show_on_cb' => 'cmb2_hide_if_no_cats',
422
			)
423
		);
424
		$cmb->add_field(
425
			array(
426
				'name'       => __( 'Fibre', 'lsx-health-plan' ),
427
				'id'         => $this->slug . '_fibre',
428
				'desc'       => __( 'Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
429
				'type'       => 'text',
430
				'show_on_cb' => 'cmb2_hide_if_no_cats',
431
			)
432
		);
433
		$cmb->add_field(
434
			array(
435
				'name'       => __( 'Fat', 'lsx-health-plan' ),
436
				'id'         => $this->slug . '_fat',
437
				'desc'       => __( 'Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan' ),
438
				'type'       => 'text',
439
				'show_on_cb' => 'cmb2_hide_if_no_cats',
440
			)
441
		);
442
	}
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
443
}
444