Recipe::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
nc 1
nop 0
dl 0
loc 22
rs 9.7998
c 2
b 0
f 0
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
56
		//Breadcrumbs
0 ignored issues
show
Coding Style introduced by
No space found before comment text; expected "// Breadcrumbs" but found "//Breadcrumbs"
Loading history...
Coding Style introduced by
Inline comments must end in full-stops, exclamation marks, or question marks
Loading history...
57
		add_filter( 'wpseo_breadcrumb_links', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
58
		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 );
59
60
		// Backend Actions and Filters.
61
		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ) );
62
		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
63
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
64
65
	/**
66
	 * Return an instance of this class.
67
	 *
68
	 * @since 1.0.0
69
	 *
70
	 * @return    object \lsx_health_plan\classes\Recipe()    A single instance of this class.
71
	 */
72
	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...
73
74
		// If the single instance hasn't been set, set it now.
75
		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...
76
			self::$instance = new self();
77
		}
78
79
		return self::$instance;
80
81
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
82
83
	/**
84
	 * Register the post type.
85
	 */
86
	public function register_post_type() {
87
		$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...
88
			'name'               => esc_html__( 'Recipes', 'lsx-health-plan' ),
89
			'singular_name'      => esc_html__( 'Recipe', 'lsx-health-plan' ),
90
			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
91
			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
92
			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
93
			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
94
			'all_items'          => esc_html__( 'All Recipes', 'lsx-health-plan' ),
95
			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
96
			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
97
			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
98
			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
99
			'parent_item_colon'  => '',
100
			'menu_name'          => esc_html__( 'Recipes', 'lsx-health-plan' ),
101
		);
102
		$args         = array(
103
			'labels'             => $this->labels,
104
			'public'             => true,
105
			'publicly_queryable' => true,
106
			'show_ui'            => true,
107
			'show_in_menu'       => 'edit.php?post_type=meal-pseudo',
108
			'show_in_rest'       => true,
109
			'menu_icon'          => 'dashicons-editor-ul',
110
			'query_var'          => true,
111
			'rewrite'            => array(
112
				'slug' => 'recipe',
113
			),
114
			'capability_type'    => 'post',
115
			'has_archive'        => 'recipes',
116
			'hierarchical'       => false,
117
			'menu_position'      => null,
118
			'supports'           => array(
119
				'title',
120
				'editor',
121
				'thumbnail',
122
				'custom-fields',
123
			),
124
		);
125
		register_post_type( 'recipe', $args );
126
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
127
128
	/**
129
	 * Registers the Recipes under the Meals Post type menu.
130
	 *
131
	 * @return void
132
	 */
133
	public function register_menus() {
134
		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' );
135
		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' );
136
		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' );
137
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
138
139
	/**
140
	 * Register the Cuisine taxonomy.
141
	 */
142
	public function taxonomy_setup() {
143
		$labels = array(
144
			'name'              => esc_html_x( 'Cuisine', 'taxonomy general name', 'lsx-health-plan' ),
145
			'singular_name'     => esc_html_x( 'Cuisines', 'taxonomy singular name', 'lsx-health-plan' ),
146
			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
147
			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
148
			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
149
			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
150
			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
151
			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
152
			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
153
			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
154
			'menu_name'         => esc_html__( 'Cuisines', 'lsx-health-plan' ),
155
		);
156
		$args   = array(
157
			'hierarchical'      => true,
158
			'labels'            => $labels,
159
			'show_ui'           => true,
160
			'show_admin_column' => true,
161
			'show_in_menu'      => 'edit.php?post_type=meal',
162
			'query_var'         => true,
163
			'rewrite'           => array(
164
				'slug' => 'recipe-cuisine',
165
			),
166
		);
167
		register_taxonomy( 'recipe-cuisine', array( $this->slug ), $args );
168
169
		$labels = array(
170
			'name'              => esc_html_x( 'Recipe Type', 'taxonomy general name', 'lsx-health-plan' ),
171
			'singular_name'     => esc_html_x( 'Recipe Types', 'taxonomy singular name', 'lsx-health-plan' ),
172
			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
173
			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
174
			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
175
			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
176
			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
177
			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
178
			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
179
			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
180
			'menu_name'         => esc_html__( 'Types', 'lsx-health-plan' ),
181
		);
182
		$args   = array(
183
			'hierarchical'      => true,
184
			'labels'            => $labels,
185
			'show_ui'           => true,
186
			'show_in_menu'      => 'edit.php?post_type=meal',
187
			'show_admin_column' => true,
188
			'query_var'         => true,
189
			'rewrite'           => array(
190
				'slug' => 'recipe-type',
191
			),
192
		);
193
		register_taxonomy( 'recipe-type', array( $this->slug ), $args );
194
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
195
196
	/**
197
	 * Adds the post type to the different arrays.
198
	 *
199
	 * @param array $post_types
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
200
	 * @return array
201
	 */
202
	public function enable_post_type( $post_types = array() ) {
203
		$post_types[] = $this->slug;
204
		return $post_types;
205
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
206
207
	/**
208
	 * Enables the Bi Directional relationships
209
	 *
210
	 * @param array $connections
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
211
	 * @return void
0 ignored issues
show
Coding Style introduced by
Function return type is void, but function contains return statement
Loading history...
212
	 */
213
	public function enable_connections( $connections = array() ) {
214
		$connections['recipe']['connected_plans'] = 'connected_recipes';
215
		$connections['plan']['connected_recipes'] = 'connected_plans';
216
		return $connections;
217
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
218
219
	/**
220
	 * Remove the "Archives:" from the post type recipes.
221
	 *
222
	 * @param string $title the term title.
223
	 * @return string
224
	 */
225
	public function get_the_archive_title( $title ) {
226
		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...
227
			$title = __( 'Recipes', 'lsx-health-plan' );
228
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
229
		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...
230
			$title = __( 'Exercises', 'lsx-health-plan' );
231
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
232
		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...
233
			$queried_object = get_queried_object();
234
			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...
235
				$title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' );
236
			}
237
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
238
		return $title;
239
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
240
241
	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...
242
		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...
243
			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
244
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
245
		if ( is_singular( 'recipe' ) || is_singular( '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...
246
			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
247
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
248
		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...
249
			add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 );
250
		}
251
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
252
253
	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...
254
		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...
255
		?>
256
			<div class="archive-header-wrapper banner-archive">
257
				<?php lsx_global_header_inner_bottom(); ?>
258
				<header class="archive-header">
259
					<h1 class="archive-title">
260
						<?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...
261
							<?php the_archive_title( esc_html__( 'Type:', 'lsx' ) ); ?>
262
						<?php } else { ?>
263
							<?php echo wp_kses_post( apply_filters( 'lsx_global_header_title', get_the_archive_title() ) ); ?>
264
						<?php } ?>
265
					</h1>
266
267
					<?php
268
					lsx_health_plan_recipe_archive_description();
269
					?>
270
				</header>
271
			</div>
272
		<?php
273
		}
274
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
275
276
	/**
277
	 * Disables the global header description
278
	 *
279
	 * @param boolean $disable
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter comment
Loading history...
280
	 * @return boolean
281
	 */
282
	public function disable_global_header_description( $disable ) {
283
		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...
284
			$disable = true;
285
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
286
		return $disable;
287
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
288
289
	/**
0 ignored issues
show
Coding Style Documentation introduced by
Doc comment for parameter "$crumbs" missing
Loading history...
290
	 * Holds the array for the breadcrumbs.
291
	 *
292
	 * @var array $crumbs
293
	 * @return array
294
	 */
295
	public function recipes_breadcrumb_filter( $crumbs ) {
296
		$recipe  = \lsx_health_plan\functions\get_option( 'endpoint_recipe', 'recipe' );
297
		$recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe_archive', 'recipes' );
298
		$url     = get_post_type_archive_link( 'recipe' );
299
300
		if ( is_singular( '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...
301
			$recipe_name     = get_the_title();
302
			$term_obj_list   = get_the_terms( get_the_ID(), 'recipe-type' );
0 ignored issues
show
Bug introduced by
It seems like get_the_ID() can also be of type false; however, parameter $post of get_the_terms() does only seem to accept WP_Post|integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

302
			$term_obj_list   = get_the_terms( /** @scrutinizer ignore-type */ get_the_ID(), 'recipe-type' );
Loading history...
303
			$recipe_type     = $term_obj_list[0]->name;
304
			$recipe_type_url = get_term_link( $term_obj_list[0]->term_id );
305
306
			$new_crumbs    = array();
307
			$new_crumbs[0] = $crumbs[0];
308
309
			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...
310
				$new_crumbs[1] = array(
311
					0 => $recipes,
312
					1 => $url,
313
				);
314
				$new_crumbs[2] = array(
315
					0 => $recipe_type,
316
					1 => $recipe_type_url,
317
				);
318
				$new_crumbs[3] = array(
319
					0 => $recipe_name,
320
				);
321
			} else {
322
				$new_crumbs[1] = array(
323
					'text' => $recipes,
324
					'url'  => $url,
325
				);
326
				$new_crumbs[2] = array(
327
					'text' => $recipe_type,
328
					'url'  => $recipe_type_url,
329
				);
330
				$new_crumbs[3] = array(
331
					'text' => $recipe_name,
332
				);
333
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
334
			$crumbs = $new_crumbs;
335
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
336
		if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) {
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...
337
			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
338
339
			$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
340
341
			$new_crumbs    = array();
342
			$new_crumbs[0] = $crumbs[0];
343
344
			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...
345
				$new_crumbs[1] = array(
346
					0 => $recipes,
347
					1 => $url,
348
				);
349
				$new_crumbs[2] = array(
350
					0 => $single_term_title,
351
				);
352
			} else {
353
				$new_crumbs[1] = array(
354
					'text' => $recipes,
355
					'url'  => $url,
356
				);
357
				$new_crumbs[2] = array(
358
					'text' => $single_term_title,
359
				);
360
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
361
			$crumbs = $new_crumbs;
362
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
363
		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...
Coding Style introduced by
Blank line found at start of control structure
Loading history...
364
365
			$new_crumbs    = array();
366
			$new_crumbs[0] = $crumbs[0];
367
368
			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...
369
				$new_crumbs[1] = array(
370
					0 => $recipes,
371
				);
372
			} else {
373
				$new_crumbs[1] = array(
374
					'text' => $recipes,
375
				);
376
			}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
377
			$crumbs = $new_crumbs;
378
		}
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
379
		return $crumbs;
380
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
381
382
	/**
383
	 * Define the metabox and field configurations.
384
	 */
385
	public function featured_metabox() {
386
		$cmb = new_cmb2_box(
387
			array(
388
				'id'           => $this->slug . '_featured_metabox',
389
				'title'        => __( 'Featured', 'lsx-health-plan' ),
390
				'object_types' => array( $this->slug ),
391
				'context'      => 'side',
392
				'priority'     => 'high',
393
				'show_names'   => true,
394
			)
395
		);
396
		$cmb->add_field(
397
			array(
398
				'name'       => __( 'Featured', 'lsx-health-plan' ),
399
				'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' ),
400
				'id'         => $this->slug . '_featured',
401
				'type'       => 'checkbox',
402
				'show_on_cb' => 'cmb2_hide_if_no_cats',
403
			)
404
		);
405
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
406
407
	/**
408
	 * Define the metabox and field configurations.
409
	 */
410
	public function details_metaboxes() {
411
		$cmb = new_cmb2_box(
412
			array(
413
				'id'           => $this->slug . '_details_metabox',
414
				'title'        => __( 'Cooking Info', 'lsx-health-plan' ),
415
				'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...
416
				'context'      => 'normal',
417
				'priority'     => 'high',
418
				'show_names'   => true,
419
			)
420
		);
421
		$cmb->add_field(
422
			array(
423
				'name'       => __( 'Prep Time', 'lsx-health-plan' ),
424
				'id'         => $this->slug . '_prep_time',
425
				'desc'       => __( 'Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan' ),
426
				'type'       => 'text',
427
				'show_on_cb' => 'cmb2_hide_if_no_cats',
428
			)
429
		);
430
		$cmb->add_field(
431
			array(
432
				'name'       => __( 'Cooking Time', 'lsx-health-plan' ),
433
				'id'         => $this->slug . '_cooking_time',
434
				'desc'       => __( 'Add the cooking time i.e: 15 mins', 'lsx-health-plan' ),
435
				'type'       => 'text',
436
				'show_on_cb' => 'cmb2_hide_if_no_cats',
437
			)
438
		);
439
		$cmb->add_field(
440
			array(
441
				'name'       => __( 'Serves', 'lsx-health-plan' ),
442
				'id'         => $this->slug . '_serves',
443
				'desc'       => __( 'Add the recommended serving size i.e: 6', 'lsx-health-plan' ),
444
				'type'       => 'text',
445
				'show_on_cb' => 'cmb2_hide_if_no_cats',
446
				'attributes' => array(
447
					'type'    => 'number',
448
					'pattern' => '\d*',
449
				),
450
			)
451
		);
452
		$cmb->add_field(
453
			array(
454
				'name'       => __( 'Portion', 'lsx-health-plan' ),
455
				'desc'       => __( 'Add the recommended portion size i.e: 200mg', 'lsx-health-plan' ),
456
				'id'         => $this->slug . '_portion',
457
				'type'       => 'text',
458
				'show_on_cb' => 'cmb2_hide_if_no_cats',
459
			)
460
		);
461
		$cmb = new_cmb2_box(
462
			array(
463
				'id'           => $this->slug . '_nutritional_metabox',
464
				'title'        => __( 'Nutritional Info', 'lsx-health-plan' ),
465
				'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...
466
				'context'      => 'normal',
467
				'priority'     => 'high',
468
				'show_names'   => true,
469
			)
470
		);
471
		$cmb->add_field(
472
			array(
473
				'name'       => __( 'Energy', 'lsx-health-plan' ),
474
				'id'         => $this->slug . '_energy',
475
				'desc'       => __( 'Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan' ),
476
				'type'       => 'text',
477
				'show_on_cb' => 'cmb2_hide_if_no_cats',
478
			)
479
		);
480
		$cmb->add_field(
481
			array(
482
				'name'       => __( 'Protein', 'lsx-health-plan' ),
483
				'id'         => $this->slug . '_protein',
484
				'desc'       => __( 'Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan' ),
485
				'type'       => 'text',
486
				'show_on_cb' => 'cmb2_hide_if_no_cats',
487
			)
488
		);
489
		$cmb->add_field(
490
			array(
491
				'name'       => __( 'Carbohydrates', 'lsx-health-plan' ),
492
				'id'         => $this->slug . '_carbohydrates',
493
				'desc'       => __( 'Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
494
				'type'       => 'text',
495
				'show_on_cb' => 'cmb2_hide_if_no_cats',
496
			)
497
		);
498
		$cmb->add_field(
499
			array(
500
				'name'       => __( 'Fibre', 'lsx-health-plan' ),
501
				'id'         => $this->slug . '_fibre',
502
				'desc'       => __( 'Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan' ),
503
				'type'       => 'text',
504
				'show_on_cb' => 'cmb2_hide_if_no_cats',
505
			)
506
		);
507
		$cmb->add_field(
508
			array(
509
				'name'       => __( 'Fat', 'lsx-health-plan' ),
510
				'id'         => $this->slug . '_fat',
511
				'desc'       => __( 'Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan' ),
512
				'type'       => 'text',
513
				'show_on_cb' => 'cmb2_hide_if_no_cats',
514
			)
515
		);
516
	}
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
517
}
518