Passed
Push — dependabot/github_actions/styf... ( 4ca7c3 )
by
unknown
10:47
created
templates/taxonomy-plan-type.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,9 +10,9 @@  discard block
 block discarded – undo
10 10
 <?php lsx_content_wrap_before(); ?>
11 11
 
12 12
 <?php
13
-	$restricted = false;
14
-	$page_id    = get_the_ID();
15
-	$redirect   = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
13
+     $restricted = false;
14
+     $page_id    = get_the_ID();
15
+     $redirect   = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id;
16 16
 ?>
17 17
 
18 18
 	<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>">
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 
22 22
 		<!-- Begining restricted content -->
23 23
 		<?php
24
-		if ( ! function_exists( 'wc_memberships_view_restricted_post_content' ) || ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) ) {
25
-			?>
24
+          if ( ! function_exists( 'wc_memberships_view_restricted_post_content' ) || ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) ) {
25
+               ?>
26 26
 			<main id="main" role="main">
27 27
 
28 28
 				<?php lsx_content_top(); ?>
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 					<div class="row">
32 32
 						<?php if ( have_posts() ) : ?>
33 33
 							<?php
34
-							while ( have_posts() ) :
35
-								the_post();
36
-								?>
34
+                                   while ( have_posts() ) :
35
+                                        the_post();
36
+                                        ?>
37 37
 
38 38
 								<?php include LSX_HEALTH_PLAN_PATH . '/templates/content-archive-plan.php'; ?>
39 39
 
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 			</main><!-- #main -->
53 53
 
54 54
 			<?php
55
-		} else {
56
-			wp_redirect( $redirect );
57
-			exit;
58
-		}
59
-		?>
55
+          } else {
56
+               wp_redirect( $redirect );
57
+               exit;
58
+          }
59
+          ?>
60 60
 
61 61
 <?php lsx_content_after(); ?>
62 62
 
Please login to merge, or discard this patch.
classes/post-types/class-meal.php 1 patch
Indentation   +444 added lines, -444 removed lines patch added patch discarded remove patch
@@ -8,477 +8,477 @@
 block discarded – undo
8 8
  */
9 9
 class Meal {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Meal()
17
-	 */
18
-	protected static $instance = null;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Meal()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Holds post_type slug used as an index
22
-	 *
23
-	 * @since 1.0.0
24
-	 *
25
-	 * @var      string
26
-	 */
27
-	public $slug = 'meal';
20
+     /**
21
+      * Holds post_type slug used as an index
22
+      *
23
+      * @since 1.0.0
24
+      *
25
+      * @var      string
26
+      */
27
+     public $slug = 'meal';
28 28
 
29
-	/**
30
-	 * Constructor
31
-	 */
32
-	public function __construct() {
33
-		add_action( 'init', array( $this, 'register_post_type' ) );
34
-		add_action( 'init', array( $this, 'taxonomy_setup' ) );
29
+     /**
30
+      * Constructor
31
+      */
32
+     public function __construct() {
33
+          add_action( 'init', array( $this, 'register_post_type' ) );
34
+          add_action( 'init', array( $this, 'taxonomy_setup' ) );
35 35
 		
36
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
36
+          add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
37
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
38
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
39 39
 
40
-		// Template Redirects.
41
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
42
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
40
+          // Template Redirects.
41
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
42
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
43 43
 
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
44
+          add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
46 46
 
47
-		//Breadcrumbs
48
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
49
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
50
-	}
47
+          //Breadcrumbs
48
+          add_filter( 'wpseo_breadcrumb_links', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
49
+          add_filter( 'woocommerce_get_breadcrumb', array( $this, 'meal_breadcrumb_filter' ), 30, 1 );
50
+     }
51 51
 
52
-	/**
53
-	 * Return an instance of this class.
54
-	 *
55
-	 * @since 1.0.0
56
-	 *
57
-	 * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
58
-	 */
59
-	public static function get_instance() {
60
-		// If the single instance hasn't been set, set it now.
61
-		if ( null === self::$instance ) {
62
-			self::$instance = new self();
63
-		}
64
-		return self::$instance;
65
-	}
66
-	/**
67
-	 * Register the post type.
68
-	 */
69
-	public function register_post_type() {
70
-		$labels = array(
71
-			'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
72
-			'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
73
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
-			'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
78
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
-			'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
84
-		);
85
-		$args   = array(
86
-			'labels'             => $labels,
87
-			'public'             => true,
88
-			'publicly_queryable' => true,
89
-			'show_ui'            => true,
90
-			'show_in_menu'       => true,
91
-			'show_in_rest'       => true,
92
-			'menu_icon'          => 'dashicons-carrot',
93
-			'query_var'          => true,
94
-			'rewrite'            => array(
95
-				'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
96
-			),
97
-			'capability_type'    => 'page',
98
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
99
-			'hierarchical'       => true,
100
-			'menu_position'      => null,
101
-			'supports'           => array(
102
-				'title',
103
-				'editor',
104
-				'thumbnail',
105
-				'page-attributes',
106
-				'custom-fields',
107
-			),
108
-		);
109
-		register_post_type( 'meal', $args );
110
-	}
52
+     /**
53
+      * Return an instance of this class.
54
+      *
55
+      * @since 1.0.0
56
+      *
57
+      * @return    object \lsx_health_plan\classes\Day()    A single instance of this class.
58
+      */
59
+     public static function get_instance() {
60
+          // If the single instance hasn't been set, set it now.
61
+          if ( null === self::$instance ) {
62
+               self::$instance = new self();
63
+          }
64
+          return self::$instance;
65
+     }
66
+     /**
67
+      * Register the post type.
68
+      */
69
+     public function register_post_type() {
70
+          $labels = array(
71
+               'name'               => esc_html__( 'Meals', 'lsx-health-plan' ),
72
+               'singular_name'      => esc_html__( 'Meal', 'lsx-health-plan' ),
73
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
+               'all_items'          => esc_html__( 'All Meals', 'lsx-health-plan' ),
78
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
+               'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
+               'menu_name'          => esc_html__( 'Meals', 'lsx-health-plan' ),
84
+          );
85
+          $args   = array(
86
+               'labels'             => $labels,
87
+               'public'             => true,
88
+               'publicly_queryable' => true,
89
+               'show_ui'            => true,
90
+               'show_in_menu'       => true,
91
+               'show_in_rest'       => true,
92
+               'menu_icon'          => 'dashicons-carrot',
93
+               'query_var'          => true,
94
+               'rewrite'            => array(
95
+                    'slug' => \lsx_health_plan\functions\get_option( 'meal_single_slug', 'meal' ),
96
+               ),
97
+               'capability_type'    => 'page',
98
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meals' ),
99
+               'hierarchical'       => true,
100
+               'menu_position'      => null,
101
+               'supports'           => array(
102
+                    'title',
103
+                    'editor',
104
+                    'thumbnail',
105
+                    'page-attributes',
106
+                    'custom-fields',
107
+               ),
108
+          );
109
+          register_post_type( 'meal', $args );
110
+     }
111 111
 
112
-	/**
113
-	 * Register the Meal Type taxonomy.
114
-	 */
115
-	public function taxonomy_setup() {
116
-		$labels = array(
117
-			'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
118
-			'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
119
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
120
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
121
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
122
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
123
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
124
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
125
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
126
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
127
-			'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
128
-		);
129
-		$args   = array(
130
-			'hierarchical'      => true,
131
-			'labels'            => $labels,
132
-			'show_ui'           => true,
133
-			'show_in_menu'      => 'edit.php?post_type=meal',
134
-			'show_admin_column' => true,
135
-			'query_var'         => true,
136
-			'rewrite'           => array(
137
-				'slug' => 'meal-type',
138
-			),
139
-		);
140
-		register_taxonomy( 'meal-type', array( $this->slug ), $args );
141
-	}
112
+     /**
113
+      * Register the Meal Type taxonomy.
114
+      */
115
+     public function taxonomy_setup() {
116
+          $labels = array(
117
+               'name'              => esc_html_x( 'Meal Type', 'taxonomy general name', 'lsx-health-plan' ),
118
+               'singular_name'     => esc_html_x( 'Meal Types', 'taxonomy singular name', 'lsx-health-plan' ),
119
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
120
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
121
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
122
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
123
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
124
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
125
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
126
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
127
+               'menu_name'         => esc_html__( 'Meal Types', 'lsx-health-plan' ),
128
+          );
129
+          $args   = array(
130
+               'hierarchical'      => true,
131
+               'labels'            => $labels,
132
+               'show_ui'           => true,
133
+               'show_in_menu'      => 'edit.php?post_type=meal',
134
+               'show_admin_column' => true,
135
+               'query_var'         => true,
136
+               'rewrite'           => array(
137
+                    'slug' => 'meal-type',
138
+               ),
139
+          );
140
+          register_taxonomy( 'meal-type', array( $this->slug ), $args );
141
+     }
142 142
 
143
-	/**
144
-	 * Adds the post type to the different arrays.
145
-	 *
146
-	 * @param array $post_types
147
-	 * @return array
148
-	 */
149
-	public function enable_post_type( $post_types = array() ) {
150
-		$post_types[] = $this->slug;
151
-		return $post_types;
152
-	}
143
+     /**
144
+      * Adds the post type to the different arrays.
145
+      *
146
+      * @param array $post_types
147
+      * @return array
148
+      */
149
+     public function enable_post_type( $post_types = array() ) {
150
+          $post_types[] = $this->slug;
151
+          return $post_types;
152
+     }
153 153
 
154
-	/**
155
-	 * Enables the Bi Directional relationships
156
-	 *
157
-	 * @param array $connections
158
-	 * @return void
159
-	 */
160
-	public function enable_connections( $connections = array() ) {
161
-		$connections['meal']['connected_plans'] = 'connected_meals';
162
-		$connections['plan']['connected_meals'] = 'connected_plans';
163
-		return $connections;
164
-	}
154
+     /**
155
+      * Enables the Bi Directional relationships
156
+      *
157
+      * @param array $connections
158
+      * @return void
159
+      */
160
+     public function enable_connections( $connections = array() ) {
161
+          $connections['meal']['connected_plans'] = 'connected_meals';
162
+          $connections['plan']['connected_meals'] = 'connected_plans';
163
+          return $connections;
164
+     }
165 165
 
166
-	/**
167
-	 * Remove the "Archives:" from the post type meal.
168
-	 *
169
-	 * @param string $title the term title.
170
-	 * @return string
171
-	 */
172
-	public function get_the_archive_title( $title ) {
173
-		if ( is_post_type_archive( 'meal' ) ) {
174
-			$title = __( 'Meals', 'lsx-health-plan' );
175
-		}
176
-		return $title;
177
-	}
166
+     /**
167
+      * Remove the "Archives:" from the post type meal.
168
+      *
169
+      * @param string $title the term title.
170
+      * @return string
171
+      */
172
+     public function get_the_archive_title( $title ) {
173
+          if ( is_post_type_archive( 'meal' ) ) {
174
+               $title = __( 'Meals', 'lsx-health-plan' );
175
+          }
176
+          return $title;
177
+     }
178 178
 
179
-	/**
180
-	 * Define the metabox and field configurations.
181
-	 */
182
-	public function featured_metabox() {
183
-		$cmb = new_cmb2_box(
184
-			array(
185
-				'id'           => $this->slug . '_featured_metabox_meal',
186
-				'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
187
-				'object_types' => array( $this->slug ), // Post type
188
-				'context'      => 'side',
189
-				'priority'     => 'high',
190
-				'show_names'   => true,
191
-			)
192
-		);
193
-		$cmb->add_field(
194
-			array(
195
-				'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
196
-				'desc'       => __( 'Enable a featured meal' ),
197
-				'id'         => $this->slug . '_featured_meal',
198
-				'type'       => 'checkbox',
199
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
200
-			)
201
-		);
202
-	}
179
+     /**
180
+      * Define the metabox and field configurations.
181
+      */
182
+     public function featured_metabox() {
183
+          $cmb = new_cmb2_box(
184
+               array(
185
+                    'id'           => $this->slug . '_featured_metabox_meal',
186
+                    'title'        => __( 'Featured Meal', 'lsx-health-plan' ),
187
+                    'object_types' => array( $this->slug ), // Post type
188
+                    'context'      => 'side',
189
+                    'priority'     => 'high',
190
+                    'show_names'   => true,
191
+               )
192
+          );
193
+          $cmb->add_field(
194
+               array(
195
+                    'name'       => __( 'Featured Meal', 'lsx-health-plan' ),
196
+                    'desc'       => __( 'Enable a featured meal' ),
197
+                    'id'         => $this->slug . '_featured_meal',
198
+                    'type'       => 'checkbox',
199
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
200
+               )
201
+          );
202
+     }
203 203
 
204
-	/**
205
-	 * Define the metabox and field configurations.
206
-	 */
207
-	public function details_metaboxes() {
208
-		$cmb = new_cmb2_box( array(
209
-			'id'           => $this->slug . '_shopping_list_metabox',
210
-			'title'        => __( 'Shopping List', 'lsx-health-plan' ),
211
-			'object_types' => array( $this->slug ), // Post type
212
-			'context'      => 'normal',
213
-			'priority'     => 'high',
214
-			'show_names'   => true,
215
-		) );
216
-		$cmb->add_field( array(
217
-			'name'       => __( 'Shopping List', 'lsx-health-plan' ),
218
-			'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
219
-			'id'         => $this->slug . '_shopping_list',
220
-			'type'       => 'post_search_ajax',
221
-			// Optional :
222
-			'limit'      => 1,  // Limit selection to X items only (default 1)
223
-			'sortable'   => true, // Allow selected items to be sortable (default false)
224
-			'query_args' => array(
225
-				'post_type'      => array( 'page' ),
226
-				'post_status'    => array( 'publish' ),
227
-				'posts_per_page' => -1,
228
-			),
229
-		) );
230
-		$cmb = new_cmb2_box( array(
231
-			'id'           => $this->slug . '_details_metabox',
232
-			'title'        => __( 'Meal Details', 'lsx-health-plan' ),
233
-			'object_types' => array( $this->slug ), // Post type
234
-			'context'      => 'normal',
235
-			'priority'     => 'high',
236
-			'show_names'   => true,
237
-		) );
204
+     /**
205
+      * Define the metabox and field configurations.
206
+      */
207
+     public function details_metaboxes() {
208
+          $cmb = new_cmb2_box( array(
209
+               'id'           => $this->slug . '_shopping_list_metabox',
210
+               'title'        => __( 'Shopping List', 'lsx-health-plan' ),
211
+               'object_types' => array( $this->slug ), // Post type
212
+               'context'      => 'normal',
213
+               'priority'     => 'high',
214
+               'show_names'   => true,
215
+          ) );
216
+          $cmb->add_field( array(
217
+               'name'       => __( 'Shopping List', 'lsx-health-plan' ),
218
+               'desc'       => __( 'Connect the shopping list page that applies to this meal by entering the name of the page in the field provided.' ),
219
+               'id'         => $this->slug . '_shopping_list',
220
+               'type'       => 'post_search_ajax',
221
+               // Optional :
222
+               'limit'      => 1,  // Limit selection to X items only (default 1)
223
+               'sortable'   => true, // Allow selected items to be sortable (default false)
224
+               'query_args' => array(
225
+                    'post_type'      => array( 'page' ),
226
+                    'post_status'    => array( 'publish' ),
227
+                    'posts_per_page' => -1,
228
+               ),
229
+          ) );
230
+          $cmb = new_cmb2_box( array(
231
+               'id'           => $this->slug . '_details_metabox',
232
+               'title'        => __( 'Meal Details', 'lsx-health-plan' ),
233
+               'object_types' => array( $this->slug ), // Post type
234
+               'context'      => 'normal',
235
+               'priority'     => 'high',
236
+               'show_names'   => true,
237
+          ) );
238 238
 
239
-		$cmb->add_field( array(
240
-			'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
241
-			'id'   => $this->slug . '_short_description',
242
-			'type' => 'textarea_small',
243
-			'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
244
-		) );
239
+          $cmb->add_field( array(
240
+               'name' => __( 'Meal Short Description', 'lsx-health-plan' ),
241
+               'id'   => $this->slug . '_short_description',
242
+               'type' => 'textarea_small',
243
+               'desc' => __( 'Add a small description for this meal (optional)', 'lsx-health-plan' ),
244
+          ) );
245 245
 
246
-		$cmb->add_field( array(
247
-			'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
248
-			'id'         => $this->slug . '_pre_breakfast_snack',
249
-			'type'       => 'wysiwyg',
250
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
251
-			'options'    => array(
252
-				'textarea_rows' => 5,
253
-			),
254
-		) );
255
-		$cmb->add_field( array(
256
-			'name'       => __( 'Breakfast', 'lsx-health-plan' ),
257
-			'id'         => $this->slug . '_breakfast',
258
-			'type'       => 'wysiwyg',
259
-			'show_on_cb' => 'cmb2_hide_if_no_cats',
260
-			'options'    => array(
261
-				'textarea_rows' => 5,
262
-			),
263
-		) );
246
+          $cmb->add_field( array(
247
+               'name'       => __( 'Pre Breakfast Snack', 'lsx-health-plan' ),
248
+               'id'         => $this->slug . '_pre_breakfast_snack',
249
+               'type'       => 'wysiwyg',
250
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
251
+               'options'    => array(
252
+                    'textarea_rows' => 5,
253
+               ),
254
+          ) );
255
+          $cmb->add_field( array(
256
+               'name'       => __( 'Breakfast', 'lsx-health-plan' ),
257
+               'id'         => $this->slug . '_breakfast',
258
+               'type'       => 'wysiwyg',
259
+               'show_on_cb' => 'cmb2_hide_if_no_cats',
260
+               'options'    => array(
261
+                    'textarea_rows' => 5,
262
+               ),
263
+          ) );
264 264
 
265
-		$cmb->add_field(
266
-			array(
267
-				'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
268
-				'id'         => $this->slug . '_breakfast_snack',
269
-				'type'       => 'wysiwyg',
270
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
271
-				'options'    => array(
272
-					'textarea_rows' => 5,
273
-				),
274
-			)
275
-		);
265
+          $cmb->add_field(
266
+               array(
267
+                    'name'       => __( 'Post Breakfast Snack', 'lsx-health-plan' ),
268
+                    'id'         => $this->slug . '_breakfast_snack',
269
+                    'type'       => 'wysiwyg',
270
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
271
+                    'options'    => array(
272
+                         'textarea_rows' => 5,
273
+                    ),
274
+               )
275
+          );
276 276
 
277
-		if ( post_type_exists( 'recipe' ) ) {
278
-			$cmb->add_field(
279
-				array(
280
-					'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
281
-					'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
282
-					'id'         => 'breakfast_recipes',
283
-					'type'       => 'post_search_ajax',
284
-					// Optional :
285
-					'limit'      => 15,  // Limit selection to X items only (default 1)
286
-					'sortable'   => true, // Allow selected items to be sortable (default false)
287
-					'query_args' => array(
288
-						'post_type'      => array( 'recipe' ),
289
-						'post_status'    => array( 'publish' ),
290
-						'posts_per_page' => -1,
291
-					),
292
-				)
293
-			);
294
-		}
277
+          if ( post_type_exists( 'recipe' ) ) {
278
+               $cmb->add_field(
279
+                    array(
280
+                         'name'       => __( 'Breakfast Recipes', 'lsx-health-plan' ),
281
+                         'desc'       => __( 'Connect additional recipes options for breakfast.', 'lsx-health-plan' ),
282
+                         'id'         => 'breakfast_recipes',
283
+                         'type'       => 'post_search_ajax',
284
+                         // Optional :
285
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
286
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
287
+                         'query_args' => array(
288
+                              'post_type'      => array( 'recipe' ),
289
+                              'post_status'    => array( 'publish' ),
290
+                              'posts_per_page' => -1,
291
+                         ),
292
+                    )
293
+               );
294
+          }
295 295
 
296
-		$cmb->add_field(
297
-			array(
298
-				'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
299
-				'id'         => $this->slug . '_pre_lunch_snack',
300
-				'type'       => 'wysiwyg',
301
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
302
-				'options'    => array(
303
-					'textarea_rows' => 5,
304
-				),
305
-			)
306
-		);
307
-		$cmb->add_field(
308
-			array(
309
-				'name'       => __( 'Lunch', 'lsx-health-plan' ),
310
-				'id'         => $this->slug . '_lunch',
311
-				'type'       => 'wysiwyg',
312
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
313
-				'options'    => array(
314
-					'textarea_rows' => 5,
315
-				),
316
-			)
317
-		);
318
-		$cmb->add_field(
319
-			array(
320
-				'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
321
-				'id'         => $this->slug . '_lunch_snack',
322
-				'type'       => 'wysiwyg',
323
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
324
-				'options'    => array(
325
-					'textarea_rows' => 5,
326
-				),
327
-			)
328
-		);
296
+          $cmb->add_field(
297
+               array(
298
+                    'name'       => __( 'Pre Lunch Snack', 'lsx-health-plan' ),
299
+                    'id'         => $this->slug . '_pre_lunch_snack',
300
+                    'type'       => 'wysiwyg',
301
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
302
+                    'options'    => array(
303
+                         'textarea_rows' => 5,
304
+                    ),
305
+               )
306
+          );
307
+          $cmb->add_field(
308
+               array(
309
+                    'name'       => __( 'Lunch', 'lsx-health-plan' ),
310
+                    'id'         => $this->slug . '_lunch',
311
+                    'type'       => 'wysiwyg',
312
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
313
+                    'options'    => array(
314
+                         'textarea_rows' => 5,
315
+                    ),
316
+               )
317
+          );
318
+          $cmb->add_field(
319
+               array(
320
+                    'name'       => __( 'Post Lunch Snack', 'lsx-health-plan' ),
321
+                    'id'         => $this->slug . '_lunch_snack',
322
+                    'type'       => 'wysiwyg',
323
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
324
+                    'options'    => array(
325
+                         'textarea_rows' => 5,
326
+                    ),
327
+               )
328
+          );
329 329
 
330
-		if ( post_type_exists( 'recipe' ) ) {
331
-			$cmb->add_field(
332
-				array(
333
-					'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
334
-					'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
335
-					'id'         => 'lunch_recipes',
336
-					'type'       => 'post_search_ajax',
337
-					// Optional :
338
-					'limit'      => 15,  // Limit selection to X items only (default 1)
339
-					'sortable'   => true, // Allow selected items to be sortable (default false)
340
-					'query_args' => array(
341
-						'post_type'      => array( 'recipe' ),
342
-						'post_status'    => array( 'publish' ),
343
-						'posts_per_page' => -1,
344
-					),
345
-				)
346
-			);
347
-		}
330
+          if ( post_type_exists( 'recipe' ) ) {
331
+               $cmb->add_field(
332
+                    array(
333
+                         'name'       => __( 'Lunch Recipes', 'lsx-health-plan' ),
334
+                         'desc'       => __( 'Connect additional recipes options for lunch.', 'lsx-health-plan' ),
335
+                         'id'         => 'lunch_recipes',
336
+                         'type'       => 'post_search_ajax',
337
+                         // Optional :
338
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
339
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
340
+                         'query_args' => array(
341
+                              'post_type'      => array( 'recipe' ),
342
+                              'post_status'    => array( 'publish' ),
343
+                              'posts_per_page' => -1,
344
+                         ),
345
+                    )
346
+               );
347
+          }
348 348
 
349
-		$cmb->add_field(
350
-			array(
351
-				'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
352
-				'id'         => $this->slug . '_pre_dinner_snack',
353
-				'type'       => 'wysiwyg',
354
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
355
-				'options'    => array(
356
-					'textarea_rows' => 5,
357
-				),
358
-			)
359
-		);
360
-		$cmb->add_field(
361
-			array(
362
-				'name'       => __( 'Dinner', 'lsx-health-plan' ),
363
-				'id'         => $this->slug . '_dinner',
364
-				'type'       => 'wysiwyg',
365
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
366
-				'options'    => array(
367
-					'textarea_rows' => 5,
368
-				),
369
-			)
370
-		);
371
-		$cmb->add_field(
372
-			array(
373
-				'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
374
-				'id'         => $this->slug . '_dinner_snack',
375
-				'type'       => 'wysiwyg',
376
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
377
-				'options'    => array(
378
-					'textarea_rows' => 5,
379
-				),
380
-			)
381
-		);
349
+          $cmb->add_field(
350
+               array(
351
+                    'name'       => __( 'Pre Dinner Snack', 'lsx-health-plan' ),
352
+                    'id'         => $this->slug . '_pre_dinner_snack',
353
+                    'type'       => 'wysiwyg',
354
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
355
+                    'options'    => array(
356
+                         'textarea_rows' => 5,
357
+                    ),
358
+               )
359
+          );
360
+          $cmb->add_field(
361
+               array(
362
+                    'name'       => __( 'Dinner', 'lsx-health-plan' ),
363
+                    'id'         => $this->slug . '_dinner',
364
+                    'type'       => 'wysiwyg',
365
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
366
+                    'options'    => array(
367
+                         'textarea_rows' => 5,
368
+                    ),
369
+               )
370
+          );
371
+          $cmb->add_field(
372
+               array(
373
+                    'name'       => __( 'Post Dinner Snack', 'lsx-health-plan' ),
374
+                    'id'         => $this->slug . '_dinner_snack',
375
+                    'type'       => 'wysiwyg',
376
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
377
+                    'options'    => array(
378
+                         'textarea_rows' => 5,
379
+                    ),
380
+               )
381
+          );
382 382
 
383
-		if ( post_type_exists( 'recipe' ) ) {
384
-			$cmb->add_field(
385
-				array(
386
-					'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
387
-					'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
388
-					'id'         => 'dinner_recipes',
389
-					'type'       => 'post_search_ajax',
390
-					// Optional :
391
-					'limit'      => 15,  // Limit selection to X items only (default 1)
392
-					'sortable'   => true, // Allow selected items to be sortable (default false)
393
-					'query_args' => array(
394
-						'post_type'      => array( 'recipe' ),
395
-						'post_status'    => array( 'publish' ),
396
-						'posts_per_page' => -1,
397
-					),
398
-				)
399
-			);
400
-		}
401
-	}
402
-	/**
403
-	 * Set the post type archive to show the parent plans only.
404
-	 *
405
-	 * @param object $wp_query
406
-	 * @return array
407
-	 */
408
-	public function set_parent_only( $wp_query ) {
409
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'meal' ) || $wp_query->is_tax( array( 'meal-type' ) ) ) ) {
410
-			$wp_query->set( 'post_parent', '0' );
411
-		}
412
-	}
383
+          if ( post_type_exists( 'recipe' ) ) {
384
+               $cmb->add_field(
385
+                    array(
386
+                         'name'       => __( 'Dinner Recipes', 'lsx-health-plan' ),
387
+                         'desc'       => __( 'Connect additional recipes options for dinner.', 'lsx-health-plan' ),
388
+                         'id'         => 'dinner_recipes',
389
+                         'type'       => 'post_search_ajax',
390
+                         // Optional :
391
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
392
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
393
+                         'query_args' => array(
394
+                              'post_type'      => array( 'recipe' ),
395
+                              'post_status'    => array( 'publish' ),
396
+                              'posts_per_page' => -1,
397
+                         ),
398
+                    )
399
+               );
400
+          }
401
+     }
402
+     /**
403
+      * Set the post type archive to show the parent plans only.
404
+      *
405
+      * @param object $wp_query
406
+      * @return array
407
+      */
408
+     public function set_parent_only( $wp_query ) {
409
+          if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'meal' ) || $wp_query->is_tax( array( 'meal-type' ) ) ) ) {
410
+               $wp_query->set( 'post_parent', '0' );
411
+          }
412
+     }
413 413
 
414 414
 
415
-	/**
416
-	 * Holds the array for the single meal breadcrumbs.
417
-	 *
418
-	 * @var array $crumbs
419
-	 * @return array
420
-	 */
421
-	public function meal_breadcrumb_filter( $crumbs ) {
422
-		$meal  = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
423
-		$meals = \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meal' );
415
+     /**
416
+      * Holds the array for the single meal breadcrumbs.
417
+      *
418
+      * @var array $crumbs
419
+      * @return array
420
+      */
421
+     public function meal_breadcrumb_filter( $crumbs ) {
422
+          $meal  = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' );
423
+          $meals = \lsx_health_plan\functions\get_option( 'endpoint_meal_archive', 'meal' );
424 424
 
425
-		if ( is_singular( 'meal' ) ) {	
426
-			$meal_name     = get_the_title();
427
-			$url           = get_post_type_archive_link( $meal );
428
-			$term_obj_list = get_the_terms( get_the_ID(), 'meal-type' );
429
-			$meal_type     = $term_obj_list[0]->name;
430
-			if ( empty( $meal_type ) ) {
431
-				$meal_type = __( 'Meal', 'lsx-health-plan' );
432
-			}
433
-			$meal_type_url = get_term_link( $term_obj_list[0]->term_id );
425
+          if ( is_singular( 'meal' ) ) {	
426
+               $meal_name     = get_the_title();
427
+               $url           = get_post_type_archive_link( $meal );
428
+               $term_obj_list = get_the_terms( get_the_ID(), 'meal-type' );
429
+               $meal_type     = $term_obj_list[0]->name;
430
+               if ( empty( $meal_type ) ) {
431
+                    $meal_type = __( 'Meal', 'lsx-health-plan' );
432
+               }
433
+               $meal_type_url = get_term_link( $term_obj_list[0]->term_id );
434 434
 
435
-			$new_crumbs    = array();
436
-			$new_crumbs[0] = $crumbs[0];
435
+               $new_crumbs    = array();
436
+               $new_crumbs[0] = $crumbs[0];
437 437
 
438
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
439
-				$new_crumbs[1] = array(
440
-					0 => $meals,
441
-					1 => $url,
442
-				);
443
-				$new_crumbs[2] = array(
444
-					0 => $meal_type,
445
-					1 => $meal_type_url,
446
-				);
447
-				$new_crumbs[3] = array(
448
-					0 => $meal_name,
449
-				);
450
-			} else {
451
-				$new_crumbs[1] = array(
452
-					'text' => $meals,
453
-					'url'  => $url,
454
-				);
455
-				$new_crumbs[2] = array(
456
-					'text' => $meal_type,
457
-					'url'  => $meal_type_url,
458
-				);
459
-				$new_crumbs[3] = array(
460
-					'text' => $meal_name,
461
-				);
462
-			}
463
-			$crumbs = $new_crumbs;
438
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
439
+                    $new_crumbs[1] = array(
440
+                         0 => $meals,
441
+                         1 => $url,
442
+                    );
443
+                    $new_crumbs[2] = array(
444
+                         0 => $meal_type,
445
+                         1 => $meal_type_url,
446
+                    );
447
+                    $new_crumbs[3] = array(
448
+                         0 => $meal_name,
449
+                    );
450
+               } else {
451
+                    $new_crumbs[1] = array(
452
+                         'text' => $meals,
453
+                         'url'  => $url,
454
+                    );
455
+                    $new_crumbs[2] = array(
456
+                         'text' => $meal_type,
457
+                         'url'  => $meal_type_url,
458
+                    );
459
+                    $new_crumbs[3] = array(
460
+                         'text' => $meal_name,
461
+                    );
462
+               }
463
+               $crumbs = $new_crumbs;
464 464
 
465
-		}
466
-		if ( is_post_type_archive( 'meal' ) ) {
465
+          }
466
+          if ( is_post_type_archive( 'meal' ) ) {
467 467
 
468
-			$new_crumbs    = array();
469
-			$new_crumbs[0] = $crumbs[0];
468
+               $new_crumbs    = array();
469
+               $new_crumbs[0] = $crumbs[0];
470 470
 
471
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
472
-				$new_crumbs[1] = array(
473
-					0 => $meals,
474
-				);
475
-			} else {
476
-				$new_crumbs[1] = array(
477
-					'text' => $meals,
478
-				);
479
-			}
480
-			$crumbs = $new_crumbs;
481
-		}
482
-		return $crumbs;
483
-	}
471
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
472
+                    $new_crumbs[1] = array(
473
+                         0 => $meals,
474
+                    );
475
+               } else {
476
+                    $new_crumbs[1] = array(
477
+                         'text' => $meals,
478
+                    );
479
+               }
480
+               $crumbs = $new_crumbs;
481
+          }
482
+          return $crumbs;
483
+     }
484 484
 }
Please login to merge, or discard this patch.
classes/post-types/class-exercise.php 1 patch
Indentation   +478 added lines, -478 removed lines patch added patch discarded remove patch
@@ -8,483 +8,483 @@
 block discarded – undo
8 8
  */
9 9
 class Exercise {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\Exercise()
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 = 'exercise';
28
-
29
-	/**
30
-	 * Constructor
31
-	 */
32
-	public function __construct() {
33
-
34
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
35
-			// Post Type and Taxonomies.
36
-			add_action( 'init', array( $this, 'register_post_type' ) );
37
-			add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) );
38
-			add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) );
39
-			add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) );
40
-			add_action( 'admin_menu', array( $this, 'register_menus' ) );
41
-
42
-			// Custom Fields.
43
-			add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 );
44
-			add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 );
45
-			add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
46
-
47
-			// Template Redirects.
48
-			add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
49
-			add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
50
-
51
-			//Breadcrumbs
52
-			add_filter( 'wpseo_breadcrumb_links', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
53
-			add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
54
-
55
-		}
56
-
57
-	}
58
-
59
-
60
-	/**
61
-	 * Return an instance of this class.
62
-	 *
63
-	 * @since 1.0.0
64
-	 *
65
-	 * @return    object \lsx_health_plan\classes\Exercise()    A single instance of this class.
66
-	 */
67
-	public static function get_instance() {
68
-		// If the single instance hasn't been set, set it now.
69
-		if ( null === self::$instance ) {
70
-			self::$instance = new self();
71
-		}
72
-		return self::$instance;
73
-	}
74
-	/**
75
-	 * Register the post type.
76
-	 */
77
-	public function register_post_type() {
78
-		$labels = array(
79
-			'name'               => esc_html__( 'Exercises', 'lsx-health-plan' ),
80
-			'singular_name'      => esc_html__( 'Exercise', 'lsx-health-plan' ),
81
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
82
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
83
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
84
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
85
-			'all_items'          => esc_html__( 'All Exercises', 'lsx-health-plan' ),
86
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
87
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
88
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
89
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
90
-			'parent_item_colon'  => '',
91
-			'menu_name'          => esc_html__( 'Exercises', 'lsx-health-plan' ),
92
-		);
93
-		$args   = array(
94
-			'labels'             => $labels,
95
-			'public'             => true,
96
-			'publicly_queryable' => true,
97
-			'show_ui'            => true,
98
-			'show_in_menu'       => 'edit.php?post_type=workout-pseudo',
99
-			'show_in_rest'       => true,
100
-			'menu_icon'          => 'dashicons-universal-access',
101
-			'query_var'          => true,
102
-			'rewrite'            => array(
103
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
104
-			),
105
-			'capability_type'    => 'page',
106
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ),
107
-			'hierarchical'       => false,
108
-			'menu_position'      => null,
109
-			'supports'           => array(
110
-				'title',
111
-				'thumbnail',
112
-				'editor',
113
-				'excerpt',
114
-				'custom-fields',
115
-			),
116
-		);
117
-		register_post_type( 'exercise', $args );
118
-	}
119
-
120
-	/**
121
-	 * Register the Exercise taxonomy.
122
-	 *
123
-	 * @return void
124
-	 */
125
-	public function exercise_type_taxonomy_setup() {
126
-		$labels = array(
127
-			'name'              => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ),
128
-			'singular_name'     => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ),
129
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
130
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
131
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
132
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
133
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
134
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
135
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
136
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
137
-			'menu_name'         => esc_html__( 'Exercise Types', 'lsx-health-plan' ),
138
-		);
139
-
140
-		$args = array(
141
-			'hierarchical'      => true,
142
-			'labels'            => $labels,
143
-			'show_ui'           => true,
144
-			'show_admin_column' => true,
145
-			'query_var'         => true,
146
-			'rewrite'           => array(
147
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ),
148
-			),
149
-			'show_in_rest'      => true,
150
-		);
151
-
152
-		register_taxonomy( 'exercise-type', array( 'exercise' ), $args );
153
-	}
154
-
155
-	/**
156
-	 * Register the Exercise taxonomy.
157
-	 *
158
-	 * @return void
159
-	 */
160
-	public function equipment_taxonomy_setup() {
161
-		$labels = array(
162
-			'name'              => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ),
163
-			'singular_name'     => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ),
164
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
165
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
166
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
167
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
168
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
169
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
170
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
171
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
172
-			'menu_name'         => esc_html__( 'Equipment', 'lsx-health-plan' ),
173
-		);
174
-
175
-		$args = array(
176
-			'hierarchical'      => true,
177
-			'labels'            => $labels,
178
-			'show_ui'           => true,
179
-			'show_admin_column' => true,
180
-			'query_var'         => true,
181
-			'rewrite'           => array(
182
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ),
183
-			),
184
-			'show_in_rest'      => true,
185
-		);
186
-
187
-		register_taxonomy( 'equipment', array( 'exercise' ), $args );
188
-	}
189
-
190
-	/**
191
-	 * Register the Muscle Group taxonomy.
192
-	 *
193
-	 * @return void
194
-	 */
195
-	public function muscle_group_taxonomy_setup() {
196
-		$labels = array(
197
-			'name'              => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ),
198
-			'singular_name'     => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ),
199
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
200
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
201
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
202
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
203
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
204
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
205
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
206
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
207
-			'menu_name'         => esc_html__( 'Muscle Groups', 'lsx-health-plan' ),
208
-		);
209
-
210
-		$args = array(
211
-			'hierarchical'      => true,
212
-			'labels'            => $labels,
213
-			'show_ui'           => true,
214
-			'show_admin_column' => true,
215
-			'query_var'         => true,
216
-			'rewrite'           => array(
217
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ),
218
-			),
219
-			'show_in_rest'      => true,
220
-		);
221
-
222
-		register_taxonomy( 'muscle-group', array( 'exercise' ), $args );
223
-	}
224
-
225
-	/**
226
-	 * Registers the Recipes under the Meals Post type menu.
227
-	 *
228
-	 * @return void
229
-	 */
230
-	public function register_menus() {
231
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' );
232
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' );
233
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' );
234
-		add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' );
235
-	}
236
-
237
-	/**
238
-	 * Adds the post type to the different arrays.
239
-	 *
240
-	 * @param array $post_types
241
-	 * @return array
242
-	 */
243
-	public function enable_post_type( $post_types = array() ) {
244
-		$post_types[] = $this->slug;
245
-		return $post_types;
246
-	}
247
-
248
-	/**
249
-	 * Enables the Bi Directional relationships
250
-	 *
251
-	 * @param array $connections
252
-	 * @return void
253
-	 */
254
-	public function enable_connections( $connections = array() ) {
255
-		$connections['exercise']['connected_workouts'] = 'connected_exercises';
256
-		$connections['workout']['connected_exercises'] = 'connected_workouts';
257
-		return $connections;
258
-	}
259
-
260
-	/**
261
-	 * Define the metabox and field configurations.
262
-	 */
263
-	public function gallery_metabox() {
264
-		$cmb = new_cmb2_box(
265
-			array(
266
-				'id'           => $this->slug . '_gallery_details_metabox',
267
-				'title'        => __( 'Exercise Gallery', 'lsx-health-plan' ),
268
-				'object_types' => array( $this->slug ),
269
-				'context'      => 'normal',
270
-				'priority'     => 'low',
271
-				'show_names'   => true,
272
-			)
273
-		);
274
-
275
-		$cmb->add_field(
276
-			array(
277
-				'name'    => __( 'Layout', 'lsx-health-plan' ),
278
-				'id'      => $this->slug . '_gallery_layout',
279
-				'type'    => 'radio',
280
-				'options' => array(
281
-					'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
282
-					'grid'   => __( 'Grid', 'lsx-health-plan' ),
283
-				),
284
-				'default' => 'grid',
285
-			)
286
-		);
287
-
288
-		$cmb->add_field(
289
-			array(
290
-				'name'    => __( 'Grid Columns', 'lsx-health-plan' ),
291
-				'id'      => $this->slug . '_gallery_columns',
292
-				'type'    => 'select',
293
-				'options' => array(
294
-					'3' => __( '2 Columns', 'lsx-health-plan' ),
295
-					'4' => __( '3 Columns', 'lsx-health-plan' ),
296
-				),
297
-				'default' => '1',
298
-			)
299
-		);
300
-
301
-		// Repeatable group.
302
-		$gallery_group = $cmb->add_field(
303
-			array(
304
-				'id'      => $this->slug . '_gallery',
305
-				'type'    => 'group',
306
-				'options' => array(
307
-					'group_title'   => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
308
-					'add_button'    => __( 'Add Item', 'lsx-health-plan' ),
309
-					'remove_button' => __( 'Remove Item', 'lsx-health-plan' ),
310
-					'sortable'      => true,
311
-				),
312
-				'desc'    => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ),
313
-				'classes' => 'lsx-admin-row',
314
-			)
315
-		);
316
-
317
-		// Title.
318
-		$cmb->add_group_field(
319
-			$gallery_group,
320
-			array(
321
-				'name'       => __( 'Image', 'lsx-health-plan' ),
322
-				'id'         => $this->slug . '_gallery_image',
323
-				'type'       => 'file',
324
-				'text'       => array(
325
-					'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
326
-				),
327
-				'desc'       => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ),
328
-				'query_args' => array(
329
-					'type' => array(
330
-						'image/gif',
331
-						'image/jpeg',
332
-						'image/png',
333
-					),
334
-				),
335
-				'preview_size' => 'lsx-thumbnail-wide',
336
-				'classes' => 'lsx-field-col lsx-field-col-80',
337
-			)
338
-		);
339
-
340
-		// Title.
341
-		$cmb->add_group_field(
342
-			$gallery_group,
343
-			array(
344
-				'name'    => __( 'oEmbed', 'lsx-health-plan' ),
345
-				'id'      => $this->slug . '_gallery_embed',
346
-				'type'    => 'text',
347
-				'desc'    => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ),
348
-				'classes' => 'test-apply-form lsx-field-col lsx-field-col-50',
349
-			)
350
-		);
351
-
352
-		$cmb->add_group_field(
353
-			$gallery_group,
354
-			array(
355
-				'name'    => __( 'External Media', 'lsx-health-plan' ),
356
-				'id'      => $this->slug . '_gallery_external',
357
-				'type'    => 'textarea_code',
358
-				'desc'    => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: &lt;iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen&gt;&lt;/iframe&gt;', 'lsx-health-plan' ),
359
-				'classes' => 'lsx-field-col lsx-field-col-50',
360
-			)
361
-		);
362
-	}
363
-
364
-	/**
365
-	 * Registers the general settings for the exercise.
366
-	 *
367
-	 * @return void
368
-	 */
369
-	public function exercise_details() {
370
-		$cmb = new_cmb2_box(
371
-			array(
372
-				'id'           => $this->slug . '_general_details_metabox',
373
-				'title'        => __( 'Details', 'lsx-health-plan' ),
374
-				'object_types' => array( $this->slug ),
375
-				'context'      => 'normal',
376
-				'priority'     => 'high',
377
-				'show_names'   => true,
378
-			)
379
-		);
380
-
381
-		$cmb->add_field(
382
-			array(
383
-				'name'    => __( 'Side', 'lsx-health-plan' ),
384
-				'id'      => $this->slug . '_side',
385
-				'type'    => 'select',
386
-				'options' => array(
387
-					''      => __( 'Select', 'lsx-health-plan' ),
388
-					'left'  => __( 'Left', 'lsx-health-plan' ),
389
-					'right' => __( 'Right', 'lsx-health-plan' ),
390
-				),
391
-				'desc'    => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ),
392
-			)
393
-		);
394
-	}
395
-
396
-	/**
397
-	 * Holds the array for the single exercise breadcrumbs.
398
-	 *
399
-	 * @var array $crumbs
400
-	 * @return array
401
-	 */
402
-	public function exercise_breadcrumb_filter( $crumbs ) {
403
-		$exercise  = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' );
404
-		$exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' );
405
-		$url       = get_post_type_archive_link( $exercise );
406
-
407
-		if ( is_singular( 'exercise' ) ) {
408
-			$exercise_name     = get_the_title();	
409
-			$term_obj_list     = get_the_terms( get_the_ID(), 'exercise-type' );
410
-			$exercise_type     = $term_obj_list[0]->name;
411
-			$exercise_type_url = get_term_link( $term_obj_list[0]->term_id );
412
-
413
-			$new_crumbs    = array();
414
-			$new_crumbs[0] = $crumbs[0];
415
-
416
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
417
-				$new_crumbs[1] = array(
418
-					0 => $exercises,
419
-					1 => $url,
420
-				);
421
-				$new_crumbs[2] = array(
422
-					0 => $exercise_type,
423
-					1 => $exercise_type_url,
424
-				);
425
-				$new_crumbs[3] = array(
426
-					0 => $exercise_name,
427
-				);
428
-			} else {
429
-				$new_crumbs[1] = array(
430
-					'text' => $exercises,
431
-					'url'  => $url,
432
-				);
433
-				$new_crumbs[2] = array(
434
-					'text' => $exercise_type,
435
-					'url'  => $exercise_type_url,
436
-				);
437
-				$new_crumbs[3] = array(
438
-					'text' => $exercise_name,
439
-				);
440
-			}
441
-			$crumbs = $new_crumbs;
11
+     /**
12
+      * Holds class instance
13
+      *
14
+      * @since 1.0.0
15
+      *
16
+      * @var      object \lsx_health_plan\classes\Exercise()
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 = 'exercise';
28
+
29
+     /**
30
+      * Constructor
31
+      */
32
+     public function __construct() {
33
+
34
+          if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
35
+               // Post Type and Taxonomies.
36
+               add_action( 'init', array( $this, 'register_post_type' ) );
37
+               add_action( 'init', array( $this, 'exercise_type_taxonomy_setup' ) );
38
+               add_action( 'init', array( $this, 'equipment_taxonomy_setup' ) );
39
+               add_action( 'init', array( $this, 'muscle_group_taxonomy_setup' ) );
40
+               add_action( 'admin_menu', array( $this, 'register_menus' ) );
41
+
42
+               // Custom Fields.
43
+               add_action( 'cmb2_admin_init', array( $this, 'exercise_details' ), 8 );
44
+               add_action( 'cmb2_admin_init', array( $this, 'gallery_metabox' ), 9 );
45
+               add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
46
+
47
+               // Template Redirects.
48
+               add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
49
+               add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
50
+
51
+               //Breadcrumbs
52
+               add_filter( 'wpseo_breadcrumb_links', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
53
+               add_filter( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
54
+
55
+          }
56
+
57
+     }
58
+
59
+
60
+     /**
61
+      * Return an instance of this class.
62
+      *
63
+      * @since 1.0.0
64
+      *
65
+      * @return    object \lsx_health_plan\classes\Exercise()    A single instance of this class.
66
+      */
67
+     public static function get_instance() {
68
+          // If the single instance hasn't been set, set it now.
69
+          if ( null === self::$instance ) {
70
+               self::$instance = new self();
71
+          }
72
+          return self::$instance;
73
+     }
74
+     /**
75
+      * Register the post type.
76
+      */
77
+     public function register_post_type() {
78
+          $labels = array(
79
+               'name'               => esc_html__( 'Exercises', 'lsx-health-plan' ),
80
+               'singular_name'      => esc_html__( 'Exercise', 'lsx-health-plan' ),
81
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
82
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
83
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
84
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
85
+               'all_items'          => esc_html__( 'All Exercises', 'lsx-health-plan' ),
86
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
87
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
88
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
89
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
90
+               'parent_item_colon'  => '',
91
+               'menu_name'          => esc_html__( 'Exercises', 'lsx-health-plan' ),
92
+          );
93
+          $args   = array(
94
+               'labels'             => $labels,
95
+               'public'             => true,
96
+               'publicly_queryable' => true,
97
+               'show_ui'            => true,
98
+               'show_in_menu'       => 'edit.php?post_type=workout-pseudo',
99
+               'show_in_rest'       => true,
100
+               'menu_icon'          => 'dashicons-universal-access',
101
+               'query_var'          => true,
102
+               'rewrite'            => array(
103
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
104
+               ),
105
+               'capability_type'    => 'page',
106
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ),
107
+               'hierarchical'       => false,
108
+               'menu_position'      => null,
109
+               'supports'           => array(
110
+                    'title',
111
+                    'thumbnail',
112
+                    'editor',
113
+                    'excerpt',
114
+                    'custom-fields',
115
+               ),
116
+          );
117
+          register_post_type( 'exercise', $args );
118
+     }
119
+
120
+     /**
121
+      * Register the Exercise taxonomy.
122
+      *
123
+      * @return void
124
+      */
125
+     public function exercise_type_taxonomy_setup() {
126
+          $labels = array(
127
+               'name'              => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ),
128
+               'singular_name'     => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ),
129
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
130
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
131
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
132
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
133
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
134
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
135
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
136
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
137
+               'menu_name'         => esc_html__( 'Exercise Types', 'lsx-health-plan' ),
138
+          );
139
+
140
+          $args = array(
141
+               'hierarchical'      => true,
142
+               'labels'            => $labels,
143
+               'show_ui'           => true,
144
+               'show_admin_column' => true,
145
+               'query_var'         => true,
146
+               'rewrite'           => array(
147
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ),
148
+               ),
149
+               'show_in_rest'      => true,
150
+          );
151
+
152
+          register_taxonomy( 'exercise-type', array( 'exercise' ), $args );
153
+     }
154
+
155
+     /**
156
+      * Register the Exercise taxonomy.
157
+      *
158
+      * @return void
159
+      */
160
+     public function equipment_taxonomy_setup() {
161
+          $labels = array(
162
+               'name'              => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ),
163
+               'singular_name'     => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ),
164
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
165
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
166
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
167
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
168
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
169
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
170
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
171
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
172
+               'menu_name'         => esc_html__( 'Equipment', 'lsx-health-plan' ),
173
+          );
174
+
175
+          $args = array(
176
+               'hierarchical'      => true,
177
+               'labels'            => $labels,
178
+               'show_ui'           => true,
179
+               'show_admin_column' => true,
180
+               'query_var'         => true,
181
+               'rewrite'           => array(
182
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ),
183
+               ),
184
+               'show_in_rest'      => true,
185
+          );
186
+
187
+          register_taxonomy( 'equipment', array( 'exercise' ), $args );
188
+     }
189
+
190
+     /**
191
+      * Register the Muscle Group taxonomy.
192
+      *
193
+      * @return void
194
+      */
195
+     public function muscle_group_taxonomy_setup() {
196
+          $labels = array(
197
+               'name'              => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ),
198
+               'singular_name'     => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ),
199
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
200
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
201
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
202
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
203
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
204
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
205
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
206
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
207
+               'menu_name'         => esc_html__( 'Muscle Groups', 'lsx-health-plan' ),
208
+          );
209
+
210
+          $args = array(
211
+               'hierarchical'      => true,
212
+               'labels'            => $labels,
213
+               'show_ui'           => true,
214
+               'show_admin_column' => true,
215
+               'query_var'         => true,
216
+               'rewrite'           => array(
217
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_musclegroup', 'muscle-group' ),
218
+               ),
219
+               'show_in_rest'      => true,
220
+          );
221
+
222
+          register_taxonomy( 'muscle-group', array( 'exercise' ), $args );
223
+     }
224
+
225
+     /**
226
+      * Registers the Recipes under the Meals Post type menu.
227
+      *
228
+      * @return void
229
+      */
230
+     public function register_menus() {
231
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercises', 'lsx-health-plan' ), esc_html__( 'Exercises', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=exercise' );
232
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Exercise Types', 'lsx-health-plan' ), esc_html__( 'Exercise Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=exercise-type&post_type=exercise' );
233
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Equipment', 'lsx-health-plan' ), esc_html__( 'Equipment', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=equipment&post_type=exercise' );
234
+          add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Muscle Groups', 'lsx-health-plan' ), esc_html__( 'Muscle Groups', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=muscle-group&post_type=exercise' );
235
+     }
236
+
237
+     /**
238
+      * Adds the post type to the different arrays.
239
+      *
240
+      * @param array $post_types
241
+      * @return array
242
+      */
243
+     public function enable_post_type( $post_types = array() ) {
244
+          $post_types[] = $this->slug;
245
+          return $post_types;
246
+     }
247
+
248
+     /**
249
+      * Enables the Bi Directional relationships
250
+      *
251
+      * @param array $connections
252
+      * @return void
253
+      */
254
+     public function enable_connections( $connections = array() ) {
255
+          $connections['exercise']['connected_workouts'] = 'connected_exercises';
256
+          $connections['workout']['connected_exercises'] = 'connected_workouts';
257
+          return $connections;
258
+     }
259
+
260
+     /**
261
+      * Define the metabox and field configurations.
262
+      */
263
+     public function gallery_metabox() {
264
+          $cmb = new_cmb2_box(
265
+               array(
266
+                    'id'           => $this->slug . '_gallery_details_metabox',
267
+                    'title'        => __( 'Exercise Gallery', 'lsx-health-plan' ),
268
+                    'object_types' => array( $this->slug ),
269
+                    'context'      => 'normal',
270
+                    'priority'     => 'low',
271
+                    'show_names'   => true,
272
+               )
273
+          );
274
+
275
+          $cmb->add_field(
276
+               array(
277
+                    'name'    => __( 'Layout', 'lsx-health-plan' ),
278
+                    'id'      => $this->slug . '_gallery_layout',
279
+                    'type'    => 'radio',
280
+                    'options' => array(
281
+                         'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
282
+                         'grid'   => __( 'Grid', 'lsx-health-plan' ),
283
+                    ),
284
+                    'default' => 'grid',
285
+               )
286
+          );
287
+
288
+          $cmb->add_field(
289
+               array(
290
+                    'name'    => __( 'Grid Columns', 'lsx-health-plan' ),
291
+                    'id'      => $this->slug . '_gallery_columns',
292
+                    'type'    => 'select',
293
+                    'options' => array(
294
+                         '3' => __( '2 Columns', 'lsx-health-plan' ),
295
+                         '4' => __( '3 Columns', 'lsx-health-plan' ),
296
+                    ),
297
+                    'default' => '1',
298
+               )
299
+          );
300
+
301
+          // Repeatable group.
302
+          $gallery_group = $cmb->add_field(
303
+               array(
304
+                    'id'      => $this->slug . '_gallery',
305
+                    'type'    => 'group',
306
+                    'options' => array(
307
+                         'group_title'   => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
308
+                         'add_button'    => __( 'Add Item', 'lsx-health-plan' ),
309
+                         'remove_button' => __( 'Remove Item', 'lsx-health-plan' ),
310
+                         'sortable'      => true,
311
+                    ),
312
+                    'desc'    => __( 'Upload only one image, video or gif per gallery group, each group will only display 1 item.', 'lsx-health-plan' ),
313
+                    'classes' => 'lsx-admin-row',
314
+               )
315
+          );
316
+
317
+          // Title.
318
+          $cmb->add_group_field(
319
+               $gallery_group,
320
+               array(
321
+                    'name'       => __( 'Image', 'lsx-health-plan' ),
322
+                    'id'         => $this->slug . '_gallery_image',
323
+                    'type'       => 'file',
324
+                    'text'       => array(
325
+                         'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
326
+                    ),
327
+                    'desc'       => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ),
328
+                    'query_args' => array(
329
+                         'type' => array(
330
+                              'image/gif',
331
+                              'image/jpeg',
332
+                              'image/png',
333
+                         ),
334
+                    ),
335
+                    'preview_size' => 'lsx-thumbnail-wide',
336
+                    'classes' => 'lsx-field-col lsx-field-col-80',
337
+               )
338
+          );
339
+
340
+          // Title.
341
+          $cmb->add_group_field(
342
+               $gallery_group,
343
+               array(
344
+                    'name'    => __( 'oEmbed', 'lsx-health-plan' ),
345
+                    'id'      => $this->slug . '_gallery_embed',
346
+                    'type'    => 'text',
347
+                    'desc'    => __( 'Drop in the embed url for your video from YouTube, Vimeo or DailyMotion, e.g: "https://www.youtube.com/watch?v=9xwazD5SyVg". A full list of supports formats can be found at <a href="https://make.wordpress.org/support/user-manual/content/media/adding-media-to-your-pages-and-posts/embedding-media-from-other-sites/">WordPress</a>', 'lsx-health-plan' ),
348
+                    'classes' => 'test-apply-form lsx-field-col lsx-field-col-50',
349
+               )
350
+          );
351
+
352
+          $cmb->add_group_field(
353
+               $gallery_group,
354
+               array(
355
+                    'name'    => __( 'External Media', 'lsx-health-plan' ),
356
+                    'id'      => $this->slug . '_gallery_external',
357
+                    'type'    => 'textarea_code',
358
+                    'desc'    => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: &lt;iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen&gt;&lt;/iframe&gt;', 'lsx-health-plan' ),
359
+                    'classes' => 'lsx-field-col lsx-field-col-50',
360
+               )
361
+          );
362
+     }
363
+
364
+     /**
365
+      * Registers the general settings for the exercise.
366
+      *
367
+      * @return void
368
+      */
369
+     public function exercise_details() {
370
+          $cmb = new_cmb2_box(
371
+               array(
372
+                    'id'           => $this->slug . '_general_details_metabox',
373
+                    'title'        => __( 'Details', 'lsx-health-plan' ),
374
+                    'object_types' => array( $this->slug ),
375
+                    'context'      => 'normal',
376
+                    'priority'     => 'high',
377
+                    'show_names'   => true,
378
+               )
379
+          );
380
+
381
+          $cmb->add_field(
382
+               array(
383
+                    'name'    => __( 'Side', 'lsx-health-plan' ),
384
+                    'id'      => $this->slug . '_side',
385
+                    'type'    => 'select',
386
+                    'options' => array(
387
+                         ''      => __( 'Select', 'lsx-health-plan' ),
388
+                         'left'  => __( 'Left', 'lsx-health-plan' ),
389
+                         'right' => __( 'Right', 'lsx-health-plan' ),
390
+                    ),
391
+                    'desc'    => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ),
392
+               )
393
+          );
394
+     }
395
+
396
+     /**
397
+      * Holds the array for the single exercise breadcrumbs.
398
+      *
399
+      * @var array $crumbs
400
+      * @return array
401
+      */
402
+     public function exercise_breadcrumb_filter( $crumbs ) {
403
+          $exercise  = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' );
404
+          $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' );
405
+          $url       = get_post_type_archive_link( $exercise );
406
+
407
+          if ( is_singular( 'exercise' ) ) {
408
+               $exercise_name     = get_the_title();	
409
+               $term_obj_list     = get_the_terms( get_the_ID(), 'exercise-type' );
410
+               $exercise_type     = $term_obj_list[0]->name;
411
+               $exercise_type_url = get_term_link( $term_obj_list[0]->term_id );
412
+
413
+               $new_crumbs    = array();
414
+               $new_crumbs[0] = $crumbs[0];
415
+
416
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
417
+                    $new_crumbs[1] = array(
418
+                         0 => $exercises,
419
+                         1 => $url,
420
+                    );
421
+                    $new_crumbs[2] = array(
422
+                         0 => $exercise_type,
423
+                         1 => $exercise_type_url,
424
+                    );
425
+                    $new_crumbs[3] = array(
426
+                         0 => $exercise_name,
427
+                    );
428
+               } else {
429
+                    $new_crumbs[1] = array(
430
+                         'text' => $exercises,
431
+                         'url'  => $url,
432
+                    );
433
+                    $new_crumbs[2] = array(
434
+                         'text' => $exercise_type,
435
+                         'url'  => $exercise_type_url,
436
+                    );
437
+                    $new_crumbs[3] = array(
438
+                         'text' => $exercise_name,
439
+                    );
440
+               }
441
+               $crumbs = $new_crumbs;
442 442
 		
443
-		}
444
-		if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) {
445
-			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
446
-
447
-			$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
448
-
449
-			$new_crumbs    = array();
450
-			$new_crumbs[0] = $crumbs[0];
451
-
452
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
453
-				$new_crumbs[1] = array(
454
-					0 => $exercises,
455
-					1 => $url,
456
-				);
457
-				$new_crumbs[2] = array(
458
-					0 => $single_term_title,
459
-				);
460
-			} else {
461
-				$new_crumbs[1] = array(
462
-					'text' => $exercises,
463
-					'url'  => $url,
464
-				);
465
-				$new_crumbs[2] = array(
466
-					'text' => $single_term_title,
467
-				);
468
-			}
469
-			$crumbs = $new_crumbs;
470
-
471
-		}
472
-		if ( is_post_type_archive( 'exercise' ) ) {
473
-
474
-			$new_crumbs    = array();
475
-			$new_crumbs[0] = $crumbs[0];
476
-
477
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
478
-				$new_crumbs[1] = array(
479
-					0 => $exercises,
480
-				);
481
-			} else {
482
-				$new_crumbs[1] = array(
483
-					'text' => $exercises,
484
-				);
485
-			}
486
-			$crumbs = $new_crumbs;
487
-		}
488
-		return $crumbs;
489
-	}
443
+          }
444
+          if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) {
445
+               $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
446
+
447
+               $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
448
+
449
+               $new_crumbs    = array();
450
+               $new_crumbs[0] = $crumbs[0];
451
+
452
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
453
+                    $new_crumbs[1] = array(
454
+                         0 => $exercises,
455
+                         1 => $url,
456
+                    );
457
+                    $new_crumbs[2] = array(
458
+                         0 => $single_term_title,
459
+                    );
460
+               } else {
461
+                    $new_crumbs[1] = array(
462
+                         'text' => $exercises,
463
+                         'url'  => $url,
464
+                    );
465
+                    $new_crumbs[2] = array(
466
+                         'text' => $single_term_title,
467
+                    );
468
+               }
469
+               $crumbs = $new_crumbs;
470
+
471
+          }
472
+          if ( is_post_type_archive( 'exercise' ) ) {
473
+
474
+               $new_crumbs    = array();
475
+               $new_crumbs[0] = $crumbs[0];
476
+
477
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
478
+                    $new_crumbs[1] = array(
479
+                         0 => $exercises,
480
+                    );
481
+               } else {
482
+                    $new_crumbs[1] = array(
483
+                         'text' => $exercises,
484
+                    );
485
+               }
486
+               $crumbs = $new_crumbs;
487
+          }
488
+          return $crumbs;
489
+     }
490 490
 }
Please login to merge, or discard this patch.
classes/post-types/class-workout.php 1 patch
Indentation   +457 added lines, -457 removed lines patch added patch discarded remove patch
@@ -10,461 +10,461 @@
 block discarded – undo
10 10
  */
11 11
 class Workout {
12 12
 
13
-	/**
14
-	 * Holds class instance
15
-	 *
16
-	 * @since 1.0.0
17
-	 *
18
-	 * @var      object \lsx_health_plan\classes\Workout()
19
-	 */
20
-	protected static $instance = null;
21
-
22
-	/**
23
-	 * Holds post_type slug used as an index
24
-	 *
25
-	 * @since 1.0.0
26
-	 *
27
-	 * @var      string
28
-	 */
29
-	public $slug = 'workout';
30
-
31
-	/**
32
-	 * Constructor
33
-	 */
34
-	public function __construct() {
35
-		add_action( 'init', array( $this, 'register_post_type' ) );
36
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
37
-		add_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) );
38
-		add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
39
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
40
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
41
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
42
-
43
-		// Template Redirects.
44
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
46
-
47
-		//Breadcrumbs
48
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
49
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
50
-	}
51
-
52
-	/**
53
-	 * Return an instance of this class.
54
-	 *
55
-	 * @since 1.0.0
56
-	 *
57
-	 * @return    object \lsx_health_plan\classes\Workout()    A single instance of this class.
58
-	 */
59
-	public static function get_instance() {
60
-		// If the single instance hasn't been set, set it now.
61
-		if ( null === self::$instance ) {
62
-			self::$instance = new self();
63
-		}
64
-		return self::$instance;
65
-	}
66
-	/**
67
-	 * Register the post type.
68
-	 */
69
-	public function register_post_type() {
70
-		$labels = array(
71
-			'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
72
-			'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
73
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
-			'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
78
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
-			'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
84
-		);
85
-		$args = array(
86
-			'labels'             => $labels,
87
-			'public'             => true,
88
-			'publicly_queryable' => true,
89
-			'show_ui'            => true,
90
-			'show_in_menu'       => true,
91
-			'show_in_rest'       => true,
92
-			'menu_icon'          => 'dashicons-universal-access',
93
-			'query_var'          => true,
94
-			'rewrite'            => array(
95
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
96
-			),
97
-			'capability_type'    => 'page',
98
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
99
-			'hierarchical'       => true,
100
-			'menu_position'      => null,
101
-			'supports'           => array(
102
-				'title',
103
-				'thumbnail',
104
-				'editor',
105
-				'excerpt',
106
-				'page-attributes',
107
-				'custom-fields',
108
-			),
109
-		);
110
-		register_post_type( 'workout', $args );
111
-	}
112
-
113
-	/**
114
-	 * Register the Type taxonomy.
115
-	 */
116
-	public function workout_type_taxonomy_setup() {
117
-		$labels = array(
118
-			'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
119
-			'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
120
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
121
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
122
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
123
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
124
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
125
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
126
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
127
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
128
-			'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
129
-		);
130
-
131
-		$args = array(
132
-			'hierarchical'      => true,
133
-			'labels'            => $labels,
134
-			'show_ui'           => true,
135
-			'show_admin_column' => true,
136
-			'query_var'         => true,
137
-			'rewrite'           => array(
138
-				'slug' => 'workout-type',
139
-			),
140
-		);
141
-
142
-		register_taxonomy( 'workout-type', array( 'workout' ), $args );
143
-	}
144
-
145
-	/**
146
-	 * Adds the post type to the different arrays.
147
-	 *
148
-	 * @param array $post_types
149
-	 * @return array
150
-	 */
151
-	public function enable_post_type( $post_types = array() ) {
152
-		$post_types[] = $this->slug;
153
-		return $post_types;
154
-	}
155
-
156
-	/**
157
-	 * Enables the Bi Directional relationships
158
-	 *
159
-	 * @param array $connections
160
-	 * @return void
161
-	 */
162
-	public function enable_connections( $connections = array() ) {
163
-		$connections['workout']['connected_plans'] = 'connected_workouts';
164
-		$connections['plan']['connected_workouts'] = 'connected_plans';
165
-
166
-		$connections['workout']['connected_videos'] = 'connected_workouts';
167
-		$connections['video']['connected_workouts'] = 'connected_videos';
168
-
169
-		$connections['workout']['connected_posts'] = 'connected_workouts';
170
-		$connections['post']['connected_workouts'] = 'connected_posts';
171
-		return $connections;
172
-	}
173
-
174
-	/**
175
-	 * Remove the "Archives:" from the post type workouts.
176
-	 *
177
-	 * @param string $title the term title.
178
-	 * @return string
179
-	 */
180
-	public function get_the_archive_title( $title ) {
181
-		if ( is_post_type_archive( 'workout' ) ) {
182
-			$title = __( 'Workouts', 'lsx-health-plan' );
183
-		}
184
-		return $title;
185
-	}
186
-
187
-	/**
188
-	 * Define the metabox and field configurations.
189
-	 */
190
-	public function featured_metabox() {
191
-		$cmb = new_cmb2_box(
192
-			array(
193
-				'id'           => $this->slug . '_featured_metabox_workout',
194
-				'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
195
-				'object_types' => array( $this->slug ), // Post type
196
-				'context'      => 'side',
197
-				'priority'     => 'high',
198
-				'show_names'   => true,
199
-			)
200
-		);
201
-		$cmb->add_field(
202
-			array(
203
-				'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
204
-				'desc'       => __( 'Enable a featured workout' ),
205
-				'id'         => $this->slug . '_featured_workout',
206
-				'type'       => 'checkbox',
207
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
208
-			)
209
-		);
210
-	}
211
-
212
-	/**
213
-	 * Define the metabox and field configurations.
214
-	 */
215
-	public function details_metaboxes() {
216
-
217
-		$cmb = new_cmb2_box( array(
218
-			'id'           => $this->slug . '_details_metabox',
219
-			'title'        => __( 'Workout Details', 'lsx-health-plan' ),
220
-			'object_types' => array( $this->slug ), // Post type
221
-			'context'      => 'normal',
222
-			'priority'     => 'high',
223
-			'show_names'   => true,
224
-		) );
225
-
226
-		$cmb->add_field( array(
227
-			'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
228
-			'id'   => $this->slug . '_short_description',
229
-			'type' => 'textarea_small',
230
-			'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
231
-		) );
232
-
233
-		$workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
234
-		if ( false !== $workout_sections && null !== $workout_sections ) {
235
-			$i = 1;
236
-			while ( $i <= $workout_sections ) {
237
-
238
-				$cmb_group = new_cmb2_box( array(
239
-					'id'           => $this->slug . '_section_' . $i . '_metabox',
240
-					'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
241
-					'object_types' => array( $this->slug ),
242
-				) );
243
-
244
-				$cmb_group->add_field( array(
245
-					'name'       => __( 'Title', 'lsx-health-plan' ),
246
-					'id'         => $this->slug . '_section_' . $i . '_title',
247
-					'type'       => 'text',
248
-					'show_on_cb' => 'cmb2_hide_if_no_cats',
249
-				) );
250
-
251
-				$cmb_group->add_field(
252
-					array(
253
-						'name'       => __( 'Description', 'lsx-health-plan' ),
254
-						'id'         => $this->slug . '_section_' . $i . '_description',
255
-						'type'       => 'wysiwyg',
256
-						'show_on_cb' => 'cmb2_hide_if_no_cats',
257
-						'options'    => array(
258
-							'textarea_rows' => 5,
259
-						),
260
-					)
261
-				);
262
-
263
-				/**
264
-				 * Repeatable Field Groups
265
-				 */
266
-				// $group_field_id is the field id string, so in this case: $prefix . 'demo'
267
-				$group_field_id = $cmb_group->add_field(
268
-					array(
269
-						'id'      => $this->slug . '_section_' . $i,
270
-						'type'    => 'group',
271
-						'options' => array(
272
-							'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
273
-							'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
274
-							'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
275
-							'sortable'      => true,
276
-							'closed'        => true, // true to have the groups closed by default
277
-						),
278
-					)
279
-				);
280
-
281
-				if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
282
-					$cmb_group->add_group_field(
283
-						$group_field_id,
284
-						array(
285
-							'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
286
-							'id'         => 'connected_exercises',
287
-							'type'       => 'post_search_ajax',
288
-							// Optional :
289
-							'limit'      => 1, // Limit selection to X items only (default 1)
290
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
291
-							'query_args' => array(
292
-								'post_type'      => array( 'exercise' ),
293
-								'post_status'    => array( 'publish' ),
294
-								'posts_per_page' => -1,
295
-							),
296
-						)
297
-					);
298
-				} else {
299
-					$cmb_group->add_group_field(
300
-						$group_field_id,
301
-						array(
302
-							'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
303
-							'id'         => 'connected_videos',
304
-							'type'       => 'post_search_ajax',
305
-							// Optional :
306
-							'limit'      => 1, // Limit selection to X items only (default 1)
307
-							'sortable'   => true,  // Allow selected items to be sortable (default false)
308
-							'query_args' => array(
309
-								'post_type'      => array( 'video' ),
310
-								'post_status'    => array( 'publish' ),
311
-								'posts_per_page' => -1,
312
-							),
313
-						)
314
-					);
315
-					$cmb_group->add_group_field(
316
-						$group_field_id,
317
-						array(
318
-							'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
319
-							'id'   => 'name',
320
-							'type' => 'text',
321
-							// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
322
-						)
323
-					);
324
-
325
-					$cmb_group->add_group_field(
326
-						$group_field_id,
327
-						array(
328
-							'name'    => __( 'Description', 'lsx-health-plan' ),
329
-							'id'      => 'description',
330
-							'type'    => 'wysiwyg',
331
-							'options' => array(
332
-								'textarea_rows' => 2,
333
-							),
334
-						)
335
-					);
336
-				}
337
-
338
-				$cmb_group->add_group_field(
339
-					$group_field_id,
340
-					array(
341
-						'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
342
-						'id'   => 'alt_title',
343
-						'type' => 'text',
344
-					)
345
-				);
346
-				$cmb_group->add_group_field(
347
-					$group_field_id,
348
-					array(
349
-						'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
350
-						'id'   => 'alt_description',
351
-						'type' => 'textarea_small',
352
-					)
353
-				);
354
-				$cmb_group->add_group_field(
355
-					$group_field_id,
356
-					array(
357
-						'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
358
-						'id'   => 'reps',
359
-						'type' => 'text',
360
-						// 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
361
-					)
362
-				);
363
-				$cmb_group->add_group_field(
364
-					$group_field_id,
365
-					array(
366
-						'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
367
-						'id'           => 'exercise_alt_thumbnail',
368
-						'type'         => 'file',
369
-						'text'         => array(
370
-							'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
371
-						),
372
-						'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
373
-						'query_args'   => array(
374
-							'type' => array(
375
-								'image/gif',
376
-								'image/jpeg',
377
-								'image/png',
378
-							),
379
-						),
380
-						'preview_size' => 'thumbnail',
381
-						'classes'      => 'lsx-field-col lsx-field-add-field  lsx-field-col-25',
382
-					)
383
-				);
384
-
385
-				$i++;
386
-			};
387
-		}
388
-	}
389
-	/**
390
-	 * Set the post type archive to show the parent plans only.
391
-	 *
392
-	 * @param object $wp_query
393
-	 * @return array
394
-	 */
395
-	public function set_parent_only( $wp_query ) {
396
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) {
397
-			$wp_query->set( 'post_parent', '0' );
398
-		}
399
-	}
400
-
401
-	/**
402
-	 * Holds the array for the single workout breadcrumbs.
403
-	 *
404
-	 * @var array $crumbs
405
-	 * @return array
406
-	 */
407
-	public function workout_breadcrumb_filter( $crumbs ) {
408
-		$workout  = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
409
-		$workouts = \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workout' );
410
-
411
-		if ( is_singular( 'workout' ) ) {	
412
-			$workout_name  = get_the_title();
413
-			$url           = get_post_type_archive_link( $workout );
414
-			$term_obj_list = get_the_terms( get_the_ID(), 'workout-type' );
415
-			$workout_type  = $term_obj_list[0]->name;
416
-			if ( empty( $workout_type ) ) {
417
-				$workout_type = __( 'Workout', 'lsx-health-plan' );
418
-			}
419
-			$workout_type_url = get_term_link( $term_obj_list[0]->term_id );
420
-
421
-			$new_crumbs    = array();
422
-			$new_crumbs[0] = $crumbs[0];
423
-
424
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
425
-				$new_crumbs[1] = array(
426
-					0 => $workouts,
427
-					1 => $url,
428
-				);
429
-				$new_crumbs[2] = array(
430
-					0 => $workout_type,
431
-					1 => $workout_type_url,
432
-				);
433
-				$new_crumbs[3] = array(
434
-					0 => $workout_name,
435
-				);
436
-			} else {
437
-				$new_crumbs[1] = array(
438
-					'text' => $workouts,
439
-					'url'  => $url,
440
-				);
441
-				$new_crumbs[2] = array(
442
-					'text' => $workout_type,
443
-					'url'  => $workout_type_url,
444
-				);
445
-				$new_crumbs[3] = array(
446
-					'text' => $workout_name,
447
-				);
448
-			}
449
-			$crumbs = $new_crumbs;
450
-
451
-		}
452
-		if ( is_post_type_archive( 'workout' ) ) {
453
-
454
-			$new_crumbs    = array();
455
-			$new_crumbs[0] = $crumbs[0];
456
-
457
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
458
-				$new_crumbs[1] = array(
459
-					0 => $workouts,
460
-				);
461
-			} else {
462
-				$new_crumbs[1] = array(
463
-					'text' => $workouts,
464
-				);
465
-			}
466
-			$crumbs = $new_crumbs;
467
-		}
468
-		return $crumbs;
469
-	}
13
+     /**
14
+      * Holds class instance
15
+      *
16
+      * @since 1.0.0
17
+      *
18
+      * @var      object \lsx_health_plan\classes\Workout()
19
+      */
20
+     protected static $instance = null;
21
+
22
+     /**
23
+      * Holds post_type slug used as an index
24
+      *
25
+      * @since 1.0.0
26
+      *
27
+      * @var      string
28
+      */
29
+     public $slug = 'workout';
30
+
31
+     /**
32
+      * Constructor
33
+      */
34
+     public function __construct() {
35
+          add_action( 'init', array( $this, 'register_post_type' ) );
36
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
37
+          add_action( 'init', array( $this, 'workout_type_taxonomy_setup' ) );
38
+          add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 );
39
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
40
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) );
41
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
42
+
43
+          // Template Redirects.
44
+          add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
45
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
46
+
47
+          //Breadcrumbs
48
+          add_filter( 'wpseo_breadcrumb_links', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
49
+          add_filter( 'woocommerce_get_breadcrumb', array( $this, 'workout_breadcrumb_filter' ), 30, 1 );
50
+     }
51
+
52
+     /**
53
+      * Return an instance of this class.
54
+      *
55
+      * @since 1.0.0
56
+      *
57
+      * @return    object \lsx_health_plan\classes\Workout()    A single instance of this class.
58
+      */
59
+     public static function get_instance() {
60
+          // If the single instance hasn't been set, set it now.
61
+          if ( null === self::$instance ) {
62
+               self::$instance = new self();
63
+          }
64
+          return self::$instance;
65
+     }
66
+     /**
67
+      * Register the post type.
68
+      */
69
+     public function register_post_type() {
70
+          $labels = array(
71
+               'name'               => esc_html__( 'Workouts', 'lsx-health-plan' ),
72
+               'singular_name'      => esc_html__( 'Workout', 'lsx-health-plan' ),
73
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
74
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
75
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
76
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
77
+               'all_items'          => esc_html__( 'All Workouts', 'lsx-health-plan' ),
78
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
79
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
80
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
81
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
82
+               'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
83
+               'menu_name'          => esc_html__( 'Workouts', 'lsx-health-plan' ),
84
+          );
85
+          $args = array(
86
+               'labels'             => $labels,
87
+               'public'             => true,
88
+               'publicly_queryable' => true,
89
+               'show_ui'            => true,
90
+               'show_in_menu'       => true,
91
+               'show_in_rest'       => true,
92
+               'menu_icon'          => 'dashicons-universal-access',
93
+               'query_var'          => true,
94
+               'rewrite'            => array(
95
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ),
96
+               ),
97
+               'capability_type'    => 'page',
98
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workouts' ),
99
+               'hierarchical'       => true,
100
+               'menu_position'      => null,
101
+               'supports'           => array(
102
+                    'title',
103
+                    'thumbnail',
104
+                    'editor',
105
+                    'excerpt',
106
+                    'page-attributes',
107
+                    'custom-fields',
108
+               ),
109
+          );
110
+          register_post_type( 'workout', $args );
111
+     }
112
+
113
+     /**
114
+      * Register the Type taxonomy.
115
+      */
116
+     public function workout_type_taxonomy_setup() {
117
+          $labels = array(
118
+               'name'              => esc_html_x( 'Workout Type', 'taxonomy general name', 'lsx-health-plan' ),
119
+               'singular_name'     => esc_html_x( 'Workout Type', 'taxonomy singular name', 'lsx-health-plan' ),
120
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
121
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
122
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
123
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
124
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
125
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
126
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
127
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
128
+               'menu_name'         => esc_html__( 'Workout Types', 'lsx-health-plan' ),
129
+          );
130
+
131
+          $args = array(
132
+               'hierarchical'      => true,
133
+               'labels'            => $labels,
134
+               'show_ui'           => true,
135
+               'show_admin_column' => true,
136
+               'query_var'         => true,
137
+               'rewrite'           => array(
138
+                    'slug' => 'workout-type',
139
+               ),
140
+          );
141
+
142
+          register_taxonomy( 'workout-type', array( 'workout' ), $args );
143
+     }
144
+
145
+     /**
146
+      * Adds the post type to the different arrays.
147
+      *
148
+      * @param array $post_types
149
+      * @return array
150
+      */
151
+     public function enable_post_type( $post_types = array() ) {
152
+          $post_types[] = $this->slug;
153
+          return $post_types;
154
+     }
155
+
156
+     /**
157
+      * Enables the Bi Directional relationships
158
+      *
159
+      * @param array $connections
160
+      * @return void
161
+      */
162
+     public function enable_connections( $connections = array() ) {
163
+          $connections['workout']['connected_plans'] = 'connected_workouts';
164
+          $connections['plan']['connected_workouts'] = 'connected_plans';
165
+
166
+          $connections['workout']['connected_videos'] = 'connected_workouts';
167
+          $connections['video']['connected_workouts'] = 'connected_videos';
168
+
169
+          $connections['workout']['connected_posts'] = 'connected_workouts';
170
+          $connections['post']['connected_workouts'] = 'connected_posts';
171
+          return $connections;
172
+     }
173
+
174
+     /**
175
+      * Remove the "Archives:" from the post type workouts.
176
+      *
177
+      * @param string $title the term title.
178
+      * @return string
179
+      */
180
+     public function get_the_archive_title( $title ) {
181
+          if ( is_post_type_archive( 'workout' ) ) {
182
+               $title = __( 'Workouts', 'lsx-health-plan' );
183
+          }
184
+          return $title;
185
+     }
186
+
187
+     /**
188
+      * Define the metabox and field configurations.
189
+      */
190
+     public function featured_metabox() {
191
+          $cmb = new_cmb2_box(
192
+               array(
193
+                    'id'           => $this->slug . '_featured_metabox_workout',
194
+                    'title'        => __( 'Featured Workout', 'lsx-health-plan' ),
195
+                    'object_types' => array( $this->slug ), // Post type
196
+                    'context'      => 'side',
197
+                    'priority'     => 'high',
198
+                    'show_names'   => true,
199
+               )
200
+          );
201
+          $cmb->add_field(
202
+               array(
203
+                    'name'       => __( 'Featured Workout', 'lsx-health-plan' ),
204
+                    'desc'       => __( 'Enable a featured workout' ),
205
+                    'id'         => $this->slug . '_featured_workout',
206
+                    'type'       => 'checkbox',
207
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
208
+               )
209
+          );
210
+     }
211
+
212
+     /**
213
+      * Define the metabox and field configurations.
214
+      */
215
+     public function details_metaboxes() {
216
+
217
+          $cmb = new_cmb2_box( array(
218
+               'id'           => $this->slug . '_details_metabox',
219
+               'title'        => __( 'Workout Details', 'lsx-health-plan' ),
220
+               'object_types' => array( $this->slug ), // Post type
221
+               'context'      => 'normal',
222
+               'priority'     => 'high',
223
+               'show_names'   => true,
224
+          ) );
225
+
226
+          $cmb->add_field( array(
227
+               'name' => __( 'Workout Short Description', 'lsx-health-plan' ),
228
+               'id'   => $this->slug . '_short_description',
229
+               'type' => 'textarea_small',
230
+               'desc' => __( 'Add a small description for this workout (optional)', 'lsx-health-plan' ),
231
+          ) );
232
+
233
+          $workout_sections = apply_filters( 'lsx_health_plan_workout_sections_amount', 6 );
234
+          if ( false !== $workout_sections && null !== $workout_sections ) {
235
+               $i = 1;
236
+               while ( $i <= $workout_sections ) {
237
+
238
+                    $cmb_group = new_cmb2_box( array(
239
+                         'id'           => $this->slug . '_section_' . $i . '_metabox',
240
+                         'title'        => esc_html__( 'Exercise Group ', 'lsx-health-plan' ) . $i,
241
+                         'object_types' => array( $this->slug ),
242
+                    ) );
243
+
244
+                    $cmb_group->add_field( array(
245
+                         'name'       => __( 'Title', 'lsx-health-plan' ),
246
+                         'id'         => $this->slug . '_section_' . $i . '_title',
247
+                         'type'       => 'text',
248
+                         'show_on_cb' => 'cmb2_hide_if_no_cats',
249
+                    ) );
250
+
251
+                    $cmb_group->add_field(
252
+                         array(
253
+                              'name'       => __( 'Description', 'lsx-health-plan' ),
254
+                              'id'         => $this->slug . '_section_' . $i . '_description',
255
+                              'type'       => 'wysiwyg',
256
+                              'show_on_cb' => 'cmb2_hide_if_no_cats',
257
+                              'options'    => array(
258
+                                   'textarea_rows' => 5,
259
+                              ),
260
+                         )
261
+                    );
262
+
263
+                    /**
264
+                     * Repeatable Field Groups
265
+                     */
266
+                    // $group_field_id is the field id string, so in this case: $prefix . 'demo'
267
+                    $group_field_id = $cmb_group->add_field(
268
+                         array(
269
+                              'id'      => $this->slug . '_section_' . $i,
270
+                              'type'    => 'group',
271
+                              'options' => array(
272
+                                   'group_title'   => esc_html__( 'Exercise {#}', 'lsx-health-plan' ), // {#} gets replaced by row number
273
+                                   'add_button'    => esc_html__( 'Add New', 'lsx-health-plan' ),
274
+                                   'remove_button' => esc_html__( 'Delete', 'lsx-health-plan' ),
275
+                                   'sortable'      => true,
276
+                                   'closed'        => true, // true to have the groups closed by default
277
+                              ),
278
+                         )
279
+                    );
280
+
281
+                    if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
282
+                         $cmb_group->add_group_field(
283
+                              $group_field_id,
284
+                              array(
285
+                                   'name'       => __( 'Exercise related to this workout', 'lsx-health-plan' ),
286
+                                   'id'         => 'connected_exercises',
287
+                                   'type'       => 'post_search_ajax',
288
+                                   // Optional :
289
+                                   'limit'      => 1, // Limit selection to X items only (default 1)
290
+                                   'sortable'   => true,  // Allow selected items to be sortable (default false)
291
+                                   'query_args' => array(
292
+                                        'post_type'      => array( 'exercise' ),
293
+                                        'post_status'    => array( 'publish' ),
294
+                                        'posts_per_page' => -1,
295
+                                   ),
296
+                              )
297
+                         );
298
+                    } else {
299
+                         $cmb_group->add_group_field(
300
+                              $group_field_id,
301
+                              array(
302
+                                   'name'       => __( 'Video related to this workout', 'lsx-health-plan' ),
303
+                                   'id'         => 'connected_videos',
304
+                                   'type'       => 'post_search_ajax',
305
+                                   // Optional :
306
+                                   'limit'      => 1, // Limit selection to X items only (default 1)
307
+                                   'sortable'   => true,  // Allow selected items to be sortable (default false)
308
+                                   'query_args' => array(
309
+                                        'post_type'      => array( 'video' ),
310
+                                        'post_status'    => array( 'publish' ),
311
+                                        'posts_per_page' => -1,
312
+                                   ),
313
+                              )
314
+                         );
315
+                         $cmb_group->add_group_field(
316
+                              $group_field_id,
317
+                              array(
318
+                                   'name' => esc_html__( 'Workout Name', 'lsx-health-plan' ),
319
+                                   'id'   => 'name',
320
+                                   'type' => 'text',
321
+                                   // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
322
+                              )
323
+                         );
324
+
325
+                         $cmb_group->add_group_field(
326
+                              $group_field_id,
327
+                              array(
328
+                                   'name'    => __( 'Description', 'lsx-health-plan' ),
329
+                                   'id'      => 'description',
330
+                                   'type'    => 'wysiwyg',
331
+                                   'options' => array(
332
+                                        'textarea_rows' => 2,
333
+                                   ),
334
+                              )
335
+                         );
336
+                    }
337
+
338
+                    $cmb_group->add_group_field(
339
+                         $group_field_id,
340
+                         array(
341
+                              'name' => esc_html__( 'Exercise title (Optional)', 'lsx-health-plan' ),
342
+                              'id'   => 'alt_title',
343
+                              'type' => 'text',
344
+                         )
345
+                    );
346
+                    $cmb_group->add_group_field(
347
+                         $group_field_id,
348
+                         array(
349
+                              'name' => esc_html__( 'Exercise Description (Optional)', 'lsx-health-plan' ),
350
+                              'id'   => 'alt_description',
351
+                              'type' => 'textarea_small',
352
+                         )
353
+                    );
354
+                    $cmb_group->add_group_field(
355
+                         $group_field_id,
356
+                         array(
357
+                              'name' => esc_html__( 'Reps / Time / Distance', 'lsx-health-plan' ),
358
+                              'id'   => 'reps',
359
+                              'type' => 'text',
360
+                              // 'repeatable' => true, // Repeatable fields are supported w/in repeatable groups (for most types)
361
+                         )
362
+                    );
363
+                    $cmb_group->add_group_field(
364
+                         $group_field_id,
365
+                         array(
366
+                              'name'         => __( 'Exercise Image (Optional)', 'lsx-health-plan' ),
367
+                              'id'           => 'exercise_alt_thumbnail',
368
+                              'type'         => 'file',
369
+                              'text'         => array(
370
+                                   'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
371
+                              ),
372
+                              'desc'         => __( 'Upload an image 300px x 300px in size.', 'lsx-health-plan' ),
373
+                              'query_args'   => array(
374
+                                   'type' => array(
375
+                                        'image/gif',
376
+                                        'image/jpeg',
377
+                                        'image/png',
378
+                                   ),
379
+                              ),
380
+                              'preview_size' => 'thumbnail',
381
+                              'classes'      => 'lsx-field-col lsx-field-add-field  lsx-field-col-25',
382
+                         )
383
+                    );
384
+
385
+                    $i++;
386
+               };
387
+          }
388
+     }
389
+     /**
390
+      * Set the post type archive to show the parent plans only.
391
+      *
392
+      * @param object $wp_query
393
+      * @return array
394
+      */
395
+     public function set_parent_only( $wp_query ) {
396
+          if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'workout' ) || $wp_query->is_tax( array( 'workout-type' ) ) ) ) {
397
+               $wp_query->set( 'post_parent', '0' );
398
+          }
399
+     }
400
+
401
+     /**
402
+      * Holds the array for the single workout breadcrumbs.
403
+      *
404
+      * @var array $crumbs
405
+      * @return array
406
+      */
407
+     public function workout_breadcrumb_filter( $crumbs ) {
408
+          $workout  = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' );
409
+          $workouts = \lsx_health_plan\functions\get_option( 'endpoint_workout_archive', 'workout' );
410
+
411
+          if ( is_singular( 'workout' ) ) {	
412
+               $workout_name  = get_the_title();
413
+               $url           = get_post_type_archive_link( $workout );
414
+               $term_obj_list = get_the_terms( get_the_ID(), 'workout-type' );
415
+               $workout_type  = $term_obj_list[0]->name;
416
+               if ( empty( $workout_type ) ) {
417
+                    $workout_type = __( 'Workout', 'lsx-health-plan' );
418
+               }
419
+               $workout_type_url = get_term_link( $term_obj_list[0]->term_id );
420
+
421
+               $new_crumbs    = array();
422
+               $new_crumbs[0] = $crumbs[0];
423
+
424
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
425
+                    $new_crumbs[1] = array(
426
+                         0 => $workouts,
427
+                         1 => $url,
428
+                    );
429
+                    $new_crumbs[2] = array(
430
+                         0 => $workout_type,
431
+                         1 => $workout_type_url,
432
+                    );
433
+                    $new_crumbs[3] = array(
434
+                         0 => $workout_name,
435
+                    );
436
+               } else {
437
+                    $new_crumbs[1] = array(
438
+                         'text' => $workouts,
439
+                         'url'  => $url,
440
+                    );
441
+                    $new_crumbs[2] = array(
442
+                         'text' => $workout_type,
443
+                         'url'  => $workout_type_url,
444
+                    );
445
+                    $new_crumbs[3] = array(
446
+                         'text' => $workout_name,
447
+                    );
448
+               }
449
+               $crumbs = $new_crumbs;
450
+
451
+          }
452
+          if ( is_post_type_archive( 'workout' ) ) {
453
+
454
+               $new_crumbs    = array();
455
+               $new_crumbs[0] = $crumbs[0];
456
+
457
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
458
+                    $new_crumbs[1] = array(
459
+                         0 => $workouts,
460
+                    );
461
+               } else {
462
+                    $new_crumbs[1] = array(
463
+                         'text' => $workouts,
464
+                    );
465
+               }
466
+               $crumbs = $new_crumbs;
467
+          }
468
+          return $crumbs;
469
+     }
470 470
 }
Please login to merge, or discard this patch.
classes/post-types/class-recipe.php 1 patch
Indentation   +491 added lines, -491 removed lines patch added patch discarded remove patch
@@ -8,251 +8,251 @@  discard block
 block discarded – undo
8 8
  */
9 9
 class Recipe {
10 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() {
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
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
-	}
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() {
73
-
74
-		// If the single instance hasn't been set, set it now.
75
-		if ( null === self::$instance ) {
76
-			self::$instance = new self();
77
-		}
78
-
79
-		return self::$instance;
80
-
81
-	}
82
-
83
-	/**
84
-	 * Register the post type.
85
-	 */
86
-	public function register_post_type() {
87
-		$this->labels = array(
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
-	}
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
-	}
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
-	}
195
-
196
-	/**
197
-	 * Adds the post type to the different arrays.
198
-	 *
199
-	 * @param array $post_types
200
-	 * @return array
201
-	 */
202
-	public function enable_post_type( $post_types = array() ) {
203
-		$post_types[] = $this->slug;
204
-		return $post_types;
205
-	}
206
-
207
-	/**
208
-	 * Enables the Bi Directional relationships
209
-	 *
210
-	 * @param array $connections
211
-	 * @return void
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
-	}
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' ) ) {
227
-			$title = __( 'Recipes', 'lsx-health-plan' );
228
-		}
229
-		if ( is_post_type_archive( 'exercise' ) ) {
230
-			$title = __( 'Exercises', 'lsx-health-plan' );
231
-		}
232
-		if ( is_tax( 'recipe-type' ) ) {
233
-			$queried_object = get_queried_object();
234
-			if ( isset( $queried_object->name ) ) {
235
-				$title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' );
236
-			}
237
-		}
238
-		return $title;
239
-	}
240
-
241
-	public function remove_archive_original_header() {
242
-		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
243
-			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
244
-		}
245
-		if ( is_singular( 'recipe' ) || is_singular( 'exercise' ) ) {
246
-			remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
247
-		}
248
-		if ( ! is_post_type_archive() ) {
249
-			add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 );
250
-		}
251
-	}
252
-
253
-	public function hp_lsx_archive_header() {
254
-		if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
255
-		?>
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() {
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
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
+     }
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() {
73
+
74
+          // If the single instance hasn't been set, set it now.
75
+          if ( null === self::$instance ) {
76
+               self::$instance = new self();
77
+          }
78
+
79
+          return self::$instance;
80
+
81
+     }
82
+
83
+     /**
84
+      * Register the post type.
85
+      */
86
+     public function register_post_type() {
87
+          $this->labels = array(
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
+     }
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
+     }
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
+     }
195
+
196
+     /**
197
+      * Adds the post type to the different arrays.
198
+      *
199
+      * @param array $post_types
200
+      * @return array
201
+      */
202
+     public function enable_post_type( $post_types = array() ) {
203
+          $post_types[] = $this->slug;
204
+          return $post_types;
205
+     }
206
+
207
+     /**
208
+      * Enables the Bi Directional relationships
209
+      *
210
+      * @param array $connections
211
+      * @return void
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
+     }
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' ) ) {
227
+               $title = __( 'Recipes', 'lsx-health-plan' );
228
+          }
229
+          if ( is_post_type_archive( 'exercise' ) ) {
230
+               $title = __( 'Exercises', 'lsx-health-plan' );
231
+          }
232
+          if ( is_tax( 'recipe-type' ) ) {
233
+               $queried_object = get_queried_object();
234
+               if ( isset( $queried_object->name ) ) {
235
+                    $title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' );
236
+               }
237
+          }
238
+          return $title;
239
+     }
240
+
241
+     public function remove_archive_original_header() {
242
+          if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
243
+               remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
244
+          }
245
+          if ( is_singular( 'recipe' ) || is_singular( 'exercise' ) ) {
246
+               remove_action( 'lsx_content_wrap_before', 'lsx_global_header' );
247
+          }
248
+          if ( ! is_post_type_archive() ) {
249
+               add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 );
250
+          }
251
+     }
252
+
253
+     public function hp_lsx_archive_header() {
254
+          if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) {
255
+          ?>
256 256
 			<div class="archive-header-wrapper banner-archive">
257 257
 				<?php lsx_global_header_inner_bottom(); ?>
258 258
 				<header class="archive-header">
@@ -265,253 +265,253 @@  discard block
 block discarded – undo
265 265
 					</h1>
266 266
 
267 267
 					<?php
268
-					lsx_health_plan_recipe_archive_description();
269
-					?>
268
+                         lsx_health_plan_recipe_archive_description();
269
+                         ?>
270 270
 				</header>
271 271
 			</div>
272 272
 		<?php
273
-		}
274
-	}
275
-
276
-	/**
277
-	 * Disables the global header description
278
-	 *
279
-	 * @param boolean $disable
280
-	 * @return boolean
281
-	 */
282
-	public function disable_global_header_description( $disable ) {
283
-		if ( is_tax( 'recipe-type' ) ) {
284
-			$disable = true;
285
-		}
286
-		return $disable;
287
-	}
288
-
289
-	/**
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' ) ) {
301
-			$recipe_name     = get_the_title();
302
-			$term_obj_list   = get_the_terms( get_the_ID(), 'recipe-type' );
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' ) ) {
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
-			}
334
-			$crumbs = $new_crumbs;
335
-		}
336
-		if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) {
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' ) ) {
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
-			}
361
-			$crumbs = $new_crumbs;
362
-		}
363
-		if ( is_post_type_archive( 'recipe' ) ) {
364
-
365
-			$new_crumbs    = array();
366
-			$new_crumbs[0] = $crumbs[0];
367
-
368
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
369
-				$new_crumbs[1] = array(
370
-					0 => $recipes,
371
-				);
372
-			} else {
373
-				$new_crumbs[1] = array(
374
-					'text' => $recipes,
375
-				);
376
-			}
377
-			$crumbs = $new_crumbs;
378
-		}
379
-		return $crumbs;
380
-	}
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
-	}
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
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
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
-	}
273
+          }
274
+     }
275
+
276
+     /**
277
+      * Disables the global header description
278
+      *
279
+      * @param boolean $disable
280
+      * @return boolean
281
+      */
282
+     public function disable_global_header_description( $disable ) {
283
+          if ( is_tax( 'recipe-type' ) ) {
284
+               $disable = true;
285
+          }
286
+          return $disable;
287
+     }
288
+
289
+     /**
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' ) ) {
301
+               $recipe_name     = get_the_title();
302
+               $term_obj_list   = get_the_terms( get_the_ID(), 'recipe-type' );
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' ) ) {
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
+               }
334
+               $crumbs = $new_crumbs;
335
+          }
336
+          if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) {
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' ) ) {
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
+               }
361
+               $crumbs = $new_crumbs;
362
+          }
363
+          if ( is_post_type_archive( 'recipe' ) ) {
364
+
365
+               $new_crumbs    = array();
366
+               $new_crumbs[0] = $crumbs[0];
367
+
368
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
369
+                    $new_crumbs[1] = array(
370
+                         0 => $recipes,
371
+                    );
372
+               } else {
373
+                    $new_crumbs[1] = array(
374
+                         'text' => $recipes,
375
+                    );
376
+               }
377
+               $crumbs = $new_crumbs;
378
+          }
379
+          return $crumbs;
380
+     }
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
+     }
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
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
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
+     }
517 517
 }
Please login to merge, or discard this patch.
classes/post-types/class-plan.php 1 patch
Indentation   +572 added lines, -572 removed lines patch added patch discarded remove patch
@@ -10,208 +10,208 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class Plan {
12 12
 
13
-	/**
14
-	 * Holds class instance
15
-	 *
16
-	 * @since 1.0.0
17
-	 *
18
-	 * @var      object \lsx_health_plan\classes\Plan()
19
-	 */
20
-	protected static $instance = null;
21
-
22
-	/**
23
-	 * Holds post_type slug used as an index
24
-	 *
25
-	 * @since 1.0.0
26
-	 *
27
-	 * @var      string
28
-	 */
29
-	public $slug = 'plan';
30
-
31
-	/**
32
-	 * Constructor
33
-	 */
34
-	public function __construct() {
35
-
36
-		add_action( 'init', array( $this, 'register_post_type' ) );
37
-		add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) );
38
-		add_action( 'init', array( $this, 'week_taxonomy_setup' ) );
39
-
40
-		// Icons for the plan types.
41
-		add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 );
42
-		add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 );
43
-		$prefix_taxonomy = 'plan-type';
44
-		add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 );
45
-
46
-		// Register the Metaboxes.
47
-		add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
48
-		add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 );
49
-		add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 );
50
-		add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 );
51
-
52
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
53
-		//add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 );
54
-
55
-		// Template Redirects.
56
-		add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
57
-		add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
58
-
59
-		// Plan Archive Actions.
60
-		add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
61
-		add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
62
-		add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 );
63
-		add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 );
64
-		add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 );
65
-
66
-		//Breadcrumbs
67
-		add_filter( 'wpseo_breadcrumb_links', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
68
-		add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
13
+     /**
14
+      * Holds class instance
15
+      *
16
+      * @since 1.0.0
17
+      *
18
+      * @var      object \lsx_health_plan\classes\Plan()
19
+      */
20
+     protected static $instance = null;
21
+
22
+     /**
23
+      * Holds post_type slug used as an index
24
+      *
25
+      * @since 1.0.0
26
+      *
27
+      * @var      string
28
+      */
29
+     public $slug = 'plan';
30
+
31
+     /**
32
+      * Constructor
33
+      */
34
+     public function __construct() {
35
+
36
+          add_action( 'init', array( $this, 'register_post_type' ) );
37
+          add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) );
38
+          add_action( 'init', array( $this, 'week_taxonomy_setup' ) );
39
+
40
+          // Icons for the plan types.
41
+          add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 );
42
+          add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 );
43
+          $prefix_taxonomy = 'plan-type';
44
+          add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 );
45
+
46
+          // Register the Metaboxes.
47
+          add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 );
48
+          add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 );
49
+          add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 );
50
+          add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 );
51
+
52
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
53
+          //add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 );
54
+
55
+          // Template Redirects.
56
+          add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 );
57
+          add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 );
58
+
59
+          // Plan Archive Actions.
60
+          add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 );
61
+          add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 );
62
+          add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 );
63
+          add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 );
64
+          add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 );
65
+
66
+          //Breadcrumbs
67
+          add_filter( 'wpseo_breadcrumb_links', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
68
+          add_filter( 'woocommerce_get_breadcrumb', array( $this, 'plan_breadcrumb_filter' ), 30, 1 );
69 69
 		
70
-	}
71
-
72
-	/**
73
-	 * Return an instance of this class.
74
-	 *
75
-	 * @since 1.0.0
76
-	 *
77
-	 * @return    object \lsx_health_plan\classes\Meal_Plan()    A single instance of this class.
78
-	 */
79
-	public static function get_instance() {
80
-		// If the single instance hasn't been set, set it now.
81
-		if ( null === self::$instance ) {
82
-			self::$instance = new self();
83
-		}
84
-		return self::$instance;
85
-	}
86
-	/**
87
-	 * Register the post type.
88
-	 */
89
-	public function register_post_type() {
90
-		$labels = array(
91
-			'name'               => esc_html__( 'Plans', 'lsx-health-plan' ),
92
-			'singular_name'      => esc_html__( 'Plan', 'lsx-health-plan' ),
93
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
94
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
95
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
96
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
97
-			'all_items'          => esc_html__( 'All Plans', 'lsx-health-plan' ),
98
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
99
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
100
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
101
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
102
-			'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
103
-			'menu_name'          => esc_html__( 'Plans', 'lsx-health-plan' ),
104
-		);
105
-		$args   = array(
106
-			'labels'             => $labels,
107
-			'public'             => true,
108
-			'publicly_queryable' => true,
109
-			'show_ui'            => true,
110
-			'show_in_menu'       => true,
111
-			'show_in_rest'       => true,
112
-			'menu_icon'          => 'dashicons-welcome-write-blog',
113
-			'query_var'          => true,
114
-			'rewrite'            => array(
115
-				'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ),
116
-			),
117
-			'capability_type'    => 'page',
118
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ),
119
-			'hierarchical'       => false,
120
-			'menu_position'      => null,
121
-			'supports'           => array(
122
-				'title',
123
-				'editor',
124
-				'thumbnail',
125
-				'page-attributes',
126
-				'custom-fields',
127
-			),
128
-		);
129
-		register_post_type( 'plan', $args );
130
-	}
131
-
132
-	/**
133
-	 * Register the Type taxonomy.
134
-	 */
135
-	public function plan_type_taxonomy_setup() {
136
-		$labels = array(
137
-			'name'              => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ),
138
-			'singular_name'     => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ),
139
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
140
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
141
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
142
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
143
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
144
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
145
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
146
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
147
-			'menu_name'         => esc_html__( 'Plan Types', 'lsx-health-plan' ),
148
-		);
149
-
150
-		$args = array(
151
-			'hierarchical'      => true,
152
-			'labels'            => $labels,
153
-			'show_ui'           => true,
154
-			'show_admin_column' => true,
155
-			'query_var'         => true,
156
-			'rewrite'           => array(
157
-				'slug' => 'plan-type',
158
-			),
159
-		);
160
-
161
-		register_taxonomy( 'plan-type', array( 'plan' ), $args );
162
-	}
163
-
164
-	/**
165
-	 * Register the Week taxonomy.
166
-	 */
167
-	public function week_taxonomy_setup() {
168
-		$labels = array(
169
-			'name'              => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ),
170
-			'singular_name'     => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ),
171
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
172
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
173
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
174
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
175
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
176
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
177
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
178
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
179
-			'menu_name'         => esc_html__( 'Weeks', 'lsx-health-plan' ),
180
-		);
181
-
182
-		$args = array(
183
-			'hierarchical'      => true,
184
-			'labels'            => $labels,
185
-			'show_ui'           => true,
186
-			'show_admin_column' => true,
187
-			'query_var'         => true,
188
-			'show_in_rest'      => true,
189
-			'rewrite'           => array(
190
-				'slug' => 'week',
191
-			),
192
-		);
193
-
194
-		register_taxonomy( 'week', array( 'plan' ), $args );
195
-	}
196
-
197
-	/**
198
-	 * Output the form field for this metadata when adding a new term
199
-	 *
200
-	 * @since 0.1.0
201
-	 */
202
-	public function add_thumbnail_form_field( $term = false ) {
203
-		if ( is_object( $term ) ) {
204
-			$value         = get_term_meta( $term->term_id, 'thumbnail', true );
205
-			$image_preview = wp_get_attachment_image_src( $value, 'thumbnail' );
206
-
207
-			if ( is_array( $image_preview ) ) {
208
-				$image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
209
-			}
210
-		} else {
211
-			$image_preview = false;
212
-			$value         = false;
213
-		}
214
-		?>
70
+     }
71
+
72
+     /**
73
+      * Return an instance of this class.
74
+      *
75
+      * @since 1.0.0
76
+      *
77
+      * @return    object \lsx_health_plan\classes\Meal_Plan()    A single instance of this class.
78
+      */
79
+     public static function get_instance() {
80
+          // If the single instance hasn't been set, set it now.
81
+          if ( null === self::$instance ) {
82
+               self::$instance = new self();
83
+          }
84
+          return self::$instance;
85
+     }
86
+     /**
87
+      * Register the post type.
88
+      */
89
+     public function register_post_type() {
90
+          $labels = array(
91
+               'name'               => esc_html__( 'Plans', 'lsx-health-plan' ),
92
+               'singular_name'      => esc_html__( 'Plan', 'lsx-health-plan' ),
93
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
94
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
95
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
96
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
97
+               'all_items'          => esc_html__( 'All Plans', 'lsx-health-plan' ),
98
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
99
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
100
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
101
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
102
+               'parent_item_colon'  => esc_html__( 'Parent:', 'lsx-health-plan' ),
103
+               'menu_name'          => esc_html__( 'Plans', 'lsx-health-plan' ),
104
+          );
105
+          $args   = array(
106
+               'labels'             => $labels,
107
+               'public'             => true,
108
+               'publicly_queryable' => true,
109
+               'show_ui'            => true,
110
+               'show_in_menu'       => true,
111
+               'show_in_rest'       => true,
112
+               'menu_icon'          => 'dashicons-welcome-write-blog',
113
+               'query_var'          => true,
114
+               'rewrite'            => array(
115
+                    'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ),
116
+               ),
117
+               'capability_type'    => 'page',
118
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ),
119
+               'hierarchical'       => false,
120
+               'menu_position'      => null,
121
+               'supports'           => array(
122
+                    'title',
123
+                    'editor',
124
+                    'thumbnail',
125
+                    'page-attributes',
126
+                    'custom-fields',
127
+               ),
128
+          );
129
+          register_post_type( 'plan', $args );
130
+     }
131
+
132
+     /**
133
+      * Register the Type taxonomy.
134
+      */
135
+     public function plan_type_taxonomy_setup() {
136
+          $labels = array(
137
+               'name'              => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ),
138
+               'singular_name'     => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ),
139
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
140
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
141
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
142
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
143
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
144
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
145
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
146
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
147
+               'menu_name'         => esc_html__( 'Plan Types', 'lsx-health-plan' ),
148
+          );
149
+
150
+          $args = array(
151
+               'hierarchical'      => true,
152
+               'labels'            => $labels,
153
+               'show_ui'           => true,
154
+               'show_admin_column' => true,
155
+               'query_var'         => true,
156
+               'rewrite'           => array(
157
+                    'slug' => 'plan-type',
158
+               ),
159
+          );
160
+
161
+          register_taxonomy( 'plan-type', array( 'plan' ), $args );
162
+     }
163
+
164
+     /**
165
+      * Register the Week taxonomy.
166
+      */
167
+     public function week_taxonomy_setup() {
168
+          $labels = array(
169
+               'name'              => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ),
170
+               'singular_name'     => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ),
171
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
172
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
173
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
174
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
175
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
176
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
177
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
178
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
179
+               'menu_name'         => esc_html__( 'Weeks', 'lsx-health-plan' ),
180
+          );
181
+
182
+          $args = array(
183
+               'hierarchical'      => true,
184
+               'labels'            => $labels,
185
+               'show_ui'           => true,
186
+               'show_admin_column' => true,
187
+               'query_var'         => true,
188
+               'show_in_rest'      => true,
189
+               'rewrite'           => array(
190
+                    'slug' => 'week',
191
+               ),
192
+          );
193
+
194
+          register_taxonomy( 'week', array( 'plan' ), $args );
195
+     }
196
+
197
+     /**
198
+      * Output the form field for this metadata when adding a new term
199
+      *
200
+      * @since 0.1.0
201
+      */
202
+     public function add_thumbnail_form_field( $term = false ) {
203
+          if ( is_object( $term ) ) {
204
+               $value         = get_term_meta( $term->term_id, 'thumbnail', true );
205
+               $image_preview = wp_get_attachment_image_src( $value, 'thumbnail' );
206
+
207
+               if ( is_array( $image_preview ) ) {
208
+                    $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />';
209
+               }
210
+          } else {
211
+               $image_preview = false;
212
+               $value         = false;
213
+          }
214
+          ?>
215 215
 		<tr class="form-field form-required term-thumbnail-wrap">
216 216
 			<th scope="row"><label for="thumbnail"><?php esc_html_e( 'Icon Image', 'lsx-health-plan' ); ?></label></th>
217 217
 			<td>
@@ -225,379 +225,379 @@  discard block
 block discarded – undo
225 225
 			</td>
226 226
 		</tr>
227 227
 		<?php
228
-	}
229
-
230
-	/**
231
-	 * Saves the Taxonomy term icon image
232
-	 *
233
-	 * @since 0.1.0
234
-	 *
235
-	 * @param  int    $term_id
236
-	 * @param  string $taxonomy
237
-	 */
238
-	public function save_meta( $term_id = 0, $taxonomy = '' ) {
239
-		if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
240
-			return;
241
-		}
242
-
243
-		if ( ! isset( $_POST['thumbnail'] ) ) {
244
-			return;
245
-		}
246
-
247
-		if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) {
248
-			if ( ! isset( $_POST['thumbnail'] ) ) {
249
-				return;
250
-			}
251
-
252
-			$thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] );
253
-			$thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : '';
254
-
255
-			if ( empty( $thumbnail_meta ) ) {
256
-				delete_term_meta( $term_id, 'thumbnail' );
257
-			} else {
258
-				update_term_meta( $term_id, 'thumbnail', $thumbnail_meta );
259
-			}
260
-		}
261
-	}
262
-
263
-	/**
264
-	 * Define the metabox and field configurations.
265
-	 */
266
-	public function details_metaboxes() {
267
-		$cmb = new_cmb2_box( array(
268
-			'id'           => $this->slug . '_details_metabox',
269
-			'title'        => __( 'Details', 'lsx-health-plan' ),
270
-			'object_types' => array( $this->slug ), // Post type
271
-			'context'      => 'normal',
272
-			'priority'     => 'high',
273
-			'show_names'   => true,
274
-		) );
275
-
276
-		$cmb->add_field( array(
277
-			'name' => __( 'Plan Short Description', 'lsx-health-plan' ),
278
-			'id'   => $this->slug . '_short_description',
279
-			'type' => 'textarea_small',
280
-			'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ),
281
-		) );
282
-
283
-		$warmup_type = 'page';
284
-		if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
285
-			$warmup_type = array( 'page', 'workout' );
286
-		}
287
-		$cmb->add_field( array(
288
-			'name'       => __( 'Warmup', 'lsx-health-plan' ),
289
-			'desc'       => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ),
290
-			'id'         => $this->slug . '_warmup',
291
-			'type'       => 'post_search_ajax',
292
-			// Optional :
293
-			'limit'      => 3,  // Limit selection to X items only (default 1)
294
-			'sortable'   => true, // Allow selected items to be sortable (default false)
295
-			'query_args' => array(
296
-				'post_type'      => $warmup_type,
297
-				'post_status'    => array( 'publish' ),
298
-				'posts_per_page' => -1,
299
-			),
300
-		) );
301
-	}
302
-
303
-	/**
304
-	 * Adds the post type to the different arrays.
305
-	 *
306
-	 * @param array $post_types
307
-	 * @return array
308
-	 */
309
-	public function enable_post_type( $post_types = array() ) {
310
-		$post_types[] = $this->slug;
311
-		return $post_types;
312
-	}
313
-
314
-	/**
315
-	 * Registers the workout connections on the plan post type.
316
-	 *
317
-	 * @return void
318
-	 */
319
-	public function plan_connections() {
320
-		$cmb = new_cmb2_box(
321
-			array(
322
-				'id'           => $this->slug . '_connections_metabox',
323
-				'title'        => __( 'Plans', 'lsx-health-plan' ),
324
-				'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ),
325
-				'context'      => 'normal',
326
-				'priority'     => 'high',
327
-				'show_names'   => true,
328
-			)
329
-		);
330
-		$cmb->add_field(
331
-			array(
332
-				'name'       => __( 'Plan', 'lsx-health-plan' ),
333
-				'id'         => 'connected_plans',
334
-				'desc'       => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ),
335
-				'type'       => 'post_search_ajax',
336
-				'limit'      => 15,
337
-				'sortable'   => true,
338
-				'query_args' => array(
339
-					'post_type'      => array( 'plan' ),
340
-					'post_status'    => array( 'publish' ),
341
-					'posts_per_page' => -1,
342
-				),
343
-			)
344
-		);
345
-	}
346
-
347
-	/**
348
-	 * Remove the "Archives:" from the post type.
349
-	 *
350
-	 * @param string $title the term title.
351
-	 * @return string
352
-	 */
353
-	public function get_the_archive_title( $title ) {
354
-		if ( is_post_type_archive( 'plan' ) ) {
355
-			$title = __( 'Our health plans', 'lsx-health-plan' );
356
-		}
357
-		return $title;
358
-	}
359
-
360
-	/**
361
-	 * Set the post type archive to show the parent plans only.
362
-	 *
363
-	 * @param object $wp_query
364
-	 * @return array
365
-	 */
366
-	public function set_parent_only( $wp_query ) {
367
-		if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) {
368
-			$wp_query->set( 'post_parent', '0' );
369
-		}
370
-	}
371
-
372
-	/**
373
-	 * Define the metabox and field configurations.
374
-	 */
375
-	public function featured_metabox() {
376
-		$cmb = new_cmb2_box(
377
-			array(
378
-				'id'           => $this->slug . '_featured_metabox_plan',
379
-				'title'        => __( 'Featured Plan', 'lsx-health-plan' ),
380
-				'object_types' => array( $this->slug ), // Post type
381
-				'context'      => 'side',
382
-				'priority'     => 'high',
383
-				'show_names'   => true,
384
-			)
385
-		);
386
-		$cmb->add_field(
387
-			array(
388
-				'name'       => __( 'Featured Plan', 'lsx-health-plan' ),
389
-				'desc'       => __( 'Enable a featured plan' ),
390
-				'id'         => $this->slug . '_featured_plan',
391
-				'type'       => 'checkbox',
392
-				'show_on_cb' => 'cmb2_hide_if_no_cats',
393
-			)
394
-		);
395
-	}
396
-
397
-	/**
398
-	 * Define the metabox and field configurations.
399
-	 */
400
-	public function sections_metabox_loop() {
401
-		$cmb = new_cmb2_box(
402
-			array(
403
-				'id'           => $this->slug . '_sections_metabox',
404
-				'title'        => __( 'Sections', 'lsx-health-plan' ),
405
-				'object_types' => array( $this->slug ), // Post type.
406
-				'context'      => 'normal',
407
-				'priority'     => 'low',
408
-				'show_names'   => true,
409
-			)
410
-		);
411
-
412
-		/*
228
+     }
229
+
230
+     /**
231
+      * Saves the Taxonomy term icon image
232
+      *
233
+      * @since 0.1.0
234
+      *
235
+      * @param  int    $term_id
236
+      * @param  string $taxonomy
237
+      */
238
+     public function save_meta( $term_id = 0, $taxonomy = '' ) {
239
+          if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
240
+               return;
241
+          }
242
+
243
+          if ( ! isset( $_POST['thumbnail'] ) ) {
244
+               return;
245
+          }
246
+
247
+          if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) {
248
+               if ( ! isset( $_POST['thumbnail'] ) ) {
249
+                    return;
250
+               }
251
+
252
+               $thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] );
253
+               $thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : '';
254
+
255
+               if ( empty( $thumbnail_meta ) ) {
256
+                    delete_term_meta( $term_id, 'thumbnail' );
257
+               } else {
258
+                    update_term_meta( $term_id, 'thumbnail', $thumbnail_meta );
259
+               }
260
+          }
261
+     }
262
+
263
+     /**
264
+      * Define the metabox and field configurations.
265
+      */
266
+     public function details_metaboxes() {
267
+          $cmb = new_cmb2_box( array(
268
+               'id'           => $this->slug . '_details_metabox',
269
+               'title'        => __( 'Details', 'lsx-health-plan' ),
270
+               'object_types' => array( $this->slug ), // Post type
271
+               'context'      => 'normal',
272
+               'priority'     => 'high',
273
+               'show_names'   => true,
274
+          ) );
275
+
276
+          $cmb->add_field( array(
277
+               'name' => __( 'Plan Short Description', 'lsx-health-plan' ),
278
+               'id'   => $this->slug . '_short_description',
279
+               'type' => 'textarea_small',
280
+               'desc' => __( 'Add a small description for this plan (optional)', 'lsx-health-plan' ),
281
+          ) );
282
+
283
+          $warmup_type = 'page';
284
+          if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) {
285
+               $warmup_type = array( 'page', 'workout' );
286
+          }
287
+          $cmb->add_field( array(
288
+               'name'       => __( 'Warmup', 'lsx-health-plan' ),
289
+               'desc'       => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ),
290
+               'id'         => $this->slug . '_warmup',
291
+               'type'       => 'post_search_ajax',
292
+               // Optional :
293
+               'limit'      => 3,  // Limit selection to X items only (default 1)
294
+               'sortable'   => true, // Allow selected items to be sortable (default false)
295
+               'query_args' => array(
296
+                    'post_type'      => $warmup_type,
297
+                    'post_status'    => array( 'publish' ),
298
+                    'posts_per_page' => -1,
299
+               ),
300
+          ) );
301
+     }
302
+
303
+     /**
304
+      * Adds the post type to the different arrays.
305
+      *
306
+      * @param array $post_types
307
+      * @return array
308
+      */
309
+     public function enable_post_type( $post_types = array() ) {
310
+          $post_types[] = $this->slug;
311
+          return $post_types;
312
+     }
313
+
314
+     /**
315
+      * Registers the workout connections on the plan post type.
316
+      *
317
+      * @return void
318
+      */
319
+     public function plan_connections() {
320
+          $cmb = new_cmb2_box(
321
+               array(
322
+                    'id'           => $this->slug . '_connections_metabox',
323
+                    'title'        => __( 'Plans', 'lsx-health-plan' ),
324
+                    'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ),
325
+                    'context'      => 'normal',
326
+                    'priority'     => 'high',
327
+                    'show_names'   => true,
328
+               )
329
+          );
330
+          $cmb->add_field(
331
+               array(
332
+                    'name'       => __( 'Plan', 'lsx-health-plan' ),
333
+                    'id'         => 'connected_plans',
334
+                    'desc'       => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ),
335
+                    'type'       => 'post_search_ajax',
336
+                    'limit'      => 15,
337
+                    'sortable'   => true,
338
+                    'query_args' => array(
339
+                         'post_type'      => array( 'plan' ),
340
+                         'post_status'    => array( 'publish' ),
341
+                         'posts_per_page' => -1,
342
+                    ),
343
+               )
344
+          );
345
+     }
346
+
347
+     /**
348
+      * Remove the "Archives:" from the post type.
349
+      *
350
+      * @param string $title the term title.
351
+      * @return string
352
+      */
353
+     public function get_the_archive_title( $title ) {
354
+          if ( is_post_type_archive( 'plan' ) ) {
355
+               $title = __( 'Our health plans', 'lsx-health-plan' );
356
+          }
357
+          return $title;
358
+     }
359
+
360
+     /**
361
+      * Set the post type archive to show the parent plans only.
362
+      *
363
+      * @param object $wp_query
364
+      * @return array
365
+      */
366
+     public function set_parent_only( $wp_query ) {
367
+          if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) {
368
+               $wp_query->set( 'post_parent', '0' );
369
+          }
370
+     }
371
+
372
+     /**
373
+      * Define the metabox and field configurations.
374
+      */
375
+     public function featured_metabox() {
376
+          $cmb = new_cmb2_box(
377
+               array(
378
+                    'id'           => $this->slug . '_featured_metabox_plan',
379
+                    'title'        => __( 'Featured Plan', 'lsx-health-plan' ),
380
+                    'object_types' => array( $this->slug ), // Post type
381
+                    'context'      => 'side',
382
+                    'priority'     => 'high',
383
+                    'show_names'   => true,
384
+               )
385
+          );
386
+          $cmb->add_field(
387
+               array(
388
+                    'name'       => __( 'Featured Plan', 'lsx-health-plan' ),
389
+                    'desc'       => __( 'Enable a featured plan' ),
390
+                    'id'         => $this->slug . '_featured_plan',
391
+                    'type'       => 'checkbox',
392
+                    'show_on_cb' => 'cmb2_hide_if_no_cats',
393
+               )
394
+          );
395
+     }
396
+
397
+     /**
398
+      * Define the metabox and field configurations.
399
+      */
400
+     public function sections_metabox_loop() {
401
+          $cmb = new_cmb2_box(
402
+               array(
403
+                    'id'           => $this->slug . '_sections_metabox',
404
+                    'title'        => __( 'Sections', 'lsx-health-plan' ),
405
+                    'object_types' => array( $this->slug ), // Post type.
406
+                    'context'      => 'normal',
407
+                    'priority'     => 'low',
408
+                    'show_names'   => true,
409
+               )
410
+          );
411
+
412
+          /*
413 413
 		This is where the repeatable group is defined, each field has the same ID as the legacy field.
414 414
 		There is a function which runs and adds to looped fields to individual fields for WP Query compatability.
415 415
 		*/
416
-		$group = $cmb->add_field(
417
-			array(
418
-				'id'      => $this->slug . '_sections',
419
-				'type'    => 'group',
420
-				'options' => array(
421
-					'group_title'   => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
422
-					'add_button'    => __( 'Add section', 'lsx-health-plan' ),
423
-					'remove_button' => __( 'Remove section', 'lsx-health-plan' ),
424
-					'sortable'      => true,
425
-					'closed'        => true, // true to have the groups closed by default
426
-				),
427
-				'classes' => 'lsx-admin-row',
416
+          $group = $cmb->add_field(
417
+               array(
418
+                    'id'      => $this->slug . '_sections',
419
+                    'type'    => 'group',
420
+                    'options' => array(
421
+                         'group_title'   => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
422
+                         'add_button'    => __( 'Add section', 'lsx-health-plan' ),
423
+                         'remove_button' => __( 'Remove section', 'lsx-health-plan' ),
424
+                         'sortable'      => true,
425
+                         'closed'        => true, // true to have the groups closed by default
426
+                    ),
427
+                    'classes' => 'lsx-admin-row',
428 428
 				
429
-			)
430
-		);
431
-
432
-		$cmb->add_group_field(
433
-			$group,
434
-			array(
435
-				'name'       => __( 'Title', 'lsx-health-plan' ),
436
-				'id'         => 'title',
437
-				'type'       => 'text',
438
-				'desc'       => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ),
439
-				'classes'    => 'lsx-field-col  lsx-field-col-50',
440
-			)
441
-		);
442
-
443
-		$cmb->add_group_field(
444
-			$group,
445
-			array(
446
-				'name'       => __( 'Group', 'lsx-health-plan' ),
447
-				'id'         => 'group',
448
-				'type'       => 'text',
449
-				'desc'       => __( 'e.g Week 1 / January', 'lsx-health-plan' ),
450
-				'classes'    => 'lsx-field-col  lsx-field-col-50',
451
-			)
452
-		);
453
-
454
-		$cmb->add_group_field(
455
-			$group,
456
-			array(
457
-				'name' => __( 'Overview', 'lsx-health-plan' ),
458
-				'id'   => 'description',
459
-				'type' => 'wysiwyg',
460
-			)
461
-		);
462
-
463
-		if ( post_type_exists( 'workout' ) ) {
464
-			$cmb->add_group_field(
465
-				$group,
466
-				array(
467
-					'name'       => __( 'Workouts', 'lsx-health-plan' ),
468
-					'id'         => 'connected_workouts',
469
-					'desc'       => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ),
470
-					'type'       => 'post_search_ajax',
471
-					'limit'      => 15,
472
-					'sortable'   => true,
473
-					'query_args' => array(
474
-						'post_type'      => array( 'workout' ),
475
-						'post_status'    => array( 'publish' ),
476
-						'posts_per_page' => -1,
477
-					),
478
-					'classes'    => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
479
-				)
480
-			);
481
-			$cmb->add_group_field(
482
-				$group,
483
-				array(
484
-					'name'        => __( 'Rest day', 'lsx-health-plan' ),
485
-					'id'          => 'rest_day_enabled',
486
-					'type'        => 'checkbox',
487
-					'value'       => 1,
488
-					'default'     => 0,
489
-					'description' => __( 'Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan' ),
490
-					'classes'     => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
491
-				)
492
-			);
493
-		}
494
-
495
-		if ( post_type_exists( 'meal' ) ) {
496
-			$cmb->add_group_field(
497
-				$group,
498
-				array(
499
-					'name'       => __( 'Meals', 'lsx-health-plan' ),
500
-					'desc'       => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ),
501
-					'id'         => 'connected_meals',
502
-					'type'       => 'post_search_ajax',
503
-					// Optional :
504
-					'limit'      => 15, // Limit selection to X items only (default 1)
505
-					'sortable'   => true, // Allow selected items to be sortable (default false)
506
-					'query_args' => array(
507
-						'post_type'      => array( 'meal' ),
508
-						'post_status'    => array( 'publish' ),
509
-						'posts_per_page' => -1,
510
-					),
511
-					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
512
-				)
513
-			);
514
-		}
515
-		if ( post_type_exists( 'tip' ) ) {
516
-			$cmb->add_group_field(
517
-				$group,
518
-				array(
519
-					'name'       => __( 'Tips', 'lsx-health-plan' ),
520
-					'id'         => 'connected_tips',
521
-					'desc'       => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ),
522
-					'type'       => 'post_search_ajax',
523
-					// Optional :
524
-					'limit'      => 15,  // Limit selection to X items only (default 1)
525
-					'sortable'   => true,  // Allow selected items to be sortable (default false)
526
-					'query_args' => array(
527
-						'post_type'      => array( 'tip' ),
528
-						'post_status'    => array( 'publish' ),
529
-						'posts_per_page' => -1,
530
-					),
531
-					'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
532
-				)
533
-			);
534
-		}
535
-	}
536
-
537
-	/**
538
-	 * Holds the array for the single plan breadcrumbs.
539
-	 *
540
-	 * @var array $crumbs
541
-	 * @return array
542
-	 */
543
-	public function plan_breadcrumb_filter( $crumbs ) {
544
-		$plan  = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
545
-		$plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' );
546
-
547
-		if ( is_singular( 'plan' ) ) {	
548
-			$plan_name     = get_the_title();
549
-			$url           = get_post_type_archive_link( $plan );
550
-			$term_obj_list = get_the_terms( get_the_ID(), 'plan-type' );
551
-			$plan_type     = $term_obj_list[0]->name;
552
-			$plan_type_url = get_term_link( $term_obj_list[0]->term_id );
553
-
554
-			$new_crumbs    = array();
555
-			$new_crumbs[0] = $crumbs[0];
556
-
557
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
558
-				$new_crumbs[1] = array(
559
-					0 => $plans,
560
-					1 => $url,
561
-				);
562
-				$new_crumbs[2] = array(
563
-					0 => $plan_type,
564
-					1 => $plan_type_url,
565
-				);
566
-				$new_crumbs[3] = array(
567
-					0 => $plan_name,
568
-				);
569
-			} else {
570
-				$new_crumbs[1] = array(
571
-					'text' => $plans,
572
-					'url'  => $url,
573
-				);
574
-				$new_crumbs[2] = array(
575
-					'text' => $plan_type,
576
-					'url'  => $plan_type_url,
577
-				);
578
-				$new_crumbs[3] = array(
579
-					'text' => $plan_name,
580
-				);
581
-			}
582
-			$crumbs = $new_crumbs;
583
-
584
-		}
585
-		if ( is_post_type_archive( 'plan' ) ) {
586
-
587
-			$new_crumbs    = array();
588
-			$new_crumbs[0] = $crumbs[0];
589
-
590
-			if ( function_exists( 'woocommerce_breadcrumb' ) ) {
591
-				$new_crumbs[1] = array(
592
-					0 => $plans,
593
-				);
594
-			} else {
595
-				$new_crumbs[1] = array(
596
-					'text' => $plans,
597
-				);
598
-			}
599
-			$crumbs = $new_crumbs;
600
-		}
601
-		return $crumbs;
602
-	}
429
+               )
430
+          );
431
+
432
+          $cmb->add_group_field(
433
+               $group,
434
+               array(
435
+                    'name'       => __( 'Title', 'lsx-health-plan' ),
436
+                    'id'         => 'title',
437
+                    'type'       => 'text',
438
+                    'desc'       => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ),
439
+                    'classes'    => 'lsx-field-col  lsx-field-col-50',
440
+               )
441
+          );
442
+
443
+          $cmb->add_group_field(
444
+               $group,
445
+               array(
446
+                    'name'       => __( 'Group', 'lsx-health-plan' ),
447
+                    'id'         => 'group',
448
+                    'type'       => 'text',
449
+                    'desc'       => __( 'e.g Week 1 / January', 'lsx-health-plan' ),
450
+                    'classes'    => 'lsx-field-col  lsx-field-col-50',
451
+               )
452
+          );
453
+
454
+          $cmb->add_group_field(
455
+               $group,
456
+               array(
457
+                    'name' => __( 'Overview', 'lsx-health-plan' ),
458
+                    'id'   => 'description',
459
+                    'type' => 'wysiwyg',
460
+               )
461
+          );
462
+
463
+          if ( post_type_exists( 'workout' ) ) {
464
+               $cmb->add_group_field(
465
+                    $group,
466
+                    array(
467
+                         'name'       => __( 'Workouts', 'lsx-health-plan' ),
468
+                         'id'         => 'connected_workouts',
469
+                         'desc'       => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ),
470
+                         'type'       => 'post_search_ajax',
471
+                         'limit'      => 15,
472
+                         'sortable'   => true,
473
+                         'query_args' => array(
474
+                              'post_type'      => array( 'workout' ),
475
+                              'post_status'    => array( 'publish' ),
476
+                              'posts_per_page' => -1,
477
+                         ),
478
+                         'classes'    => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
479
+                    )
480
+               );
481
+               $cmb->add_group_field(
482
+                    $group,
483
+                    array(
484
+                         'name'        => __( 'Rest day', 'lsx-health-plan' ),
485
+                         'id'          => 'rest_day_enabled',
486
+                         'type'        => 'checkbox',
487
+                         'value'       => 1,
488
+                         'default'     => 0,
489
+                         'description' => __( 'Enabling the rest day will add an item called "Rest" with no links.', 'lsx-health-plan' ),
490
+                         'classes'     => 'lsx-field-col lsx-field-add-field lsx-field-col-50',
491
+                    )
492
+               );
493
+          }
494
+
495
+          if ( post_type_exists( 'meal' ) ) {
496
+               $cmb->add_group_field(
497
+                    $group,
498
+                    array(
499
+                         'name'       => __( 'Meals', 'lsx-health-plan' ),
500
+                         'desc'       => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ),
501
+                         'id'         => 'connected_meals',
502
+                         'type'       => 'post_search_ajax',
503
+                         // Optional :
504
+                         'limit'      => 15, // Limit selection to X items only (default 1)
505
+                         'sortable'   => true, // Allow selected items to be sortable (default false)
506
+                         'query_args' => array(
507
+                              'post_type'      => array( 'meal' ),
508
+                              'post_status'    => array( 'publish' ),
509
+                              'posts_per_page' => -1,
510
+                         ),
511
+                         'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
512
+                    )
513
+               );
514
+          }
515
+          if ( post_type_exists( 'tip' ) ) {
516
+               $cmb->add_group_field(
517
+                    $group,
518
+                    array(
519
+                         'name'       => __( 'Tips', 'lsx-health-plan' ),
520
+                         'id'         => 'connected_tips',
521
+                         'desc'       => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ),
522
+                         'type'       => 'post_search_ajax',
523
+                         // Optional :
524
+                         'limit'      => 15,  // Limit selection to X items only (default 1)
525
+                         'sortable'   => true,  // Allow selected items to be sortable (default false)
526
+                         'query_args' => array(
527
+                              'post_type'      => array( 'tip' ),
528
+                              'post_status'    => array( 'publish' ),
529
+                              'posts_per_page' => -1,
530
+                         ),
531
+                         'classes'    => 'lsx-field-col lsx-field-add-field  lsx-field-col-50',
532
+                    )
533
+               );
534
+          }
535
+     }
536
+
537
+     /**
538
+      * Holds the array for the single plan breadcrumbs.
539
+      *
540
+      * @var array $crumbs
541
+      * @return array
542
+      */
543
+     public function plan_breadcrumb_filter( $crumbs ) {
544
+          $plan  = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' );
545
+          $plans = \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plan' );
546
+
547
+          if ( is_singular( 'plan' ) ) {	
548
+               $plan_name     = get_the_title();
549
+               $url           = get_post_type_archive_link( $plan );
550
+               $term_obj_list = get_the_terms( get_the_ID(), 'plan-type' );
551
+               $plan_type     = $term_obj_list[0]->name;
552
+               $plan_type_url = get_term_link( $term_obj_list[0]->term_id );
553
+
554
+               $new_crumbs    = array();
555
+               $new_crumbs[0] = $crumbs[0];
556
+
557
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
558
+                    $new_crumbs[1] = array(
559
+                         0 => $plans,
560
+                         1 => $url,
561
+                    );
562
+                    $new_crumbs[2] = array(
563
+                         0 => $plan_type,
564
+                         1 => $plan_type_url,
565
+                    );
566
+                    $new_crumbs[3] = array(
567
+                         0 => $plan_name,
568
+                    );
569
+               } else {
570
+                    $new_crumbs[1] = array(
571
+                         'text' => $plans,
572
+                         'url'  => $url,
573
+                    );
574
+                    $new_crumbs[2] = array(
575
+                         'text' => $plan_type,
576
+                         'url'  => $plan_type_url,
577
+                    );
578
+                    $new_crumbs[3] = array(
579
+                         'text' => $plan_name,
580
+                    );
581
+               }
582
+               $crumbs = $new_crumbs;
583
+
584
+          }
585
+          if ( is_post_type_archive( 'plan' ) ) {
586
+
587
+               $new_crumbs    = array();
588
+               $new_crumbs[0] = $crumbs[0];
589
+
590
+               if ( function_exists( 'woocommerce_breadcrumb' ) ) {
591
+                    $new_crumbs[1] = array(
592
+                         0 => $plans,
593
+                    );
594
+               } else {
595
+                    $new_crumbs[1] = array(
596
+                         'text' => $plans,
597
+                    );
598
+               }
599
+               $crumbs = $new_crumbs;
600
+          }
601
+          return $crumbs;
602
+     }
603 603
 }
Please login to merge, or discard this patch.
classes/integrations/woocommerce/class-plans.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -8,146 +8,146 @@
 block discarded – undo
8 8
  */
9 9
 class Plans {
10 10
 
11
-	/**
12
-	 * Holds class instance
13
-	 *
14
-	 * @since 1.0.0
15
-	 *
16
-	 * @var      object \lsx_health_plan\classes\integrations\woocommerce\Plans()
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\integrations\woocommerce\Plans()
17
+      */
18
+     protected static $instance = null;
19 19
 
20
-	/**
21
-	 * Holds the current screen var if it is active.
22
-	 *
23
-	 * @var string
24
-	 */
25
-	public $screen = '';
20
+     /**
21
+      * Holds the current screen var if it is active.
22
+      *
23
+      * @var string
24
+      */
25
+     public $screen = '';
26 26
 
27
-	/**
28
-	 * Holds the current array of product IDS.
29
-	 *
30
-	 * @var array
31
-	 */
32
-	public $product_ids = array();
27
+     /**
28
+      * Holds the current array of product IDS.
29
+      *
30
+      * @var array
31
+      */
32
+     public $product_ids = array();
33 33
 
34
-	/**
35
-	 * Holds the curret parent ID.
36
-	 *
37
-	 * @var int
38
-	 */
39
-	public $parent_id = 0;
34
+     /**
35
+      * Holds the curret parent ID.
36
+      *
37
+      * @var int
38
+      */
39
+     public $parent_id = 0;
40 40
 
41
-	/**
42
-	 * Constructor
43
-	 */
44
-	public function __construct() {
45
-		// Remove the default restrictions, as we will add our own.
46
-		add_action( 'wp', array( $this, 'set_screen' ), 1 );
47
-		add_action( 'wp', array( $this, 'disable_parent_plan_restrictions' ), 2 );
48
-		add_action( 'wp', array( $this, 'child_plan_redirect_restrictions' ), 2 );
41
+     /**
42
+      * Constructor
43
+      */
44
+     public function __construct() {
45
+          // Remove the default restrictions, as we will add our own.
46
+          add_action( 'wp', array( $this, 'set_screen' ), 1 );
47
+          add_action( 'wp', array( $this, 'disable_parent_plan_restrictions' ), 2 );
48
+          add_action( 'wp', array( $this, 'child_plan_redirect_restrictions' ), 2 );
49 49
 
50
-		// Initiate the WP Head functions.
51
-		add_action( 'wp_head', array( $this, 'set_screen' ) );
52
-		add_action( 'lsx_content_top', 'lsx_hp_single_plan_products' );
50
+          // Initiate the WP Head functions.
51
+          add_action( 'wp_head', array( $this, 'set_screen' ) );
52
+          add_action( 'lsx_content_top', 'lsx_hp_single_plan_products' );
53 53
 
54
-		// Plan Archive Actions.
55
-		add_action( 'lsx_entry_before', array( $this, 'set_product_ids' ) );
56
-	}
54
+          // Plan Archive Actions.
55
+          add_action( 'lsx_entry_before', array( $this, 'set_product_ids' ) );
56
+     }
57 57
 
58
-	/**
59
-	 * Return an instance of this class.
60
-	 *
61
-	 * @since 1.0.0
62
-	 *
63
-	 * @return    object \lsx_health_plan\classes\integrations\woocommerce\Plans()    A single instance of this class.
64
-	 */
65
-	public static function get_instance() {
66
-		// If the single instance hasn't been set, set it now.
67
-		if ( null === self::$instance ) {
68
-			self::$instance = new self();
69
-		}
70
-		return self::$instance;
71
-	}
58
+     /**
59
+      * Return an instance of this class.
60
+      *
61
+      * @since 1.0.0
62
+      *
63
+      * @return    object \lsx_health_plan\classes\integrations\woocommerce\Plans()    A single instance of this class.
64
+      */
65
+     public static function get_instance() {
66
+          // If the single instance hasn't been set, set it now.
67
+          if ( null === self::$instance ) {
68
+               self::$instance = new self();
69
+          }
70
+          return self::$instance;
71
+     }
72 72
 
73
-	/**
74
-	 * Define the product metabox on the plan post type
75
-	 */
76
-	public function set_screen() {
77
-		if ( is_singular( array( 'plan' ) ) ) {
78
-			$section = get_query_var( 'section' );
79
-			if ( ! empty( $section ) ) {
80
-				$this->screen = 'child_plan';
81
-			} else {
82
-				$this->screen = 'parent_plan';
83
-			}
84
-			$product_ids = get_post_meta( get_the_ID(), 'plan_product', true );
85
-			if ( false !== $product_ids && ! empty( $product_ids ) ) {
86
-				$this->product_ids = $product_ids;
87
-			}
88
-		}
89
-		if ( is_singular( array( 'workout', 'meal' ) ) ) {
90
-			$parent_id = wp_get_post_parent_id( get_the_ID() );
91
-			if ( 0 === $parent_id || false === $parent_id ) {
92
-				$this->screen = 'parent_plan';
93
-			} else {
94
-				$this->screen = 'child_plan';
95
-			}
96
-		}
97
-		if ( is_post_type_archive( array( 'plan', 'workout', 'meal' ) ) || is_tax( array( 'plan-type', 'workout-type', 'meal-type' ) ) ) {
98
-			$this->screen = 'plan_archive';
99
-		}
100
-	}
73
+     /**
74
+      * Define the product metabox on the plan post type
75
+      */
76
+     public function set_screen() {
77
+          if ( is_singular( array( 'plan' ) ) ) {
78
+               $section = get_query_var( 'section' );
79
+               if ( ! empty( $section ) ) {
80
+                    $this->screen = 'child_plan';
81
+               } else {
82
+                    $this->screen = 'parent_plan';
83
+               }
84
+               $product_ids = get_post_meta( get_the_ID(), 'plan_product', true );
85
+               if ( false !== $product_ids && ! empty( $product_ids ) ) {
86
+                    $this->product_ids = $product_ids;
87
+               }
88
+          }
89
+          if ( is_singular( array( 'workout', 'meal' ) ) ) {
90
+               $parent_id = wp_get_post_parent_id( get_the_ID() );
91
+               if ( 0 === $parent_id || false === $parent_id ) {
92
+                    $this->screen = 'parent_plan';
93
+               } else {
94
+                    $this->screen = 'child_plan';
95
+               }
96
+          }
97
+          if ( is_post_type_archive( array( 'plan', 'workout', 'meal' ) ) || is_tax( array( 'plan-type', 'workout-type', 'meal-type' ) ) ) {
98
+               $this->screen = 'plan_archive';
99
+          }
100
+     }
101 101
 
102
-	/**
103
-	 * Sets the post type archive product ids.
104
-	 *
105
-	 * @return void
106
-	 */
107
-	public function set_product_ids() {
108
-		$this->product_ids = false;
109
-		if ( 'plan' === get_post_type() ) {
110
-			$product_ids = get_post_meta( get_the_ID(), 'plan_product', true );
111
-			if ( false !== $product_ids && ! empty( $product_ids ) ) {
112
-				$this->product_ids = $product_ids;
113
-			}
114
-		}
115
-	}
102
+     /**
103
+      * Sets the post type archive product ids.
104
+      *
105
+      * @return void
106
+      */
107
+     public function set_product_ids() {
108
+          $this->product_ids = false;
109
+          if ( 'plan' === get_post_type() ) {
110
+               $product_ids = get_post_meta( get_the_ID(), 'plan_product', true );
111
+               if ( false !== $product_ids && ! empty( $product_ids ) ) {
112
+                    $this->product_ids = $product_ids;
113
+               }
114
+          }
115
+     }
116 116
 
117
-	/**
118
-	 * Disable WC Memberships restrictions for plan parents. We add our own custom
119
-	 * restriction functionality elsewhere.
120
-	 */
121
-	public function disable_parent_plan_restrictions() {
122
-		if ( '' === $this->screen || ! function_exists( 'wc_memberships' ) ) {
123
-			return;
124
-		}
117
+     /**
118
+      * Disable WC Memberships restrictions for plan parents. We add our own custom
119
+      * restriction functionality elsewhere.
120
+      */
121
+     public function disable_parent_plan_restrictions() {
122
+          if ( '' === $this->screen || ! function_exists( 'wc_memberships' ) ) {
123
+               return;
124
+          }
125 125
 
126
-		$restrictions = wc_memberships()->get_restrictions_instance()->get_posts_restrictions_instance();
127
-		remove_action( 'wp', array( $restrictions, 'handle_restriction_modes' ) );
128
-	}
126
+          $restrictions = wc_memberships()->get_restrictions_instance()->get_posts_restrictions_instance();
127
+          remove_action( 'wp', array( $restrictions, 'handle_restriction_modes' ) );
128
+     }
129 129
 
130
-	/**
131
-	 * Disable WC Memberships restrictions for plan parents. We add our own custom
132
-	 * restriction functionality elsewhere.
133
-	 */
134
-	public function child_plan_redirect_restrictions() {
135
-		if ( ! function_exists( 'wc_memberships' ) || ! is_singular( 'plan' ) || 'child_plan' !== $this->screen || ! function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
136
-			return;
137
-		}
138
-		$restricted = wc_memberships_is_post_content_restricted() && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
139
-		if ( true === $restricted ) {
140
-			wp_redirect( get_permalink( get_the_ID() ) );
141
-			exit;
142
-		}
143
-	}
130
+     /**
131
+      * Disable WC Memberships restrictions for plan parents. We add our own custom
132
+      * restriction functionality elsewhere.
133
+      */
134
+     public function child_plan_redirect_restrictions() {
135
+          if ( ! function_exists( 'wc_memberships' ) || ! is_singular( 'plan' ) || 'child_plan' !== $this->screen || ! function_exists( 'wc_memberships_is_post_content_restricted' ) ) {
136
+               return;
137
+          }
138
+          $restricted = wc_memberships_is_post_content_restricted() && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() );
139
+          if ( true === $restricted ) {
140
+               wp_redirect( get_permalink( get_the_ID() ) );
141
+               exit;
142
+          }
143
+     }
144 144
 
145
-	/**
146
-	 * Returns the ids of the attached products.
147
-	 *
148
-	 * @return array
149
-	 */
150
-	public function get_products() {
151
-		return $this->product_ids;
152
-	}
145
+     /**
146
+      * Returns the ids of the attached products.
147
+      *
148
+      * @return array
149
+      */
150
+     public function get_products() {
151
+          return $this->product_ids;
152
+     }
153 153
 }
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 ( ! function_exists( 'wc_memberships_view_restricted_post_content' ) || current_user_can( 'wc_memberships_view_restricted_post_content', $page_id ) ) {
24
-			?>
23
+          if ( ! function_exists( 'wc_memberships_view_restricted_post_content' ) || 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/taxonomy-muscle-group.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 ( ! function_exists( 'wc_memberships_view_restricted_post_content' ) || current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) {
24
-			?>
23
+          if ( ! function_exists( 'wc_memberships_view_restricted_post_content' ) || current_user_can( 'wc_memberships_view_restricted_post_content', $post_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-exercise.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.