Passed
Push — add/multiplan ( 254fd4...1128c7 )
by Virginia
04:22
created
includes/conditionals.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
  * @return boolean
13 13
  */
14 14
 function lsx_health_plan_has_warmup( $post_id = '' ) {
15
-	if ( '' === $post_id ) {
16
-		$post_id = get_the_ID();
17
-	}
18
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' );
15
+     if ( '' === $post_id ) {
16
+          $post_id = get_the_ID();
17
+     }
18
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' );
19 19
 }
20 20
 
21 21
 /**
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
  * @return boolean
26 26
  */
27 27
 function lsx_health_plan_has_workout( $post_id = '' ) {
28
-	if ( ! post_type_exists( 'workout' ) ) {
29
-		return false;
30
-	}
31
-	if ( '' === $post_id ) {
32
-		$post_id = get_the_ID();
33
-	}
34
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' );
28
+     if ( ! post_type_exists( 'workout' ) ) {
29
+          return false;
30
+     }
31
+     if ( '' === $post_id ) {
32
+          $post_id = get_the_ID();
33
+     }
34
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' );
35 35
 }
36 36
 
37 37
 /**
@@ -41,14 +41,14 @@  discard block
 block discarded – undo
41 41
  * @return boolean
42 42
  */
43 43
 function lsx_health_plan_has_meal( $post_id = '' ) {
44
-	if ( ! post_type_exists( 'meal' ) ) {
45
-		return false;
46
-	}
47
-	if ( '' === $post_id ) {
48
-		$post_id = get_the_ID();
49
-	}
50
-	echo \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' );
51
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' );
44
+     if ( ! post_type_exists( 'meal' ) ) {
45
+          return false;
46
+     }
47
+     if ( '' === $post_id ) {
48
+          $post_id = get_the_ID();
49
+     }
50
+     echo \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' );
51
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' );
52 52
 }
53 53
 
54 54
 /**
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
  * @return boolean
59 59
  */
60 60
 function lsx_health_plan_has_recipe( $post_id = '' ) {
61
-	if ( ! post_type_exists( 'recipe' ) ) {
62
-		return false;
63
-	}
64
-	if ( '' === $post_id ) {
65
-		$post_id = get_the_ID();
66
-	}
67
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' );
61
+     if ( ! post_type_exists( 'recipe' ) ) {
62
+          return false;
63
+     }
64
+     if ( '' === $post_id ) {
65
+          $post_id = get_the_ID();
66
+     }
67
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' );
68 68
 }
69 69
 
70 70
 /**
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
  * @return boolean
75 75
  */
76 76
 function lsx_health_plan_has_downloads( $post_id = '' ) {
77
-	$has_downloads = false;
78
-	if ( '' === $post_id ) {
79
-		$post_id = get_the_ID();
80
-	}
81
-	$downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id );
82
-	if ( ! empty( $downloads ) ) {
83
-		$has_downloads = true;
84
-	}
85
-	return $has_downloads;
77
+     $has_downloads = false;
78
+     if ( '' === $post_id ) {
79
+          $post_id = get_the_ID();
80
+     }
81
+     $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id );
82
+     if ( ! empty( $downloads ) ) {
83
+          $has_downloads = true;
84
+     }
85
+     return $has_downloads;
86 86
 }
87 87
 
88 88
 /**
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
  * @return boolean
93 93
  */
94 94
 function lsx_health_plan_has_tip( $post_id = '' ) {
95
-	if ( ! post_type_exists( 'tip' ) ) {
96
-		return false;
97
-	}
98
-	if ( '' === $post_id ) {
99
-		$post_id = get_the_ID();
100
-	}
101
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' );
95
+     if ( ! post_type_exists( 'tip' ) ) {
96
+          return false;
97
+     }
98
+     if ( '' === $post_id ) {
99
+          $post_id = get_the_ID();
100
+     }
101
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' );
102 102
 }
103 103
 
104 104
 /**
@@ -108,13 +108,13 @@  discard block
 block discarded – undo
108 108
  * @return boolean
109 109
  */
110 110
 function lsx_health_plan_has_video( $post_id = '' ) {
111
-	if ( ! post_type_exists( 'video' ) ) {
112
-		return false;
113
-	}
114
-	if ( '' === $post_id ) {
115
-		$post_id = get_the_ID();
116
-	}
117
-	return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' );
111
+     if ( ! post_type_exists( 'video' ) ) {
112
+          return false;
113
+     }
114
+     if ( '' === $post_id ) {
115
+          $post_id = get_the_ID();
116
+     }
117
+     return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' );
118 118
 }
119 119
 
120 120
 /**
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
  * @return boolean
124 124
  */
125 125
 function lsx_health_plan_user_has_purchase() {
126
-	$valid_order = false;
127
-	$product_id  = \lsx_health_plan\functions\get_option( 'membership_product', false );
126
+     $valid_order = false;
127
+     $product_id  = \lsx_health_plan\functions\get_option( 'membership_product', false );
128 128
 
129
-	if ( is_user_logged_in() && false !== $product_id ) {
130
-		$current_user = wp_get_current_user();
131
-		if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) {
132
-			$valid_order = true;
133
-		}
134
-	}
135
-	return $valid_order;
129
+     if ( is_user_logged_in() && false !== $product_id ) {
130
+          $current_user = wp_get_current_user();
131
+          if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) {
132
+               $valid_order = true;
133
+          }
134
+     }
135
+     return $valid_order;
136 136
 }
137 137
 
138 138
 /**
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
  * @return boolean
143 143
  */
144 144
 function lsx_health_plan_is_current_tab( $needle = '' ) {
145
-	$is_tab = false;
146
-	$plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
147
-	if ( false === $plan_slug ) {
148
-		$plan_slug = 'my-plan';
149
-	}
150
-	if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) {
151
-		$endpoint = get_query_var( 'endpoint' );
152
-		if ( false !== $endpoint && $needle === $endpoint ) {
153
-			$is_tab = true;
154
-		}
155
-	}
156
-	return $is_tab;
145
+     $is_tab = false;
146
+     $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false );
147
+     if ( false === $plan_slug ) {
148
+          $plan_slug = 'my-plan';
149
+     }
150
+     if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) {
151
+          $endpoint = get_query_var( 'endpoint' );
152
+          if ( false !== $endpoint && $needle === $endpoint ) {
153
+               $is_tab = true;
154
+          }
155
+     }
156
+     return $is_tab;
157 157
 }
158 158
 
159 159
 /**
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
  * @return boolean
164 164
  */
165 165
 function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) {
166
-	$is_complete = false;
167
-	if ( '' === $post_id ) {
168
-		$post_id = get_the_ID();
169
-	}
170
-	$key             = \lsx_health_plan\functions\plan\generate_section_id( $section_key );
171
-	$is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true );
172
-	if ( false !== $is_day_complete && '' !== $is_day_complete ) {
173
-		$is_complete = true;
174
-	}
166
+     $is_complete = false;
167
+     if ( '' === $post_id ) {
168
+          $post_id = get_the_ID();
169
+     }
170
+     $key             = \lsx_health_plan\functions\plan\generate_section_id( $section_key );
171
+     $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true );
172
+     if ( false !== $is_day_complete && '' !== $is_day_complete ) {
173
+          $is_complete = true;
174
+     }
175 175
 
176
-	return $is_complete;
176
+     return $is_complete;
177 177
 }
178 178
 
179 179
 function lsx_health_plan_is_plan_complete() {
180
-	$complete = false;
181
-	return $complete;
180
+     $complete = false;
181
+     return $complete;
182 182
 }
183 183
 
184 184
 /**
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
  * @return boolean
189 189
  */
190 190
 function lsx_health_plan_week_has_downloads( $week = '' ) {
191
-	$has_downloads = false;
192
-	if ( '' !== $week ) {
193
-		$downloads = \lsx_health_plan\functions\get_weekly_downloads( $week );
194
-		if ( ! empty( $downloads ) ) {
195
-			$has_downloads = true;
196
-		}
197
-	}
198
-	return $has_downloads;
191
+     $has_downloads = false;
192
+     if ( '' !== $week ) {
193
+          $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week );
194
+          if ( ! empty( $downloads ) ) {
195
+               $has_downloads = true;
196
+          }
197
+     }
198
+     return $has_downloads;
199 199
 }
200 200
 
201 201
 /**
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
  * @return boolean
206 206
  */
207 207
 function lsx_health_plan_has_tips( $post_id = '' ) {
208
-	$has_tips = false;
209
-	if ( '' === $post_id ) {
210
-		$post_id = get_the_ID();
211
-	}
212
-	$post_type      = get_post_type( $post_id );
213
-	$connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true );
214
-	$connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips );
215
-	if ( ! empty( $connected_tips ) ) {
216
-		$has_tips = true;
217
-	}
218
-	return $has_tips;
208
+     $has_tips = false;
209
+     if ( '' === $post_id ) {
210
+          $post_id = get_the_ID();
211
+     }
212
+     $post_type      = get_post_type( $post_id );
213
+     $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true );
214
+     $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips );
215
+     if ( ! empty( $connected_tips ) ) {
216
+          $has_tips = true;
217
+     }
218
+     return $has_tips;
219 219
 }
Please login to merge, or discard this patch.
classes/post-types/class-exercise.php 1 patch
Indentation   +423 added lines, -423 removed lines patch added patch discarded remove patch
@@ -8,428 +8,428 @@
 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( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
53
-
54
-		}
55
-
56
-	}
57
-
58
-
59
-	/**
60
-	 * Return an instance of this class.
61
-	 *
62
-	 * @since 1.0.0
63
-	 *
64
-	 * @return    object \lsx_health_plan\classes\Exercise()    A single instance of this class.
65
-	 */
66
-	public static function get_instance() {
67
-		// If the single instance hasn't been set, set it now.
68
-		if ( null === self::$instance ) {
69
-			self::$instance = new self();
70
-		}
71
-		return self::$instance;
72
-	}
73
-	/**
74
-	 * Register the post type.
75
-	 */
76
-	public function register_post_type() {
77
-		$labels = array(
78
-			'name'               => esc_html__( 'Exercises', 'lsx-health-plan' ),
79
-			'singular_name'      => esc_html__( 'Exercise', 'lsx-health-plan' ),
80
-			'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
81
-			'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
82
-			'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
83
-			'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
84
-			'all_items'          => esc_html__( 'All Exercises', 'lsx-health-plan' ),
85
-			'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
86
-			'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
87
-			'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
88
-			'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
89
-			'parent_item_colon'  => '',
90
-			'menu_name'          => esc_html__( 'Exercises', 'lsx-health-plan' ),
91
-		);
92
-		$args   = array(
93
-			'labels'             => $labels,
94
-			'public'             => true,
95
-			'publicly_queryable' => true,
96
-			'show_ui'            => true,
97
-			'show_in_menu'       => false,
98
-			'show_in_rest'       => true,
99
-			'menu_icon'          => 'dashicons-universal-access',
100
-			'query_var'          => true,
101
-			'rewrite'            => array(
102
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
103
-			),
104
-			'capability_type'    => 'page',
105
-			'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ),
106
-			'hierarchical'       => false,
107
-			'menu_position'      => null,
108
-			'supports'           => array(
109
-				'title',
110
-				'thumbnail',
111
-				'editor',
112
-				'excerpt',
113
-				'custom-fields',
114
-			),
115
-		);
116
-		register_post_type( 'exercise', $args );
117
-	}
118
-
119
-	/**
120
-	 * Register the Exercise taxonomy.
121
-	 *
122
-	 * @return void
123
-	 */
124
-	public function exercise_type_taxonomy_setup() {
125
-		$labels = array(
126
-			'name'              => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ),
127
-			'singular_name'     => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ),
128
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
129
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
130
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
131
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
132
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
133
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
134
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
135
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
136
-			'menu_name'         => esc_html__( 'Exercise Types', 'lsx-health-plan' ),
137
-		);
138
-
139
-		$args = array(
140
-			'hierarchical'      => true,
141
-			'labels'            => $labels,
142
-			'show_ui'           => true,
143
-			'show_admin_column' => true,
144
-			'query_var'         => true,
145
-			'rewrite'           => array(
146
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ),
147
-			),
148
-			'show_in_rest'      => true,
149
-		);
150
-
151
-		register_taxonomy( 'exercise-type', array( 'exercise' ), $args );
152
-	}
153
-
154
-	/**
155
-	 * Register the Exercise taxonomy.
156
-	 *
157
-	 * @return void
158
-	 */
159
-	public function equipment_taxonomy_setup() {
160
-		$labels = array(
161
-			'name'              => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ),
162
-			'singular_name'     => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ),
163
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
164
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
165
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
166
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
167
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
168
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
169
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
170
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
171
-			'menu_name'         => esc_html__( 'Equipment', 'lsx-health-plan' ),
172
-		);
173
-
174
-		$args = array(
175
-			'hierarchical'      => true,
176
-			'labels'            => $labels,
177
-			'show_ui'           => true,
178
-			'show_admin_column' => true,
179
-			'query_var'         => true,
180
-			'rewrite'           => array(
181
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ),
182
-			),
183
-			'show_in_rest'      => true,
184
-		);
185
-
186
-		register_taxonomy( 'equipment', array( 'exercise' ), $args );
187
-	}
188
-
189
-	/**
190
-	 * Register the Muscle Group taxonomy.
191
-	 *
192
-	 * @return void
193
-	 */
194
-	public function muscle_group_taxonomy_setup() {
195
-		$labels = array(
196
-			'name'              => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ),
197
-			'singular_name'     => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ),
198
-			'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
199
-			'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
200
-			'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
201
-			'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
202
-			'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
203
-			'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
204
-			'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
205
-			'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
206
-			'menu_name'         => esc_html__( 'Muscle Groups', 'lsx-health-plan' ),
207
-		);
208
-
209
-		$args = array(
210
-			'hierarchical'      => true,
211
-			'labels'            => $labels,
212
-			'show_ui'           => true,
213
-			'show_admin_column' => true,
214
-			'query_var'         => true,
215
-			'rewrite'           => array(
216
-				'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_muscle_group', 'muscle-group' ),
217
-			),
218
-			'show_in_rest'      => true,
219
-		);
220
-
221
-		register_taxonomy( 'muscle-group', array( 'exercise' ), $args );
222
-	}
223
-
224
-	/**
225
-	 * Registers the Recipes under the Meals Post type menu.
226
-	 *
227
-	 * @return void
228
-	 */
229
-	public function register_menus() {
230
-		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' );
231
-		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' );
232
-		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' );
233
-		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' );
234
-	}
235
-
236
-	/**
237
-	 * Adds the post type to the different arrays.
238
-	 *
239
-	 * @param array $post_types
240
-	 * @return array
241
-	 */
242
-	public function enable_post_type( $post_types = array() ) {
243
-		$post_types[] = $this->slug;
244
-		return $post_types;
245
-	}
246
-
247
-	/**
248
-	 * Enables the Bi Directional relationships
249
-	 *
250
-	 * @param array $connections
251
-	 * @return void
252
-	 */
253
-	public function enable_connections( $connections = array() ) {
254
-		$connections['exercise']['connected_workouts'] = 'connected_exercises';
255
-		$connections['workout']['connected_exercises'] = 'connected_workouts';
256
-		return $connections;
257
-	}
258
-
259
-	/**
260
-	 * Define the metabox and field configurations.
261
-	 */
262
-	public function gallery_metabox() {
263
-		$cmb = new_cmb2_box(
264
-			array(
265
-				'id'           => $this->slug . '_gallery_details_metabox',
266
-				'title'        => __( 'Exercise Gallery', 'lsx-health-plan' ),
267
-				'object_types' => array( $this->slug ),
268
-				'context'      => 'normal',
269
-				'priority'     => 'low',
270
-				'show_names'   => true,
271
-			)
272
-		);
273
-
274
-		$cmb->add_field(
275
-			array(
276
-				'name'    => __( 'Layout', 'lsx-health-plan' ),
277
-				'id'      => $this->slug . '_gallery_layout',
278
-				'type'    => 'radio',
279
-				'options' => array(
280
-					'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
281
-					'grid'   => __( 'Grid', 'lsx-health-plan' ),
282
-				),
283
-				'default' => 'grid',
284
-			)
285
-		);
286
-
287
-		$cmb->add_field(
288
-			array(
289
-				'name'    => __( 'Grid Columns', 'lsx-health-plan' ),
290
-				'id'      => $this->slug . '_gallery_columns',
291
-				'type'    => 'select',
292
-				'options' => array(
293
-					'3' => __( '2 Columns', 'lsx-health-plan' ),
294
-					'4' => __( '3 Columns', 'lsx-health-plan' ),
295
-				),
296
-				'default' => '1',
297
-			)
298
-		);
299
-
300
-		// Repeatable group.
301
-		$gallery_group = $cmb->add_field(
302
-			array(
303
-				'id'      => $this->slug . '_gallery',
304
-				'type'    => 'group',
305
-				'options' => array(
306
-					'group_title'   => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
307
-					'add_button'    => __( 'Add Item', 'lsx-health-plan' ),
308
-					'remove_button' => __( 'Remove Item', 'lsx-health-plan' ),
309
-					'sortable'      => true,
310
-				),
311
-				'classes' => 'lsx-admin-row',
312
-			)
313
-		);
314
-
315
-		// Title.
316
-		$cmb->add_group_field(
317
-			$gallery_group,
318
-			array(
319
-				'name'       => __( 'Image', 'lsx-health-plan' ),
320
-				'id'         => $this->slug . '_gallery_image',
321
-				'type'       => 'file',
322
-				'text'       => array(
323
-					'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
324
-				),
325
-				'desc'       => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ),
326
-				'query_args' => array(
327
-					'type' => array(
328
-						'image/gif',
329
-						'image/jpeg',
330
-						'image/png',
331
-					),
332
-				),
333
-				'preview_size' => 'lsx-thumbnail-wide',
334
-			)
335
-		);
336
-
337
-		// Title.
338
-		$cmb->add_group_field(
339
-			$gallery_group,
340
-			array(
341
-				'name'         => __( 'oEmbed', 'lsx-health-plan' ),
342
-				'id'           => $this->slug . '_gallery_embed',
343
-				'type'         => 'text',
344
-				'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' ),
345
-			)
346
-		);
347
-
348
-		$cmb->add_group_field(
349
-			$gallery_group,
350
-			array(
351
-				'name'         => __( 'External Media', 'lsx-health-plan' ),
352
-				'id'           => $this->slug . '_gallery_external',
353
-				'type'         => 'textarea_code',
354
-				'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' ),
355
-			)
356
-		);
357
-	}
358
-
359
-	/**
360
-	 * Registers the general settings for the exercise.
361
-	 *
362
-	 * @return void
363
-	 */
364
-	public function exercise_details() {
365
-		$cmb = new_cmb2_box(
366
-			array(
367
-				'id'           => $this->slug . '_general_details_metabox',
368
-				'title'        => __( 'Details', 'lsx-health-plan' ),
369
-				'object_types' => array( $this->slug ),
370
-				'context'      => 'normal',
371
-				'priority'     => 'high',
372
-				'show_names'   => true,
373
-			)
374
-		);
375
-
376
-		$cmb->add_field(
377
-			array(
378
-				'name'    => __( 'Side', 'lsx-health-plan' ),
379
-				'id'      => $this->slug . '_side',
380
-				'type'    => 'select',
381
-				'options' => array(
382
-					''      => __( 'Select', 'lsx-health-plan' ),
383
-					'left'  => __( 'Left', 'lsx-health-plan' ),
384
-					'right' => __( 'Right', 'lsx-health-plan' ),
385
-				),
386
-				'desc'    => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ),
387
-			)
388
-		);
389
-	}
390
-
391
-	/**
392
-	 * Holds the array for the single exercise breadcrumbs.
393
-	 *
394
-	 * @var array $crumbs
395
-	 * @return array
396
-	 */
397
-	public function exercise_breadcrumb_filter( $crumbs ) {
398
-		$exercise  = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' );
399
-		$exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' );
400
-		$url       = get_post_type_archive_link( $exercise );
401
-
402
-		if ( is_singular( 'exercise' ) ) {
403
-			$exercise_name     = get_the_title();	
404
-			$term_obj_list     = get_the_terms( get_the_ID(), 'exercise-type' );
405
-			$exercise_type     = $term_obj_list[0]->name;
406
-			$exercise_type_url = get_term_link( $term_obj_list[0]->term_id );
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( 'woocommerce_get_breadcrumb', array( $this, 'exercise_breadcrumb_filter' ), 30, 1 );
53
+
54
+          }
55
+
56
+     }
57
+
58
+
59
+     /**
60
+      * Return an instance of this class.
61
+      *
62
+      * @since 1.0.0
63
+      *
64
+      * @return    object \lsx_health_plan\classes\Exercise()    A single instance of this class.
65
+      */
66
+     public static function get_instance() {
67
+          // If the single instance hasn't been set, set it now.
68
+          if ( null === self::$instance ) {
69
+               self::$instance = new self();
70
+          }
71
+          return self::$instance;
72
+     }
73
+     /**
74
+      * Register the post type.
75
+      */
76
+     public function register_post_type() {
77
+          $labels = array(
78
+               'name'               => esc_html__( 'Exercises', 'lsx-health-plan' ),
79
+               'singular_name'      => esc_html__( 'Exercise', 'lsx-health-plan' ),
80
+               'add_new'            => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ),
81
+               'add_new_item'       => esc_html__( 'Add New', 'lsx-health-plan' ),
82
+               'edit_item'          => esc_html__( 'Edit', 'lsx-health-plan' ),
83
+               'new_item'           => esc_html__( 'New', 'lsx-health-plan' ),
84
+               'all_items'          => esc_html__( 'All Exercises', 'lsx-health-plan' ),
85
+               'view_item'          => esc_html__( 'View', 'lsx-health-plan' ),
86
+               'search_items'       => esc_html__( 'Search', 'lsx-health-plan' ),
87
+               'not_found'          => esc_html__( 'None found', 'lsx-health-plan' ),
88
+               'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ),
89
+               'parent_item_colon'  => '',
90
+               'menu_name'          => esc_html__( 'Exercises', 'lsx-health-plan' ),
91
+          );
92
+          $args   = array(
93
+               'labels'             => $labels,
94
+               'public'             => true,
95
+               'publicly_queryable' => true,
96
+               'show_ui'            => true,
97
+               'show_in_menu'       => false,
98
+               'show_in_rest'       => true,
99
+               'menu_icon'          => 'dashicons-universal-access',
100
+               'query_var'          => true,
101
+               'rewrite'            => array(
102
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ),
103
+               ),
104
+               'capability_type'    => 'page',
105
+               'has_archive'        => \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercises' ),
106
+               'hierarchical'       => false,
107
+               'menu_position'      => null,
108
+               'supports'           => array(
109
+                    'title',
110
+                    'thumbnail',
111
+                    'editor',
112
+                    'excerpt',
113
+                    'custom-fields',
114
+               ),
115
+          );
116
+          register_post_type( 'exercise', $args );
117
+     }
118
+
119
+     /**
120
+      * Register the Exercise taxonomy.
121
+      *
122
+      * @return void
123
+      */
124
+     public function exercise_type_taxonomy_setup() {
125
+          $labels = array(
126
+               'name'              => esc_html_x( 'Exercise Type', 'taxonomy general name', 'lsx-health-plan' ),
127
+               'singular_name'     => esc_html_x( 'Exercise Type', 'taxonomy singular name', 'lsx-health-plan' ),
128
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
129
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
130
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
131
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
132
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
133
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
134
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
135
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
136
+               'menu_name'         => esc_html__( 'Exercise Types', 'lsx-health-plan' ),
137
+          );
138
+
139
+          $args = array(
140
+               'hierarchical'      => true,
141
+               'labels'            => $labels,
142
+               'show_ui'           => true,
143
+               'show_admin_column' => true,
144
+               'query_var'         => true,
145
+               'rewrite'           => array(
146
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_type', 'exercise-type' ),
147
+               ),
148
+               'show_in_rest'      => true,
149
+          );
150
+
151
+          register_taxonomy( 'exercise-type', array( 'exercise' ), $args );
152
+     }
153
+
154
+     /**
155
+      * Register the Exercise taxonomy.
156
+      *
157
+      * @return void
158
+      */
159
+     public function equipment_taxonomy_setup() {
160
+          $labels = array(
161
+               'name'              => esc_html_x( 'Equipment', 'taxonomy general name', 'lsx-health-plan' ),
162
+               'singular_name'     => esc_html_x( 'Equipment', 'taxonomy singular name', 'lsx-health-plan' ),
163
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
164
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
165
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
166
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
167
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
168
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
169
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
170
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
171
+               'menu_name'         => esc_html__( 'Equipment', 'lsx-health-plan' ),
172
+          );
173
+
174
+          $args = array(
175
+               'hierarchical'      => true,
176
+               'labels'            => $labels,
177
+               'show_ui'           => true,
178
+               'show_admin_column' => true,
179
+               'query_var'         => true,
180
+               'rewrite'           => array(
181
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_equipment', 'equipment' ),
182
+               ),
183
+               'show_in_rest'      => true,
184
+          );
185
+
186
+          register_taxonomy( 'equipment', array( 'exercise' ), $args );
187
+     }
188
+
189
+     /**
190
+      * Register the Muscle Group taxonomy.
191
+      *
192
+      * @return void
193
+      */
194
+     public function muscle_group_taxonomy_setup() {
195
+          $labels = array(
196
+               'name'              => esc_html_x( 'Muscle Groups', 'taxonomy general name', 'lsx-health-plan' ),
197
+               'singular_name'     => esc_html_x( 'Muscle Group', 'taxonomy singular name', 'lsx-health-plan' ),
198
+               'search_items'      => esc_html__( 'Search', 'lsx-health-plan' ),
199
+               'all_items'         => esc_html__( 'All', 'lsx-health-plan' ),
200
+               'parent_item'       => esc_html__( 'Parent', 'lsx-health-plan' ),
201
+               'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ),
202
+               'edit_item'         => esc_html__( 'Edit', 'lsx-health-plan' ),
203
+               'update_item'       => esc_html__( 'Update', 'lsx-health-plan' ),
204
+               'add_new_item'      => esc_html__( 'Add New', 'lsx-health-plan' ),
205
+               'new_item_name'     => esc_html__( 'New Name', 'lsx-health-plan' ),
206
+               'menu_name'         => esc_html__( 'Muscle Groups', 'lsx-health-plan' ),
207
+          );
208
+
209
+          $args = array(
210
+               'hierarchical'      => true,
211
+               'labels'            => $labels,
212
+               'show_ui'           => true,
213
+               'show_admin_column' => true,
214
+               'query_var'         => true,
215
+               'rewrite'           => array(
216
+                    'slug' => \lsx_health_plan\functions\get_option( 'endpoint_exercise_muscle_group', 'muscle-group' ),
217
+               ),
218
+               'show_in_rest'      => true,
219
+          );
220
+
221
+          register_taxonomy( 'muscle-group', array( 'exercise' ), $args );
222
+     }
223
+
224
+     /**
225
+      * Registers the Recipes under the Meals Post type menu.
226
+      *
227
+      * @return void
228
+      */
229
+     public function register_menus() {
230
+          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' );
231
+          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' );
232
+          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' );
233
+          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' );
234
+     }
235
+
236
+     /**
237
+      * Adds the post type to the different arrays.
238
+      *
239
+      * @param array $post_types
240
+      * @return array
241
+      */
242
+     public function enable_post_type( $post_types = array() ) {
243
+          $post_types[] = $this->slug;
244
+          return $post_types;
245
+     }
246
+
247
+     /**
248
+      * Enables the Bi Directional relationships
249
+      *
250
+      * @param array $connections
251
+      * @return void
252
+      */
253
+     public function enable_connections( $connections = array() ) {
254
+          $connections['exercise']['connected_workouts'] = 'connected_exercises';
255
+          $connections['workout']['connected_exercises'] = 'connected_workouts';
256
+          return $connections;
257
+     }
258
+
259
+     /**
260
+      * Define the metabox and field configurations.
261
+      */
262
+     public function gallery_metabox() {
263
+          $cmb = new_cmb2_box(
264
+               array(
265
+                    'id'           => $this->slug . '_gallery_details_metabox',
266
+                    'title'        => __( 'Exercise Gallery', 'lsx-health-plan' ),
267
+                    'object_types' => array( $this->slug ),
268
+                    'context'      => 'normal',
269
+                    'priority'     => 'low',
270
+                    'show_names'   => true,
271
+               )
272
+          );
273
+
274
+          $cmb->add_field(
275
+               array(
276
+                    'name'    => __( 'Layout', 'lsx-health-plan' ),
277
+                    'id'      => $this->slug . '_gallery_layout',
278
+                    'type'    => 'radio',
279
+                    'options' => array(
280
+                         'slider' => __( 'Slider', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
281
+                         'grid'   => __( 'Grid', 'lsx-health-plan' ),
282
+                    ),
283
+                    'default' => 'grid',
284
+               )
285
+          );
286
+
287
+          $cmb->add_field(
288
+               array(
289
+                    'name'    => __( 'Grid Columns', 'lsx-health-plan' ),
290
+                    'id'      => $this->slug . '_gallery_columns',
291
+                    'type'    => 'select',
292
+                    'options' => array(
293
+                         '3' => __( '2 Columns', 'lsx-health-plan' ),
294
+                         '4' => __( '3 Columns', 'lsx-health-plan' ),
295
+                    ),
296
+                    'default' => '1',
297
+               )
298
+          );
299
+
300
+          // Repeatable group.
301
+          $gallery_group = $cmb->add_field(
302
+               array(
303
+                    'id'      => $this->slug . '_gallery',
304
+                    'type'    => 'group',
305
+                    'options' => array(
306
+                         'group_title'   => __( 'Gallery', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number
307
+                         'add_button'    => __( 'Add Item', 'lsx-health-plan' ),
308
+                         'remove_button' => __( 'Remove Item', 'lsx-health-plan' ),
309
+                         'sortable'      => true,
310
+                    ),
311
+                    'classes' => 'lsx-admin-row',
312
+               )
313
+          );
314
+
315
+          // Title.
316
+          $cmb->add_group_field(
317
+               $gallery_group,
318
+               array(
319
+                    'name'       => __( 'Image', 'lsx-health-plan' ),
320
+                    'id'         => $this->slug . '_gallery_image',
321
+                    'type'       => 'file',
322
+                    'text'       => array(
323
+                         'add_upload_file_text' => __( 'Add File', 'lsx-health-plan' ),
324
+                    ),
325
+                    'desc'       => __( 'Upload an image a minimum of 800px x 600px in size.', 'lsx-health-plan' ),
326
+                    'query_args' => array(
327
+                         'type' => array(
328
+                              'image/gif',
329
+                              'image/jpeg',
330
+                              'image/png',
331
+                         ),
332
+                    ),
333
+                    'preview_size' => 'lsx-thumbnail-wide',
334
+               )
335
+          );
336
+
337
+          // Title.
338
+          $cmb->add_group_field(
339
+               $gallery_group,
340
+               array(
341
+                    'name'         => __( 'oEmbed', 'lsx-health-plan' ),
342
+                    'id'           => $this->slug . '_gallery_embed',
343
+                    'type'         => 'text',
344
+                    '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' ),
345
+               )
346
+          );
347
+
348
+          $cmb->add_group_field(
349
+               $gallery_group,
350
+               array(
351
+                    'name'         => __( 'External Media', 'lsx-health-plan' ),
352
+                    'id'           => $this->slug . '_gallery_external',
353
+                    'type'         => 'textarea_code',
354
+                    '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' ),
355
+               )
356
+          );
357
+     }
358
+
359
+     /**
360
+      * Registers the general settings for the exercise.
361
+      *
362
+      * @return void
363
+      */
364
+     public function exercise_details() {
365
+          $cmb = new_cmb2_box(
366
+               array(
367
+                    'id'           => $this->slug . '_general_details_metabox',
368
+                    'title'        => __( 'Details', 'lsx-health-plan' ),
369
+                    'object_types' => array( $this->slug ),
370
+                    'context'      => 'normal',
371
+                    'priority'     => 'high',
372
+                    'show_names'   => true,
373
+               )
374
+          );
375
+
376
+          $cmb->add_field(
377
+               array(
378
+                    'name'    => __( 'Side', 'lsx-health-plan' ),
379
+                    'id'      => $this->slug . '_side',
380
+                    'type'    => 'select',
381
+                    'options' => array(
382
+                         ''      => __( 'Select', 'lsx-health-plan' ),
383
+                         'left'  => __( 'Left', 'lsx-health-plan' ),
384
+                         'right' => __( 'Right', 'lsx-health-plan' ),
385
+                    ),
386
+                    'desc'    => __( 'Select which side this exercise uses. ', 'lsx-health-plan' ),
387
+               )
388
+          );
389
+     }
390
+
391
+     /**
392
+      * Holds the array for the single exercise breadcrumbs.
393
+      *
394
+      * @var array $crumbs
395
+      * @return array
396
+      */
397
+     public function exercise_breadcrumb_filter( $crumbs ) {
398
+          $exercise  = \lsx_health_plan\functions\get_option( 'endpoint_exercise', 'exercise' );
399
+          $exercises = \lsx_health_plan\functions\get_option( 'endpoint_exercise_archive', 'exercise' );
400
+          $url       = get_post_type_archive_link( $exercise );
401
+
402
+          if ( is_singular( 'exercise' ) ) {
403
+               $exercise_name     = get_the_title();	
404
+               $term_obj_list     = get_the_terms( get_the_ID(), 'exercise-type' );
405
+               $exercise_type     = $term_obj_list[0]->name;
406
+               $exercise_type_url = get_term_link( $term_obj_list[0]->term_id );
407 407
 		
408
-			$crumbs[1] = array(
409
-				0 => $exercises,
410
-				1 => $url,
411
-			);
412
-			$crumbs[2] = array(
413
-				0 => $exercise_type,
414
-				1 => $exercise_type_url,
415
-			);
416
-			$crumbs[3] = array(
417
-				0 => $exercise_name,
418
-			);
419
-		}
420
-		if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) {
421
-			$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
422
-
423
-			$single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
424
-
425
-			$crumbs[1] = array(
426
-				0 => $exercises,
427
-				1 => $url,
428
-			);
429
-			$crumbs[2] = array(
430
-				0 => $single_term_title,
431
-			);
432
-		}
433
-		return $crumbs;
434
-	}
408
+               $crumbs[1] = array(
409
+                    0 => $exercises,
410
+                    1 => $url,
411
+               );
412
+               $crumbs[2] = array(
413
+                    0 => $exercise_type,
414
+                    1 => $exercise_type_url,
415
+               );
416
+               $crumbs[3] = array(
417
+                    0 => $exercise_name,
418
+               );
419
+          }
420
+          if ( is_tax( 'exercise-type' ) || is_tax( 'muscle-group' ) || is_tax( 'equipment' ) ) {
421
+               $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); 
422
+
423
+               $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name;
424
+
425
+               $crumbs[1] = array(
426
+                    0 => $exercises,
427
+                    1 => $url,
428
+               );
429
+               $crumbs[2] = array(
430
+                    0 => $single_term_title,
431
+               );
432
+          }
433
+          return $crumbs;
434
+     }
435 435
 }
Please login to merge, or discard this patch.