@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | * @param string $post_id |
| 12 | 12 | * @return boolean |
| 13 | 13 | */ |
| 14 | -function lsx_health_plan_has_warmup( $post_id = '' ) { |
|
| 15 | - if ( '' === $post_id ) { |
|
| 14 | +function lsx_health_plan_has_warmup($post_id = '') { |
|
| 15 | + if ('' === $post_id) { |
|
| 16 | 16 | $post_id = get_the_ID(); |
| 17 | 17 | } |
| 18 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
| 18 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'plan_warmup'); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -24,22 +24,22 @@ discard block |
||
| 24 | 24 | * @param string $post_id |
| 25 | 25 | * @return boolean |
| 26 | 26 | */ |
| 27 | -function lsx_health_plan_has_workout( $post_id = '' ) { |
|
| 28 | - if ( ! post_type_exists( 'workout' ) ) { |
|
| 27 | +function lsx_health_plan_has_workout($post_id = '') { |
|
| 28 | + if ( ! post_type_exists('workout')) { |
|
| 29 | 29 | return false; |
| 30 | 30 | } |
| 31 | - if ( '' === $post_id ) { |
|
| 31 | + if ('' === $post_id) { |
|
| 32 | 32 | $post_id = get_the_ID(); |
| 33 | 33 | } |
| 34 | 34 | $has_workouts = false; |
| 35 | 35 | |
| 36 | - $section_key = get_query_var( 'section', false ); |
|
| 37 | - if ( false !== $section_key ) { |
|
| 38 | - $section_info = \lsx_health_plan\functions\plan\get_section_info( $section_key ); |
|
| 39 | - if ( isset( $section_info['connected_workouts'] ) && ! empty( $section_info['connected_workouts'] ) ) { |
|
| 36 | + $section_key = get_query_var('section', false); |
|
| 37 | + if (false !== $section_key) { |
|
| 38 | + $section_info = \lsx_health_plan\functions\plan\get_section_info($section_key); |
|
| 39 | + if (isset($section_info['connected_workouts']) && ! empty($section_info['connected_workouts'])) { |
|
| 40 | 40 | $has_workouts = true; |
| 41 | 41 | } |
| 42 | - } elseif ( \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ) ) { |
|
| 42 | + } elseif (\lsx_health_plan\functions\has_attached_post($post_id, 'connected_workouts')) { |
|
| 43 | 43 | $has_workouts = true; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | * @param string $post_id |
| 53 | 53 | * @return boolean |
| 54 | 54 | */ |
| 55 | -function lsx_health_plan_has_meal( $post_id = '' ) { |
|
| 56 | - if ( ! post_type_exists( 'meal' ) ) { |
|
| 55 | +function lsx_health_plan_has_meal($post_id = '') { |
|
| 56 | + if ( ! post_type_exists('meal')) { |
|
| 57 | 57 | return false; |
| 58 | 58 | } |
| 59 | - if ( '' === $post_id ) { |
|
| 59 | + if ('' === $post_id) { |
|
| 60 | 60 | $post_id = get_the_ID(); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
| 63 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_meals'); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -69,14 +69,14 @@ discard block |
||
| 69 | 69 | * @param string $post_id |
| 70 | 70 | * @return boolean |
| 71 | 71 | */ |
| 72 | -function lsx_health_plan_has_recipe( $post_id = '' ) { |
|
| 73 | - if ( ! post_type_exists( 'recipe' ) ) { |
|
| 72 | +function lsx_health_plan_has_recipe($post_id = '') { |
|
| 73 | + if ( ! post_type_exists('recipe')) { |
|
| 74 | 74 | return false; |
| 75 | 75 | } |
| 76 | - if ( '' === $post_id ) { |
|
| 76 | + if ('' === $post_id) { |
|
| 77 | 77 | $post_id = get_the_ID(); |
| 78 | 78 | } |
| 79 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
| 79 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_recipes'); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | * @param string $post_id |
| 86 | 86 | * @return boolean |
| 87 | 87 | */ |
| 88 | -function lsx_health_plan_has_downloads( $post_id = '' ) { |
|
| 88 | +function lsx_health_plan_has_downloads($post_id = '') { |
|
| 89 | 89 | $has_downloads = false; |
| 90 | - if ( '' === $post_id ) { |
|
| 90 | + if ('' === $post_id) { |
|
| 91 | 91 | $post_id = get_the_ID(); |
| 92 | 92 | } |
| 93 | - $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
| 94 | - if ( ! empty( $downloads ) ) { |
|
| 93 | + $downloads = \lsx_health_plan\functions\get_downloads('all', $post_id); |
|
| 94 | + if ( ! empty($downloads)) { |
|
| 95 | 95 | $has_downloads = true; |
| 96 | 96 | } |
| 97 | 97 | return $has_downloads; |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | * @param string $post_id |
| 104 | 104 | * @return boolean |
| 105 | 105 | */ |
| 106 | -function lsx_health_plan_has_tip( $post_id = '' ) { |
|
| 107 | - if ( ! post_type_exists( 'tip' ) ) { |
|
| 106 | +function lsx_health_plan_has_tip($post_id = '') { |
|
| 107 | + if ( ! post_type_exists('tip')) { |
|
| 108 | 108 | return false; |
| 109 | 109 | } |
| 110 | - if ( '' === $post_id ) { |
|
| 110 | + if ('' === $post_id) { |
|
| 111 | 111 | $post_id = get_the_ID(); |
| 112 | 112 | } |
| 113 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
| 113 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_tips'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,14 +119,14 @@ discard block |
||
| 119 | 119 | * @param string $post_id |
| 120 | 120 | * @return boolean |
| 121 | 121 | */ |
| 122 | -function lsx_health_plan_has_video( $post_id = '' ) { |
|
| 123 | - if ( ! post_type_exists( 'video' ) ) { |
|
| 122 | +function lsx_health_plan_has_video($post_id = '') { |
|
| 123 | + if ( ! post_type_exists('video')) { |
|
| 124 | 124 | return false; |
| 125 | 125 | } |
| 126 | - if ( '' === $post_id ) { |
|
| 126 | + if ('' === $post_id) { |
|
| 127 | 127 | $post_id = get_the_ID(); |
| 128 | 128 | } |
| 129 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
| 129 | + return \lsx_health_plan\functions\has_attached_post($post_id, 'connected_videos'); |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | function lsx_health_plan_user_has_purchase() { |
| 138 | 138 | $valid_order = false; |
| 139 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
| 139 | + $product_id = \lsx_health_plan\functions\get_option('membership_product', false); |
|
| 140 | 140 | |
| 141 | - if ( is_user_logged_in() && false !== $product_id ) { |
|
| 141 | + if (is_user_logged_in() && false !== $product_id) { |
|
| 142 | 142 | $current_user = wp_get_current_user(); |
| 143 | - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
| 143 | + if (wc_customer_bought_product($current_user->user_email, $current_user->ID, $product_id)) { |
|
| 144 | 144 | $valid_order = true; |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -153,15 +153,15 @@ discard block |
||
| 153 | 153 | * @param string $post_id |
| 154 | 154 | * @return boolean |
| 155 | 155 | */ |
| 156 | -function lsx_health_plan_is_current_tab( $needle = '' ) { |
|
| 156 | +function lsx_health_plan_is_current_tab($needle = '') { |
|
| 157 | 157 | $is_tab = false; |
| 158 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
| 159 | - if ( false === $plan_slug ) { |
|
| 158 | + $plan_slug = \lsx_health_plan\functions\get_option('my_plan_slug', false); |
|
| 159 | + if (false === $plan_slug) { |
|
| 160 | 160 | $plan_slug = 'my-plan'; |
| 161 | 161 | } |
| 162 | - if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
| 163 | - $endpoint = get_query_var( 'endpoint' ); |
|
| 164 | - if ( false !== $endpoint && $needle === $endpoint ) { |
|
| 162 | + if (is_singular('plan') || is_page($plan_slug)) { |
|
| 163 | + $endpoint = get_query_var('endpoint'); |
|
| 164 | + if (false !== $endpoint && $needle === $endpoint) { |
|
| 165 | 165 | $is_tab = true; |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | * @param string $post_id |
| 175 | 175 | * @return boolean |
| 176 | 176 | */ |
| 177 | -function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) { |
|
| 177 | +function lsx_health_plan_is_day_complete($post_id = '', $section_key = '') { |
|
| 178 | 178 | $is_complete = false; |
| 179 | - if ( '' === $post_id ) { |
|
| 179 | + if ('' === $post_id) { |
|
| 180 | 180 | $post_id = get_the_ID(); |
| 181 | 181 | } |
| 182 | - $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
| 183 | - $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
| 184 | - if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
| 182 | + $key = \lsx_health_plan\functions\plan\generate_section_id($section_key); |
|
| 183 | + $is_day_complete = get_user_meta(get_current_user_id(), 'day_' . $key . '_complete', true); |
|
| 184 | + if (false !== $is_day_complete && '' !== $is_day_complete) { |
|
| 185 | 185 | $is_complete = true; |
| 186 | 186 | } |
| 187 | 187 | |
@@ -199,11 +199,11 @@ discard block |
||
| 199 | 199 | * @param string $week The week name 'week-1'. |
| 200 | 200 | * @return boolean |
| 201 | 201 | */ |
| 202 | -function lsx_health_plan_week_has_downloads( $week = '' ) { |
|
| 202 | +function lsx_health_plan_week_has_downloads($week = '') { |
|
| 203 | 203 | $has_downloads = false; |
| 204 | - if ( '' !== $week ) { |
|
| 205 | - $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
| 206 | - if ( ! empty( $downloads ) ) { |
|
| 204 | + if ('' !== $week) { |
|
| 205 | + $downloads = \lsx_health_plan\functions\get_weekly_downloads($week); |
|
| 206 | + if ( ! empty($downloads)) { |
|
| 207 | 207 | $has_downloads = true; |
| 208 | 208 | } |
| 209 | 209 | } |
@@ -216,15 +216,15 @@ discard block |
||
| 216 | 216 | * @param string $post_id |
| 217 | 217 | * @return boolean |
| 218 | 218 | */ |
| 219 | -function lsx_health_plan_has_tips( $post_id = '' ) { |
|
| 219 | +function lsx_health_plan_has_tips($post_id = '') { |
|
| 220 | 220 | $has_tips = false; |
| 221 | - if ( '' === $post_id ) { |
|
| 221 | + if ('' === $post_id) { |
|
| 222 | 222 | $post_id = get_the_ID(); |
| 223 | 223 | } |
| 224 | - $post_type = get_post_type( $post_id ); |
|
| 225 | - $connected_tips = get_post_meta( get_the_ID(), $post_type . '_connected_tips', true ); |
|
| 226 | - $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
| 227 | - if ( ! empty( $connected_tips ) ) { |
|
| 224 | + $post_type = get_post_type($post_id); |
|
| 225 | + $connected_tips = get_post_meta(get_the_ID(), $post_type . '_connected_tips', true); |
|
| 226 | + $connected_tips = \lsx_health_plan\functions\check_posts_exist($connected_tips); |
|
| 227 | + if ( ! empty($connected_tips)) { |
|
| 228 | 228 | $has_tips = true; |
| 229 | 229 | } |
| 230 | 230 | return $has_tips; |
@@ -16,59 +16,59 @@ discard block |
||
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | 18 | $plan_id = get_the_ID(); |
| 19 | -$has_sections = \lsx_health_plan\functions\plan\has_sections( $plan_id ); |
|
| 19 | +$has_sections = \lsx_health_plan\functions\plan\has_sections($plan_id); |
|
| 20 | 20 | $restricted = false; |
| 21 | -$is_section = get_query_var( 'section', false ); |
|
| 21 | +$is_section = get_query_var('section', false); |
|
| 22 | 22 | |
| 23 | 23 | // Getting translated endpoint. |
| 24 | -$plan = \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ); |
|
| 24 | +$plan = \lsx_health_plan\functions\get_option('endpoint_plan', 'plan'); |
|
| 25 | 25 | |
| 26 | -$connected_members = get_post_meta( get_the_ID(), ( $plan . '_connected_team_member' ), true ); |
|
| 27 | -$connected_articles = get_post_meta( get_the_ID(), ( $plan . '_connected_articles' ), true ); |
|
| 28 | -$small_description = get_post_meta( get_the_ID(), ( $plan . '_short_description' ), true ); |
|
| 26 | +$connected_members = get_post_meta(get_the_ID(), ($plan . '_connected_team_member'), true); |
|
| 27 | +$connected_articles = get_post_meta(get_the_ID(), ($plan . '_connected_articles'), true); |
|
| 28 | +$small_description = get_post_meta(get_the_ID(), ($plan . '_short_description'), true); |
|
| 29 | 29 | |
| 30 | -if ( ! empty( $has_sections ) && empty( $is_section ) ) { |
|
| 30 | +if ( ! empty($has_sections) && empty($is_section)) { |
|
| 31 | 31 | $plan_type_class = 'parent-plan'; |
| 32 | 32 | } |
| 33 | -if ( ! empty( $has_sections ) && ! empty( $is_section ) ) { |
|
| 33 | +if ( ! empty($has_sections) && ! empty($is_section)) { |
|
| 34 | 34 | $plan_type_class = 'child-plan'; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | // Get the plan restrictions. |
| 38 | -if ( function_exists( 'wc_memberships_is_post_content_restricted' ) && wc_memberships_is_post_content_restricted( get_the_ID() ) ) { |
|
| 39 | - $restricted = ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
| 38 | +if (function_exists('wc_memberships_is_post_content_restricted') && wc_memberships_is_post_content_restricted(get_the_ID())) { |
|
| 39 | + $restricted = ! current_user_can('wc_memberships_view_restricted_post_content', get_the_ID()); |
|
| 40 | 40 | } |
| 41 | -if ( false === $restricted ) { |
|
| 42 | - $round_progress = round( \lsx_health_plan\functions\get_progress( get_the_ID() ), 0 ); |
|
| 41 | +if (false === $restricted) { |
|
| 42 | + $round_progress = round(\lsx_health_plan\functions\get_progress(get_the_ID()), 0); |
|
| 43 | 43 | } |
| 44 | 44 | ?> |
| 45 | 45 | |
| 46 | -<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>"> |
|
| 46 | +<div id="primary" class="content-area <?php echo esc_attr(lsx_main_class()); ?>"> |
|
| 47 | 47 | |
| 48 | 48 | <?php lsx_content_before(); ?> |
| 49 | 49 | |
| 50 | - <main id="main" class="site-main <?php echo esc_html( $plan_type_class ); ?>" role="main"> |
|
| 50 | + <main id="main" class="site-main <?php echo esc_html($plan_type_class); ?>" role="main"> |
|
| 51 | 51 | |
| 52 | 52 | <?php lsx_content_top(); ?> |
| 53 | 53 | |
| 54 | 54 | <div class="post-wrapper"> |
| 55 | - <?php if ( ! empty( $has_sections ) && empty( $is_section ) ) { ?> |
|
| 55 | + <?php if ( ! empty($has_sections) && empty($is_section)) { ?> |
|
| 56 | 56 | <div class="plan-content"> |
| 57 | 57 | <?php the_content(); ?> |
| 58 | 58 | </div> |
| 59 | 59 | <?php } ?> |
| 60 | 60 | |
| 61 | 61 | <?php |
| 62 | - if ( ! empty( $has_sections ) ) { |
|
| 63 | - if ( false === $is_section ) { |
|
| 62 | + if ( ! empty($has_sections)) { |
|
| 63 | + if (false === $is_section) { |
|
| 64 | 64 | ?> |
| 65 | 65 | <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> |
| 66 | 66 | <div class="entry-content"> |
| 67 | 67 | <div class="single-plan-inner main-plan-content"> |
| 68 | 68 | <div class="single-plan-section-title title-lined"> |
| 69 | - <?php lsx_get_svg_icon( 'my-plan.svg' ); ?> |
|
| 70 | - <h2><?php echo esc_html_e( 'Your Plan', 'lsx-health-plan' ); ?></h2> |
|
| 71 | - <?php if ( class_exists( 'LSX_Sharing' ) ) { |
|
| 69 | + <?php lsx_get_svg_icon('my-plan.svg'); ?> |
|
| 70 | + <h2><?php echo esc_html_e('Your Plan', 'lsx-health-plan'); ?></h2> |
|
| 71 | + <?php if (class_exists('LSX_Sharing')) { |
|
| 72 | 72 | lsx_content_sharing(); |
| 73 | 73 | } ?> |
| 74 | 74 | </div> |
@@ -76,36 +76,36 @@ discard block |
||
| 76 | 76 | <div class="set-box set content-box entry-content"> |
| 77 | 77 | <div class="plan-top-content"> |
| 78 | 78 | <?php |
| 79 | - if ( $connected_members ) { |
|
| 80 | - echo wp_kses_post( lsx_hp_member_connected( $connected_members, $plan ) ); |
|
| 79 | + if ($connected_members) { |
|
| 80 | + echo wp_kses_post(lsx_hp_member_connected($connected_members, $plan)); |
|
| 81 | 81 | } |
| 82 | - if ( false === $restricted ) { |
|
| 83 | - echo wp_kses_post( '<span class="progress"><progress class="bar" value="' . $round_progress . '" max="100"> ' . $round_progress . '% </progress><span>' . $round_progress . '%</span></span>' ); |
|
| 82 | + if (false === $restricted) { |
|
| 83 | + echo wp_kses_post('<span class="progress"><progress class="bar" value="' . $round_progress . '" max="100"> ' . $round_progress . '% </progress><span>' . $round_progress . '%</span></span>'); |
|
| 84 | 84 | } |
| 85 | - if ( $small_description ) { |
|
| 85 | + if ($small_description) { |
|
| 86 | 86 | ?> |
| 87 | 87 | <div class="the-content"> |
| 88 | - <span><?php echo esc_html( $small_description ); ?></span> |
|
| 88 | + <span><?php echo esc_html($small_description); ?></span> |
|
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | 91 | } |
| 92 | 92 | ?> |
| 93 | 93 | </div> |
| 94 | 94 | <?php |
| 95 | - if ( lsx_health_plan_has_tips() ) { |
|
| 96 | - echo wp_kses_post( do_shortcode( '[lsx_health_plan_featured_tips_block]' ) ); |
|
| 95 | + if (lsx_health_plan_has_tips()) { |
|
| 96 | + echo wp_kses_post(do_shortcode('[lsx_health_plan_featured_tips_block]')); |
|
| 97 | 97 | } ?> |
| 98 | 98 | </div> |
| 99 | 99 | <div class="the-plan-content"> |
| 100 | 100 | <?php |
| 101 | - echo do_shortcode( '[lsx_health_plan_day_plan_block week_view="true" show_downloads="true" plan="' . get_the_ID() . '"]' ); |
|
| 101 | + echo do_shortcode('[lsx_health_plan_day_plan_block week_view="true" show_downloads="true" plan="' . get_the_ID() . '"]'); |
|
| 102 | 102 | |
| 103 | 103 | ?> |
| 104 | 104 | <div class="row status-plan-buttons main-plan-btn"> |
| 105 | 105 | <?php |
| 106 | - if ( function_exists( 'wc_get_page_id' ) ) { |
|
| 106 | + if (function_exists('wc_get_page_id')) { |
|
| 107 | 107 | ?> |
| 108 | - <a class="btn border-btn" href="<?php echo wp_kses_post( get_permalink( wc_get_page_id( 'myaccount' ) ) ); ?>"><?php esc_html_e( 'My Plans', 'lsx-health-plan' ); ?></a> |
|
| 108 | + <a class="btn border-btn" href="<?php echo wp_kses_post(get_permalink(wc_get_page_id('myaccount'))); ?>"><?php esc_html_e('My Plans', 'lsx-health-plan'); ?></a> |
|
| 109 | 109 | <?php |
| 110 | 110 | } |
| 111 | 111 | ?> |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | <?php |
| 129 | 129 | // Show the buttons on the single plan tabs. |
| 130 | - if ( ! empty( $has_sections ) && false !== $is_section ) { |
|
| 130 | + if ( ! empty($has_sections) && false !== $is_section) { |
|
| 131 | 131 | ?> |
| 132 | 132 | <div class="row status-plan-buttons"> |
| 133 | 133 | <?php lsx_health_plan_day_button(); ?> |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | <?php lsx_content_bottom(); ?> |
| 140 | 140 | |
| 141 | 141 | <?php |
| 142 | - if ( ! empty( $connected_articles ) ) { |
|
| 143 | - lsx_hp_single_related( $connected_articles, __( 'Latest articles', 'lsx-health-plan' ) ); |
|
| 142 | + if ( ! empty($connected_articles)) { |
|
| 143 | + lsx_hp_single_related($connected_articles, __('Latest articles', 'lsx-health-plan')); |
|
| 144 | 144 | } |
| 145 | 145 | ?> |
| 146 | 146 | |