@@ -11,29 +11,29 @@ discard block |
||
| 11 | 11 | * @return void |
| 12 | 12 | */ |
| 13 | 13 | function lsx_health_plan_workout_box() { |
| 14 | - if ( ! post_type_exists( 'workout' ) ) { |
|
| 15 | - return; |
|
| 16 | - } |
|
| 17 | - $intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false ); |
|
| 18 | - ?> |
|
| 14 | + if ( ! post_type_exists( 'workout' ) ) { |
|
| 15 | + return; |
|
| 16 | + } |
|
| 17 | + $intro_text = \lsx_health_plan\functions\get_option( 'workout_intro', false ); |
|
| 18 | + ?> |
|
| 19 | 19 | <div class="workout-instructions"> |
| 20 | 20 | <div class="row"> |
| 21 | 21 | <div class="col-md-12"> |
| 22 | 22 | <?php |
| 23 | - if ( false !== $intro_text ) { |
|
| 24 | - ?> |
|
| 23 | + if ( false !== $intro_text ) { |
|
| 24 | + ?> |
|
| 25 | 25 | <div class="excerpt"> |
| 26 | 26 | <p><?php echo wp_kses_post( wpautop( $intro_text ) ); ?></p> |
| 27 | 27 | </div> |
| 28 | 28 | <?php |
| 29 | - } else { |
|
| 30 | - ?> |
|
| 29 | + } else { |
|
| 30 | + ?> |
|
| 31 | 31 | <div class="content-intro"> |
| 32 | 32 | <h3><?php esc_html_e( "Don't forget your warm up!", 'lsx-health-plan' ); ?></h3> |
| 33 | 33 | <p><?php esc_html_e( 'Be sure to do the warm-up before every workout session.', 'lsx-health-plan' ); ?></p> |
| 34 | 34 | </div> |
| 35 | 35 | <?php |
| 36 | - } ?> |
|
| 36 | + } ?> |
|
| 37 | 37 | </div> |
| 38 | 38 | </div> |
| 39 | 39 | </div> |
@@ -46,28 +46,28 @@ discard block |
||
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | 48 | function lsx_health_plan_meal_box() { |
| 49 | - if ( ! post_type_exists( 'meal' ) ) { |
|
| 50 | - return; |
|
| 51 | - } |
|
| 52 | - ?> |
|
| 49 | + if ( ! post_type_exists( 'meal' ) ) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 52 | + ?> |
|
| 53 | 53 | <div class="col-md-4" > |
| 54 | 54 | <div class="lsx-health-plan-box"> |
| 55 | 55 | <h3 class="title meal-plan-title title-lined"><?php esc_html_e( 'Your Meal Plan', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'meal.svg' ); ?></h3> |
| 56 | 56 | <div class="spacer"></div> |
| 57 | 57 | <?php |
| 58 | - $intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false ); |
|
| 59 | - if ( false !== $intro_text ) { |
|
| 60 | - ?> |
|
| 58 | + $intro_text = \lsx_health_plan\functions\get_option( 'meal_plan_intro', false ); |
|
| 59 | + if ( false !== $intro_text ) { |
|
| 60 | + ?> |
|
| 61 | 61 | <div class="excerpt"> |
| 62 | 62 | <p><?php echo wp_kses_post( $intro_text ); ?></p> |
| 63 | 63 | </div> |
| 64 | 64 | <?php |
| 65 | - } |
|
| 66 | - $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
| 67 | - if ( false === $meal ) { |
|
| 68 | - $meal = 'meal'; |
|
| 69 | - } |
|
| 70 | - ?> |
|
| 65 | + } |
|
| 66 | + $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
| 67 | + if ( false === $meal ) { |
|
| 68 | + $meal = 'meal'; |
|
| 69 | + } |
|
| 70 | + ?> |
|
| 71 | 71 | <a href="<?php the_permalink(); ?><?php echo esc_attr( $meal ); ?>/" class="btn"><?php esc_html_e( 'View your meal plan', 'lsx-health-plan' ); ?></a> |
| 72 | 72 | </div> |
| 73 | 73 | </div> |
@@ -80,28 +80,28 @@ discard block |
||
| 80 | 80 | * @return void |
| 81 | 81 | */ |
| 82 | 82 | function lsx_health_plan_recipe_box() { |
| 83 | - if ( ! post_type_exists( 'recipe' ) ) { |
|
| 84 | - return; |
|
| 85 | - } |
|
| 86 | - ?> |
|
| 83 | + if ( ! post_type_exists( 'recipe' ) ) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | + ?> |
|
| 87 | 87 | <div class="col-md-4" > |
| 88 | 88 | <div class="lsx-health-plan-box"> |
| 89 | 89 | <h3 class="title recipes-title title-lined"><?php esc_html_e( 'Recipes', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'recipes.svg' ); ?></h3> |
| 90 | 90 | <div class="spacer"></div> |
| 91 | 91 | <?php |
| 92 | - $intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false ); |
|
| 93 | - if ( false !== $intro_text ) { |
|
| 94 | - ?> |
|
| 92 | + $intro_text = \lsx_health_plan\functions\get_option( 'recipes_intro', false ); |
|
| 93 | + if ( false !== $intro_text ) { |
|
| 94 | + ?> |
|
| 95 | 95 | <div class="excerpt"> |
| 96 | 96 | <p><?php echo wp_kses_post( $intro_text ); ?></p> |
| 97 | 97 | </div> |
| 98 | 98 | <?php |
| 99 | - } |
|
| 100 | - $recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false ); |
|
| 101 | - if ( false === $recipes ) { |
|
| 102 | - $recipes = 'recipes'; |
|
| 103 | - } |
|
| 104 | - ?> |
|
| 99 | + } |
|
| 100 | + $recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false ); |
|
| 101 | + if ( false === $recipes ) { |
|
| 102 | + $recipes = 'recipes'; |
|
| 103 | + } |
|
| 104 | + ?> |
|
| 105 | 105 | <a href="<?php the_permalink(); ?><?php echo esc_attr( $recipes ); ?>/" class="btn"><?php esc_html_e( 'View all recipes', 'lsx-health-plan' ); ?></a> |
| 106 | 106 | </div> |
| 107 | 107 | </div> |
@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | * @return void |
| 115 | 115 | */ |
| 116 | 116 | function lsx_health_plan_downloads_box() { |
| 117 | - global $current_user; |
|
| 118 | - ?> |
|
| 117 | + global $current_user; |
|
| 118 | + ?> |
|
| 119 | 119 | <div class="col-md-4 day-download-box" > |
| 120 | 120 | <div class="lsx-health-plan-box"> |
| 121 | 121 | <h3 class="title downloads-title title-lined"><?php esc_html_e( 'Downloads', 'lsx-health-plan' ); ?><?php lsx_get_svg_icon( 'download.svg' ); ?></h3> |
@@ -123,13 +123,13 @@ discard block |
||
| 123 | 123 | <div class="download-list"> |
| 124 | 124 | <ul> |
| 125 | 125 | <?php |
| 126 | - $downloads = \lsx_health_plan\functions\get_downloads(); |
|
| 127 | - if ( ! empty( $downloads ) ) { |
|
| 128 | - foreach ( $downloads as $download ) { |
|
| 129 | - echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' ); |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - ?> |
|
| 126 | + $downloads = \lsx_health_plan\functions\get_downloads(); |
|
| 127 | + if ( ! empty( $downloads ) ) { |
|
| 128 | + foreach ( $downloads as $download ) { |
|
| 129 | + echo wp_kses_post( '<li><a href=""><i class="fa fa-file-pdf"></i>' . do_shortcode( '[download id="' . $download . '"]' ) . '</a></li>' ); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + ?> |
|
| 133 | 133 | </ul> |
| 134 | 134 | </div> |
| 135 | 135 | </div> |
@@ -144,15 +144,15 @@ discard block |
||
| 144 | 144 | * @return void |
| 145 | 145 | */ |
| 146 | 146 | function lsx_health_plan_nav_class( $tab = '' ) { |
| 147 | - $nav_classes = array(); |
|
| 148 | - if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) { |
|
| 149 | - $nav_classes[] = 'active'; |
|
| 150 | - } elseif ( lsx_health_plan_is_current_tab( $tab ) ) { |
|
| 151 | - $nav_classes[] = 'active'; |
|
| 152 | - } |
|
| 153 | - if ( ! empty( $nav_classes ) ) { |
|
| 154 | - echo wp_kses_post( implode( ' ', $nav_classes ) ); |
|
| 155 | - } |
|
| 147 | + $nav_classes = array(); |
|
| 148 | + if ( function_exists( 'is_wc_endpoint_url' ) && 'edit-account' === $tab && is_wc_endpoint_url( 'edit-account' ) ) { |
|
| 149 | + $nav_classes[] = 'active'; |
|
| 150 | + } elseif ( lsx_health_plan_is_current_tab( $tab ) ) { |
|
| 151 | + $nav_classes[] = 'active'; |
|
| 152 | + } |
|
| 153 | + if ( ! empty( $nav_classes ) ) { |
|
| 154 | + echo wp_kses_post( implode( ' ', $nav_classes ) ); |
|
| 155 | + } |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -161,34 +161,34 @@ discard block |
||
| 161 | 161 | * @return void |
| 162 | 162 | */ |
| 163 | 163 | function lsx_health_plan_my_profile_tabs() { |
| 164 | - ?> |
|
| 164 | + ?> |
|
| 165 | 165 | <div id="account-nav"> |
| 166 | 166 | <ul class="nav nav-pills"> |
| 167 | 167 | <li class=" |
| 168 | 168 | <?php |
| 169 | - if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) { |
|
| 170 | - echo esc_attr( 'active' ); |
|
| 171 | - } |
|
| 172 | - ?> |
|
| 169 | + if ( ( function_exists( 'is_wc_endpoint_url' ) && ! is_wc_endpoint_url( 'edit-account' ) ) || ! function_exists( 'is_wc_endpoint_url' ) ) { |
|
| 170 | + echo esc_attr( 'active' ); |
|
| 171 | + } |
|
| 172 | + ?> |
|
| 173 | 173 | "><a class="my-plan-tab" href="<?php the_permalink(); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a></li> |
| 174 | 174 | <?php |
| 175 | - if ( function_exists( 'WC' ) ) { |
|
| 176 | - ?> |
|
| 175 | + if ( function_exists( 'WC' ) ) { |
|
| 176 | + ?> |
|
| 177 | 177 | <li class=" |
| 178 | 178 | <?php |
| 179 | - if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) { |
|
| 180 | - echo esc_attr( 'active' ); |
|
| 181 | - } |
|
| 182 | - ?> |
|
| 179 | + if ( function_exists( 'is_wc_endpoint_url' ) && is_wc_endpoint_url( 'edit-account' ) ) { |
|
| 180 | + echo esc_attr( 'active' ); |
|
| 181 | + } |
|
| 182 | + ?> |
|
| 183 | 183 | "><a class="account-details-tab" href="<?php the_permalink(); ?>edit-account/"><?php esc_html_e( 'Account Details', 'lsx-health-plan' ); ?></a></li> |
| 184 | 184 | <?php |
| 185 | - } |
|
| 186 | - if ( is_user_logged_in() ) { |
|
| 187 | - ?> |
|
| 185 | + } |
|
| 186 | + if ( is_user_logged_in() ) { |
|
| 187 | + ?> |
|
| 188 | 188 | <li class=""><a class="logout-tab" href="<?php echo esc_url( wp_logout_url( get_permalink() ) ); ?>"><?php esc_html_e( 'Logout', 'lsx-health-plan' ); ?></a></li> |
| 189 | 189 | <?php |
| 190 | - } |
|
| 191 | - ?> |
|
| 190 | + } |
|
| 191 | + ?> |
|
| 192 | 192 | </ul> |
| 193 | 193 | </div> |
| 194 | 194 | <?php |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @return void |
| 201 | 201 | */ |
| 202 | 202 | function lsx_health_plan_my_profile_box() { |
| 203 | - ?> |
|
| 203 | + ?> |
|
| 204 | 204 | <div class="lsx-health-plan my-profile-block wp-block-cover alignfull"> |
| 205 | 205 | <div class="wp-block-cover__inner-container"> |
| 206 | 206 | <h2><?php esc_html_e( 'My Dashboard', 'lsx-health-plan' ); ?></h2> |
@@ -210,14 +210,14 @@ discard block |
||
| 210 | 210 | <div class="profile-navigation"> |
| 211 | 211 | <div class="profile-photo"> |
| 212 | 212 | <?php |
| 213 | - global $current_user; |
|
| 214 | - if ( function_exists( 'WC' ) ) { |
|
| 215 | - get_current_user(); |
|
| 216 | - } |
|
| 217 | - if ( class_exists( 'WP_User_Avatar_Setup' ) ) { |
|
| 218 | - echo get_avatar( $current_user->ID, 240 ); |
|
| 219 | - } |
|
| 220 | - ?> |
|
| 213 | + global $current_user; |
|
| 214 | + if ( function_exists( 'WC' ) ) { |
|
| 215 | + get_current_user(); |
|
| 216 | + } |
|
| 217 | + if ( class_exists( 'WP_User_Avatar_Setup' ) ) { |
|
| 218 | + echo get_avatar( $current_user->ID, 240 ); |
|
| 219 | + } |
|
| 220 | + ?> |
|
| 221 | 221 | </div> |
| 222 | 222 | </div> |
| 223 | 223 | <?php } ?> |
@@ -225,88 +225,88 @@ discard block |
||
| 225 | 225 | <div class="profile-details"> |
| 226 | 226 | <h1 class="title-lined has-text-color"><?php echo esc_html( $current_user->display_name ); ?></h1> |
| 227 | 227 | <?php |
| 228 | - $disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
| 229 | - if ( 'on' !== $disable_stats && function_exists( 'WC' ) ) { |
|
| 228 | + $disable_stats = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
| 229 | + if ( 'on' !== $disable_stats && function_exists( 'WC' ) ) { |
|
| 230 | 230 | |
| 231 | - $is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false ); |
|
| 232 | - $is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false ); |
|
| 233 | - $is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false ); |
|
| 234 | - $is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false ); |
|
| 231 | + $is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false ); |
|
| 232 | + $is_height_disabled = \lsx_health_plan\functions\get_option( 'disable_height_checkbox', false ); |
|
| 233 | + $is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false ); |
|
| 234 | + $is_bmi_disabled = \lsx_health_plan\functions\get_option( 'disable_bmi_checkbox', false ); |
|
| 235 | 235 | |
| 236 | - $weight = get_user_meta( get_current_user_id(), 'weight', true ); |
|
| 237 | - $waist = get_user_meta( get_current_user_id(), 'waist', true ); |
|
| 238 | - $height = get_user_meta( get_current_user_id(), 'height', true ); |
|
| 236 | + $weight = get_user_meta( get_current_user_id(), 'weight', true ); |
|
| 237 | + $waist = get_user_meta( get_current_user_id(), 'waist', true ); |
|
| 238 | + $height = get_user_meta( get_current_user_id(), 'height', true ); |
|
| 239 | 239 | |
| 240 | - $height_m = 0; |
|
| 241 | - if ( is_numeric( $height ) ) { |
|
| 242 | - $height_m = $height / 100; |
|
| 243 | - } |
|
| 240 | + $height_m = 0; |
|
| 241 | + if ( is_numeric( $height ) ) { |
|
| 242 | + $height_m = $height / 100; |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - if ( 1 < $weight && 1 < $height_m ) { |
|
| 246 | - $bmi = $weight / ( $height_m * $height_m ); |
|
| 247 | - $bmi = number_format( $bmi, 1 ); |
|
| 248 | - } else { |
|
| 249 | - $bmi = __( 'Add more data', 'lsx-health-plan' ); |
|
| 250 | - } |
|
| 245 | + if ( 1 < $weight && 1 < $height_m ) { |
|
| 246 | + $bmi = $weight / ( $height_m * $height_m ); |
|
| 247 | + $bmi = number_format( $bmi, 1 ); |
|
| 248 | + } else { |
|
| 249 | + $bmi = __( 'Add more data', 'lsx-health-plan' ); |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - ?> |
|
| 252 | + ?> |
|
| 253 | 253 | |
| 254 | 254 | <div> |
| 255 | 255 | <?php if ( 'on' !== $is_weight_disabled ) { ?> |
| 256 | 256 | <span><strong><?php esc_html_e( 'Weight:', 'lsx-health-plan' ); ?></strong> |
| 257 | 257 | <?php |
| 258 | - if ( '' !== $weight ) { |
|
| 259 | - echo wp_kses_post( $weight . ' kg' ); |
|
| 260 | - } else { |
|
| 261 | - echo '/'; |
|
| 262 | - } |
|
| 263 | - ?> |
|
| 258 | + if ( '' !== $weight ) { |
|
| 259 | + echo wp_kses_post( $weight . ' kg' ); |
|
| 260 | + } else { |
|
| 261 | + echo '/'; |
|
| 262 | + } |
|
| 263 | + ?> |
|
| 264 | 264 | </span> |
| 265 | 265 | <?php } |
| 266 | - if ( 'on' !== $is_waist_disabled ) { |
|
| 267 | - ?> |
|
| 266 | + if ( 'on' !== $is_waist_disabled ) { |
|
| 267 | + ?> |
|
| 268 | 268 | <span><strong><?php esc_html_e( 'Waist:', 'lsx-health-plan' ); ?></strong> |
| 269 | 269 | <?php |
| 270 | - if ( '' !== $waist ) { |
|
| 271 | - echo wp_kses_post( $waist . ' cm' ); |
|
| 272 | - } else { |
|
| 273 | - echo '/'; |
|
| 274 | - } |
|
| 275 | - ?> |
|
| 270 | + if ( '' !== $waist ) { |
|
| 271 | + echo wp_kses_post( $waist . ' cm' ); |
|
| 272 | + } else { |
|
| 273 | + echo '/'; |
|
| 274 | + } |
|
| 275 | + ?> |
|
| 276 | 276 | </span> |
| 277 | 277 | <?php } |
| 278 | - if ( 'on' !== $is_bmi_disabled ) { |
|
| 279 | - ?> |
|
| 278 | + if ( 'on' !== $is_bmi_disabled ) { |
|
| 279 | + ?> |
|
| 280 | 280 | <span><strong><?php esc_html_e( 'BMI:', 'lsx-health-plan' ); ?></strong> |
| 281 | 281 | <?php |
| 282 | - if ( '' !== $bmi ) { |
|
| 283 | - echo wp_kses_post( $bmi ); |
|
| 284 | - } else { |
|
| 285 | - echo '/'; |
|
| 286 | - } |
|
| 287 | - ?> |
|
| 282 | + if ( '' !== $bmi ) { |
|
| 283 | + echo wp_kses_post( $bmi ); |
|
| 284 | + } else { |
|
| 285 | + echo '/'; |
|
| 286 | + } |
|
| 287 | + ?> |
|
| 288 | 288 | </span> |
| 289 | 289 | <?php } ?> |
| 290 | 290 | </div> |
| 291 | 291 | <?php |
| 292 | - } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - // Only display the edit account link if woocommerce is active. |
|
| 295 | - if ( function_exists( 'WC' ) ) { |
|
| 296 | - ?> |
|
| 294 | + // Only display the edit account link if woocommerce is active. |
|
| 295 | + if ( function_exists( 'WC' ) ) { |
|
| 296 | + ?> |
|
| 297 | 297 | <div class="edit-profile"> |
| 298 | 298 | <?php |
| 299 | - if ( function_exists( 'wc_get_page_id' ) ) { |
|
| 300 | - $url_id = wc_get_page_id( 'myaccount' ); |
|
| 301 | - } else { |
|
| 302 | - $url_id = ''; |
|
| 303 | - } |
|
| 304 | - ?> |
|
| 299 | + if ( function_exists( 'wc_get_page_id' ) ) { |
|
| 300 | + $url_id = wc_get_page_id( 'myaccount' ); |
|
| 301 | + } else { |
|
| 302 | + $url_id = ''; |
|
| 303 | + } |
|
| 304 | + ?> |
|
| 305 | 305 | <a href="<?php echo esc_url( get_permalink( $url_id ) ); ?>edit-account/"><?php esc_html_e( 'Edit', 'lsx-health-plan' ); ?></a> |
| 306 | 306 | </div> |
| 307 | 307 | <?php |
| 308 | - } |
|
| 309 | - ?> |
|
| 308 | + } |
|
| 309 | + ?> |
|
| 310 | 310 | </div> |
| 311 | 311 | <?php } ?> |
| 312 | 312 | </section> |
@@ -322,75 +322,75 @@ discard block |
||
| 322 | 322 | * @return void |
| 323 | 323 | */ |
| 324 | 324 | function lsx_health_plan_all_plans_block() { |
| 325 | - global $post, $product; |
|
| 326 | - |
|
| 327 | - // If this is the my plan page, and the user is logged out, show to WC login. |
|
| 328 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
| 329 | - if ( function_exists( 'is_wc_endpoint_url' ) && false !== $plan_slug && is_page( $plan_slug ) && ! is_user_logged_in() ) { |
|
| 330 | - echo wp_kses_post( '<div id="edit-account-tab"><div class="edit-account-section">' ); |
|
| 331 | - echo wp_kses_post( '<h2 class="title-lined my-plan"></h2>' ); |
|
| 332 | - echo do_shortcode( '[woocommerce_my_account]' ); |
|
| 333 | - echo wp_kses_post( '</div></div>' ); |
|
| 334 | - return; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - $args = array( |
|
| 338 | - 'orderby' => 'menu_order', |
|
| 339 | - 'order' => 'ASC', |
|
| 340 | - 'post_type' => 'plan', |
|
| 341 | - 'nopagin' => true, |
|
| 342 | - 'post_parent' => 0, |
|
| 343 | - ); |
|
| 344 | - |
|
| 345 | - if ( function_exists( '\lsx_health_plan\functions\woocommerce\get_membership_products' ) ) { |
|
| 346 | - $product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products(); |
|
| 347 | - if ( ! empty( $product_ids ) ) { |
|
| 348 | - $args['meta_query'] = array( |
|
| 349 | - 'relation' => 'OR', |
|
| 350 | - array( |
|
| 351 | - 'key' => '_plan_product_id', |
|
| 352 | - 'value' => $product_ids, |
|
| 353 | - 'compare' => 'IN', |
|
| 354 | - ), |
|
| 355 | - array( |
|
| 356 | - 'key' => '_plan_product_id', |
|
| 357 | - 'compare' => 'NOT EXISTS', |
|
| 358 | - ), |
|
| 359 | - ); |
|
| 360 | - } |
|
| 361 | - } |
|
| 362 | - |
|
| 363 | - $the_query = new WP_Query( $args ); |
|
| 364 | - ?> |
|
| 325 | + global $post, $product; |
|
| 326 | + |
|
| 327 | + // If this is the my plan page, and the user is logged out, show to WC login. |
|
| 328 | + $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
| 329 | + if ( function_exists( 'is_wc_endpoint_url' ) && false !== $plan_slug && is_page( $plan_slug ) && ! is_user_logged_in() ) { |
|
| 330 | + echo wp_kses_post( '<div id="edit-account-tab"><div class="edit-account-section">' ); |
|
| 331 | + echo wp_kses_post( '<h2 class="title-lined my-plan"></h2>' ); |
|
| 332 | + echo do_shortcode( '[woocommerce_my_account]' ); |
|
| 333 | + echo wp_kses_post( '</div></div>' ); |
|
| 334 | + return; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + $args = array( |
|
| 338 | + 'orderby' => 'menu_order', |
|
| 339 | + 'order' => 'ASC', |
|
| 340 | + 'post_type' => 'plan', |
|
| 341 | + 'nopagin' => true, |
|
| 342 | + 'post_parent' => 0, |
|
| 343 | + ); |
|
| 344 | + |
|
| 345 | + if ( function_exists( '\lsx_health_plan\functions\woocommerce\get_membership_products' ) ) { |
|
| 346 | + $product_ids = \lsx_health_plan\functions\woocommerce\get_membership_products(); |
|
| 347 | + if ( ! empty( $product_ids ) ) { |
|
| 348 | + $args['meta_query'] = array( |
|
| 349 | + 'relation' => 'OR', |
|
| 350 | + array( |
|
| 351 | + 'key' => '_plan_product_id', |
|
| 352 | + 'value' => $product_ids, |
|
| 353 | + 'compare' => 'IN', |
|
| 354 | + ), |
|
| 355 | + array( |
|
| 356 | + 'key' => '_plan_product_id', |
|
| 357 | + 'compare' => 'NOT EXISTS', |
|
| 358 | + ), |
|
| 359 | + ); |
|
| 360 | + } |
|
| 361 | + } |
|
| 362 | + |
|
| 363 | + $the_query = new WP_Query( $args ); |
|
| 364 | + ?> |
|
| 365 | 365 | <div class="all-plans-block plan-grid block-all-plans-block"> |
| 366 | 366 | <div class="row"> |
| 367 | 367 | <?php |
| 368 | - if ( $the_query->have_posts() ) : |
|
| 369 | - while ( $the_query->have_posts() ) : |
|
| 370 | - $the_query->the_post(); |
|
| 371 | - lsx_entry_before(); |
|
| 372 | - $completed_class = ''; |
|
| 373 | - $linked_product = false; |
|
| 374 | - $restricted = false; |
|
| 375 | - $product = null; |
|
| 376 | - if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
| 377 | - $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
|
| 378 | - $linked_product = wc_get_product( $products[0] ); |
|
| 379 | - $product = $linked_product; |
|
| 380 | - } |
|
| 381 | - if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
| 382 | - $restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - if ( lsx_health_plan_is_plan_complete() ) { |
|
| 386 | - $completed_class = 'completed'; |
|
| 387 | - } |
|
| 388 | - $round_progress = ''; |
|
| 389 | - $completed_progress = '100'; |
|
| 390 | - if ( false === $restricted ) { |
|
| 391 | - $round_progress = round( \lsx_health_plan\functions\get_progress( get_the_ID() ), 0 ); |
|
| 392 | - } |
|
| 393 | - ?> |
|
| 368 | + if ( $the_query->have_posts() ) : |
|
| 369 | + while ( $the_query->have_posts() ) : |
|
| 370 | + $the_query->the_post(); |
|
| 371 | + lsx_entry_before(); |
|
| 372 | + $completed_class = ''; |
|
| 373 | + $linked_product = false; |
|
| 374 | + $restricted = false; |
|
| 375 | + $product = null; |
|
| 376 | + if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
| 377 | + $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
|
| 378 | + $linked_product = wc_get_product( $products[0] ); |
|
| 379 | + $product = $linked_product; |
|
| 380 | + } |
|
| 381 | + if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
| 382 | + $restricted = wc_memberships_is_post_content_restricted( get_the_ID() ) && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + if ( lsx_health_plan_is_plan_complete() ) { |
|
| 386 | + $completed_class = 'completed'; |
|
| 387 | + } |
|
| 388 | + $round_progress = ''; |
|
| 389 | + $completed_progress = '100'; |
|
| 390 | + if ( false === $restricted ) { |
|
| 391 | + $round_progress = round( \lsx_health_plan\functions\get_progress( get_the_ID() ), 0 ); |
|
| 392 | + } |
|
| 393 | + ?> |
|
| 394 | 394 | <div class="col-xs-12 col-sm-6 col-md-4"> |
| 395 | 395 | <article class="lsx-slot lsx-hp-shadow <?php echo esc_html( 'progress-') . $round_progress; ?>"> |
| 396 | 396 | <div class="plan-feature-img"> |
@@ -399,45 +399,45 @@ discard block |
||
| 399 | 399 | <?php } ?> |
| 400 | 400 | <a href="<?php echo esc_url( get_permalink() ); ?>"> |
| 401 | 401 | <?php |
| 402 | - $featured_image = get_the_post_thumbnail(); |
|
| 403 | - if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 404 | - the_post_thumbnail( 'lsx-thumbnail', array( |
|
| 405 | - 'class' => 'aligncenter', |
|
| 406 | - ) ); |
|
| 407 | - } else { |
|
| 408 | - ?> |
|
| 402 | + $featured_image = get_the_post_thumbnail(); |
|
| 403 | + if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 404 | + the_post_thumbnail( 'lsx-thumbnail', array( |
|
| 405 | + 'class' => 'aligncenter', |
|
| 406 | + ) ); |
|
| 407 | + } else { |
|
| 408 | + ?> |
|
| 409 | 409 | <img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
| 410 | 410 | <?php |
| 411 | - } |
|
| 412 | - ?> |
|
| 411 | + } |
|
| 412 | + ?> |
|
| 413 | 413 | </a> |
| 414 | 414 | </div> |
| 415 | 415 | <div class="content-box plan-content-box"> |
| 416 | 416 | <h3 class="plan id-<?php the_ID(); ?> <?php echo esc_attr( $completed_class ); ?>"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?></a></h3> |
| 417 | 417 | <?php |
| 418 | - echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) ); |
|
| 419 | - ?> |
|
| 418 | + echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) ); |
|
| 419 | + ?> |
|
| 420 | 420 | <?php |
| 421 | - if ( false !== $linked_product && false !== $restricted ) { |
|
| 422 | - echo wp_kses_post( $linked_product->get_price_html() ); |
|
| 423 | - } |
|
| 424 | - ?> |
|
| 421 | + if ( false !== $linked_product && false !== $restricted ) { |
|
| 422 | + echo wp_kses_post( $linked_product->get_price_html() ); |
|
| 423 | + } |
|
| 424 | + ?> |
|
| 425 | 425 | <div class="excerpt"> |
| 426 | 426 | <?php |
| 427 | - if ( ! has_excerpt() ) { |
|
| 428 | - $content = wp_trim_words( get_the_content(), 20 ); |
|
| 429 | - $content = '<p>' . $content . '</pre>'; |
|
| 430 | - } else { |
|
| 431 | - $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
| 432 | - } |
|
| 433 | - echo wp_kses_post( $content ); |
|
| 434 | - ?> |
|
| 427 | + if ( ! has_excerpt() ) { |
|
| 428 | + $content = wp_trim_words( get_the_content(), 20 ); |
|
| 429 | + $content = '<p>' . $content . '</pre>'; |
|
| 430 | + } else { |
|
| 431 | + $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
| 432 | + } |
|
| 433 | + echo wp_kses_post( $content ); |
|
| 434 | + ?> |
|
| 435 | 435 | </div> |
| 436 | 436 | <?php |
| 437 | - if ( false === $restricted ) { |
|
| 438 | - echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '" max="100"> ' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '% </progress><span>' . $round_progress . '%</span></span>' ); |
|
| 439 | - } |
|
| 440 | - ?> |
|
| 437 | + if ( false === $restricted ) { |
|
| 438 | + echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '" max="100"> ' . \lsx_health_plan\functions\get_progress( get_the_ID() ) . '% </progress><span>' . $round_progress . '%</span></span>' ); |
|
| 439 | + } |
|
| 440 | + ?> |
|
| 441 | 441 | </div> |
| 442 | 442 | </article> |
| 443 | 443 | </div> |
@@ -456,36 +456,36 @@ discard block |
||
| 456 | 456 | * @return void |
| 457 | 457 | */ |
| 458 | 458 | function lsx_health_plan_day_plan_block( $args = array() ) { |
| 459 | - $defaults = array( |
|
| 460 | - 'plan' => '', |
|
| 461 | - ); |
|
| 462 | - $args = wp_parse_args( $args, $defaults ); |
|
| 463 | - |
|
| 464 | - if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) { |
|
| 465 | - $sections = \lsx_health_plan\functions\plan\get_sections(); |
|
| 466 | - ?> |
|
| 459 | + $defaults = array( |
|
| 460 | + 'plan' => '', |
|
| 461 | + ); |
|
| 462 | + $args = wp_parse_args( $args, $defaults ); |
|
| 463 | + |
|
| 464 | + if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) { |
|
| 465 | + $sections = \lsx_health_plan\functions\plan\get_sections(); |
|
| 466 | + ?> |
|
| 467 | 467 | <div class="daily-plan-block day-grid"> |
| 468 | 468 | <?php |
| 469 | - foreach ( $sections as $section_key => $section_values ) { |
|
| 470 | - $defaults = array( |
|
| 471 | - 'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ), |
|
| 472 | - ); |
|
| 473 | - $section_args = wp_parse_args( $section_values, $defaults ); |
|
| 474 | - |
|
| 475 | - $completed_class = ''; |
|
| 476 | - if ( lsx_health_plan_is_day_complete() ) { |
|
| 477 | - $completed_class = 'completed'; |
|
| 478 | - } |
|
| 479 | - ?> |
|
| 469 | + foreach ( $sections as $section_key => $section_values ) { |
|
| 470 | + $defaults = array( |
|
| 471 | + 'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ), |
|
| 472 | + ); |
|
| 473 | + $section_args = wp_parse_args( $section_values, $defaults ); |
|
| 474 | + |
|
| 475 | + $completed_class = ''; |
|
| 476 | + if ( lsx_health_plan_is_day_complete() ) { |
|
| 477 | + $completed_class = 'completed'; |
|
| 478 | + } |
|
| 479 | + ?> |
|
| 480 | 480 | <a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>"> |
| 481 | 481 | <div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div> |
| 482 | 482 | </a> |
| 483 | 483 | <?php |
| 484 | - } |
|
| 485 | - ?> |
|
| 484 | + } |
|
| 485 | + ?> |
|
| 486 | 486 | </div> |
| 487 | 487 | <?php |
| 488 | - } |
|
| 488 | + } |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -495,44 +495,44 @@ discard block |
||
| 495 | 495 | * @return void |
| 496 | 496 | */ |
| 497 | 497 | function lsx_health_plan_week_plan_block( $args = array() ) { |
| 498 | - $defaults = array( |
|
| 499 | - 'show_downloads' => false, |
|
| 500 | - 'plan' => '', |
|
| 501 | - ); |
|
| 502 | - $args = wp_parse_args( $args, $defaults ); |
|
| 503 | - |
|
| 504 | - if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) { |
|
| 505 | - $groups = \lsx_health_plan\functions\plan\get_sections( true ); |
|
| 506 | - |
|
| 507 | - if ( ! empty( $groups ) ) { |
|
| 508 | - $counter = 1; |
|
| 509 | - $group_open = false; |
|
| 510 | - |
|
| 511 | - foreach ( $groups as $group_key => $sections ) { |
|
| 512 | - $collapse_class = ''; |
|
| 513 | - $group_title = \lsx_health_plan\functions\plan\get_group_title( $sections ); |
|
| 514 | - |
|
| 515 | - // Determine if the current week is complete. |
|
| 516 | - $day_ids = wp_list_pluck( $sections, 'title' ); |
|
| 517 | - if ( false === $group_open ) { |
|
| 518 | - if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) { |
|
| 519 | - $collapse_class = 'in'; |
|
| 520 | - $group_open = true; |
|
| 521 | - } elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) { |
|
| 522 | - $collapse_class = 'in'; |
|
| 523 | - $group_open = true; |
|
| 524 | - } |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - // Determine if there are any weekly downloads. |
|
| 528 | - $week_downloads_view = ''; |
|
| 529 | - if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) { |
|
| 530 | - $weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key ); |
|
| 531 | - if ( ! empty( $weekly_downloads ) ) { |
|
| 532 | - $week_downloads_view = 'week-downloads-view-on'; |
|
| 533 | - } |
|
| 534 | - } |
|
| 535 | - ?> |
|
| 498 | + $defaults = array( |
|
| 499 | + 'show_downloads' => false, |
|
| 500 | + 'plan' => '', |
|
| 501 | + ); |
|
| 502 | + $args = wp_parse_args( $args, $defaults ); |
|
| 503 | + |
|
| 504 | + if ( isset( $args['plan'] ) && '' !== $args['plan'] && \lsx_health_plan\functions\plan\has_sections( $args['plan'] ) ) { |
|
| 505 | + $groups = \lsx_health_plan\functions\plan\get_sections( true ); |
|
| 506 | + |
|
| 507 | + if ( ! empty( $groups ) ) { |
|
| 508 | + $counter = 1; |
|
| 509 | + $group_open = false; |
|
| 510 | + |
|
| 511 | + foreach ( $groups as $group_key => $sections ) { |
|
| 512 | + $collapse_class = ''; |
|
| 513 | + $group_title = \lsx_health_plan\functions\plan\get_group_title( $sections ); |
|
| 514 | + |
|
| 515 | + // Determine if the current week is complete. |
|
| 516 | + $day_ids = wp_list_pluck( $sections, 'title' ); |
|
| 517 | + if ( false === $group_open ) { |
|
| 518 | + if ( 1 === $counter && ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) { |
|
| 519 | + $collapse_class = 'in'; |
|
| 520 | + $group_open = true; |
|
| 521 | + } elseif ( ! \lsx_health_plan\functions\is_week_complete( false, $day_ids, $group_title ) ) { |
|
| 522 | + $collapse_class = 'in'; |
|
| 523 | + $group_open = true; |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + // Determine if there are any weekly downloads. |
|
| 528 | + $week_downloads_view = ''; |
|
| 529 | + if ( isset( $args['show_downloads'] ) && false !== $args['show_downloads'] ) { |
|
| 530 | + $weekly_downloads = \lsx_health_plan\functions\get_weekly_downloads( $group_key ); |
|
| 531 | + if ( ! empty( $weekly_downloads ) ) { |
|
| 532 | + $week_downloads_view = 'week-downloads-view-on'; |
|
| 533 | + } |
|
| 534 | + } |
|
| 535 | + ?> |
|
| 536 | 536 | <div class="daily-plan-block week-grid"> |
| 537 | 537 | <a href="#group-<?php echo esc_attr( $group_key ); ?>" data-toggle="collapse" class="week-title"><?php echo esc_attr( $group_title ); ?></a> |
| 538 | 538 | <div id="group-<?php echo esc_attr( $group_key ); ?>" class="week-row collapse <?php echo esc_attr( $collapse_class ); ?>"> |
@@ -546,46 +546,46 @@ discard block |
||
| 546 | 546 | <div class="week-meals-recipes-box-inner"> |
| 547 | 547 | <?php |
| 548 | 548 | |
| 549 | - foreach ( $sections as $section_key => $section_values ) { |
|
| 549 | + foreach ( $sections as $section_key => $section_values ) { |
|
| 550 | 550 | |
| 551 | - $defaults = array( |
|
| 552 | - 'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ), |
|
| 553 | - ); |
|
| 554 | - $section_args = wp_parse_args( $section_values, $defaults ); |
|
| 551 | + $defaults = array( |
|
| 552 | + 'title' => __( 'Day', 'lsx-health-plan' ) . ' ' . ( $section_key + 1 ), |
|
| 553 | + ); |
|
| 554 | + $section_args = wp_parse_args( $section_values, $defaults ); |
|
| 555 | 555 | |
| 556 | - $completed_class = ''; |
|
| 557 | - if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) { |
|
| 558 | - $completed_class = 'completed'; |
|
| 559 | - } |
|
| 560 | - if ( $section_args['rest_day_enabled'] && ! $section_args['connected_meals'] ) { |
|
| 561 | - ?> |
|
| 556 | + $completed_class = ''; |
|
| 557 | + if ( lsx_health_plan_is_day_complete( $args['plan'], $section_args['title'] ) ) { |
|
| 558 | + $completed_class = 'completed'; |
|
| 559 | + } |
|
| 560 | + if ( $section_args['rest_day_enabled'] && ! $section_args['connected_meals'] ) { |
|
| 561 | + ?> |
|
| 562 | 562 | <span class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>"> |
| 563 | 563 | <div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div> |
| 564 | 564 | </span> |
| 565 | 565 | <?php |
| 566 | - } else { |
|
| 567 | - ?> |
|
| 566 | + } else { |
|
| 567 | + ?> |
|
| 568 | 568 | <a href="<?php echo esc_attr( \lsx_health_plan\functions\plan\get_permalink( $args['plan'], $section_args['title'] ) ); ?>" class="day id-<?php echo esc_attr( $section_key + 1 ); ?> <?php echo esc_attr( $completed_class ); ?>"> |
| 569 | 569 | <div class="plan-content"><?php echo esc_attr( $section_args['title'] ); ?></div> |
| 570 | 570 | </a> |
| 571 | 571 | <?php |
| 572 | - } |
|
| 573 | - } |
|
| 574 | - ?> |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + ?> |
|
| 575 | 575 | </div> |
| 576 | 576 | </div> |
| 577 | 577 | <?php |
| 578 | - if ( ! empty( $week_downloads_view ) ) { |
|
| 579 | - lsx_health_plan_weekly_downloads( $weekly_downloads ); |
|
| 580 | - } |
|
| 581 | - ?> |
|
| 578 | + if ( ! empty( $week_downloads_view ) ) { |
|
| 579 | + lsx_health_plan_weekly_downloads( $weekly_downloads ); |
|
| 580 | + } |
|
| 581 | + ?> |
|
| 582 | 582 | </div> |
| 583 | 583 | </div> |
| 584 | 584 | </div> |
| 585 | 585 | <?php |
| 586 | - } |
|
| 587 | - } |
|
| 588 | - } |
|
| 586 | + } |
|
| 587 | + } |
|
| 588 | + } |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -595,22 +595,22 @@ discard block |
||
| 595 | 595 | * @return void |
| 596 | 596 | */ |
| 597 | 597 | function lsx_health_plan_weekly_downloads( $weekly_downloads = array() ) { |
| 598 | - if ( ! empty( $weekly_downloads ) ) { |
|
| 599 | - ?> |
|
| 598 | + if ( ! empty( $weekly_downloads ) ) { |
|
| 599 | + ?> |
|
| 600 | 600 | <div class="week-download-box"> |
| 601 | 601 | <h3 class="title"><?php lsx_get_svg_icon( 'download.svg' ); ?><?php echo esc_html_e( 'Downloads', 'lsx-health-plan' ); ?></h3> |
| 602 | 602 | <ul class="week-download-box-list"> |
| 603 | 603 | <?php |
| 604 | - foreach ( $weekly_downloads as $weekly_download ) { |
|
| 605 | - ?> |
|
| 604 | + foreach ( $weekly_downloads as $weekly_download ) { |
|
| 605 | + ?> |
|
| 606 | 606 | <li><?php echo wp_kses_post( do_shortcode( '[download id="' . $weekly_download . '"]' ) ); ?></li> |
| 607 | 607 | <?php |
| 608 | - } |
|
| 609 | - ?> |
|
| 608 | + } |
|
| 609 | + ?> |
|
| 610 | 610 | </ul> |
| 611 | 611 | </div> |
| 612 | 612 | <?php |
| 613 | - } |
|
| 613 | + } |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | /** |
@@ -619,9 +619,9 @@ discard block |
||
| 619 | 619 | * @return void |
| 620 | 620 | */ |
| 621 | 621 | function lsx_health_plan_items( $args = array() ) { |
| 622 | - global $shortcode_args; |
|
| 623 | - $shortcode_args = $args; |
|
| 624 | - include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php'; |
|
| 622 | + global $shortcode_args; |
|
| 623 | + $shortcode_args = $args; |
|
| 624 | + include LSX_HEALTH_PLAN_PATH . '/templates/partials/shortcode-loop.php'; |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | /** |
@@ -630,10 +630,10 @@ discard block |
||
| 630 | 630 | * @return void |
| 631 | 631 | */ |
| 632 | 632 | function lsx_health_plan_featured_video_block() { |
| 633 | - if ( ! post_type_exists( 'video' ) ) { |
|
| 634 | - return; |
|
| 635 | - } |
|
| 636 | - include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php'; |
|
| 633 | + if ( ! post_type_exists( 'video' ) ) { |
|
| 634 | + return; |
|
| 635 | + } |
|
| 636 | + include LSX_HEALTH_PLAN_PATH . '/templates/featured-videos.php'; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | /** |
@@ -642,10 +642,10 @@ discard block |
||
| 642 | 642 | * @return void |
| 643 | 643 | */ |
| 644 | 644 | function lsx_health_plan_featured_recipes_block() { |
| 645 | - if ( ! post_type_exists( 'recipe' ) ) { |
|
| 646 | - return; |
|
| 647 | - } |
|
| 648 | - include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php'; |
|
| 645 | + if ( ! post_type_exists( 'recipe' ) ) { |
|
| 646 | + return; |
|
| 647 | + } |
|
| 648 | + include LSX_HEALTH_PLAN_PATH . '/templates/featured-recipes.php'; |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | /** |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | * @return void |
| 655 | 655 | */ |
| 656 | 656 | function lsx_health_plan_featured_tips_block() { |
| 657 | - include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php'; |
|
| 657 | + include LSX_HEALTH_PLAN_PATH . '/templates/featured-tips.php'; |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
@@ -664,11 +664,11 @@ discard block |
||
| 664 | 664 | * @return void |
| 665 | 665 | */ |
| 666 | 666 | function lsx_health_plan_day_button() { |
| 667 | - if ( lsx_health_plan_is_day_complete() ) { |
|
| 668 | - lsx_health_plan_unlock_button(); |
|
| 669 | - } else { |
|
| 670 | - lsx_health_plan_complete_button(); |
|
| 671 | - } |
|
| 667 | + if ( lsx_health_plan_is_day_complete() ) { |
|
| 668 | + lsx_health_plan_unlock_button(); |
|
| 669 | + } else { |
|
| 670 | + lsx_health_plan_complete_button(); |
|
| 671 | + } |
|
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | * @return void |
| 678 | 678 | */ |
| 679 | 679 | function lsx_health_plan_complete_button() { |
| 680 | - ?> |
|
| 680 | + ?> |
|
| 681 | 681 | <div class="single-plan-inner-buttons"> |
| 682 | 682 | <form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn"> |
| 683 | 683 | <?php wp_nonce_field( 'complete', 'lsx-health-plan-actions' ); ?> |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | * @return void |
| 696 | 696 | */ |
| 697 | 697 | function lsx_health_plan_unlock_button() { |
| 698 | - ?> |
|
| 698 | + ?> |
|
| 699 | 699 | <div class="single-plan-inner-buttons"> |
| 700 | 700 | <form action="<?php the_permalink(); ?>" method="post" class="form-complete-day complete-plan-btn"> |
| 701 | 701 | <?php wp_nonce_field( 'unlock', 'lsx-health-plan-actions' ); ?> |
@@ -714,10 +714,10 @@ discard block |
||
| 714 | 714 | * @return void |
| 715 | 715 | */ |
| 716 | 716 | function lsx_health_plan_single_nav() { |
| 717 | - $tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' ); |
|
| 718 | - if ( '' !== $tab_template_path ) { |
|
| 719 | - require $tab_template_path; |
|
| 720 | - } |
|
| 717 | + $tab_template_path = apply_filters( 'lsx_health_plan_single_nav_path', LSX_HEALTH_PLAN_PATH . '/templates/single-plan-tabs.php' ); |
|
| 718 | + if ( '' !== $tab_template_path ) { |
|
| 719 | + require $tab_template_path; |
|
| 720 | + } |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -727,32 +727,32 @@ discard block |
||
| 727 | 727 | * @return void |
| 728 | 728 | */ |
| 729 | 729 | function lsx_health_plan_single_tabs() { |
| 730 | - $endpoint = get_query_var( 'endpoint' ); |
|
| 731 | - switch ( $endpoint ) { |
|
| 732 | - case 'meal': |
|
| 733 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php'; |
|
| 734 | - break; |
|
| 735 | - |
|
| 736 | - case 'recipes': |
|
| 737 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php'; |
|
| 738 | - break; |
|
| 739 | - |
|
| 740 | - case 'workout': |
|
| 741 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php'; |
|
| 742 | - break; |
|
| 743 | - |
|
| 744 | - case 'warm-up': |
|
| 745 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php'; |
|
| 746 | - break; |
|
| 747 | - |
|
| 748 | - default: |
|
| 749 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php'; |
|
| 750 | - break; |
|
| 751 | - } |
|
| 752 | - $tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path ); |
|
| 753 | - if ( '' !== $tab_template_path ) { |
|
| 754 | - include $tab_template_path; |
|
| 755 | - } |
|
| 730 | + $endpoint = get_query_var( 'endpoint' ); |
|
| 731 | + switch ( $endpoint ) { |
|
| 732 | + case 'meal': |
|
| 733 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-meal.php'; |
|
| 734 | + break; |
|
| 735 | + |
|
| 736 | + case 'recipes': |
|
| 737 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-recipes.php'; |
|
| 738 | + break; |
|
| 739 | + |
|
| 740 | + case 'workout': |
|
| 741 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-workout.php'; |
|
| 742 | + break; |
|
| 743 | + |
|
| 744 | + case 'warm-up': |
|
| 745 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-warm-up.php'; |
|
| 746 | + break; |
|
| 747 | + |
|
| 748 | + default: |
|
| 749 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . '/templates/tab-content-plan.php'; |
|
| 750 | + break; |
|
| 751 | + } |
|
| 752 | + $tab_template_path = apply_filters( 'lsx_health_plan_single_tab_path', $tab_template_path ); |
|
| 753 | + if ( '' !== $tab_template_path ) { |
|
| 754 | + include $tab_template_path; |
|
| 755 | + } |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | /** |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | * @return void |
| 762 | 762 | */ |
| 763 | 763 | function lsx_health_plan_recipe_data() { |
| 764 | - include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php'; |
|
| 764 | + include LSX_HEALTH_PLAN_PATH . '/templates/table-recipe-data.php'; |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -770,11 +770,11 @@ discard block |
||
| 770 | 770 | * @return recipe_type |
| 771 | 771 | */ |
| 772 | 772 | function lsx_health_plan_recipe_type() { |
| 773 | - $term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' ); |
|
| 774 | - $recipe_type = $term_obj_list[0]->name; |
|
| 775 | - if ( ! empty( $recipe_type ) ) { |
|
| 776 | - return $recipe_type; |
|
| 777 | - } |
|
| 773 | + $term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' ); |
|
| 774 | + $recipe_type = $term_obj_list[0]->name; |
|
| 775 | + if ( ! empty( $recipe_type ) ) { |
|
| 776 | + return $recipe_type; |
|
| 777 | + } |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | /** |
@@ -785,35 +785,35 @@ discard block |
||
| 785 | 785 | * @return void |
| 786 | 786 | */ |
| 787 | 787 | function lsx_health_plan_workout_video_play_button( $m, $group, $echo = true ) { |
| 788 | - $workout_video = ''; |
|
| 789 | - $giphy = ''; |
|
| 790 | - $youtube = ''; |
|
| 791 | - if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) { |
|
| 792 | - $workout_video = esc_html( $group['connected_videos'] ); |
|
| 793 | - $giphy = get_post_meta( $workout_video, 'video_giphy_source', true ); |
|
| 794 | - $youtube = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) ); |
|
| 795 | - $content = get_post_field( 'post_content', $workout_video ); |
|
| 796 | - $play_button = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
| 797 | - |
|
| 798 | - $modal_body = ''; |
|
| 799 | - if ( ! empty( $giphy ) ) { |
|
| 800 | - $giphy = \lsx_health_plan\functions\get_video_url( $giphy ); |
|
| 801 | - $modal_body = $giphy; // WPCS: XSS OK. |
|
| 802 | - } elseif ( ! empty( $youtube ) ) { |
|
| 803 | - $modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK. |
|
| 804 | - 'width' => 480, |
|
| 805 | - ) ); |
|
| 806 | - } |
|
| 807 | - $modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>'; |
|
| 808 | - $modal_body .= $content; |
|
| 809 | - \lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body ); |
|
| 810 | - |
|
| 811 | - if ( true === $echo ) { |
|
| 812 | - echo wp_kses_post( $play_button ); |
|
| 813 | - } else { |
|
| 814 | - return $play_button; |
|
| 815 | - } |
|
| 816 | - } |
|
| 788 | + $workout_video = ''; |
|
| 789 | + $giphy = ''; |
|
| 790 | + $youtube = ''; |
|
| 791 | + if ( isset( $group['connected_videos'] ) && '' !== $group['connected_videos'] ) { |
|
| 792 | + $workout_video = esc_html( $group['connected_videos'] ); |
|
| 793 | + $giphy = get_post_meta( $workout_video, 'video_giphy_source', true ); |
|
| 794 | + $youtube = esc_url( get_post_meta( $workout_video, 'video_youtube_source', 1 ) ); |
|
| 795 | + $content = get_post_field( 'post_content', $workout_video ); |
|
| 796 | + $play_button = '<button data-toggle="modal" data-target="#workout-video-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
| 797 | + |
|
| 798 | + $modal_body = ''; |
|
| 799 | + if ( ! empty( $giphy ) ) { |
|
| 800 | + $giphy = \lsx_health_plan\functions\get_video_url( $giphy ); |
|
| 801 | + $modal_body = $giphy; // WPCS: XSS OK. |
|
| 802 | + } elseif ( ! empty( $youtube ) ) { |
|
| 803 | + $modal_body = wp_oembed_get( $youtube, array( // WPCS: XSS OK. |
|
| 804 | + 'width' => 480, |
|
| 805 | + ) ); |
|
| 806 | + } |
|
| 807 | + $modal_body .= '<h5 class="modal-title title-lined">' . $group['name'] . '</h5>'; |
|
| 808 | + $modal_body .= $content; |
|
| 809 | + \lsx_health_plan\functions\register_modal( 'workout-video-modal-' . $m, '', $modal_body ); |
|
| 810 | + |
|
| 811 | + if ( true === $echo ) { |
|
| 812 | + echo wp_kses_post( $play_button ); |
|
| 813 | + } else { |
|
| 814 | + return $play_button; |
|
| 815 | + } |
|
| 816 | + } |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | /** |
@@ -822,21 +822,21 @@ discard block |
||
| 822 | 822 | * @return void |
| 823 | 823 | */ |
| 824 | 824 | function lsx_health_plan_recipe_archive_description() { |
| 825 | - $description = ''; |
|
| 826 | - if ( is_post_type_archive( 'recipe' ) ) { |
|
| 827 | - $description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' ); |
|
| 828 | - } elseif ( is_post_type_archive( 'exercise' ) ) { |
|
| 829 | - $description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' ); |
|
| 830 | - } elseif ( is_tax() ) { |
|
| 831 | - $description = get_the_archive_description(); |
|
| 832 | - } |
|
| 833 | - if ( '' !== $description ) { |
|
| 834 | - ?> |
|
| 825 | + $description = ''; |
|
| 826 | + if ( is_post_type_archive( 'recipe' ) ) { |
|
| 827 | + $description = \lsx_health_plan\functions\get_option( 'recipe_archive_description', '' ); |
|
| 828 | + } elseif ( is_post_type_archive( 'exercise' ) ) { |
|
| 829 | + $description = \lsx_health_plan\functions\get_option( 'exercise_archive_description', '' ); |
|
| 830 | + } elseif ( is_tax() ) { |
|
| 831 | + $description = get_the_archive_description(); |
|
| 832 | + } |
|
| 833 | + if ( '' !== $description ) { |
|
| 834 | + ?> |
|
| 835 | 835 | <div class="lsx-hp-archive-description row"> |
| 836 | 836 | <div class="col-xs-12 description-wrapper"><?php echo wp_kses_post( wpautop( $description ) ); ?></div> |
| 837 | 837 | </div> |
| 838 | 838 | <?php |
| 839 | - } |
|
| 839 | + } |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | /** |
@@ -845,23 +845,23 @@ discard block |
||
| 845 | 845 | * @return void |
| 846 | 846 | */ |
| 847 | 847 | function lsx_health_plan_workout_main_content() { |
| 848 | - // Getting translated endpoint. |
|
| 849 | - $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ); |
|
| 850 | - |
|
| 851 | - $connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true ); |
|
| 852 | - $small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true ); |
|
| 853 | - |
|
| 854 | - $content = ''; |
|
| 855 | - if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) { |
|
| 856 | - $content .= '<div class="short-desc set-box set content-box entry-content">'; |
|
| 857 | - $content .= '<div class="the-content">'; |
|
| 858 | - $content .= lsx_hp_member_connected( $connected_members, $workout ); |
|
| 859 | - $content .= '<span>' . $small_description . '</span>'; |
|
| 860 | - $content .= '</div>'; |
|
| 861 | - $content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' ); |
|
| 862 | - $content .= '</div>'; |
|
| 863 | - } |
|
| 864 | - return $content; |
|
| 848 | + // Getting translated endpoint. |
|
| 849 | + $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ); |
|
| 850 | + |
|
| 851 | + $connected_members = get_post_meta( get_the_ID(), ( $workout . '_connected_team_member' ), true ); |
|
| 852 | + $small_description = get_post_meta( get_the_ID(), ( $workout . '_short_description' ), true ); |
|
| 853 | + |
|
| 854 | + $content = ''; |
|
| 855 | + if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) { |
|
| 856 | + $content .= '<div class="short-desc set-box set content-box entry-content">'; |
|
| 857 | + $content .= '<div class="the-content">'; |
|
| 858 | + $content .= lsx_hp_member_connected( $connected_members, $workout ); |
|
| 859 | + $content .= '<span>' . $small_description . '</span>'; |
|
| 860 | + $content .= '</div>'; |
|
| 861 | + $content .= do_shortcode( '[lsx_health_plan_featured_tips_block]' ); |
|
| 862 | + $content .= '</div>'; |
|
| 863 | + } |
|
| 864 | + return $content; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | /** |
@@ -870,23 +870,23 @@ discard block |
||
| 870 | 870 | * @return void |
| 871 | 871 | */ |
| 872 | 872 | function lsx_health_plan_meal_main_content() { |
| 873 | - // Getting translated endpoint. |
|
| 874 | - $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ); |
|
| 875 | - |
|
| 876 | - $connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true ); |
|
| 877 | - $small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true ); |
|
| 878 | - |
|
| 879 | - $content_meal = ''; |
|
| 880 | - if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) { |
|
| 881 | - $content_meal .= '<div class="set-box set content-box entry-content">'; |
|
| 882 | - $content_meal .= '<div class="the-content">'; |
|
| 883 | - $content_meal .= lsx_hp_member_connected( $connected_members, $meal ); |
|
| 884 | - $content_meal .= '<span>' . $small_description . '</span>'; |
|
| 885 | - $content_meal .= '</div>'; |
|
| 886 | - $content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' ); |
|
| 887 | - $content_meal .= '</div>'; |
|
| 888 | - } |
|
| 889 | - return $content_meal; |
|
| 873 | + // Getting translated endpoint. |
|
| 874 | + $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ); |
|
| 875 | + |
|
| 876 | + $connected_members = get_post_meta( get_the_ID(), ( $meal . '_connected_team_member' ), true ); |
|
| 877 | + $small_description = get_post_meta( get_the_ID(), ( $meal . '_short_description' ), true ); |
|
| 878 | + |
|
| 879 | + $content_meal = ''; |
|
| 880 | + if ( $small_description || $connected_members || lsx_health_plan_has_tips() ) { |
|
| 881 | + $content_meal .= '<div class="set-box set content-box entry-content">'; |
|
| 882 | + $content_meal .= '<div class="the-content">'; |
|
| 883 | + $content_meal .= lsx_hp_member_connected( $connected_members, $meal ); |
|
| 884 | + $content_meal .= '<span>' . $small_description . '</span>'; |
|
| 885 | + $content_meal .= '</div>'; |
|
| 886 | + $content_meal .= do_shortcode( '[lsx_health_plan_featured_tips_block]' ); |
|
| 887 | + $content_meal .= '</div>'; |
|
| 888 | + } |
|
| 889 | + return $content_meal; |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | |
@@ -897,36 +897,36 @@ discard block |
||
| 897 | 897 | * @return void |
| 898 | 898 | */ |
| 899 | 899 | function lsx_health_plan_workout_tab_content( $index = 1 ) { |
| 900 | - global $group_name,$shortcode_args; |
|
| 901 | - $group_name = 'workout_section_' . $index; |
|
| 902 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 903 | - $layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) ); |
|
| 904 | - |
|
| 905 | - // Check for shortcode overrides. |
|
| 906 | - if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) { |
|
| 907 | - $layout = $shortcode_args['layout']; |
|
| 908 | - } |
|
| 909 | - } else { |
|
| 910 | - $layout = 'table'; |
|
| 911 | - } |
|
| 912 | - |
|
| 913 | - switch ( $layout ) { |
|
| 914 | - case 'list': |
|
| 915 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php'; |
|
| 916 | - break; |
|
| 917 | - |
|
| 918 | - case 'grid': |
|
| 919 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php'; |
|
| 920 | - break; |
|
| 921 | - |
|
| 922 | - case 'table': |
|
| 923 | - $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php'; |
|
| 924 | - break; |
|
| 925 | - } |
|
| 926 | - $tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path ); |
|
| 927 | - if ( '' !== $tab_template_path ) { |
|
| 928 | - include $tab_template_path; |
|
| 929 | - } |
|
| 900 | + global $group_name,$shortcode_args; |
|
| 901 | + $group_name = 'workout_section_' . $index; |
|
| 902 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 903 | + $layout = strtolower( \lsx_health_plan\functions\get_option( 'workout_tab_layout', 'table' ) ); |
|
| 904 | + |
|
| 905 | + // Check for shortcode overrides. |
|
| 906 | + if ( null !== $shortcode_args && isset( $shortcode_args['layout'] ) ) { |
|
| 907 | + $layout = $shortcode_args['layout']; |
|
| 908 | + } |
|
| 909 | + } else { |
|
| 910 | + $layout = 'table'; |
|
| 911 | + } |
|
| 912 | + |
|
| 913 | + switch ( $layout ) { |
|
| 914 | + case 'list': |
|
| 915 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-list.php'; |
|
| 916 | + break; |
|
| 917 | + |
|
| 918 | + case 'grid': |
|
| 919 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-grid.php'; |
|
| 920 | + break; |
|
| 921 | + |
|
| 922 | + case 'table': |
|
| 923 | + $tab_template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-table.php'; |
|
| 924 | + break; |
|
| 925 | + } |
|
| 926 | + $tab_template_path = apply_filters( 'lsx_health_plan_workout_tab_content_path', $tab_template_path ); |
|
| 927 | + if ( '' !== $tab_template_path ) { |
|
| 928 | + include $tab_template_path; |
|
| 929 | + } |
|
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | /** |
@@ -935,28 +935,28 @@ discard block |
||
| 935 | 935 | * @return void |
| 936 | 936 | */ |
| 937 | 937 | function lsx_health_plan_workout_sets() { |
| 938 | - if ( is_singular( 'workout' ) ) { |
|
| 939 | - global $connected_workouts; |
|
| 940 | - $connected_workouts = array( get_the_ID() ); |
|
| 941 | - } |
|
| 942 | - if ( is_singular( 'plan' ) ) { |
|
| 943 | - |
|
| 944 | - global $connected_workouts; |
|
| 945 | - |
|
| 946 | - $section_key = get_query_var( 'section' ); |
|
| 947 | - if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) { |
|
| 948 | - $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key ); |
|
| 949 | - if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) { |
|
| 950 | - |
|
| 951 | - $connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] ); |
|
| 952 | - } |
|
| 953 | - } |
|
| 954 | - } |
|
| 955 | - $template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php'; |
|
| 956 | - $template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path ); |
|
| 957 | - if ( '' !== $template_path && ! empty( $template_path ) ) { |
|
| 958 | - include $template_path; |
|
| 959 | - } |
|
| 938 | + if ( is_singular( 'workout' ) ) { |
|
| 939 | + global $connected_workouts; |
|
| 940 | + $connected_workouts = array( get_the_ID() ); |
|
| 941 | + } |
|
| 942 | + if ( is_singular( 'plan' ) ) { |
|
| 943 | + |
|
| 944 | + global $connected_workouts; |
|
| 945 | + |
|
| 946 | + $section_key = get_query_var( 'section' ); |
|
| 947 | + if ( '' !== $section && \lsx_health_plan\functions\plan\has_sections() ) { |
|
| 948 | + $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key ); |
|
| 949 | + if ( isset( $section_info['connected_workouts'] ) && '' !== $section_info['connected_workouts'] ) { |
|
| 950 | + |
|
| 951 | + $connected_workouts = \lsx_health_plan\functions\prep_array( $section_info['connected_workouts'] ); |
|
| 952 | + } |
|
| 953 | + } |
|
| 954 | + } |
|
| 955 | + $template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php'; |
|
| 956 | + $template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path ); |
|
| 957 | + if ( '' !== $template_path && ! empty( $template_path ) ) { |
|
| 958 | + include $template_path; |
|
| 959 | + } |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | /** |
@@ -967,11 +967,11 @@ discard block |
||
| 967 | 967 | */ |
| 968 | 968 | function lsx_health_plan_warmup_sets( $connected_workouts ) { |
| 969 | 969 | |
| 970 | - $template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php'; |
|
| 971 | - $template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path ); |
|
| 972 | - if ( '' !== $template_path && ! empty( $template_path ) ) { |
|
| 973 | - include $template_path; |
|
| 974 | - } |
|
| 970 | + $template_path = LSX_HEALTH_PLAN_PATH . 'templates/partials/workout-sets.php'; |
|
| 971 | + $template_path = apply_filters( 'lsx_health_plan_workout_set_template_path', $template_path ); |
|
| 972 | + if ( '' !== $template_path && ! empty( $template_path ) ) { |
|
| 973 | + include $template_path; |
|
| 974 | + } |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | /** |
@@ -981,48 +981,48 @@ discard block |
||
| 981 | 981 | * @return void |
| 982 | 982 | */ |
| 983 | 983 | function lsx_hp_meal_plan_recipes( $args = array() ) { |
| 984 | - $defaults = array( |
|
| 985 | - 'meal_id' => false, |
|
| 986 | - 'meal_time' => '', |
|
| 987 | - 'modal' => true, |
|
| 988 | - ); |
|
| 989 | - $args = wp_parse_args( $args, $defaults ); |
|
| 990 | - // Looking for recipes. |
|
| 991 | - $connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true ); |
|
| 992 | - if ( ! empty( $connected_recipes ) ) { |
|
| 993 | - $query_args = array( |
|
| 994 | - 'orderby' => 'date', |
|
| 995 | - 'order' => 'DESC', |
|
| 996 | - 'post_type' => 'recipe', |
|
| 997 | - 'post__in' => $connected_recipes, |
|
| 998 | - ); |
|
| 999 | - $recipes = new WP_Query( $query_args ); |
|
| 1000 | - ?> |
|
| 984 | + $defaults = array( |
|
| 985 | + 'meal_id' => false, |
|
| 986 | + 'meal_time' => '', |
|
| 987 | + 'modal' => true, |
|
| 988 | + ); |
|
| 989 | + $args = wp_parse_args( $args, $defaults ); |
|
| 990 | + // Looking for recipes. |
|
| 991 | + $connected_recipes = get_post_meta( $args['meal_id'], $args['meal_time'] . '_recipes', true ); |
|
| 992 | + if ( ! empty( $connected_recipes ) ) { |
|
| 993 | + $query_args = array( |
|
| 994 | + 'orderby' => 'date', |
|
| 995 | + 'order' => 'DESC', |
|
| 996 | + 'post_type' => 'recipe', |
|
| 997 | + 'post__in' => $connected_recipes, |
|
| 998 | + ); |
|
| 999 | + $recipes = new WP_Query( $query_args ); |
|
| 1000 | + ?> |
|
| 1001 | 1001 | <div class="recipes"> |
| 1002 | 1002 | <div class="row eating-row"> |
| 1003 | 1003 | <?php |
| 1004 | - if ( $recipes->have_posts() ) { |
|
| 1005 | - while ( $recipes->have_posts() ) { |
|
| 1006 | - $recipes->the_post(); |
|
| 1007 | - if ( false !== $args['modal'] ) { |
|
| 1008 | - \lsx_health_plan\functions\recipes\register_recipe_modal(); |
|
| 1009 | - } |
|
| 1010 | - ?> |
|
| 1004 | + if ( $recipes->have_posts() ) { |
|
| 1005 | + while ( $recipes->have_posts() ) { |
|
| 1006 | + $recipes->the_post(); |
|
| 1007 | + if ( false !== $args['modal'] ) { |
|
| 1008 | + \lsx_health_plan\functions\recipes\register_recipe_modal(); |
|
| 1009 | + } |
|
| 1010 | + ?> |
|
| 1011 | 1011 | <div class="recipe-column"> |
| 1012 | 1012 | <a data-toggle="modal" data-target="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" href="#recipe-modal-<?php echo esc_attr( get_the_ID() ); ?>" class="recipe-box box-shadow"> |
| 1013 | 1013 | <div class="recipe-feature-img"> |
| 1014 | 1014 | <?php |
| 1015 | - $featured_image = get_the_post_thumbnail(); |
|
| 1016 | - if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 1017 | - the_post_thumbnail( 'lsx-thumbnail-square', array( |
|
| 1018 | - 'class' => 'aligncenter', |
|
| 1019 | - ) ); |
|
| 1020 | - } else { |
|
| 1021 | - ?> |
|
| 1015 | + $featured_image = get_the_post_thumbnail(); |
|
| 1016 | + if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 1017 | + the_post_thumbnail( 'lsx-thumbnail-square', array( |
|
| 1018 | + 'class' => 'aligncenter', |
|
| 1019 | + ) ); |
|
| 1020 | + } else { |
|
| 1021 | + ?> |
|
| 1022 | 1022 | <img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . 'assets/images/placeholder.jpg' ); ?>"> |
| 1023 | 1023 | <?php |
| 1024 | - } |
|
| 1025 | - ?> |
|
| 1024 | + } |
|
| 1025 | + ?> |
|
| 1026 | 1026 | </div> |
| 1027 | 1027 | <div class="recipe-content"> |
| 1028 | 1028 | <h3 class="recipe-title"><?php the_title(); ?></h3> |
@@ -1031,41 +1031,41 @@ discard block |
||
| 1031 | 1031 | </a> |
| 1032 | 1032 | </div> |
| 1033 | 1033 | <?php |
| 1034 | - } |
|
| 1035 | - } |
|
| 1036 | - wp_reset_postdata(); |
|
| 1037 | - ?> |
|
| 1034 | + } |
|
| 1035 | + } |
|
| 1036 | + wp_reset_postdata(); |
|
| 1037 | + ?> |
|
| 1038 | 1038 | </div> |
| 1039 | 1039 | </div> |
| 1040 | 1040 | <?php |
| 1041 | 1041 | |
| 1042 | - } |
|
| 1042 | + } |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | /** |
| 1046 | 1046 | * Output the connected. |
| 1047 | 1047 | */ |
| 1048 | 1048 | function lsx_hp_recipe_plan_meta( $args = array() ) { |
| 1049 | - $defaults = array(); |
|
| 1050 | - $top_level_plans = array(); |
|
| 1051 | - // Get meals this exercise is connected to. |
|
| 1052 | - $plans = get_post_meta( get_the_ID(), 'connected_plans', true ); |
|
| 1053 | - if ( ! empty( $plans ) ) { |
|
| 1054 | - $plan = end( $plans ); |
|
| 1055 | - $has_parent = wp_get_post_parent_id( $plan ); |
|
| 1056 | - if ( 0 === $has_parent ) { |
|
| 1057 | - $top_level_plans[] = $plan; |
|
| 1058 | - } elseif ( false !== $top_level_plans ) { |
|
| 1059 | - $top_level_plans[] = $has_parent; |
|
| 1060 | - } |
|
| 1061 | - } |
|
| 1062 | - if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) { |
|
| 1063 | - $top_level_plans = array_unique( $top_level_plans ); |
|
| 1064 | - $top_level_plan = end( $top_level_plans ); |
|
| 1065 | - ?> |
|
| 1049 | + $defaults = array(); |
|
| 1050 | + $top_level_plans = array(); |
|
| 1051 | + // Get meals this exercise is connected to. |
|
| 1052 | + $plans = get_post_meta( get_the_ID(), 'connected_plans', true ); |
|
| 1053 | + if ( ! empty( $plans ) ) { |
|
| 1054 | + $plan = end( $plans ); |
|
| 1055 | + $has_parent = wp_get_post_parent_id( $plan ); |
|
| 1056 | + if ( 0 === $has_parent ) { |
|
| 1057 | + $top_level_plans[] = $plan; |
|
| 1058 | + } elseif ( false !== $top_level_plans ) { |
|
| 1059 | + $top_level_plans[] = $has_parent; |
|
| 1060 | + } |
|
| 1061 | + } |
|
| 1062 | + if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) { |
|
| 1063 | + $top_level_plans = array_unique( $top_level_plans ); |
|
| 1064 | + $top_level_plan = end( $top_level_plans ); |
|
| 1065 | + ?> |
|
| 1066 | 1066 | <span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span> |
| 1067 | 1067 | <?php |
| 1068 | - } |
|
| 1068 | + } |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | /** |
@@ -1073,42 +1073,42 @@ discard block |
||
| 1073 | 1073 | */ |
| 1074 | 1074 | function lsx_hp_exercise_plan_meta() { |
| 1075 | 1075 | |
| 1076 | - $top_level_plans = array(); |
|
| 1077 | - |
|
| 1078 | - // Get workouts this exercise is connected to. |
|
| 1079 | - $workouts = get_post_meta( get_the_ID(), 'connected_workouts', true ); |
|
| 1080 | - |
|
| 1081 | - if ( '' !== $workouts && ! is_array( $workouts ) ) { |
|
| 1082 | - $workouts = array( $workouts ); |
|
| 1083 | - } |
|
| 1084 | - if ( ! empty( $workouts ) ) { |
|
| 1085 | - foreach ( $workouts as $workout ) { |
|
| 1086 | - // Get the plans this workout is connected to. |
|
| 1087 | - $plans = get_post_meta( $workout, 'connected_plans', true ); |
|
| 1088 | - |
|
| 1089 | - if ( '' !== $plans && ! is_array( $plans ) ) { |
|
| 1090 | - $plans = array( $plans ); |
|
| 1091 | - } |
|
| 1092 | - if ( ! empty( $plans ) ) { |
|
| 1093 | - foreach ( $plans as $plan ) { |
|
| 1094 | - $has_parent = wp_get_post_parent_id( $plan ); |
|
| 1095 | - if ( 0 === $has_parent ) { |
|
| 1096 | - $top_level_plans = $plan; |
|
| 1097 | - } else { |
|
| 1098 | - $top_level_plans = $has_parent; |
|
| 1099 | - } |
|
| 1100 | - } |
|
| 1101 | - } |
|
| 1102 | - } |
|
| 1103 | - } |
|
| 1104 | - |
|
| 1105 | - if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) { |
|
| 1106 | - $top_level_plans = array_unique( $top_level_plans ); |
|
| 1107 | - $top_level_plan = end( $top_level_plans ); |
|
| 1108 | - ?> |
|
| 1076 | + $top_level_plans = array(); |
|
| 1077 | + |
|
| 1078 | + // Get workouts this exercise is connected to. |
|
| 1079 | + $workouts = get_post_meta( get_the_ID(), 'connected_workouts', true ); |
|
| 1080 | + |
|
| 1081 | + if ( '' !== $workouts && ! is_array( $workouts ) ) { |
|
| 1082 | + $workouts = array( $workouts ); |
|
| 1083 | + } |
|
| 1084 | + if ( ! empty( $workouts ) ) { |
|
| 1085 | + foreach ( $workouts as $workout ) { |
|
| 1086 | + // Get the plans this workout is connected to. |
|
| 1087 | + $plans = get_post_meta( $workout, 'connected_plans', true ); |
|
| 1088 | + |
|
| 1089 | + if ( '' !== $plans && ! is_array( $plans ) ) { |
|
| 1090 | + $plans = array( $plans ); |
|
| 1091 | + } |
|
| 1092 | + if ( ! empty( $plans ) ) { |
|
| 1093 | + foreach ( $plans as $plan ) { |
|
| 1094 | + $has_parent = wp_get_post_parent_id( $plan ); |
|
| 1095 | + if ( 0 === $has_parent ) { |
|
| 1096 | + $top_level_plans = $plan; |
|
| 1097 | + } else { |
|
| 1098 | + $top_level_plans = $has_parent; |
|
| 1099 | + } |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1102 | + } |
|
| 1103 | + } |
|
| 1104 | + |
|
| 1105 | + if ( ! empty( $top_level_plans ) && ( '' !== $top_level_plans ) ) { |
|
| 1106 | + $top_level_plans = array_unique( $top_level_plans ); |
|
| 1107 | + $top_level_plan = end( $top_level_plans ); |
|
| 1108 | + ?> |
|
| 1109 | 1109 | <span class="recipe-type recipe-parent"><?php echo esc_html( get_the_title( $top_level_plan ) ); ?></span> |
| 1110 | 1110 | <?php |
| 1111 | - } |
|
| 1111 | + } |
|
| 1112 | 1112 | } |
| 1113 | 1113 | |
| 1114 | 1114 | /** |
@@ -1118,7 +1118,7 @@ discard block |
||
| 1118 | 1118 | * @return void |
| 1119 | 1119 | */ |
| 1120 | 1120 | function lsx_hp_single_related( $related_content, $post_type_text ) { |
| 1121 | - ?> |
|
| 1121 | + ?> |
|
| 1122 | 1122 | <section id="lsx-hp-related"> |
| 1123 | 1123 | <div class="row lsx-related-posts lsx-related-posts-title"> |
| 1124 | 1124 | <div class="col-xs-12"> |
@@ -1129,14 +1129,14 @@ discard block |
||
| 1129 | 1129 | <div class="col-xs-12"> |
| 1130 | 1130 | <div class="lsx-related-posts-wrapper"> |
| 1131 | 1131 | <?php |
| 1132 | - $i = 0; |
|
| 1133 | - foreach ( $related_content as $article ) { |
|
| 1134 | - $post_title = get_the_title( $article ); |
|
| 1135 | - $post_categories = wp_get_post_categories( $article ); |
|
| 1136 | - $post_link = get_permalink( $article ); |
|
| 1137 | - |
|
| 1138 | - $cats = array(); |
|
| 1139 | - ?> |
|
| 1132 | + $i = 0; |
|
| 1133 | + foreach ( $related_content as $article ) { |
|
| 1134 | + $post_title = get_the_title( $article ); |
|
| 1135 | + $post_categories = wp_get_post_categories( $article ); |
|
| 1136 | + $post_link = get_permalink( $article ); |
|
| 1137 | + |
|
| 1138 | + $cats = array(); |
|
| 1139 | + ?> |
|
| 1140 | 1140 | <article id="post-<?php echo esc_html( $article ); ?>" class="lsx-slot post"> |
| 1141 | 1141 | <div class="entry-layout lsx-hp-shadow"> |
| 1142 | 1142 | <div class="entry-layout-content"> |
@@ -1144,25 +1144,25 @@ discard block |
||
| 1144 | 1144 | <div class="entry-image"> |
| 1145 | 1145 | <a href="<?php echo esc_url( $post_link ); ?>" class="thumbnail"> |
| 1146 | 1146 | <?php |
| 1147 | - $featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' ); |
|
| 1148 | - if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 1149 | - echo wp_kses_post( $featured_image ); |
|
| 1150 | - } else { |
|
| 1151 | - ?> |
|
| 1147 | + $featured_image = get_the_post_thumbnail( $article, 'lsx-thumbnail-wide' ); |
|
| 1148 | + if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 1149 | + echo wp_kses_post( $featured_image ); |
|
| 1150 | + } else { |
|
| 1151 | + ?> |
|
| 1152 | 1152 | <img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
| 1153 | 1153 | <?php |
| 1154 | - } |
|
| 1155 | - ?> |
|
| 1154 | + } |
|
| 1155 | + ?> |
|
| 1156 | 1156 | </a> |
| 1157 | 1157 | </div> |
| 1158 | 1158 | <div class="entry-meta"> |
| 1159 | 1159 | <?php |
| 1160 | - foreach ( $post_categories as $c ) { |
|
| 1161 | - $cat = get_category( $c ); |
|
| 1162 | - /* Translators: %s: category name */ |
|
| 1163 | - $cats[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '" title="' . sprintf( esc_html__( 'Posts in %s', 'lsx-blog-customizer' ), $cat->name ) . '">' . $cat->name . '</a>'; |
|
| 1164 | - } |
|
| 1165 | - if ( ! empty( $cats ) ) { ?> |
|
| 1160 | + foreach ( $post_categories as $c ) { |
|
| 1161 | + $cat = get_category( $c ); |
|
| 1162 | + /* Translators: %s: category name */ |
|
| 1163 | + $cats[] = '<a href="' . esc_url( get_category_link( $cat->term_id ) ) . '" title="' . sprintf( esc_html__( 'Posts in %s', 'lsx-blog-customizer' ), $cat->name ) . '">' . $cat->name . '</a>'; |
|
| 1164 | + } |
|
| 1165 | + if ( ! empty( $cats ) ) { ?> |
|
| 1166 | 1166 | <div class="post-categories"><span></span><?php echo wp_kses_post( implode( ', ', $cats ) ); ?></div> |
| 1167 | 1167 | <?php } ?> |
| 1168 | 1168 | </div> |
@@ -1177,8 +1177,8 @@ discard block |
||
| 1177 | 1177 | </article> |
| 1178 | 1178 | |
| 1179 | 1179 | <?php |
| 1180 | - if (++$i === 3) break; |
|
| 1181 | - } ?> |
|
| 1180 | + if (++$i === 3) break; |
|
| 1181 | + } ?> |
|
| 1182 | 1182 | </div> |
| 1183 | 1183 | </div> |
| 1184 | 1184 | </div> |
@@ -1193,32 +1193,32 @@ discard block |
||
| 1193 | 1193 | * @return void |
| 1194 | 1194 | */ |
| 1195 | 1195 | function lsx_hp_member_connected( $connected_members, $post_type ) { |
| 1196 | - if ( ! empty( $connected_members ) ) { |
|
| 1197 | - $content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">'; |
|
| 1198 | - foreach ( $connected_members as $member ) { |
|
| 1199 | - $post_link = get_permalink( $member ); |
|
| 1200 | - $member_name = get_the_title( $member ); |
|
| 1201 | - $member_name = '<span class="lsx-team-name">' . $member_name . '</span>'; |
|
| 1202 | - |
|
| 1203 | - $member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>'; |
|
| 1204 | - |
|
| 1205 | - $roles = ''; |
|
| 1206 | - $terms = get_the_terms( $member, 'team_role' ); |
|
| 1207 | - |
|
| 1208 | - if ( $terms && ! is_wp_error( $terms ) ) { |
|
| 1209 | - $roles = array(); |
|
| 1210 | - |
|
| 1211 | - foreach ( $terms as $term ) { |
|
| 1212 | - $roles[] = $term->name; |
|
| 1213 | - } |
|
| 1214 | - |
|
| 1215 | - $roles = join( ', ', $roles ); |
|
| 1216 | - } |
|
| 1217 | - $member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : ''; |
|
| 1218 | - |
|
| 1219 | - $content .= '<p>' . $member_roles . ': ' . $member_link . '</p>'; |
|
| 1220 | - } |
|
| 1221 | - $content .= '</div>'; |
|
| 1222 | - return $content; |
|
| 1223 | - } |
|
| 1196 | + if ( ! empty( $connected_members ) ) { |
|
| 1197 | + $content = '<div id="hp-connected-members" class="hp-connected-members connected-' . $post_type . '">'; |
|
| 1198 | + foreach ( $connected_members as $member ) { |
|
| 1199 | + $post_link = get_permalink( $member ); |
|
| 1200 | + $member_name = get_the_title( $member ); |
|
| 1201 | + $member_name = '<span class="lsx-team-name">' . $member_name . '</span>'; |
|
| 1202 | + |
|
| 1203 | + $member_link = '<a href="' . $post_link . '" >' . $member_name . '</a>'; |
|
| 1204 | + |
|
| 1205 | + $roles = ''; |
|
| 1206 | + $terms = get_the_terms( $member, 'team_role' ); |
|
| 1207 | + |
|
| 1208 | + if ( $terms && ! is_wp_error( $terms ) ) { |
|
| 1209 | + $roles = array(); |
|
| 1210 | + |
|
| 1211 | + foreach ( $terms as $term ) { |
|
| 1212 | + $roles[] = $term->name; |
|
| 1213 | + } |
|
| 1214 | + |
|
| 1215 | + $roles = join( ', ', $roles ); |
|
| 1216 | + } |
|
| 1217 | + $member_roles = '' !== $roles ? "<small class='lsx-team-roles'>$roles</small>" : ''; |
|
| 1218 | + |
|
| 1219 | + $content .= '<p>' . $member_roles . ': ' . $member_link . '</p>'; |
|
| 1220 | + } |
|
| 1221 | + $content .= '</div>'; |
|
| 1222 | + return $content; |
|
| 1223 | + } |
|
| 1224 | 1224 | } |
@@ -17,27 +17,27 @@ discard block |
||
| 17 | 17 | * @return boolean |
| 18 | 18 | */ |
| 19 | 19 | function has_attached_post( $post_id = '', $meta_key = '', $single = true ) { |
| 20 | - $has_post = false; |
|
| 21 | - if ( '' === $post_id ) { |
|
| 22 | - $post_id = get_the_ID(); |
|
| 23 | - } |
|
| 24 | - $items = get_post_meta( $post_id, $meta_key, $single ); |
|
| 25 | - if ( '' !== $items && false !== $items && 0 !== $items ) { |
|
| 26 | - if ( ! is_array( $items ) ) { |
|
| 27 | - $items = array( $items ); |
|
| 28 | - } |
|
| 29 | - $items = check_posts_exist( $items ); |
|
| 30 | - if ( ! empty( $items ) ) { |
|
| 31 | - $has_post = true; |
|
| 32 | - } |
|
| 33 | - } else { |
|
| 34 | - // Check for defaults. |
|
| 35 | - $options = get_option( 'all' ); |
|
| 36 | - if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) { |
|
| 37 | - $has_post = true; |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - return $has_post; |
|
| 20 | + $has_post = false; |
|
| 21 | + if ( '' === $post_id ) { |
|
| 22 | + $post_id = get_the_ID(); |
|
| 23 | + } |
|
| 24 | + $items = get_post_meta( $post_id, $meta_key, $single ); |
|
| 25 | + if ( '' !== $items && false !== $items && 0 !== $items ) { |
|
| 26 | + if ( ! is_array( $items ) ) { |
|
| 27 | + $items = array( $items ); |
|
| 28 | + } |
|
| 29 | + $items = check_posts_exist( $items ); |
|
| 30 | + if ( ! empty( $items ) ) { |
|
| 31 | + $has_post = true; |
|
| 32 | + } |
|
| 33 | + } else { |
|
| 34 | + // Check for defaults. |
|
| 35 | + $options = get_option( 'all' ); |
|
| 36 | + if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) { |
|
| 37 | + $has_post = true; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + return $has_post; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -48,18 +48,18 @@ discard block |
||
| 48 | 48 | * @return mixed Option value |
| 49 | 49 | */ |
| 50 | 50 | function get_option( $key = '', $default = false ) { |
| 51 | - if ( function_exists( 'cmb2_get_option' ) ) { |
|
| 52 | - return cmb2_get_option( 'lsx_health_plan_options', $key, $default ); |
|
| 53 | - } |
|
| 54 | - // Fallback to get_option if CMB2 is not loaded yet. |
|
| 55 | - $opts = \get_option( 'lsx_health_plan_options', $default ); |
|
| 56 | - $val = $default; |
|
| 57 | - if ( 'all' === $key ) { |
|
| 58 | - $val = $opts; |
|
| 59 | - } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { |
|
| 60 | - $val = $opts[ $key ]; |
|
| 61 | - } |
|
| 62 | - return $val; |
|
| 51 | + if ( function_exists( 'cmb2_get_option' ) ) { |
|
| 52 | + return cmb2_get_option( 'lsx_health_plan_options', $key, $default ); |
|
| 53 | + } |
|
| 54 | + // Fallback to get_option if CMB2 is not loaded yet. |
|
| 55 | + $opts = \get_option( 'lsx_health_plan_options', $default ); |
|
| 56 | + $val = $default; |
|
| 57 | + if ( 'all' === $key ) { |
|
| 58 | + $val = $opts; |
|
| 59 | + } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { |
|
| 60 | + $val = $opts[ $key ]; |
|
| 61 | + } |
|
| 62 | + return $val; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -70,54 +70,54 @@ discard block |
||
| 70 | 70 | * @return mixed Option value |
| 71 | 71 | */ |
| 72 | 72 | function get_downloads( $type = 'all', $post_id = '' ) { |
| 73 | - $lsx_health_plan = \lsx_health_plan(); |
|
| 74 | - $post_types = $lsx_health_plan->get_post_types(); |
|
| 75 | - if ( '' === $post_id ) { |
|
| 76 | - $post_id = get_the_ID(); |
|
| 77 | - } |
|
| 78 | - $downloads = array(); |
|
| 79 | - $options = get_option( 'all' ); |
|
| 80 | - |
|
| 81 | - foreach ( $post_types as $post_type ) { |
|
| 82 | - if ( 'all' === $type || in_array( $type, $post_types, true ) ) { |
|
| 83 | - |
|
| 84 | - // Get the default downloads for this post type. |
|
| 85 | - $default_downloads = array(); |
|
| 86 | - $new_downloads = array(); |
|
| 87 | - if ( isset( $options[ 'download_' . $post_type ] ) ) { |
|
| 88 | - if ( is_array( $options[ 'download_' . $post_type ] ) ) { |
|
| 89 | - $default_downloads = $options[ 'download_' . $post_type ]; |
|
| 90 | - } else { |
|
| 91 | - $default_downloads[] = $options[ 'download_' . $post_type ]; |
|
| 92 | - } |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - if ( 'page' === $post_type ) { |
|
| 96 | - $key = 'plan_warmup'; |
|
| 97 | - } else { |
|
| 98 | - $key = 'connected_' . $post_type . 's'; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $connected_items = get_post_meta( $post_id, $key, true ); |
|
| 102 | - if ( ! empty( $connected_items ) ) { |
|
| 103 | - foreach ( $connected_items as $connected_item ) { |
|
| 104 | - $current_downloads = get_post_meta( $connected_item, 'connected_downloads', true ); |
|
| 105 | - if ( false !== $current_downloads && ! empty( $current_downloads ) ) { |
|
| 106 | - $new_downloads = array_merge( $new_downloads, $current_downloads ); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - if ( ! empty( $new_downloads ) ) { |
|
| 112 | - $downloads = array_merge( $downloads, $new_downloads ); |
|
| 113 | - } elseif ( ! empty( $default_downloads ) ) { |
|
| 114 | - $downloads = array_merge( $downloads, $default_downloads ); |
|
| 115 | - } |
|
| 116 | - $downloads = array_unique( $downloads ); |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - $downloads = check_posts_exist( $downloads ); |
|
| 120 | - return $downloads; |
|
| 73 | + $lsx_health_plan = \lsx_health_plan(); |
|
| 74 | + $post_types = $lsx_health_plan->get_post_types(); |
|
| 75 | + if ( '' === $post_id ) { |
|
| 76 | + $post_id = get_the_ID(); |
|
| 77 | + } |
|
| 78 | + $downloads = array(); |
|
| 79 | + $options = get_option( 'all' ); |
|
| 80 | + |
|
| 81 | + foreach ( $post_types as $post_type ) { |
|
| 82 | + if ( 'all' === $type || in_array( $type, $post_types, true ) ) { |
|
| 83 | + |
|
| 84 | + // Get the default downloads for this post type. |
|
| 85 | + $default_downloads = array(); |
|
| 86 | + $new_downloads = array(); |
|
| 87 | + if ( isset( $options[ 'download_' . $post_type ] ) ) { |
|
| 88 | + if ( is_array( $options[ 'download_' . $post_type ] ) ) { |
|
| 89 | + $default_downloads = $options[ 'download_' . $post_type ]; |
|
| 90 | + } else { |
|
| 91 | + $default_downloads[] = $options[ 'download_' . $post_type ]; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + if ( 'page' === $post_type ) { |
|
| 96 | + $key = 'plan_warmup'; |
|
| 97 | + } else { |
|
| 98 | + $key = 'connected_' . $post_type . 's'; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $connected_items = get_post_meta( $post_id, $key, true ); |
|
| 102 | + if ( ! empty( $connected_items ) ) { |
|
| 103 | + foreach ( $connected_items as $connected_item ) { |
|
| 104 | + $current_downloads = get_post_meta( $connected_item, 'connected_downloads', true ); |
|
| 105 | + if ( false !== $current_downloads && ! empty( $current_downloads ) ) { |
|
| 106 | + $new_downloads = array_merge( $new_downloads, $current_downloads ); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + if ( ! empty( $new_downloads ) ) { |
|
| 112 | + $downloads = array_merge( $downloads, $new_downloads ); |
|
| 113 | + } elseif ( ! empty( $default_downloads ) ) { |
|
| 114 | + $downloads = array_merge( $downloads, $default_downloads ); |
|
| 115 | + } |
|
| 116 | + $downloads = array_unique( $downloads ); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + $downloads = check_posts_exist( $downloads ); |
|
| 120 | + return $downloads; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -127,35 +127,35 @@ discard block |
||
| 127 | 127 | * @return array an array of the downloads or empty. |
| 128 | 128 | */ |
| 129 | 129 | function get_weekly_downloads( $week = '' ) { |
| 130 | - $downloads = array(); |
|
| 131 | - if ( '' !== $week ) { |
|
| 132 | - $saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week ); |
|
| 133 | - if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) { |
|
| 134 | - $downloads = $saved_downloads; |
|
| 135 | - } else { |
|
| 136 | - $args = array( |
|
| 137 | - 'orderby' => 'title', |
|
| 138 | - 'order' => 'ASC', |
|
| 139 | - 'post_type' => 'dlm_download', |
|
| 140 | - 'posts_per_page' => -1, |
|
| 141 | - 'nopagin' => true, |
|
| 142 | - 'fields' => 'ids', |
|
| 143 | - 'tax_query' => array( |
|
| 144 | - array( |
|
| 145 | - 'taxonomy' => 'dlm_download_category', |
|
| 146 | - 'field' => 'slug', |
|
| 147 | - 'terms' => array( $week ), |
|
| 148 | - ), |
|
| 149 | - ), |
|
| 150 | - ); |
|
| 151 | - $download_query = new \WP_Query( $args ); |
|
| 152 | - if ( $download_query->have_posts() ) { |
|
| 153 | - $downloads = $download_query->posts; |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - $downloads = check_posts_exist( $downloads ); |
|
| 158 | - return $downloads; |
|
| 130 | + $downloads = array(); |
|
| 131 | + if ( '' !== $week ) { |
|
| 132 | + $saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week ); |
|
| 133 | + if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) { |
|
| 134 | + $downloads = $saved_downloads; |
|
| 135 | + } else { |
|
| 136 | + $args = array( |
|
| 137 | + 'orderby' => 'title', |
|
| 138 | + 'order' => 'ASC', |
|
| 139 | + 'post_type' => 'dlm_download', |
|
| 140 | + 'posts_per_page' => -1, |
|
| 141 | + 'nopagin' => true, |
|
| 142 | + 'fields' => 'ids', |
|
| 143 | + 'tax_query' => array( |
|
| 144 | + array( |
|
| 145 | + 'taxonomy' => 'dlm_download_category', |
|
| 146 | + 'field' => 'slug', |
|
| 147 | + 'terms' => array( $week ), |
|
| 148 | + ), |
|
| 149 | + ), |
|
| 150 | + ); |
|
| 151 | + $download_query = new \WP_Query( $args ); |
|
| 152 | + if ( $download_query->have_posts() ) { |
|
| 153 | + $downloads = $download_query->posts; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + $downloads = check_posts_exist( $downloads ); |
|
| 158 | + return $downloads; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | /** |
@@ -165,22 +165,22 @@ discard block |
||
| 165 | 165 | * @return void |
| 166 | 166 | */ |
| 167 | 167 | function check_posts_exist( $post_ids = array() ) { |
| 168 | - $new_ids = array(); |
|
| 169 | - global $wpdb; |
|
| 170 | - if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { |
|
| 171 | - $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
| 172 | - $query = " |
|
| 168 | + $new_ids = array(); |
|
| 169 | + global $wpdb; |
|
| 170 | + if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { |
|
| 171 | + $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
| 172 | + $query = " |
|
| 173 | 173 | SELECT `ID` |
| 174 | 174 | FROM `{$wpdb->posts}` |
| 175 | 175 | WHERE `ID` IN ({$post_ids}) |
| 176 | 176 | AND `post_status` != 'trash' |
| 177 | 177 | "; |
| 178 | - $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL |
|
| 179 | - if ( ! empty( $results ) ) { |
|
| 180 | - $new_ids = wp_list_pluck( $results, 'ID' ); |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - return $new_ids; |
|
| 178 | + $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL |
|
| 179 | + if ( ! empty( $results ) ) { |
|
| 180 | + $new_ids = wp_list_pluck( $results, 'ID' ); |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + return $new_ids; |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -192,13 +192,13 @@ discard block |
||
| 192 | 192 | * @return void |
| 193 | 193 | */ |
| 194 | 194 | function register_modal( $id = '', $title = '', $body = '' ) { |
| 195 | - lsx_health_plan()->frontend->modals->register_modal( |
|
| 196 | - array( |
|
| 197 | - 'title' => $title, |
|
| 198 | - 'body' => $body, |
|
| 199 | - ), |
|
| 200 | - $id |
|
| 201 | - ); |
|
| 195 | + lsx_health_plan()->frontend->modals->register_modal( |
|
| 196 | + array( |
|
| 197 | + 'title' => $title, |
|
| 198 | + 'body' => $body, |
|
| 199 | + ), |
|
| 200 | + $id |
|
| 201 | + ); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -208,13 +208,13 @@ discard block |
||
| 208 | 208 | * @return void |
| 209 | 209 | */ |
| 210 | 210 | function output_modal( $args = array() ) { |
| 211 | - $defaults = array( |
|
| 212 | - 'id' => '', |
|
| 213 | - 'title' => '', |
|
| 214 | - 'body' => '', |
|
| 215 | - ); |
|
| 216 | - $args = wp_parse_args( $args, $defaults ); |
|
| 217 | - ?> |
|
| 211 | + $defaults = array( |
|
| 212 | + 'id' => '', |
|
| 213 | + 'title' => '', |
|
| 214 | + 'body' => '', |
|
| 215 | + ); |
|
| 216 | + $args = wp_parse_args( $args, $defaults ); |
|
| 217 | + ?> |
|
| 218 | 218 | <!-- Modal --> |
| 219 | 219 | <div class="modal fade lsx-health-plan-modal" id="<?php echo esc_html( $args['id'] ); ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo esc_html( $args['id'] ); ?>" aria-hidden="true"> |
| 220 | 220 | <div class="modal-dialog" role="document"> |
@@ -222,36 +222,36 @@ discard block |
||
| 222 | 222 | <button type="button" class="close" data-dismiss="modal">×</button> |
| 223 | 223 | <div class="modal-header"> |
| 224 | 224 | <?php |
| 225 | - if ( '' !== $args['title'] ) { |
|
| 226 | - echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' ); |
|
| 227 | - } |
|
| 228 | - ?> |
|
| 225 | + if ( '' !== $args['title'] ) { |
|
| 226 | + echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' ); |
|
| 227 | + } |
|
| 228 | + ?> |
|
| 229 | 229 | </div> |
| 230 | 230 | <div class="modal-body"> |
| 231 | 231 | <?php |
| 232 | - if ( '' !== $args['body'] ) { |
|
| 233 | - $allowed_html = array( |
|
| 234 | - 'iframe' => array( |
|
| 235 | - 'data-src' => array(), |
|
| 236 | - 'src' => array(), |
|
| 237 | - 'width' => array(), |
|
| 238 | - 'height' => array(), |
|
| 239 | - 'frameBorder' => array( '0' ), |
|
| 240 | - 'class' => array(), |
|
| 241 | - 'allowFullScreen' => array(), |
|
| 242 | - 'style' => array(), |
|
| 243 | - ), |
|
| 244 | - 'h5' => array( |
|
| 245 | - 'class' => array(), |
|
| 246 | - ), |
|
| 247 | - ); |
|
| 248 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 249 | - echo wp_kses_post( $args['body'] ); |
|
| 250 | - } else { |
|
| 251 | - echo wp_kses( $args['body'], $allowed_html ); |
|
| 252 | - } |
|
| 253 | - } |
|
| 254 | - ?> |
|
| 232 | + if ( '' !== $args['body'] ) { |
|
| 233 | + $allowed_html = array( |
|
| 234 | + 'iframe' => array( |
|
| 235 | + 'data-src' => array(), |
|
| 236 | + 'src' => array(), |
|
| 237 | + 'width' => array(), |
|
| 238 | + 'height' => array(), |
|
| 239 | + 'frameBorder' => array( '0' ), |
|
| 240 | + 'class' => array(), |
|
| 241 | + 'allowFullScreen' => array(), |
|
| 242 | + 'style' => array(), |
|
| 243 | + ), |
|
| 244 | + 'h5' => array( |
|
| 245 | + 'class' => array(), |
|
| 246 | + ), |
|
| 247 | + ); |
|
| 248 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 249 | + echo wp_kses_post( $args['body'] ); |
|
| 250 | + } else { |
|
| 251 | + echo wp_kses( $args['body'], $allowed_html ); |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | + ?> |
|
| 255 | 255 | </div> |
| 256 | 256 | </div> |
| 257 | 257 | </div> |
@@ -267,18 +267,18 @@ discard block |
||
| 267 | 267 | * @return void |
| 268 | 268 | */ |
| 269 | 269 | function get_video_url( $embed ) { |
| 270 | - $url = ''; |
|
| 271 | - if ( false !== stripos( $embed, '<iframe' ) ) { |
|
| 272 | - preg_match( '/src="([^"]+)"/', $embed, $match ); |
|
| 273 | - if ( is_array( $match ) && isset( $match[1] ) ) { |
|
| 274 | - $url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>'; |
|
| 275 | - } else { |
|
| 276 | - $url = $embed; |
|
| 277 | - } |
|
| 278 | - } else { |
|
| 279 | - $url = $embed; |
|
| 280 | - } |
|
| 281 | - return $url; |
|
| 270 | + $url = ''; |
|
| 271 | + if ( false !== stripos( $embed, '<iframe' ) ) { |
|
| 272 | + preg_match( '/src="([^"]+)"/', $embed, $match ); |
|
| 273 | + if ( is_array( $match ) && isset( $match[1] ) ) { |
|
| 274 | + $url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>'; |
|
| 275 | + } else { |
|
| 276 | + $url = $embed; |
|
| 277 | + } |
|
| 278 | + } else { |
|
| 279 | + $url = $embed; |
|
| 280 | + } |
|
| 281 | + return $url; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | * @return boolean |
| 290 | 290 | */ |
| 291 | 291 | function is_week_complete( $term_id = false, $section_keys = array(), $group_title = '' ) { |
| 292 | - $return = false; |
|
| 293 | - if ( ! empty( $section_keys ) ) { |
|
| 294 | - $group_count = count( $section_keys ); |
|
| 295 | - foreach ( $section_keys as &$pid ) { |
|
| 296 | - $pid = 'day_' . \lsx_health_plan\functions\plan\generate_section_id( $pid ) . '_complete'; |
|
| 297 | - } |
|
| 298 | - $days_complete = get_meta_amounts( $section_keys ); |
|
| 299 | - if ( (int) $group_count === (int) $days_complete ) { |
|
| 300 | - $return = true; |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - return $return; |
|
| 292 | + $return = false; |
|
| 293 | + if ( ! empty( $section_keys ) ) { |
|
| 294 | + $group_count = count( $section_keys ); |
|
| 295 | + foreach ( $section_keys as &$pid ) { |
|
| 296 | + $pid = 'day_' . \lsx_health_plan\functions\plan\generate_section_id( $pid ) . '_complete'; |
|
| 297 | + } |
|
| 298 | + $days_complete = get_meta_amounts( $section_keys ); |
|
| 299 | + if ( (int) $group_count === (int) $days_complete ) { |
|
| 300 | + $return = true; |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + return $return; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -311,23 +311,23 @@ discard block |
||
| 311 | 311 | * @return void |
| 312 | 312 | */ |
| 313 | 313 | function get_meta_amounts( $post_ids = array() ) { |
| 314 | - global $wpdb; |
|
| 315 | - $amount = 0; |
|
| 316 | - $current_user = wp_get_current_user(); |
|
| 317 | - if ( false !== $current_user && ! empty( $post_ids ) ) { |
|
| 318 | - $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
| 319 | - $query = " |
|
| 314 | + global $wpdb; |
|
| 315 | + $amount = 0; |
|
| 316 | + $current_user = wp_get_current_user(); |
|
| 317 | + if ( false !== $current_user && ! empty( $post_ids ) ) { |
|
| 318 | + $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
| 319 | + $query = " |
|
| 320 | 320 | SELECT COUNT(`meta_value`) |
| 321 | 321 | FROM `{$wpdb->usermeta}` |
| 322 | 322 | WHERE `meta_key` IN ({$post_ids}) |
| 323 | 323 | AND `user_id` = '{$current_user->ID}' |
| 324 | 324 | "; |
| 325 | - $results = $wpdb->get_var( $query ); // WPCS: unprepared SQL |
|
| 326 | - if ( ! empty( $results ) ) { |
|
| 327 | - $amount = $results; |
|
| 328 | - } |
|
| 329 | - } |
|
| 330 | - return $amount; |
|
| 325 | + $results = $wpdb->get_var( $query ); // WPCS: unprepared SQL |
|
| 326 | + if ( ! empty( $results ) ) { |
|
| 327 | + $amount = $results; |
|
| 328 | + } |
|
| 329 | + } |
|
| 330 | + return $amount; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
@@ -337,46 +337,46 @@ discard block |
||
| 337 | 337 | * @return void |
| 338 | 338 | */ |
| 339 | 339 | function hp_get_plan_type_meta( $post ) { |
| 340 | - $plan_meta = ''; |
|
| 340 | + $plan_meta = ''; |
|
| 341 | 341 | |
| 342 | - $term_obj_list = get_the_terms( $post->ID, 'plan-type' ); |
|
| 343 | - if ( false !== $term_obj_list ) { |
|
| 344 | - $terms_string = ''; |
|
| 345 | - $terms_ids = wp_list_pluck( $term_obj_list, 'term_id' ); |
|
| 342 | + $term_obj_list = get_the_terms( $post->ID, 'plan-type' ); |
|
| 343 | + if ( false !== $term_obj_list ) { |
|
| 344 | + $terms_string = ''; |
|
| 345 | + $terms_ids = wp_list_pluck( $term_obj_list, 'term_id' ); |
|
| 346 | 346 | |
| 347 | - foreach ( $term_obj_list as $term ) { |
|
| 348 | - $term_link = get_term_link( $term ); |
|
| 349 | - $term_name = '<a href="' . $term_link . '">' .$term->name . '<span>, </span></a>'; |
|
| 347 | + foreach ( $term_obj_list as $term ) { |
|
| 348 | + $term_link = get_term_link( $term ); |
|
| 349 | + $term_name = '<a href="' . $term_link . '">' .$term->name . '<span>, </span></a>'; |
|
| 350 | 350 | |
| 351 | - $terms_string .= $term_name; |
|
| 352 | - } |
|
| 351 | + $terms_string .= $term_name; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | - foreach ( $terms_ids as $terms_id ) { |
|
| 355 | - $term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true ); |
|
| 356 | - $img = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' ); |
|
| 357 | - if ( ! empty( $img ) ) { |
|
| 358 | - $image_url = $img[0]; |
|
| 359 | - $img = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />'; |
|
| 360 | - } |
|
| 354 | + foreach ( $terms_ids as $terms_id ) { |
|
| 355 | + $term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true ); |
|
| 356 | + $img = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' ); |
|
| 357 | + if ( ! empty( $img ) ) { |
|
| 358 | + $image_url = $img[0]; |
|
| 359 | + $img = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />'; |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - $plan_meta .= $img; |
|
| 363 | - } |
|
| 362 | + $plan_meta .= $img; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - $plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>'; |
|
| 366 | - } |
|
| 365 | + $plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>'; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - return $plan_meta; |
|
| 368 | + return $plan_meta; |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
| 372 | 372 | * Limit media library access |
| 373 | 373 | */ |
| 374 | 374 | function set_only_author( $wp_query ) { |
| 375 | - global $current_user; |
|
| 376 | - if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) { |
|
| 377 | - $wp_query->set( 'administrator', $current_user->ID ); |
|
| 378 | - add_filter( 'views_upload', 'fix_media_counts' ); |
|
| 379 | - } |
|
| 375 | + global $current_user; |
|
| 376 | + if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) { |
|
| 377 | + $wp_query->set( 'administrator', $current_user->ID ); |
|
| 378 | + add_filter( 'views_upload', 'fix_media_counts' ); |
|
| 379 | + } |
|
| 380 | 380 | } |
| 381 | 381 | add_action( 'pre_get_posts', '\lsx_health_plan\functions\set_only_author' ); |
| 382 | 382 | |
@@ -387,12 +387,12 @@ discard block |
||
| 387 | 387 | * @return void |
| 388 | 388 | */ |
| 389 | 389 | function hp_excerpt( $post_id ) { |
| 390 | - if ( ! has_excerpt( $post_id ) ) { |
|
| 391 | - $content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 ); |
|
| 392 | - } else { |
|
| 393 | - $content = get_the_excerpt( $post_id ); |
|
| 394 | - } |
|
| 395 | - return $content; |
|
| 390 | + if ( ! has_excerpt( $post_id ) ) { |
|
| 391 | + $content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 ); |
|
| 392 | + } else { |
|
| 393 | + $content = get_the_excerpt( $post_id ); |
|
| 394 | + } |
|
| 395 | + return $content; |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | /** |
@@ -402,9 +402,9 @@ discard block |
||
| 402 | 402 | * @return void |
| 403 | 403 | */ |
| 404 | 404 | function column_class( $columns = '3' ) { |
| 405 | - $cols = ''; |
|
| 406 | - $cols .= '5' === $columns ? '15' : 12 / $columns; |
|
| 407 | - return $cols; |
|
| 405 | + $cols = ''; |
|
| 406 | + $cols .= '5' === $columns ? '15' : 12 / $columns; |
|
| 407 | + return $cols; |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -414,22 +414,22 @@ discard block |
||
| 414 | 414 | * @return void |
| 415 | 415 | */ |
| 416 | 416 | function get_exercises_by_workout( $workout = '' ) { |
| 417 | - $exercises = array(); |
|
| 418 | - $i = 1; |
|
| 419 | - $section_counter = 6; |
|
| 420 | - while ( $i <= $section_counter ) { |
|
| 421 | - $group_name = 'workout_section_' . $i; |
|
| 422 | - $groups = get_post_meta( $workout, $group_name, true ); |
|
| 423 | - if ( ! empty( $groups ) ) { |
|
| 424 | - foreach ( $groups as $group ) { |
|
| 425 | - if ( isset( $group['connected_exercises'] ) ) { |
|
| 426 | - $exercises[] = $group['connected_exercises']; |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - $i++; |
|
| 431 | - } |
|
| 432 | - return $exercises; |
|
| 417 | + $exercises = array(); |
|
| 418 | + $i = 1; |
|
| 419 | + $section_counter = 6; |
|
| 420 | + while ( $i <= $section_counter ) { |
|
| 421 | + $group_name = 'workout_section_' . $i; |
|
| 422 | + $groups = get_post_meta( $workout, $group_name, true ); |
|
| 423 | + if ( ! empty( $groups ) ) { |
|
| 424 | + foreach ( $groups as $group ) { |
|
| 425 | + if ( isset( $group['connected_exercises'] ) ) { |
|
| 426 | + $exercises[] = $group['connected_exercises']; |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + $i++; |
|
| 431 | + } |
|
| 432 | + return $exercises; |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | |
@@ -440,24 +440,24 @@ discard block |
||
| 440 | 440 | * @return int |
| 441 | 441 | */ |
| 442 | 442 | function get_progress( $plan_id = false ) { |
| 443 | - $progress = 0; |
|
| 444 | - $complete = array(); |
|
| 445 | - $count = 0; |
|
| 446 | - if ( false !== $plan_id && \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) { |
|
| 447 | - $sections = \lsx_health_plan\functions\plan\get_sections(); |
|
| 448 | - $all_count = count( $sections ); |
|
| 449 | - $rest_days = 0; |
|
| 450 | - foreach ( $sections as $section_key => $section_values ) { |
|
| 451 | - if ( false !== $section_values['rest_day_enabled'] && ! $section_values['connected_meals'] ) { |
|
| 452 | - $rest_days++; |
|
| 453 | - } else if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) { |
|
| 454 | - $complete[] = true; |
|
| 455 | - } |
|
| 456 | - } |
|
| 457 | - $all_count = $all_count - $rest_days; |
|
| 458 | - $progress = (int) count( $complete ) / (int) $all_count * 100; |
|
| 459 | - } |
|
| 460 | - return $progress; |
|
| 443 | + $progress = 0; |
|
| 444 | + $complete = array(); |
|
| 445 | + $count = 0; |
|
| 446 | + if ( false !== $plan_id && \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) { |
|
| 447 | + $sections = \lsx_health_plan\functions\plan\get_sections(); |
|
| 448 | + $all_count = count( $sections ); |
|
| 449 | + $rest_days = 0; |
|
| 450 | + foreach ( $sections as $section_key => $section_values ) { |
|
| 451 | + if ( false !== $section_values['rest_day_enabled'] && ! $section_values['connected_meals'] ) { |
|
| 452 | + $rest_days++; |
|
| 453 | + } else if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) { |
|
| 454 | + $complete[] = true; |
|
| 455 | + } |
|
| 456 | + } |
|
| 457 | + $all_count = $all_count - $rest_days; |
|
| 458 | + $progress = (int) count( $complete ) / (int) $all_count * 100; |
|
| 459 | + } |
|
| 460 | + return $progress; |
|
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | |
@@ -468,17 +468,17 @@ discard block |
||
| 468 | 468 | * @return void |
| 469 | 469 | */ |
| 470 | 470 | function hp_back_archive_link() { |
| 471 | - global $wp_taxonomies; |
|
| 472 | - $post_type = get_queried_object()->taxonomy; |
|
| 471 | + global $wp_taxonomies; |
|
| 472 | + $post_type = get_queried_object()->taxonomy; |
|
| 473 | 473 | |
| 474 | - if ( is_tax() && isset( $wp_taxonomies[ $post_type ] ) ) { |
|
| 475 | - $post_type = $wp_taxonomies[ $post_type ]->object_type; |
|
| 476 | - ?> |
|
| 474 | + if ( is_tax() && isset( $wp_taxonomies[ $post_type ] ) ) { |
|
| 475 | + $post_type = $wp_taxonomies[ $post_type ]->object_type; |
|
| 476 | + ?> |
|
| 477 | 477 | <div class="archive-category-title hp-archive-category-title"> |
| 478 | 478 | <a class="back-to-blog" href="<?php echo ( esc_url( get_post_type_archive_link( $post_type[0] ) ) ); ?>"><?php echo esc_html__( 'Back To ', 'lsx' ) . esc_html( $post_type[0] ) . 's'; ?></a> |
| 479 | 479 | </div> |
| 480 | 480 | <?php |
| 481 | - } |
|
| 481 | + } |
|
| 482 | 482 | } |
| 483 | 483 | add_action( 'lsx_content_wrap_before', '\lsx_health_plan\functions\hp_back_archive_link', 20 ); |
| 484 | 484 | |
@@ -489,11 +489,11 @@ discard block |
||
| 489 | 489 | * @return array |
| 490 | 490 | */ |
| 491 | 491 | function prep_array( $item ) { |
| 492 | - if ( ! is_array( $item ) ) { |
|
| 493 | - $item = explode( ',', $item ); |
|
| 494 | - if ( ! is_array( $item ) ) { |
|
| 495 | - $item = array( $item ); |
|
| 496 | - } |
|
| 497 | - } |
|
| 498 | - return $item; |
|
| 492 | + if ( ! is_array( $item ) ) { |
|
| 493 | + $item = explode( ',', $item ); |
|
| 494 | + if ( ! is_array( $item ) ) { |
|
| 495 | + $item = array( $item ); |
|
| 496 | + } |
|
| 497 | + } |
|
| 498 | + return $item; |
|
| 499 | 499 | } |
@@ -8,129 +8,129 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Checkout { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Holds class instance |
|
| 13 | - * |
|
| 14 | - * @since 1.0.0 |
|
| 15 | - * |
|
| 16 | - * @var object \lsx_health_plan\classes\integrations\woocommerce\Checkout() |
|
| 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\Checkout() |
|
| 17 | + */ |
|
| 18 | + protected static $instance = null; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @var string |
|
| 22 | - */ |
|
| 23 | - public $plan_id = ''; |
|
| 20 | + /** |
|
| 21 | + * @var string |
|
| 22 | + */ |
|
| 23 | + public $plan_id = ''; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Constructor |
|
| 27 | - */ |
|
| 28 | - public function __construct() { |
|
| 29 | - add_filter( 'woocommerce_order_button_text', array( $this, 'checkout_button_text' ), 10, 1 ); |
|
| 25 | + /** |
|
| 26 | + * Constructor |
|
| 27 | + */ |
|
| 28 | + public function __construct() { |
|
| 29 | + add_filter( 'woocommerce_order_button_text', array( $this, 'checkout_button_text' ), 10, 1 ); |
|
| 30 | 30 | |
| 31 | - // Cart Messages. |
|
| 32 | - add_action( 'lsx_content_wrap_before', array( $this, 'cart_notices' ) ); |
|
| 33 | - add_filter( 'wc_add_to_cart_message_html', array( $this, 'add_to_cart_message' ), 10, 3 ); |
|
| 31 | + // Cart Messages. |
|
| 32 | + add_action( 'lsx_content_wrap_before', array( $this, 'cart_notices' ) ); |
|
| 33 | + add_filter( 'wc_add_to_cart_message_html', array( $this, 'add_to_cart_message' ), 10, 3 ); |
|
| 34 | 34 | |
| 35 | - // Thank you page links. |
|
| 36 | - add_filter( 'woocommerce_memberships_thank_you_message', array( $this, 'memberships_thank_you_links' ), 10, 3 ); |
|
| 37 | - } |
|
| 35 | + // Thank you page links. |
|
| 36 | + add_filter( 'woocommerce_memberships_thank_you_message', array( $this, 'memberships_thank_you_links' ), 10, 3 ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Return an instance of this class. |
|
| 41 | - * |
|
| 42 | - * @since 1.0.0 |
|
| 43 | - * |
|
| 44 | - * @return object \lsx_health_plan\classes\integrations\woocommerce\Checkout() A single instance of this class. |
|
| 45 | - */ |
|
| 46 | - public static function get_instance() { |
|
| 47 | - // If the single instance hasn't been set, set it now. |
|
| 48 | - if ( null === self::$instance ) { |
|
| 49 | - self::$instance = new self(); |
|
| 50 | - } |
|
| 51 | - return self::$instance; |
|
| 52 | - } |
|
| 39 | + /** |
|
| 40 | + * Return an instance of this class. |
|
| 41 | + * |
|
| 42 | + * @since 1.0.0 |
|
| 43 | + * |
|
| 44 | + * @return object \lsx_health_plan\classes\integrations\woocommerce\Checkout() A single instance of this class. |
|
| 45 | + */ |
|
| 46 | + public static function get_instance() { |
|
| 47 | + // If the single instance hasn't been set, set it now. |
|
| 48 | + if ( null === self::$instance ) { |
|
| 49 | + self::$instance = new self(); |
|
| 50 | + } |
|
| 51 | + return self::$instance; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Return the Place Order Text |
|
| 56 | - * |
|
| 57 | - * @param string $label |
|
| 58 | - * @return void |
|
| 59 | - */ |
|
| 60 | - public function checkout_button_text( $label = '' ) { |
|
| 61 | - $label = __( 'Place order', 'lsx-health-plan' ); |
|
| 62 | - return $label; |
|
| 63 | - } |
|
| 54 | + /** |
|
| 55 | + * Return the Place Order Text |
|
| 56 | + * |
|
| 57 | + * @param string $label |
|
| 58 | + * @return void |
|
| 59 | + */ |
|
| 60 | + public function checkout_button_text( $label = '' ) { |
|
| 61 | + $label = __( 'Place order', 'lsx-health-plan' ); |
|
| 62 | + return $label; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Saves the Plan ID to the cart data, so we can attach it to the order later. |
|
| 67 | - * |
|
| 68 | - * @param array $cart_item_data |
|
| 69 | - * @param string $product_id |
|
| 70 | - * @param string $variation_id |
|
| 71 | - * @return void |
|
| 72 | - */ |
|
| 73 | - public function add_plan_id_to_cart( $cart_item_data, $product_id, $variation_id ) { |
|
| 74 | - $plan_id = filter_input( INPUT_GET, 'plan_id' ); |
|
| 75 | - if ( empty( $plan_id ) || '' === $plan_id ) { |
|
| 76 | - return $cart_item_data; |
|
| 77 | - } |
|
| 78 | - $cart_item_data['plan_id'] = $plan_id; |
|
| 79 | - return $cart_item_data; |
|
| 80 | - } |
|
| 65 | + /** |
|
| 66 | + * Saves the Plan ID to the cart data, so we can attach it to the order later. |
|
| 67 | + * |
|
| 68 | + * @param array $cart_item_data |
|
| 69 | + * @param string $product_id |
|
| 70 | + * @param string $variation_id |
|
| 71 | + * @return void |
|
| 72 | + */ |
|
| 73 | + public function add_plan_id_to_cart( $cart_item_data, $product_id, $variation_id ) { |
|
| 74 | + $plan_id = filter_input( INPUT_GET, 'plan_id' ); |
|
| 75 | + if ( empty( $plan_id ) || '' === $plan_id ) { |
|
| 76 | + return $cart_item_data; |
|
| 77 | + } |
|
| 78 | + $cart_item_data['plan_id'] = $plan_id; |
|
| 79 | + return $cart_item_data; |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Output the WooCommerce Cart Notices. |
|
| 84 | - * |
|
| 85 | - * @return void |
|
| 86 | - */ |
|
| 87 | - public function cart_notices() { |
|
| 88 | - if ( function_exists( 'woocommerce_output_all_notices' ) && is_post_type_archive( 'plan' ) ) { |
|
| 89 | - echo wp_kses_post( '<div class="col-md-12 col-sm-12 woocommerce-notices-wrapper">' ); |
|
| 90 | - wc_print_notices(); |
|
| 91 | - echo wp_kses_post( '</div>' ); |
|
| 92 | - } |
|
| 93 | - } |
|
| 82 | + /** |
|
| 83 | + * Output the WooCommerce Cart Notices. |
|
| 84 | + * |
|
| 85 | + * @return void |
|
| 86 | + */ |
|
| 87 | + public function cart_notices() { |
|
| 88 | + if ( function_exists( 'woocommerce_output_all_notices' ) && is_post_type_archive( 'plan' ) ) { |
|
| 89 | + echo wp_kses_post( '<div class="col-md-12 col-sm-12 woocommerce-notices-wrapper">' ); |
|
| 90 | + wc_print_notices(); |
|
| 91 | + echo wp_kses_post( '</div>' ); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Changes the add to cart message and adds our course name. |
|
| 97 | - * |
|
| 98 | - * @param string $message |
|
| 99 | - * @param array $products |
|
| 100 | - * @param boolean $show_qty |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - public function add_to_cart_message( $message, $products, $show_qty ) { |
|
| 104 | - if ( isset( $_GET['plan_id'] ) ) { // @codingStandardsIgnoreLine. |
|
| 105 | - $this->plan_id = sanitize_text_field( wp_slash( $_GET['plan_id'] ) ); // @codingStandardsIgnoreLine. |
|
| 95 | + /** |
|
| 96 | + * Changes the add to cart message and adds our course name. |
|
| 97 | + * |
|
| 98 | + * @param string $message |
|
| 99 | + * @param array $products |
|
| 100 | + * @param boolean $show_qty |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + public function add_to_cart_message( $message, $products, $show_qty ) { |
|
| 104 | + if ( isset( $_GET['plan_id'] ) ) { // @codingStandardsIgnoreLine. |
|
| 105 | + $this->plan_id = sanitize_text_field( wp_slash( $_GET['plan_id'] ) ); // @codingStandardsIgnoreLine. |
|
| 106 | 106 | |
| 107 | - $title = '<strong>' . get_the_title( $this->plan_id ) . '</strong>'; |
|
| 108 | - $title = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', 1, 'lsx-health-plan' ), $title ); |
|
| 107 | + $title = '<strong>' . get_the_title( $this->plan_id ) . '</strong>'; |
|
| 108 | + $title = sprintf( _n( '%s has been added to your cart.', '%s have been added to your cart.', 1, 'lsx-health-plan' ), $title ); |
|
| 109 | 109 | |
| 110 | - // Output success messages. |
|
| 111 | - if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { |
|
| 112 | - $return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) ); |
|
| 113 | - $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( $return_to ), esc_html__( 'Continue shopping', 'lsx-health-plan' ), $title ); |
|
| 114 | - } else { |
|
| 115 | - $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( wc_get_cart_url() ), esc_html__( 'View cart', 'lsx-health-plan' ), $title ); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - return $message; |
|
| 119 | - } |
|
| 110 | + // Output success messages. |
|
| 111 | + if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) { |
|
| 112 | + $return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) ); |
|
| 113 | + $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( $return_to ), esc_html__( 'Continue shopping', 'lsx-health-plan' ), $title ); |
|
| 114 | + } else { |
|
| 115 | + $message = sprintf( '<a href="%s" tabindex="1" class="btn button wc-forward">%s</a> %s', esc_url( wc_get_cart_url() ), esc_html__( 'View cart', 'lsx-health-plan' ), $title ); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + return $message; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Replaces the links on the thank you page. |
|
| 123 | - * |
|
| 124 | - * @param string $message |
|
| 125 | - * @param int $order_id |
|
| 126 | - * @param object $memberships |
|
| 127 | - * @return string |
|
| 128 | - */ |
|
| 129 | - public function memberships_thank_you_links( $message, $order_id, $memberships ) { |
|
| 130 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
| 131 | - if ( false !== $plan_slug && '' !== $plan_slug ) { |
|
| 132 | - $message = preg_replace( '/<a(.*)href="([^"]*)"(.*)>/', '<a$1href="' . home_url( $plan_slug ) . '"$3>', $message ); |
|
| 133 | - } |
|
| 134 | - return $message; |
|
| 135 | - } |
|
| 121 | + /** |
|
| 122 | + * Replaces the links on the thank you page. |
|
| 123 | + * |
|
| 124 | + * @param string $message |
|
| 125 | + * @param int $order_id |
|
| 126 | + * @param object $memberships |
|
| 127 | + * @return string |
|
| 128 | + */ |
|
| 129 | + public function memberships_thank_you_links( $message, $order_id, $memberships ) { |
|
| 130 | + $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
| 131 | + if ( false !== $plan_slug && '' !== $plan_slug ) { |
|
| 132 | + $message = preg_replace( '/<a(.*)href="([^"]*)"(.*)>/', '<a$1href="' . home_url( $plan_slug ) . '"$3>', $message ); |
|
| 133 | + } |
|
| 134 | + return $message; |
|
| 135 | + } |
|
| 136 | 136 | } |