Passed
Push — add/multiplan ( d69cc6...0a1b11 )
by Virginia
03:38
created
classes/post-types/class-meal.php 1 patch
Indentation   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -8,375 +8,375 @@
 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 );
43
-	}
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
+     }
44 44
 
45
-	/**
46
-	 * Return an instance of this class.
47
-	 *
48
-	 * @since 1.0.0
49
-	 *
50
-	 * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
51
-	 */
52
-	public static function get_instance() {
53
-		// If the single instance hasn't been set, set it now.
54
-		if ( null === self::$instance ) {
55
-			self::$instance = new self();
56
-		}
57
-		return self::$instance;
58
-	}
59
-	/**
60
-	 * Register the post type.
61
-	 */
62
-	public function register_post_type() {
63
-		$labels = array(
64
-			'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
65
-			'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
66
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
67
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
68
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
69
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
70
-			'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
71
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
72
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
73
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
74
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
75
-			'parent_item_colon'  => '',
76
-			'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
77
-		);
78
-		$args   = array(
79
-			'labels'             => $labels,
80
-			'public'             => true,
81
-			'publicly_queryable' => true,
82
-			'show_ui'            => true,
83
-			'show_in_menu'       => true,
84
-			'show_in_rest'       => true,
85
-			'menu_icon'          => 'dashicons-carrot',
86
-			'query_var'          => true,
87
-			'rewrite'            => array(
88
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
89
-			),
90
-			'capability_type'    => 'post',
91
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
92
-			'hierarchical'       => true,
93
-			'menu_position'      => null,
94
-			'supports'           => array(
95
-				'title',
96
-				'editor',
97
-				'thumbnail',
98
-				'page-attributes',
99
-				'custom-fields',
100
-			),
101
-		);
102
-		register_post_type( 'meal', $args );
103
-	}
45
+     /**
46
+      * Return an instance of this class.
47
+      *
48
+      * @since 1.0.0
49
+      *
50
+      * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
51
+      */
52
+     public static function get_instance() {
53
+          // If the single instance hasn't been set, set it now.
54
+          if ( null === self::$instance ) {
55
+               self::$instance = new self();
56
+          }
57
+          return self::$instance;
58
+     }
59
+     /**
60
+      * Register the post type.
61
+      */
62
+     public function register_post_type() {
63
+          $labels = array(
64
+               'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
65
+               'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
66
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
67
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
68
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
69
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
70
+               'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
71
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
72
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
73
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
74
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
75
+               'parent_item_colon'  => '',
76
+               'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
77
+          );
78
+          $args   = array(
79
+               'labels'             => $labels,
80
+               'public'             => true,
81
+               'publicly_queryable' => true,
82
+               'show_ui'            => true,
83
+               'show_in_menu'       => true,
84
+               'show_in_rest'       => true,
85
+               'menu_icon'          => 'dashicons-carrot',
86
+               'query_var'          => true,
87
+               'rewrite'            => array(
88
+                    'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
89
+               ),
90
+               'capability_type'    => 'post',
91
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
92
+               'hierarchical'       => true,
93
+               'menu_position'      => null,
94
+               'supports'           => array(
95
+                    'title',
96
+                    'editor',
97
+                    'thumbnail',
98
+                    'page-attributes',
99
+                    'custom-fields',
100
+               ),
101
+          );
102
+          register_post_type( 'meal', $args );
103
+     }
104 104
 
105
-	/**
106
-	 * Register the Week taxonomy.
107
-	 */
108
-	public function taxonomy_setup() {
109
-		$labels = array(
110
-			'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
111
-			'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
112
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
113
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
114
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
115
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
116
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
117
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
118
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
119
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
120
-			'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
121
-		);
122
-		$args   = array(
123
-			'hierarchical'      => true,
124
-			'labels'            => $labels,
125
-			'show_ui'           => true,
126
-			'show_in_menu'      => 'edit.php?post_type=meal',
127
-			'show_admin_column' => true,
128
-			'query_var'         => true,
129
-			'rewrite'           => array(
130
-				'slug' => 'meal-type',
131
-			),
132
-		);
133
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
134
-	}
105
+     /**
106
+      * Register the Week taxonomy.
107
+      */
108
+     public function taxonomy_setup() {
109
+          $labels = array(
110
+               'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
111
+               'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
112
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
113
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
114
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
115
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
116
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
117
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
118
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
119
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
120
+               'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
121
+          );
122
+          $args   = array(
123
+               'hierarchical'      => true,
124
+               'labels'            => $labels,
125
+               'show_ui'           => true,
126
+               'show_in_menu'      => 'edit.php?post_type=meal',
127
+               'show_admin_column' => true,
128
+               'query_var'         => true,
129
+               'rewrite'           => array(
130
+                    'slug' => 'meal-type',
131
+               ),
132
+          );
133
+          register_taxonomy( 'meal-type', array( $this->slug ), $args );
134
+     }
135 135
 
136
-	/**
137
-	 * Adds the post type to the different arrays.
138
-	 *
139
-	 * @param array $post_types
140
-	 * @return array
141
-	 */
142
-	public function enable_post_type( $post_types = array() ) {
143
-		$post_types[] = $this->slug;
144
-		return $post_types;
145
-	}
136
+     /**
137
+      * Adds the post type to the different arrays.
138
+      *
139
+      * @param array $post_types
140
+      * @return array
141
+      */
142
+     public function enable_post_type( $post_types = array() ) {
143
+          $post_types[] = $this->slug;
144
+          return $post_types;
145
+     }
146 146
 
147
-	/**
148
-	 * Enables the Bi Directional relationships
149
-	 *
150
-	 * @param array $connections
151
-	 * @return void
152
-	 */
153
-	public function enable_connections( $connections = array() ) {
154
-		$connections['meal']['connected_plans'] = 'connected_meals';
155
-		$connections['plan']['connected_meals'] = 'connected_plans';
156
-		return $connections;
157
-	}
147
+     /**
148
+      * Enables the Bi Directional relationships
149
+      *
150
+      * @param array $connections
151
+      * @return void
152
+      */
153
+     public function enable_connections( $connections = array() ) {
154
+          $connections['meal']['connected_plans'] = 'connected_meals';
155
+          $connections['plan']['connected_meals'] = 'connected_plans';
156
+          return $connections;
157
+     }
158 158
 
159
-	/**
160
-	 * Define the metabox and field configurations.
161
-	 */
162
-	public function featured_metabox() {
163
-		$cmb = new_cmb2_box(
164
-			array(
165
-				'id'           => $this->slug . '_featured_metabox_meal',
166
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
167
-				'object_types' => array( $this->slug ), // Post type
168
-				'context'      => 'side',
169
-				'priority'     => 'high',
170
-				'show_names'   => true,
171
-			)
172
-		);
173
-		$cmb->add_field(
174
-			array(
175
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
176
-				'desc'       => __( 'Enable a featured meal' ),
177
-				'id'         => $this->slug . '_featured_meal',
178
-				'type'       => 'checkbox',
179
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
180
-			)
181
-		);
182
-	}
159
+     /**
160
+      * Define the metabox and field configurations.
161
+      */
162
+     public function featured_metabox() {
163
+          $cmb = new_cmb2_box(
164
+               array(
165
+                    'id'           => $this->slug . '_featured_metabox_meal',
166
+                    'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
167
+                    'object_types' => array( $this->slug ), // Post type
168
+                    'context'      => 'side',
169
+                    'priority'     => 'high',
170
+                    'show_names'   => true,
171
+               )
172
+          );
173
+          $cmb->add_field(
174
+               array(
175
+                    'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
176
+                    'desc'       => __( 'Enable a featured meal' ),
177
+                    'id'         => $this->slug . '_featured_meal',
178
+                    'type'       => 'checkbox',
179
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
180
+               )
181
+          );
182
+     }
183 183
 
184
-	/**
185
-	 * Define the metabox and field configurations.
186
-	 */
187
-	public function details_metaboxes() {
188
-		$cmb = new_cmb2_box( array(
189
-			'id'           => $this->slug . '_shopping_list_metabox',
190
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
191
-			'object_types' => array( $this->slug ), // Post type
192
-			'context'      => 'normal',
193
-			'priority'     => 'high',
194
-			'show_names'   => true,
195
-		) );
196
-		$cmb->add_field( array(
197
-			'name'       => __( 'Shopping List', 'lsx-health-plan' ),
198
-			'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
199
-			'id'         => $this->slug . '_shopping_list',
200
-			'type'       => 'post_search_ajax',
201
-			// Optional :
202
-			'limit'      => 1,  // Limit selection to X items only (default 1)
203
-			'sortable'   => true, // Allow selected items to be sortable (default false)
204
-			'query_args' => array(
205
-				'post_type'      => array( 'page' ),
206
-				'post_status'    => array( 'publish' ),
207
-				'posts_per_page' => -1,
208
-			),
209
-		) );
210
-		$cmb = new_cmb2_box( array(
211
-			'id'           => $this->slug . '_details_metabox',
212
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
213
-			'object_types' => array( $this->slug ), // Post type
214
-			'context'      => 'normal',
215
-			'priority'     => 'high',
216
-			'show_names'   => true,
217
-		) );
184
+     /**
185
+      * Define the metabox and field configurations.
186
+      */
187
+     public function details_metaboxes() {
188
+          $cmb = new_cmb2_box( array(
189
+               'id'           => $this->slug . '_shopping_list_metabox',
190
+               'title'        => __( 'Shopping List', 'lsx-health-plan' ),
191
+               'object_types' => array( $this->slug ), // Post type
192
+               'context'      => 'normal',
193
+               'priority'     => 'high',
194
+               'show_names'   => true,
195
+          ) );
196
+          $cmb->add_field( array(
197
+               'name'       => __( 'Shopping List', 'lsx-health-plan' ),
198
+               'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
199
+               'id'         => $this->slug . '_shopping_list',
200
+               'type'       => 'post_search_ajax',
201
+               // Optional :
202
+               'limit'      => 1,  // Limit selection to X items only (default 1)
203
+               'sortable'   => true, // Allow selected items to be sortable (default false)
204
+               'query_args' => array(
205
+                    'post_type'      => array( 'page' ),
206
+                    'post_status'    => array( 'publish' ),
207
+                    'posts_per_page' => -1,
208
+               ),
209
+          ) );
210
+          $cmb = new_cmb2_box( array(
211
+               'id'           => $this->slug . '_details_metabox',
212
+               'title'        => __( 'Meal Details', 'lsx-health-plan' ),
213
+               'object_types' => array( $this->slug ), // Post type
214
+               'context'      => 'normal',
215
+               'priority'     => 'high',
216
+               'show_names'   => true,
217
+          ) );
218 218
 
219
-		$cmb->add_field( array(
220
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
221
-			'id'   => $this->slug . '_short_description',
222
-			'type' => 'textarea_small',
223
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
224
-		) );
219
+          $cmb->add_field( array(
220
+               'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
221
+               'id'   => $this->slug . '_short_description',
222
+               'type' => 'textarea_small',
223
+               'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
224
+          ) );
225 225
 
226
-		$cmb->add_field( array(
227
-			'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
228
-			'id'         => $this->slug . '_pre_breakfast_snack',
229
-			'type'       => 'wysiwyg',
230
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
231
-			'options'    => array(
232
-				'textarea_rows' => 5,
233
-			),
234
-		) );
235
-		$cmb->add_field( array(
236
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
237
-			'id'         => $this->slug . '_breakfast',
238
-			'type'       => 'wysiwyg',
239
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
240
-			'options'    => array(
241
-				'textarea_rows' => 5,
242
-			),
243
-		) );
226
+          $cmb->add_field( array(
227
+               'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
228
+               'id'         => $this->slug . '_pre_breakfast_snack',
229
+               'type'       => 'wysiwyg',
230
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
231
+               'options'    => array(
232
+                    'textarea_rows' => 5,
233
+               ),
234
+          ) );
235
+          $cmb->add_field( array(
236
+               'name'       => __( 'Breakfast', 'lsx-health-plan' ),
237
+               'id'         => $this->slug . '_breakfast',
238
+               'type'       => 'wysiwyg',
239
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
240
+               'options'    => array(
241
+                    'textarea_rows' => 5,
242
+               ),
243
+          ) );
244 244
 
245
-		$cmb->add_field(
246
-			array(
247
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
248
-				'id'         => $this->slug . '_breakfast_snack',
249
-				'type'       => 'wysiwyg',
250
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
251
-				'options'    => array(
252
-					'textarea_rows' => 5,
253
-				),
254
-			)
255
-		);
245
+          $cmb->add_field(
246
+               array(
247
+                    'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
248
+                    'id'         => $this->slug . '_breakfast_snack',
249
+                    'type'       => 'wysiwyg',
250
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
251
+                    'options'    => array(
252
+                         'textarea_rows' => 5,
253
+                    ),
254
+               )
255
+          );
256 256
 
257
-		if ( post_type_exists( 'recipe' ) ) {
258
-			$cmb->add_field(
259
-				array(
260
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
261
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
262
-					'id'         => 'breakfast_recipes',
263
-					'type'       => 'post_search_ajax',
264
-					// Optional :
265
-					'limit'      => 15,  // Limit selection to X items only (default 1)
266
-					'sortable'   => true, // Allow selected items to be sortable (default false)
267
-					'query_args' => array(
268
-						'post_type'      => array( 'recipe' ),
269
-						'post_status'    => array( 'publish' ),
270
-						'posts_per_page' => -1,
271
-					),
272
-				)
273
-			);
274
-		}
257
+          if ( post_type_exists( 'recipe' ) ) {
258
+               $cmb->add_field(
259
+                    array(
260
+                         'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
261
+                         'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
262
+                         'id'         => 'breakfast_recipes',
263
+                         'type'       => 'post_search_ajax',
264
+                         // Optional :
265
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
266
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
267
+                         'query_args' => array(
268
+                              'post_type'      => array( 'recipe' ),
269
+                              'post_status'    => array( 'publish' ),
270
+                              'posts_per_page' => -1,
271
+                         ),
272
+                    )
273
+               );
274
+          }
275 275
 
276
-		$cmb->add_field(
277
-			array(
278
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
279
-				'id'         => $this->slug . '_pre_lunch_snack',
280
-				'type'       => 'wysiwyg',
281
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
282
-				'options'    => array(
283
-					'textarea_rows' => 5,
284
-				),
285
-			)
286
-		);
287
-		$cmb->add_field(
288
-			array(
289
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
290
-				'id'         => $this->slug . '_lunch',
291
-				'type'       => 'wysiwyg',
292
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
293
-				'options'    => array(
294
-					'textarea_rows' => 5,
295
-				),
296
-			)
297
-		);
298
-		$cmb->add_field(
299
-			array(
300
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
301
-				'id'         => $this->slug . '_lunch_snack',
302
-				'type'       => 'wysiwyg',
303
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
304
-				'options'    => array(
305
-					'textarea_rows' => 5,
306
-				),
307
-			)
308
-		);
276
+          $cmb->add_field(
277
+               array(
278
+                    'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
279
+                    'id'         => $this->slug . '_pre_lunch_snack',
280
+                    'type'       => 'wysiwyg',
281
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
282
+                    'options'    => array(
283
+                         'textarea_rows' => 5,
284
+                    ),
285
+               )
286
+          );
287
+          $cmb->add_field(
288
+               array(
289
+                    'name'       => __( 'Lunch', 'lsx-health-plan' ),
290
+                    'id'         => $this->slug . '_lunch',
291
+                    'type'       => 'wysiwyg',
292
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
293
+                    'options'    => array(
294
+                         'textarea_rows' => 5,
295
+                    ),
296
+               )
297
+          );
298
+          $cmb->add_field(
299
+               array(
300
+                    'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
301
+                    'id'         => $this->slug . '_lunch_snack',
302
+                    'type'       => 'wysiwyg',
303
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
304
+                    'options'    => array(
305
+                         'textarea_rows' => 5,
306
+                    ),
307
+               )
308
+          );
309 309
 
310
-		if ( post_type_exists( 'recipe' ) ) {
311
-			$cmb->add_field(
312
-				array(
313
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
314
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
315
-					'id'         => 'lunch_recipes',
316
-					'type'       => 'post_search_ajax',
317
-					// Optional :
318
-					'limit'      => 15,  // Limit selection to X items only (default 1)
319
-					'sortable'   => true, // Allow selected items to be sortable (default false)
320
-					'query_args' => array(
321
-						'post_type'      => array( 'recipe' ),
322
-						'post_status'    => array( 'publish' ),
323
-						'posts_per_page' => -1,
324
-					),
325
-				)
326
-			);
327
-		}
310
+          if ( post_type_exists( 'recipe' ) ) {
311
+               $cmb->add_field(
312
+                    array(
313
+                         'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
314
+                         'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
315
+                         'id'         => 'lunch_recipes',
316
+                         'type'       => 'post_search_ajax',
317
+                         // Optional :
318
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
319
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
320
+                         'query_args' => array(
321
+                              'post_type'      => array( 'recipe' ),
322
+                              'post_status'    => array( 'publish' ),
323
+                              'posts_per_page' => -1,
324
+                         ),
325
+                    )
326
+               );
327
+          }
328 328
 
329
-		$cmb->add_field(
330
-			array(
331
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
332
-				'id'         => $this->slug . '_pre_dinner_snack',
333
-				'type'       => 'wysiwyg',
334
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
335
-				'options'    => array(
336
-					'textarea_rows' => 5,
337
-				),
338
-			)
339
-		);
340
-		$cmb->add_field(
341
-			array(
342
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
343
-				'id'         => $this->slug . '_dinner',
344
-				'type'       => 'wysiwyg',
345
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
346
-				'options'    => array(
347
-					'textarea_rows' => 5,
348
-				),
349
-			)
350
-		);
351
-		$cmb->add_field(
352
-			array(
353
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
354
-				'id'         => $this->slug . '_dinner_snack',
355
-				'type'       => 'wysiwyg',
356
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
357
-				'options'    => array(
358
-					'textarea_rows' => 5,
359
-				),
360
-			)
361
-		);
329
+          $cmb->add_field(
330
+               array(
331
+                    'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
332
+                    'id'         => $this->slug . '_pre_dinner_snack',
333
+                    'type'       => 'wysiwyg',
334
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
335
+                    'options'    => array(
336
+                         'textarea_rows' => 5,
337
+                    ),
338
+               )
339
+          );
340
+          $cmb->add_field(
341
+               array(
342
+                    'name'       => __( 'Dinner', 'lsx-health-plan' ),
343
+                    'id'         => $this->slug . '_dinner',
344
+                    'type'       => 'wysiwyg',
345
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
346
+                    'options'    => array(
347
+                         'textarea_rows' => 5,
348
+                    ),
349
+               )
350
+          );
351
+          $cmb->add_field(
352
+               array(
353
+                    'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
354
+                    'id'         => $this->slug . '_dinner_snack',
355
+                    'type'       => 'wysiwyg',
356
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
357
+                    'options'    => array(
358
+                         'textarea_rows' => 5,
359
+                    ),
360
+               )
361
+          );
362 362
 
363
-		if ( post_type_exists( 'recipe' ) ) {
364
-			$cmb->add_field(
365
-				array(
366
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
367
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
368
-					'id'         => 'dinner_recipes',
369
-					'type'       => 'post_search_ajax',
370
-					// Optional :
371
-					'limit'      => 15,  // Limit selection to X items only (default 1)
372
-					'sortable'   => true, // Allow selected items to be sortable (default false)
373
-					'query_args' => array(
374
-						'post_type'      => array( 'recipe' ),
375
-						'post_status'    => array( 'publish' ),
376
-						'posts_per_page' => -1,
377
-					),
378
-				)
379
-			);
380
-		}
381
-	}
363
+          if ( post_type_exists( 'recipe' ) ) {
364
+               $cmb->add_field(
365
+                    array(
366
+                         'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
367
+                         'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
368
+                         'id'         => 'dinner_recipes',
369
+                         'type'       => 'post_search_ajax',
370
+                         // Optional :
371
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
372
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
373
+                         'query_args' => array(
374
+                              'post_type'      => array( 'recipe' ),
375
+                              'post_status'    => array( 'publish' ),
376
+                              'posts_per_page' => -1,
377
+                         ),
378
+                    )
379
+               );
380
+          }
381
+     }
382 382
 }
Please login to merge, or discard this patch.
templates/archive-meal.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 <?php lsx_content_wrap_before(); ?>
11 11
 
12 12
 <?php
13
-	$page_id  = get_the_ID();
14
-	$redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
13
+     $page_id  = get_the_ID();
14
+     $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
15 15
 ?>
16 16
 
17 17
 	<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>">
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 
21 21
 		<!-- Begining restricted content -->
22 22
 		<?php
23
-		if ( current_user_can( 'wc_memberships_view_restricted_post_content', $page_id ) ) {
24
-			?>
23
+          if ( current_user_can( 'wc_memberships_view_restricted_post_content', $page_id ) ) {
24
+               ?>
25 25
 			<main id="main" role="main">
26 26
 
27 27
 				<?php lsx_content_top(); ?>
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 					<div class="row">
31 31
 						<?php if ( have_posts() ) : ?>
32 32
 							<?php
33
-							while ( have_posts() ) :
34
-								the_post();
35
-								?>
33
+                                   while ( have_posts() ) :
34
+                                        the_post();
35
+                                        ?>
36 36
 
37 37
 								<?php include LSX_HEALTH_PLAN_PATH . '/templates/content-archive-meal.php'; ?>
38 38
 
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 			</main><!-- #main -->
52 52
 
53 53
 			<?php
54
-		} else {
55
-			wp_redirect( $redirect );
56
-			exit;
57
-		}
58
-		?>
54
+          } else {
55
+               wp_redirect( $redirect );
56
+               exit;
57
+          }
58
+          ?>
59 59
 
60 60
 <?php lsx_content_after(); ?>
61 61
 
Please login to merge, or discard this patch.
templates/content-archive-meal.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
 			<?php } ?>
23 23
 			<a href="<?php echo esc_url( get_permalink() ); ?>">
24 24
 			<?php
25
-			$featured_image = get_the_post_thumbnail();
26
-			if ( ! empty( $featured_image ) && '' !== $featured_image ) {
27
-				the_post_thumbnail( 'lsx-thumbnail-square', array(
28
-					'class' => 'aligncenter',
29
-				) );
30
-			} else {
31
-				?>
25
+               $featured_image = get_the_post_thumbnail();
26
+               if ( ! empty( $featured_image ) && '' !== $featured_image ) {
27
+                    the_post_thumbnail( 'lsx-thumbnail-square', array(
28
+                         'class' => 'aligncenter',
29
+                    ) );
30
+               } else {
31
+                    ?>
32 32
 				<img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>">
33 33
 				<?php
34
-			}
35
-			?>
34
+               }
35
+               ?>
36 36
 			</a>
37 37
 		</div>
38 38
 		<div class="content-box meal-content-box white-bg">
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 				<?php the_title( '<h3 class="meal-title">', '</h3>' ); ?>
41 41
 			</a>
42 42
 			<?php
43
-			if ( ! has_excerpt() ) {
44
-				$content = wp_trim_words( get_the_content(), 20 );
45
-				$content = '<p>' . $content . '</p>';
46
-			} else {
47
-				$content = apply_filters( 'the_excerpt', get_the_excerpt() );
48
-			}
49
-			echo wp_kses_post( $content );
50
-			?>
43
+               if ( ! has_excerpt() ) {
44
+                    $content = wp_trim_words( get_the_content(), 20 );
45
+                    $content = '<p>' . $content . '</p>';
46
+               } else {
47
+                    $content = apply_filters( 'the_excerpt', get_the_excerpt() );
48
+               }
49
+               echo wp_kses_post( $content );
50
+               ?>
51 51
 			<a href="<?php echo esc_url( get_permalink() ); ?>" class="btn border-btn"><?php esc_html_e( 'See meal', 'lsx-health-plan' ); ?></a>
52 52
 		</div>
53 53
 		<?php lsx_entry_bottom(); ?>
Please login to merge, or discard this patch.