@@ -7,38 +7,38 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | function lsx_hp_single_plan_products() { |
| 10 | - global $product; |
|
| 10 | + global $product; |
|
| 11 | 11 | |
| 12 | - $restricted = false; |
|
| 13 | - if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
| 14 | - $restricted = wc_memberships_is_post_content_restricted() && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
| 15 | - } |
|
| 16 | - if ( true === $restricted && \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
| 17 | - $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
|
| 18 | - $product_count = count( $products ); |
|
| 19 | - if ( 1 === (int) $product_count ) { |
|
| 20 | - $class = 'col-md-12'; |
|
| 21 | - } else { |
|
| 22 | - $class = 'col-md-6'; |
|
| 23 | - } |
|
| 24 | - ?> |
|
| 12 | + $restricted = false; |
|
| 13 | + if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
| 14 | + $restricted = wc_memberships_is_post_content_restricted() && ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
|
| 15 | + } |
|
| 16 | + if ( true === $restricted && \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
| 17 | + $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
|
| 18 | + $product_count = count( $products ); |
|
| 19 | + if ( 1 === (int) $product_count ) { |
|
| 20 | + $class = 'col-md-12'; |
|
| 21 | + } else { |
|
| 22 | + $class = 'col-md-6'; |
|
| 23 | + } |
|
| 24 | + ?> |
|
| 25 | 25 | <div class="plans-products-wrapper row"> |
| 26 | 26 | <?php |
| 27 | - foreach ( $products as $product ) { |
|
| 28 | - $product = wc_get_product( $product ); |
|
| 29 | - ?> |
|
| 27 | + foreach ( $products as $product ) { |
|
| 28 | + $product = wc_get_product( $product ); |
|
| 29 | + ?> |
|
| 30 | 30 | <div class="plan-product <?php echo esc_attr( $class ); ?>"> |
| 31 | 31 | <h3 class="title"><a href="<?php echo esc_html( $product->get_permalink() ); ?>"><?php echo esc_html( $product->get_title() ); ?></a></h3> |
| 32 | 32 | <?php |
| 33 | - $description = $product->is_type( 'variation' ) ? $product->get_description() : $product->get_short_description(); |
|
| 34 | - if ( '' !== $description ) { |
|
| 35 | - ?> |
|
| 33 | + $description = $product->is_type( 'variation' ) ? $product->get_description() : $product->get_short_description(); |
|
| 34 | + if ( '' !== $description ) { |
|
| 35 | + ?> |
|
| 36 | 36 | <div class="description"> |
| 37 | 37 | <?php echo esc_html( $description ); ?> |
| 38 | 38 | </div> |
| 39 | 39 | <?php |
| 40 | - } |
|
| 41 | - ?> |
|
| 40 | + } |
|
| 41 | + ?> |
|
| 42 | 42 | <?php echo wp_kses_post( $product->get_price_html() ); ?> |
| 43 | 43 | |
| 44 | 44 | <div class="add-to-cart"> |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | </div> |
| 47 | 47 | </div> |
| 48 | 48 | <?php |
| 49 | - } |
|
| 50 | - ?> |
|
| 49 | + } |
|
| 50 | + ?> |
|
| 51 | 51 | </div> |
| 52 | 52 | <?php |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | * @return void |
| 12 | 12 | */ |
| 13 | 13 | function lsx_hp_plan_archive_filters() { |
| 14 | - if ( is_post_type_archive( 'plan' ) && function_exists( 'wc_get_page_id' ) && false === apply_filters( 'lsx_hp_disable_plan_archive_filters', false ) ) { |
|
| 15 | - ?> |
|
| 14 | + if ( is_post_type_archive( 'plan' ) && function_exists( 'wc_get_page_id' ) && false === apply_filters( 'lsx_hp_disable_plan_archive_filters', false ) ) { |
|
| 15 | + ?> |
|
| 16 | 16 | <div id="type-nav"> |
| 17 | 17 | <ul class="nav nav-pills lsx-type-nav-filter"> |
| 18 | 18 | <li class="active"><a href="<?php echo empty( $group_selected ) ? '#' : esc_url( get_post_type_archive_link( 'plan' ) ); ?>" data-filter="*"><?php esc_html_e( 'All', 'lsx-health-plan' ); ?></a></li> |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | </ul> |
| 22 | 22 | </div> |
| 23 | 23 | <?php |
| 24 | - } |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
@@ -30,22 +30,22 @@ discard block |
||
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | 32 | function lsx_hp_plan_get_classes() { |
| 33 | - $classes = 'filter-free'; |
|
| 34 | - if ( \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
| 35 | - $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
|
| 36 | - $linked_product = wc_get_product( $products[0] ); |
|
| 37 | - $price = $linked_product->get_price( 'raw' ); |
|
| 38 | - if ( empty( $price ) ) { |
|
| 39 | - $classes = 'filter-free'; |
|
| 40 | - } else { |
|
| 41 | - $classes = 'filter-paid'; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - return $classes; |
|
| 33 | + $classes = 'filter-free'; |
|
| 34 | + if ( \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
| 35 | + $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
|
| 36 | + $linked_product = wc_get_product( $products[0] ); |
|
| 37 | + $price = $linked_product->get_price( 'raw' ); |
|
| 38 | + if ( empty( $price ) ) { |
|
| 39 | + $classes = 'filter-free'; |
|
| 40 | + } else { |
|
| 41 | + $classes = 'filter-paid'; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + return $classes; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | function lsx_health_plan_back_to_plan_button() { |
| 48 | - ?> |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="back-plan-btn"> |
| 50 | 50 | <a class="btn" href="<?php the_permalink(); ?>"><?php esc_html_e( 'Back To Plan', 'lsx-health-plan' ); ?></a> |
| 51 | 51 | </div> |
@@ -11,10 +11,10 @@ discard block |
||
| 11 | 11 | * @return exercise_type |
| 12 | 12 | */ |
| 13 | 13 | function lsx_health_plan_exercise_type() { |
| 14 | - $term_obj_list = get_the_term_list( get_the_ID(), 'exercise-type', '', ', ' ); |
|
| 15 | - if ( ! empty( $term_obj_list ) ) { |
|
| 16 | - return $term_obj_list; |
|
| 17 | - } |
|
| 14 | + $term_obj_list = get_the_term_list( get_the_ID(), 'exercise-type', '', ', ' ); |
|
| 15 | + if ( ! empty( $term_obj_list ) ) { |
|
| 16 | + return $term_obj_list; |
|
| 17 | + } |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | /** |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | * @return muscle_group_equipment |
| 24 | 24 | */ |
| 25 | 25 | function lsx_health_plan_muscle_group_equipment() { |
| 26 | - $term_obj_list = get_the_term_list( get_the_ID(), 'muscle-group', '', ', ' ); |
|
| 27 | - if ( ! empty( $term_obj_list ) ) { |
|
| 28 | - return $term_obj_list; |
|
| 29 | - } |
|
| 26 | + $term_obj_list = get_the_term_list( get_the_ID(), 'muscle-group', '', ', ' ); |
|
| 27 | + if ( ! empty( $term_obj_list ) ) { |
|
| 28 | + return $term_obj_list; |
|
| 29 | + } |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -35,10 +35,10 @@ discard block |
||
| 35 | 35 | * @return exercise_equipment |
| 36 | 36 | */ |
| 37 | 37 | function lsx_health_plan_exercise_equipment() { |
| 38 | - $term_obj_list = get_the_term_list( get_the_ID(), 'equipment', '', ', ' ); |
|
| 39 | - if ( ! empty( $term_obj_list ) ) { |
|
| 40 | - return $term_obj_list; |
|
| 41 | - } |
|
| 38 | + $term_obj_list = get_the_term_list( get_the_ID(), 'equipment', '', ', ' ); |
|
| 39 | + if ( ! empty( $term_obj_list ) ) { |
|
| 40 | + return $term_obj_list; |
|
| 41 | + } |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -47,81 +47,81 @@ discard block |
||
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | 49 | function lsx_health_plan_exercise_data() { |
| 50 | - include LSX_HEALTH_PLAN_PATH . '/templates/table-exercise-data.php'; |
|
| 50 | + include LSX_HEALTH_PLAN_PATH . '/templates/table-exercise-data.php'; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | function lsx_health_plan_workout_exercise_alt_button( $m, $group, $echo = true, $args = array(), $alt_title, $alt_description, $alt_image ) { |
| 54 | - $defaults = array( |
|
| 55 | - 'modal_trigger' => 'button', |
|
| 56 | - 'modal_content' => 'excerpt', |
|
| 57 | - ); |
|
| 58 | - $args = wp_parse_args( $args, $defaults ); |
|
| 54 | + $defaults = array( |
|
| 55 | + 'modal_trigger' => 'button', |
|
| 56 | + 'modal_content' => 'excerpt', |
|
| 57 | + ); |
|
| 58 | + $args = wp_parse_args( $args, $defaults ); |
|
| 59 | 59 | |
| 60 | - $exercise_id = ''; |
|
| 61 | - if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
| 62 | - $exercise_id = esc_html( $group['connected_exercises'] ); |
|
| 63 | - $content = get_post_field( 'post_content', $exercise_id ); |
|
| 64 | - $url = get_permalink( $exercise_id ); |
|
| 65 | - $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
| 66 | - $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
| 67 | - $lsx_hp = lsx_health_plan(); |
|
| 60 | + $exercise_id = ''; |
|
| 61 | + if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
| 62 | + $exercise_id = esc_html( $group['connected_exercises'] ); |
|
| 63 | + $content = get_post_field( 'post_content', $exercise_id ); |
|
| 64 | + $url = get_permalink( $exercise_id ); |
|
| 65 | + $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
| 66 | + $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
| 67 | + $lsx_hp = lsx_health_plan(); |
|
| 68 | 68 | |
| 69 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
| 70 | - $content = wp_trim_words( $content, 40 ); |
|
| 71 | - } |
|
| 69 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
| 70 | + $content = wp_trim_words( $content, 40 ); |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - if ( 'link' ) { |
|
| 74 | - $play_button = '<a data-toggle="modal" href="#workout-alt-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
| 75 | - } else { |
|
| 76 | - $play_button = '<button data-toggle="alt-modal" data-target="#workout-alt-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
| 77 | - } |
|
| 73 | + if ( 'link' ) { |
|
| 74 | + $play_button = '<a data-toggle="modal" href="#workout-alt-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
| 75 | + } else { |
|
| 76 | + $play_button = '<button data-toggle="alt-modal" data-target="#workout-alt-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - $modal_body = ''; |
|
| 79 | + $modal_body = ''; |
|
| 80 | 80 | |
| 81 | - if ( '' !== $alt_image ) { |
|
| 82 | - $modal_body .= '<div class="modal-image"/><img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '"></div>'; |
|
| 83 | - } else { |
|
| 84 | - if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
| 85 | - $gallery_args = array( |
|
| 86 | - 'css_class' => 'modal-slider', |
|
| 87 | - ); |
|
| 88 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
| 89 | - } else { |
|
| 90 | - $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
| 91 | - } |
|
| 92 | - } |
|
| 81 | + if ( '' !== $alt_image ) { |
|
| 82 | + $modal_body .= '<div class="modal-image"/><img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '"></div>'; |
|
| 83 | + } else { |
|
| 84 | + if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
| 85 | + $gallery_args = array( |
|
| 86 | + 'css_class' => 'modal-slider', |
|
| 87 | + ); |
|
| 88 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
| 89 | + } else { |
|
| 90 | + $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - if ( '' !== $alt_title ) { |
|
| 95 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $alt_title . '</h5>'; |
|
| 96 | - } else { |
|
| 97 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
| 98 | - } |
|
| 94 | + if ( '' !== $alt_title ) { |
|
| 95 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $alt_title . '</h5>'; |
|
| 96 | + } else { |
|
| 97 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - if ( ! empty( $equipment_group ) ) { |
|
| 101 | - $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
| 102 | - } |
|
| 103 | - if ( ! empty( $muscle_group ) ) { |
|
| 104 | - $modal_body .= '<span class="muscle-terms">Muscle Group: ' . $muscle_group . '</span>'; |
|
| 105 | - } |
|
| 106 | - $modal_body .= '</div>'; |
|
| 107 | - if ( '' !== $args['modal_content'] ) { |
|
| 108 | - if ( '' !== $alt_description ) { |
|
| 109 | - $modal_body .= '<div class="modal-excerpt"/>' . $alt_description . '</div>'; |
|
| 110 | - } else { |
|
| 111 | - $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
| 115 | - $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>'; |
|
| 116 | - } |
|
| 117 | - \lsx_health_plan\functions\register_modal( 'workout-alt-exercise-modal-' . $m, '', $modal_body ); |
|
| 100 | + if ( ! empty( $equipment_group ) ) { |
|
| 101 | + $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
| 102 | + } |
|
| 103 | + if ( ! empty( $muscle_group ) ) { |
|
| 104 | + $modal_body .= '<span class="muscle-terms">Muscle Group: ' . $muscle_group . '</span>'; |
|
| 105 | + } |
|
| 106 | + $modal_body .= '</div>'; |
|
| 107 | + if ( '' !== $args['modal_content'] ) { |
|
| 108 | + if ( '' !== $alt_description ) { |
|
| 109 | + $modal_body .= '<div class="modal-excerpt"/>' . $alt_description . '</div>'; |
|
| 110 | + } else { |
|
| 111 | + $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
| 115 | + $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>'; |
|
| 116 | + } |
|
| 117 | + \lsx_health_plan\functions\register_modal( 'workout-alt-exercise-modal-' . $m, '', $modal_body ); |
|
| 118 | 118 | |
| 119 | - if ( true === $echo ) { |
|
| 120 | - echo wp_kses_post( $play_button ); |
|
| 121 | - } else { |
|
| 122 | - return $play_button; |
|
| 123 | - } |
|
| 124 | - } |
|
| 119 | + if ( true === $echo ) { |
|
| 120 | + echo wp_kses_post( $play_button ); |
|
| 121 | + } else { |
|
| 122 | + return $play_button; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -134,65 +134,65 @@ discard block |
||
| 134 | 134 | * @return void |
| 135 | 135 | */ |
| 136 | 136 | function lsx_health_plan_workout_exercise_button( $m, $group, $echo = true, $args = array() ) { |
| 137 | - $defaults = array( |
|
| 138 | - 'modal_trigger' => 'button', |
|
| 139 | - 'modal_content' => 'excerpt', |
|
| 140 | - ); |
|
| 141 | - $args = wp_parse_args( $args, $defaults ); |
|
| 137 | + $defaults = array( |
|
| 138 | + 'modal_trigger' => 'button', |
|
| 139 | + 'modal_content' => 'excerpt', |
|
| 140 | + ); |
|
| 141 | + $args = wp_parse_args( $args, $defaults ); |
|
| 142 | 142 | |
| 143 | - $exercise_id = ''; |
|
| 144 | - if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
| 145 | - $exercise_id = esc_html( $group['connected_exercises'] ); |
|
| 146 | - $content = get_post_field( 'post_content', $exercise_id ); |
|
| 147 | - $url = get_permalink( $exercise_id ); |
|
| 148 | - $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
| 149 | - $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
| 150 | - $lsx_hp = lsx_health_plan(); |
|
| 143 | + $exercise_id = ''; |
|
| 144 | + if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
| 145 | + $exercise_id = esc_html( $group['connected_exercises'] ); |
|
| 146 | + $content = get_post_field( 'post_content', $exercise_id ); |
|
| 147 | + $url = get_permalink( $exercise_id ); |
|
| 148 | + $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
| 149 | + $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
| 150 | + $lsx_hp = lsx_health_plan(); |
|
| 151 | 151 | |
| 152 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
| 153 | - $content = wp_trim_words( $content, 40 ); |
|
| 154 | - } |
|
| 152 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
| 153 | + $content = wp_trim_words( $content, 40 ); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - if ( 'link' ) { |
|
| 157 | - $play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
| 158 | - } else { |
|
| 159 | - $play_button = '<button data-toggle="modal" data-target="#workout-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
| 160 | - } |
|
| 156 | + if ( 'link' ) { |
|
| 157 | + $play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
| 158 | + } else { |
|
| 159 | + $play_button = '<button data-toggle="modal" data-target="#workout-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - $modal_body = ''; |
|
| 162 | + $modal_body = ''; |
|
| 163 | 163 | |
| 164 | - if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
| 165 | - $gallery_args = array( |
|
| 166 | - 'css_class' => 'modal-slider', |
|
| 167 | - ); |
|
| 168 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
| 169 | - } else { |
|
| 170 | - $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
| 171 | - } |
|
| 164 | + if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
| 165 | + $gallery_args = array( |
|
| 166 | + 'css_class' => 'modal-slider', |
|
| 167 | + ); |
|
| 168 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
| 169 | + } else { |
|
| 170 | + $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
| 173 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
| 174 | 174 | |
| 175 | - if ( ! empty( $equipment_group ) ) { |
|
| 176 | - $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
| 177 | - } |
|
| 178 | - if ( ! empty( $muscle_group ) ) { |
|
| 179 | - $modal_body .= '<span class="muscle-terms">Muscle Group: ' . $muscle_group . '</span>'; |
|
| 180 | - } |
|
| 181 | - $modal_body .= '</div>'; |
|
| 182 | - if ( '' !== $args['modal_content'] ) { |
|
| 183 | - $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
| 184 | - } |
|
| 185 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
| 186 | - $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>'; |
|
| 187 | - } |
|
| 188 | - \lsx_health_plan\functions\register_modal( 'workout-exercise-modal-' . $m, '', $modal_body ); |
|
| 175 | + if ( ! empty( $equipment_group ) ) { |
|
| 176 | + $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
| 177 | + } |
|
| 178 | + if ( ! empty( $muscle_group ) ) { |
|
| 179 | + $modal_body .= '<span class="muscle-terms">Muscle Group: ' . $muscle_group . '</span>'; |
|
| 180 | + } |
|
| 181 | + $modal_body .= '</div>'; |
|
| 182 | + if ( '' !== $args['modal_content'] ) { |
|
| 183 | + $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
|
| 184 | + } |
|
| 185 | + if ( 'excerpt' === $args['modal_content'] ) { |
|
| 186 | + $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-heal-plan' ) . '</a>'; |
|
| 187 | + } |
|
| 188 | + \lsx_health_plan\functions\register_modal( 'workout-exercise-modal-' . $m, '', $modal_body ); |
|
| 189 | 189 | |
| 190 | - if ( true === $echo ) { |
|
| 191 | - echo wp_kses_post( $play_button ); |
|
| 192 | - } else { |
|
| 193 | - return $play_button; |
|
| 194 | - } |
|
| 195 | - } |
|
| 190 | + if ( true === $echo ) { |
|
| 191 | + echo wp_kses_post( $play_button ); |
|
| 192 | + } else { |
|
| 193 | + return $play_button; |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -203,38 +203,38 @@ discard block |
||
| 203 | 203 | * @return void |
| 204 | 204 | */ |
| 205 | 205 | function lsx_health_plan_shortcode_exercise_button( $m, $content = true ) { |
| 206 | - $equipment_group = get_the_term_list( $m, 'equipment', '', ', ' ); |
|
| 207 | - $muscle_group = get_the_term_list( $m, 'muscle-group', '', ', ' ); |
|
| 208 | - $title = get_the_title(); |
|
| 209 | - $lsx_hp = lsx_health_plan(); |
|
| 210 | - $button = '<a data-toggle="modal" href="#exercise-modal-' . $m . '" data-target="#exercise-modal-' . $m . '"></a>'; |
|
| 206 | + $equipment_group = get_the_term_list( $m, 'equipment', '', ', ' ); |
|
| 207 | + $muscle_group = get_the_term_list( $m, 'muscle-group', '', ', ' ); |
|
| 208 | + $title = get_the_title(); |
|
| 209 | + $lsx_hp = lsx_health_plan(); |
|
| 210 | + $button = '<a data-toggle="modal" href="#exercise-modal-' . $m . '" data-target="#exercise-modal-' . $m . '"></a>'; |
|
| 211 | 211 | |
| 212 | - if ( true === $content ) { |
|
| 213 | - $content = get_the_content(); |
|
| 214 | - } |
|
| 212 | + if ( true === $content ) { |
|
| 213 | + $content = get_the_content(); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - $modal_body = ''; |
|
| 217 | - if ( $lsx_hp->frontend->gallery->has_gallery( $m ) ) { |
|
| 218 | - $gallery_args = array( |
|
| 219 | - 'css_class' => 'modal-slider', |
|
| 220 | - ); |
|
| 221 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
| 222 | - } else { |
|
| 223 | - $modal_body .= '<div class="modal-image">' . get_the_post_thumbnail( $m, 'large' ) . '</div>'; |
|
| 224 | - } |
|
| 225 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $title . '</h5>'; |
|
| 216 | + $modal_body = ''; |
|
| 217 | + if ( $lsx_hp->frontend->gallery->has_gallery( $m ) ) { |
|
| 218 | + $gallery_args = array( |
|
| 219 | + 'css_class' => 'modal-slider', |
|
| 220 | + ); |
|
| 221 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
| 222 | + } else { |
|
| 223 | + $modal_body .= '<div class="modal-image">' . get_the_post_thumbnail( $m, 'large' ) . '</div>'; |
|
| 224 | + } |
|
| 225 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $title . '</h5>'; |
|
| 226 | 226 | |
| 227 | - if ( ! empty( $equipment_group ) ) { |
|
| 228 | - $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
| 229 | - } |
|
| 230 | - if ( ! empty( $muscle_group ) ) { |
|
| 231 | - $modal_body .= '<span class="muscle-terms">Muscle Group: ' . $muscle_group . '</span>'; |
|
| 232 | - } |
|
| 233 | - $modal_body .= '</div>'; |
|
| 234 | - $modal_body .= $content; |
|
| 235 | - \lsx_health_plan\functions\register_modal( 'exercise-modal-' . $m, '', $modal_body ); |
|
| 227 | + if ( ! empty( $equipment_group ) ) { |
|
| 228 | + $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
|
| 229 | + } |
|
| 230 | + if ( ! empty( $muscle_group ) ) { |
|
| 231 | + $modal_body .= '<span class="muscle-terms">Muscle Group: ' . $muscle_group . '</span>'; |
|
| 232 | + } |
|
| 233 | + $modal_body .= '</div>'; |
|
| 234 | + $modal_body .= $content; |
|
| 235 | + \lsx_health_plan\functions\register_modal( 'exercise-modal-' . $m, '', $modal_body ); |
|
| 236 | 236 | |
| 237 | - return ( $button ); |
|
| 237 | + return ( $button ); |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -246,18 +246,18 @@ discard block |
||
| 246 | 246 | * @return string |
| 247 | 247 | */ |
| 248 | 248 | function lsx_health_plan_exercise_title( $before = '', $after = '', $echo = true, $exercise_id = false ) { |
| 249 | - if ( false === $exercise_id ) { |
|
| 250 | - $exercise_id = get_the_ID(); |
|
| 251 | - } |
|
| 252 | - $title = get_the_title( $exercise_id ); |
|
| 253 | - $side = get_post_meta( $exercise_id, 'exercise_side', true ); |
|
| 254 | - if ( '' !== $side ) { |
|
| 255 | - $title .= ' - ' . ucwords( $side ); |
|
| 256 | - } |
|
| 257 | - $title = apply_filters( 'lsx_health_plan_exercise_title', $before . $title . $after, $title, $before, $after, $exercise_id ); |
|
| 258 | - if ( true === $echo ) { |
|
| 259 | - echo wp_kses_post( $title ); |
|
| 260 | - } else { |
|
| 261 | - return $title; |
|
| 262 | - } |
|
| 249 | + if ( false === $exercise_id ) { |
|
| 250 | + $exercise_id = get_the_ID(); |
|
| 251 | + } |
|
| 252 | + $title = get_the_title( $exercise_id ); |
|
| 253 | + $side = get_post_meta( $exercise_id, 'exercise_side', true ); |
|
| 254 | + if ( '' !== $side ) { |
|
| 255 | + $title .= ' - ' . ucwords( $side ); |
|
| 256 | + } |
|
| 257 | + $title = apply_filters( 'lsx_health_plan_exercise_title', $before . $title . $after, $title, $before, $after, $exercise_id ); |
|
| 258 | + if ( true === $echo ) { |
|
| 259 | + echo wp_kses_post( $title ); |
|
| 260 | + } else { |
|
| 261 | + return $title; |
|
| 262 | + } |
|
| 263 | 263 | } |
@@ -12,10 +12,10 @@ discard block |
||
| 12 | 12 | * @return boolean |
| 13 | 13 | */ |
| 14 | 14 | function lsx_health_plan_has_warmup( $post_id = '' ) { |
| 15 | - if ( '' === $post_id ) { |
|
| 16 | - $post_id = get_the_ID(); |
|
| 17 | - } |
|
| 18 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
| 15 | + if ( '' === $post_id ) { |
|
| 16 | + $post_id = get_the_ID(); |
|
| 17 | + } |
|
| 18 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'plan_warmup' ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -25,13 +25,13 @@ discard block |
||
| 25 | 25 | * @return boolean |
| 26 | 26 | */ |
| 27 | 27 | function lsx_health_plan_has_workout( $post_id = '' ) { |
| 28 | - if ( ! post_type_exists( 'workout' ) ) { |
|
| 29 | - return false; |
|
| 30 | - } |
|
| 31 | - if ( '' === $post_id ) { |
|
| 32 | - $post_id = get_the_ID(); |
|
| 33 | - } |
|
| 34 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ); |
|
| 28 | + if ( ! post_type_exists( 'workout' ) ) { |
|
| 29 | + return false; |
|
| 30 | + } |
|
| 31 | + if ( '' === $post_id ) { |
|
| 32 | + $post_id = get_the_ID(); |
|
| 33 | + } |
|
| 34 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_workouts' ); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -41,13 +41,13 @@ discard block |
||
| 41 | 41 | * @return boolean |
| 42 | 42 | */ |
| 43 | 43 | function lsx_health_plan_has_meal( $post_id = '' ) { |
| 44 | - if ( ! post_type_exists( 'meal' ) ) { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 47 | - if ( '' === $post_id ) { |
|
| 48 | - $post_id = get_the_ID(); |
|
| 49 | - } |
|
| 50 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
| 44 | + if ( ! post_type_exists( 'meal' ) ) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | + if ( '' === $post_id ) { |
|
| 48 | + $post_id = get_the_ID(); |
|
| 49 | + } |
|
| 50 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_meals' ); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | * @return boolean |
| 58 | 58 | */ |
| 59 | 59 | function lsx_health_plan_has_recipe( $post_id = '' ) { |
| 60 | - if ( ! post_type_exists( 'recipe' ) ) { |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 63 | - if ( '' === $post_id ) { |
|
| 64 | - $post_id = get_the_ID(); |
|
| 65 | - } |
|
| 66 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
| 60 | + if ( ! post_type_exists( 'recipe' ) ) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | + if ( '' === $post_id ) { |
|
| 64 | + $post_id = get_the_ID(); |
|
| 65 | + } |
|
| 66 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_recipes' ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -73,15 +73,15 @@ discard block |
||
| 73 | 73 | * @return boolean |
| 74 | 74 | */ |
| 75 | 75 | function lsx_health_plan_has_downloads( $post_id = '' ) { |
| 76 | - $has_downloads = false; |
|
| 77 | - if ( '' === $post_id ) { |
|
| 78 | - $post_id = get_the_ID(); |
|
| 79 | - } |
|
| 80 | - $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
| 81 | - if ( ! empty( $downloads ) ) { |
|
| 82 | - $has_downloads = true; |
|
| 83 | - } |
|
| 84 | - return $has_downloads; |
|
| 76 | + $has_downloads = false; |
|
| 77 | + if ( '' === $post_id ) { |
|
| 78 | + $post_id = get_the_ID(); |
|
| 79 | + } |
|
| 80 | + $downloads = \lsx_health_plan\functions\get_downloads( 'all', $post_id ); |
|
| 81 | + if ( ! empty( $downloads ) ) { |
|
| 82 | + $has_downloads = true; |
|
| 83 | + } |
|
| 84 | + return $has_downloads; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -91,13 +91,13 @@ discard block |
||
| 91 | 91 | * @return boolean |
| 92 | 92 | */ |
| 93 | 93 | function lsx_health_plan_has_tip( $post_id = '' ) { |
| 94 | - if ( ! post_type_exists( 'tip' ) ) { |
|
| 95 | - return false; |
|
| 96 | - } |
|
| 97 | - if ( '' === $post_id ) { |
|
| 98 | - $post_id = get_the_ID(); |
|
| 99 | - } |
|
| 100 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
| 94 | + if ( ! post_type_exists( 'tip' ) ) { |
|
| 95 | + return false; |
|
| 96 | + } |
|
| 97 | + if ( '' === $post_id ) { |
|
| 98 | + $post_id = get_the_ID(); |
|
| 99 | + } |
|
| 100 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_tips' ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | * @return boolean |
| 108 | 108 | */ |
| 109 | 109 | function lsx_health_plan_has_video( $post_id = '' ) { |
| 110 | - if ( ! post_type_exists( 'video' ) ) { |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 113 | - if ( '' === $post_id ) { |
|
| 114 | - $post_id = get_the_ID(); |
|
| 115 | - } |
|
| 116 | - return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
| 110 | + if ( ! post_type_exists( 'video' ) ) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + if ( '' === $post_id ) { |
|
| 114 | + $post_id = get_the_ID(); |
|
| 115 | + } |
|
| 116 | + return \lsx_health_plan\functions\has_attached_post( $post_id, 'connected_videos' ); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * @return boolean |
| 123 | 123 | */ |
| 124 | 124 | function lsx_health_plan_user_has_purchase() { |
| 125 | - $valid_order = false; |
|
| 126 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
| 125 | + $valid_order = false; |
|
| 126 | + $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
| 127 | 127 | |
| 128 | - if ( is_user_logged_in() && false !== $product_id ) { |
|
| 129 | - $current_user = wp_get_current_user(); |
|
| 130 | - if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
| 131 | - $valid_order = true; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - return $valid_order; |
|
| 128 | + if ( is_user_logged_in() && false !== $product_id ) { |
|
| 129 | + $current_user = wp_get_current_user(); |
|
| 130 | + if ( wc_customer_bought_product( $current_user->user_email, $current_user->ID, $product_id ) ) { |
|
| 131 | + $valid_order = true; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + return $valid_order; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -141,18 +141,18 @@ discard block |
||
| 141 | 141 | * @return boolean |
| 142 | 142 | */ |
| 143 | 143 | function lsx_health_plan_is_current_tab( $needle = '' ) { |
| 144 | - $is_tab = false; |
|
| 145 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
| 146 | - if ( false === $plan_slug ) { |
|
| 147 | - $plan_slug = 'my-plan'; |
|
| 148 | - } |
|
| 149 | - if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
| 150 | - $endpoint = get_query_var( 'endpoint' ); |
|
| 151 | - if ( false !== $endpoint && $needle === $endpoint ) { |
|
| 152 | - $is_tab = true; |
|
| 153 | - } |
|
| 154 | - } |
|
| 155 | - return $is_tab; |
|
| 144 | + $is_tab = false; |
|
| 145 | + $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
| 146 | + if ( false === $plan_slug ) { |
|
| 147 | + $plan_slug = 'my-plan'; |
|
| 148 | + } |
|
| 149 | + if ( is_singular( 'plan' ) || is_page( $plan_slug ) ) { |
|
| 150 | + $endpoint = get_query_var( 'endpoint' ); |
|
| 151 | + if ( false !== $endpoint && $needle === $endpoint ) { |
|
| 152 | + $is_tab = true; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | + return $is_tab; |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -162,22 +162,22 @@ discard block |
||
| 162 | 162 | * @return boolean |
| 163 | 163 | */ |
| 164 | 164 | function lsx_health_plan_is_day_complete( $post_id = '', $section_key = '' ) { |
| 165 | - $is_complete = false; |
|
| 166 | - if ( '' === $post_id ) { |
|
| 167 | - $post_id = get_the_ID(); |
|
| 168 | - } |
|
| 169 | - $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
| 170 | - $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
| 171 | - if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
| 172 | - $is_complete = true; |
|
| 173 | - } |
|
| 165 | + $is_complete = false; |
|
| 166 | + if ( '' === $post_id ) { |
|
| 167 | + $post_id = get_the_ID(); |
|
| 168 | + } |
|
| 169 | + $key = \lsx_health_plan\functions\plan\generate_section_id( $section_key ); |
|
| 170 | + $is_day_complete = get_user_meta( get_current_user_id(), 'day_' . $key . '_complete', true ); |
|
| 171 | + if ( false !== $is_day_complete && '' !== $is_day_complete ) { |
|
| 172 | + $is_complete = true; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - return $is_complete; |
|
| 175 | + return $is_complete; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | function lsx_health_plan_is_plan_complete() { |
| 179 | - $complete = false; |
|
| 180 | - return $complete; |
|
| 179 | + $complete = false; |
|
| 180 | + return $complete; |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -187,14 +187,14 @@ discard block |
||
| 187 | 187 | * @return boolean |
| 188 | 188 | */ |
| 189 | 189 | function lsx_health_plan_week_has_downloads( $week = '' ) { |
| 190 | - $has_downloads = false; |
|
| 191 | - if ( '' !== $week ) { |
|
| 192 | - $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
| 193 | - if ( ! empty( $downloads ) ) { |
|
| 194 | - $has_downloads = true; |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - return $has_downloads; |
|
| 190 | + $has_downloads = false; |
|
| 191 | + if ( '' !== $week ) { |
|
| 192 | + $downloads = \lsx_health_plan\functions\get_weekly_downloads( $week ); |
|
| 193 | + if ( ! empty( $downloads ) ) { |
|
| 194 | + $has_downloads = true; |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + return $has_downloads; |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | * @return boolean |
| 205 | 205 | */ |
| 206 | 206 | function lsx_health_plan_has_tips( $post_id = '' ) { |
| 207 | - $has_tips = false; |
|
| 208 | - if ( '' === $post_id ) { |
|
| 209 | - $post_id = get_the_ID(); |
|
| 210 | - } |
|
| 211 | - $connected_tips = get_post_meta( get_the_ID(), 'connected_tips', true ); |
|
| 212 | - $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
| 213 | - if ( ! empty( $connected_tips ) ) { |
|
| 214 | - $has_tips = true; |
|
| 215 | - } |
|
| 216 | - return $has_tips; |
|
| 207 | + $has_tips = false; |
|
| 208 | + if ( '' === $post_id ) { |
|
| 209 | + $post_id = get_the_ID(); |
|
| 210 | + } |
|
| 211 | + $connected_tips = get_post_meta( get_the_ID(), 'connected_tips', true ); |
|
| 212 | + $connected_tips = \lsx_health_plan\functions\check_posts_exist( $connected_tips ); |
|
| 213 | + if ( ! empty( $connected_tips ) ) { |
|
| 214 | + $has_tips = true; |
|
| 215 | + } |
|
| 216 | + return $has_tips; |
|
| 217 | 217 | } |
@@ -8,112 +8,112 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Frontend { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Holds class instance |
|
| 13 | - * |
|
| 14 | - * @since 1.0.0 |
|
| 15 | - * |
|
| 16 | - * @var object \lsx_health_plan\classes\Frontend() |
|
| 17 | - */ |
|
| 18 | - protected static $instance = null; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @var object \lsx_health_plan\classes\frontend\Endpoints(); |
|
| 22 | - */ |
|
| 23 | - public $endpoints; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var object \lsx_health_plan\classes\frontend\Modals(); |
|
| 27 | - */ |
|
| 28 | - public $modals; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var object \lsx_health_plan\classes\frontend\Gallery(); |
|
| 32 | - */ |
|
| 33 | - public $gallery; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var object \lsx_health_plan\classes\frontend\Plan_Status(); |
|
| 37 | - */ |
|
| 38 | - public $plan_status; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var object \lsx_health_plan\classes\frontend\General(); |
|
| 42 | - */ |
|
| 43 | - public $general; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @var object \lsx_health_plan\classes\frontend\Template_Redirects(); |
|
| 47 | - */ |
|
| 48 | - public $template_redirects; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Contructor |
|
| 52 | - */ |
|
| 53 | - public function __construct() { |
|
| 54 | - if ( ! is_admin() ) { |
|
| 55 | - $this->load_classes(); |
|
| 56 | - add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
| 11 | + /** |
|
| 12 | + * Holds class instance |
|
| 13 | + * |
|
| 14 | + * @since 1.0.0 |
|
| 15 | + * |
|
| 16 | + * @var object \lsx_health_plan\classes\Frontend() |
|
| 17 | + */ |
|
| 18 | + protected static $instance = null; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @var object \lsx_health_plan\classes\frontend\Endpoints(); |
|
| 22 | + */ |
|
| 23 | + public $endpoints; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var object \lsx_health_plan\classes\frontend\Modals(); |
|
| 27 | + */ |
|
| 28 | + public $modals; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var object \lsx_health_plan\classes\frontend\Gallery(); |
|
| 32 | + */ |
|
| 33 | + public $gallery; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var object \lsx_health_plan\classes\frontend\Plan_Status(); |
|
| 37 | + */ |
|
| 38 | + public $plan_status; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var object \lsx_health_plan\classes\frontend\General(); |
|
| 42 | + */ |
|
| 43 | + public $general; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @var object \lsx_health_plan\classes\frontend\Template_Redirects(); |
|
| 47 | + */ |
|
| 48 | + public $template_redirects; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Contructor |
|
| 52 | + */ |
|
| 53 | + public function __construct() { |
|
| 54 | + if ( ! is_admin() ) { |
|
| 55 | + $this->load_classes(); |
|
| 56 | + add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
| 57 | 57 | |
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Return an instance of this class. |
|
| 63 | - * |
|
| 64 | - * @since 1.0.0 |
|
| 65 | - * |
|
| 66 | - * @return object \lsx_health_plan\classes\Frontend() A single instance of this class. |
|
| 67 | - */ |
|
| 68 | - public static function get_instance() { |
|
| 69 | - // If the single instance hasn't been set, set it now. |
|
| 70 | - if ( null === self::$instance ) { |
|
| 71 | - self::$instance = new self(); |
|
| 72 | - } |
|
| 73 | - return self::$instance; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Loads the variable classes and the static classes. |
|
| 78 | - */ |
|
| 79 | - private function load_classes() { |
|
| 80 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php'; |
|
| 81 | - $this->endpoints = frontend\Endpoints::get_instance(); |
|
| 82 | - |
|
| 83 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-modals.php'; |
|
| 84 | - $this->modals = Modals::get_instance(); |
|
| 85 | - |
|
| 86 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php'; |
|
| 87 | - $this->gallery = frontend\Gallery::get_instance(); |
|
| 88 | - |
|
| 89 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-plan-status.php'; |
|
| 90 | - $this->plan_status = frontend\Plan_Status::get_instance(); |
|
| 91 | - |
|
| 92 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-general.php'; |
|
| 93 | - $this->general = frontend\General::get_instance(); |
|
| 94 | - |
|
| 95 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-template-redirects.php'; |
|
| 96 | - $this->template_redirects = frontend\Template_Redirects::get_instance(); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Redirect the user from the cart or checkout page if they have purchased the product already. |
|
| 101 | - * |
|
| 102 | - * @return void |
|
| 103 | - */ |
|
| 104 | - public function redirect() { |
|
| 105 | - if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
| 109 | - wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
| 110 | - die; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
| 114 | - if ( false !== $product_id && is_single( $product_id ) ) { |
|
| 115 | - wp_redirect( home_url() ); |
|
| 116 | - wp_die(); |
|
| 117 | - } |
|
| 118 | - } |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Return an instance of this class. |
|
| 63 | + * |
|
| 64 | + * @since 1.0.0 |
|
| 65 | + * |
|
| 66 | + * @return object \lsx_health_plan\classes\Frontend() A single instance of this class. |
|
| 67 | + */ |
|
| 68 | + public static function get_instance() { |
|
| 69 | + // If the single instance hasn't been set, set it now. |
|
| 70 | + if ( null === self::$instance ) { |
|
| 71 | + self::$instance = new self(); |
|
| 72 | + } |
|
| 73 | + return self::$instance; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Loads the variable classes and the static classes. |
|
| 78 | + */ |
|
| 79 | + private function load_classes() { |
|
| 80 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php'; |
|
| 81 | + $this->endpoints = frontend\Endpoints::get_instance(); |
|
| 82 | + |
|
| 83 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-modals.php'; |
|
| 84 | + $this->modals = Modals::get_instance(); |
|
| 85 | + |
|
| 86 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php'; |
|
| 87 | + $this->gallery = frontend\Gallery::get_instance(); |
|
| 88 | + |
|
| 89 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-plan-status.php'; |
|
| 90 | + $this->plan_status = frontend\Plan_Status::get_instance(); |
|
| 91 | + |
|
| 92 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-general.php'; |
|
| 93 | + $this->general = frontend\General::get_instance(); |
|
| 94 | + |
|
| 95 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-template-redirects.php'; |
|
| 96 | + $this->template_redirects = frontend\Template_Redirects::get_instance(); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Redirect the user from the cart or checkout page if they have purchased the product already. |
|
| 101 | + * |
|
| 102 | + * @return void |
|
| 103 | + */ |
|
| 104 | + public function redirect() { |
|
| 105 | + if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
| 109 | + wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
| 110 | + die; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
| 114 | + if ( false !== $product_id && is_single( $product_id ) ) { |
|
| 115 | + wp_redirect( home_url() ); |
|
| 116 | + wp_die(); |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -8,115 +8,115 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Core { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Holds class instance |
|
| 13 | - * |
|
| 14 | - * @since 1.0.0 |
|
| 15 | - * |
|
| 16 | - * @var object \lsx_health_plan\classes\Core() |
|
| 17 | - */ |
|
| 18 | - protected static $instance = null; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @var object \lsx_health_plan\classes\Setup(); |
|
| 22 | - */ |
|
| 23 | - public $setup; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var object \lsx_health_plan\classes\Admin(); |
|
| 27 | - */ |
|
| 28 | - public $admin; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var object \lsx_health_plan\classes\Frontend(); |
|
| 32 | - */ |
|
| 33 | - public $frontend; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var object \lsx_health_plan\classes\Integrations(); |
|
| 37 | - */ |
|
| 38 | - public $integrations; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var object \lsx_health_plan\classes\Integrations(); |
|
| 42 | - */ |
|
| 43 | - public $scpo_engine; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Contructor |
|
| 47 | - */ |
|
| 48 | - public function __construct() { |
|
| 49 | - $this->load_includes(); |
|
| 50 | - $this->load_classes(); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Return an instance of this class. |
|
| 55 | - * |
|
| 56 | - * @since 1.0.0 |
|
| 57 | - * |
|
| 58 | - * @return object \lsx_health_plan\classes\Core() A single instance of this class. |
|
| 59 | - */ |
|
| 60 | - public static function get_instance() { |
|
| 61 | - |
|
| 62 | - // If the single instance hasn't been set, set it now. |
|
| 63 | - if ( null === self::$instance ) { |
|
| 64 | - self::$instance = new self(); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - return self::$instance; |
|
| 68 | - |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Loads the variable classes and the static classes. |
|
| 73 | - */ |
|
| 74 | - private function load_classes() { |
|
| 75 | - |
|
| 76 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-setup.php'; |
|
| 77 | - $this->setup = Setup::get_instance(); |
|
| 78 | - |
|
| 79 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-admin.php'; |
|
| 80 | - $this->admin = Admin::get_instance(); |
|
| 81 | - |
|
| 82 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-frontend.php'; |
|
| 83 | - $this->frontend = Frontend::get_instance(); |
|
| 84 | - |
|
| 85 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-integrations.php'; |
|
| 86 | - $this->integrations = Integrations::get_instance(); |
|
| 87 | - |
|
| 88 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/class-scpo-engine.php'; |
|
| 89 | - $this->scpo_engine = SCPO_Engine::get_instance(); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Loads the plugin functions. |
|
| 94 | - */ |
|
| 95 | - private function load_includes() { |
|
| 96 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/functions.php'; |
|
| 97 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/functions/recipes.php'; |
|
| 98 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/functions/plan.php'; |
|
| 99 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/conditionals.php'; |
|
| 100 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags.php'; |
|
| 101 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/exercise.php'; |
|
| 102 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/gallery.php'; |
|
| 103 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/plan.php'; |
|
| 104 | - require_once LSX_HEALTH_PLAN_PATH . '/includes/shortcodes.php'; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Returns the post types currently active |
|
| 109 | - * |
|
| 110 | - * @return void |
|
| 111 | - */ |
|
| 112 | - public function get_post_types() { |
|
| 113 | - $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
| 114 | - foreach ( $post_types as $index => $post_type ) { |
|
| 115 | - $is_disabled = \cmb2_get_option( 'lsx_health_plan_options', $post_type . '_disabled', false ); |
|
| 116 | - if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
| 117 | - unset( $post_types[ $index ] ); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - return $post_types; |
|
| 121 | - } |
|
| 11 | + /** |
|
| 12 | + * Holds class instance |
|
| 13 | + * |
|
| 14 | + * @since 1.0.0 |
|
| 15 | + * |
|
| 16 | + * @var object \lsx_health_plan\classes\Core() |
|
| 17 | + */ |
|
| 18 | + protected static $instance = null; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @var object \lsx_health_plan\classes\Setup(); |
|
| 22 | + */ |
|
| 23 | + public $setup; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var object \lsx_health_plan\classes\Admin(); |
|
| 27 | + */ |
|
| 28 | + public $admin; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var object \lsx_health_plan\classes\Frontend(); |
|
| 32 | + */ |
|
| 33 | + public $frontend; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var object \lsx_health_plan\classes\Integrations(); |
|
| 37 | + */ |
|
| 38 | + public $integrations; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var object \lsx_health_plan\classes\Integrations(); |
|
| 42 | + */ |
|
| 43 | + public $scpo_engine; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Contructor |
|
| 47 | + */ |
|
| 48 | + public function __construct() { |
|
| 49 | + $this->load_includes(); |
|
| 50 | + $this->load_classes(); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Return an instance of this class. |
|
| 55 | + * |
|
| 56 | + * @since 1.0.0 |
|
| 57 | + * |
|
| 58 | + * @return object \lsx_health_plan\classes\Core() A single instance of this class. |
|
| 59 | + */ |
|
| 60 | + public static function get_instance() { |
|
| 61 | + |
|
| 62 | + // If the single instance hasn't been set, set it now. |
|
| 63 | + if ( null === self::$instance ) { |
|
| 64 | + self::$instance = new self(); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + return self::$instance; |
|
| 68 | + |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Loads the variable classes and the static classes. |
|
| 73 | + */ |
|
| 74 | + private function load_classes() { |
|
| 75 | + |
|
| 76 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-setup.php'; |
|
| 77 | + $this->setup = Setup::get_instance(); |
|
| 78 | + |
|
| 79 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-admin.php'; |
|
| 80 | + $this->admin = Admin::get_instance(); |
|
| 81 | + |
|
| 82 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-frontend.php'; |
|
| 83 | + $this->frontend = Frontend::get_instance(); |
|
| 84 | + |
|
| 85 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-integrations.php'; |
|
| 86 | + $this->integrations = Integrations::get_instance(); |
|
| 87 | + |
|
| 88 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/class-scpo-engine.php'; |
|
| 89 | + $this->scpo_engine = SCPO_Engine::get_instance(); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Loads the plugin functions. |
|
| 94 | + */ |
|
| 95 | + private function load_includes() { |
|
| 96 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/functions.php'; |
|
| 97 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/functions/recipes.php'; |
|
| 98 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/functions/plan.php'; |
|
| 99 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/conditionals.php'; |
|
| 100 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags.php'; |
|
| 101 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/exercise.php'; |
|
| 102 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/gallery.php'; |
|
| 103 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/template-tags/plan.php'; |
|
| 104 | + require_once LSX_HEALTH_PLAN_PATH . '/includes/shortcodes.php'; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Returns the post types currently active |
|
| 109 | + * |
|
| 110 | + * @return void |
|
| 111 | + */ |
|
| 112 | + public function get_post_types() { |
|
| 113 | + $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
| 114 | + foreach ( $post_types as $index => $post_type ) { |
|
| 115 | + $is_disabled = \cmb2_get_option( 'lsx_health_plan_options', $post_type . '_disabled', false ); |
|
| 116 | + if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
| 117 | + unset( $post_types[ $index ] ); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + return $post_types; |
|
| 121 | + } |
|
| 122 | 122 | } |
@@ -8,88 +8,88 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Endpoints { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Holds class instance |
|
| 13 | - * |
|
| 14 | - * @since 1.0.0 |
|
| 15 | - * |
|
| 16 | - * @var object \lsx_health_plan\classes\frontend\Endpoints() |
|
| 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\frontend\Endpoints() |
|
| 17 | + */ |
|
| 18 | + protected static $instance = null; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Contructor |
|
| 22 | - */ |
|
| 23 | - public function __construct() { |
|
| 24 | - add_action( 'init', array( $this, 'setup' ) ); |
|
| 25 | - } |
|
| 20 | + /** |
|
| 21 | + * Contructor |
|
| 22 | + */ |
|
| 23 | + public function __construct() { |
|
| 24 | + add_action( 'init', array( $this, 'setup' ) ); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Return an instance of this class. |
|
| 29 | - * |
|
| 30 | - * @since 1.0.0 |
|
| 31 | - * |
|
| 32 | - * @return object \lsx_health_plan\classes\frontend\Endpoints() A single instance of this class. |
|
| 33 | - */ |
|
| 34 | - public static function get_instance() { |
|
| 35 | - // If the single instance hasn't been set, set it now. |
|
| 36 | - if ( null === self::$instance ) { |
|
| 37 | - self::$instance = new self(); |
|
| 38 | - } |
|
| 39 | - return self::$instance; |
|
| 40 | - } |
|
| 27 | + /** |
|
| 28 | + * Return an instance of this class. |
|
| 29 | + * |
|
| 30 | + * @since 1.0.0 |
|
| 31 | + * |
|
| 32 | + * @return object \lsx_health_plan\classes\frontend\Endpoints() A single instance of this class. |
|
| 33 | + */ |
|
| 34 | + public static function get_instance() { |
|
| 35 | + // If the single instance hasn't been set, set it now. |
|
| 36 | + if ( null === self::$instance ) { |
|
| 37 | + self::$instance = new self(); |
|
| 38 | + } |
|
| 39 | + return self::$instance; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Runs on init |
|
| 44 | - */ |
|
| 45 | - public function setup() { |
|
| 46 | - $this->add_rewrite_rules(); |
|
| 47 | - } |
|
| 42 | + /** |
|
| 43 | + * Runs on init |
|
| 44 | + */ |
|
| 45 | + public function setup() { |
|
| 46 | + $this->add_rewrite_rules(); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Registers the rewrites. |
|
| 51 | - */ |
|
| 52 | - public function add_rewrite_rules() { |
|
| 53 | - // Here is where we add in the rewrite rules above the normal WP ones. |
|
| 54 | - add_rewrite_tag( '%endpoint%', '([^&]+)' ); |
|
| 55 | - add_rewrite_tag( '%section%', '([^&]+)' ); |
|
| 49 | + /** |
|
| 50 | + * Registers the rewrites. |
|
| 51 | + */ |
|
| 52 | + public function add_rewrite_rules() { |
|
| 53 | + // Here is where we add in the rewrite rules above the normal WP ones. |
|
| 54 | + add_rewrite_tag( '%endpoint%', '([^&]+)' ); |
|
| 55 | + add_rewrite_tag( '%section%', '([^&]+)' ); |
|
| 56 | 56 | |
| 57 | - // Plan Sections. |
|
| 58 | - add_rewrite_rule( 'plan/([^/]+)/([^/]+)/?$', 'index.php?plan=$matches[1]§ion=$matches[2]', 'top' ); |
|
| 57 | + // Plan Sections. |
|
| 58 | + add_rewrite_rule( 'plan/([^/]+)/([^/]+)/?$', 'index.php?plan=$matches[1]§ion=$matches[2]', 'top' ); |
|
| 59 | 59 | |
| 60 | - // Warm up. |
|
| 61 | - $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false ); |
|
| 62 | - if ( false === $warm_up ) { |
|
| 63 | - $warm_up = 'warm-up'; |
|
| 64 | - } |
|
| 60 | + // Warm up. |
|
| 61 | + $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false ); |
|
| 62 | + if ( false === $warm_up ) { |
|
| 63 | + $warm_up = 'warm-up'; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $warm_up . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=warm-up', 'top' ); |
|
| 66 | + add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $warm_up . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=warm-up', 'top' ); |
|
| 67 | 67 | |
| 68 | - // Workout. |
|
| 69 | - if ( post_type_exists( 'workout' ) ) { |
|
| 70 | - $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false ); |
|
| 71 | - if ( false === $workout ) { |
|
| 72 | - $workout = 'workout'; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $workout . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=workout', 'top' ); |
|
| 68 | + // Workout. |
|
| 69 | + if ( post_type_exists( 'workout' ) ) { |
|
| 70 | + $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false ); |
|
| 71 | + if ( false === $workout ) { |
|
| 72 | + $workout = 'workout'; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $workout . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=workout', 'top' ); |
|
| 76 | 76 | |
| 77 | - // Meal. |
|
| 78 | - if ( post_type_exists( 'meal' ) ) { |
|
| 79 | - $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
| 80 | - if ( false === $meal ) { |
|
| 81 | - $meal = 'meal'; |
|
| 82 | - } |
|
| 83 | - } |
|
| 84 | - add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $meal . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=meal', 'top' ); |
|
| 77 | + // Meal. |
|
| 78 | + if ( post_type_exists( 'meal' ) ) { |
|
| 79 | + $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
| 80 | + if ( false === $meal ) { |
|
| 81 | + $meal = 'meal'; |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | + add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $meal . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=meal', 'top' ); |
|
| 85 | 85 | |
| 86 | - // Recipe. |
|
| 87 | - if ( post_type_exists( 'recipe' ) ) { |
|
| 88 | - $recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false ); |
|
| 89 | - if ( false === $recipe ) { |
|
| 90 | - $recipe = 'recipes'; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $recipe . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=recipes', 'top' ); |
|
| 94 | - } |
|
| 86 | + // Recipe. |
|
| 87 | + if ( post_type_exists( 'recipe' ) ) { |
|
| 88 | + $recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', false ); |
|
| 89 | + if ( false === $recipe ) { |
|
| 90 | + $recipe = 'recipes'; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + add_rewrite_rule( 'plan/([^/]+)/([^/]+)/' . $recipe . '/?$', 'index.php?plan=$matches[1]§ion=$matches[2]&endpoint=recipes', 'top' ); |
|
| 94 | + } |
|
| 95 | 95 | } |
@@ -8,147 +8,147 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class General { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Holds class instance |
|
| 13 | - * |
|
| 14 | - * @since 1.0.0 |
|
| 15 | - * |
|
| 16 | - * @var object \lsx_health_plan\classes\frontend\General() |
|
| 17 | - */ |
|
| 18 | - protected static $instance = null; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Contructor |
|
| 22 | - */ |
|
| 23 | - public function __construct() { |
|
| 24 | - // Before Output. |
|
| 25 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
| 26 | - add_filter( 'wp_kses_allowed_html', array( $this, 'allow_html_tags_attributes' ), 100, 2 ); |
|
| 27 | - |
|
| 28 | - // Output. |
|
| 29 | - add_action( 'body_class', array( $this, 'body_classes' ) ); |
|
| 30 | - add_filter( 'lsx_global_header_title', array( $this, 'single_title' ), 200, 1 ); |
|
| 31 | - add_action( 'wp_head', array( $this, 'remove_single_footer' ), 99 ); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Return an instance of this class. |
|
| 36 | - * |
|
| 37 | - * @since 1.0.0 |
|
| 38 | - * |
|
| 39 | - * @return object \lsx_health_plan\classes\frontend\General() A single instance of this class. |
|
| 40 | - */ |
|
| 41 | - public static function get_instance() { |
|
| 42 | - // If the single instance hasn't been set, set it now. |
|
| 43 | - if ( null === self::$instance ) { |
|
| 44 | - self::$instance = new self(); |
|
| 45 | - } |
|
| 46 | - return self::$instance; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Registers the plugin frontend assets |
|
| 51 | - * |
|
| 52 | - * @return void |
|
| 53 | - */ |
|
| 54 | - public function assets() { |
|
| 55 | - |
|
| 56 | - if ( is_post_type_archive( 'plan' ) && false === \lsx_health_plan\functions\plan\is_filters_disabled() ) { |
|
| 57 | - wp_enqueue_script( 'isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_HEALTH_PLAN_URL, true ); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
| 61 | - wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
| 62 | - wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
| 63 | - |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Adds the iframe and the progress HTML tags to the allowed WordPress list. |
|
| 68 | - */ |
|
| 69 | - public function allow_html_tags_attributes( $tags, $context ) { |
|
| 70 | - if ( 'post' === $context ) { |
|
| 71 | - $tags['iframe'] = array( |
|
| 72 | - 'src' => true, |
|
| 73 | - 'height' => true, |
|
| 74 | - 'width' => true, |
|
| 75 | - 'frameborder' => true, |
|
| 76 | - 'allowfullscreen' => true, |
|
| 77 | - ); |
|
| 78 | - } |
|
| 79 | - $tags['progress'] = array( |
|
| 80 | - 'id' => true, |
|
| 81 | - 'value' => true, |
|
| 82 | - 'max' => true, |
|
| 83 | - ); |
|
| 84 | - return $tags; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * Add body classes to body. |
|
| 89 | - * |
|
| 90 | - * @param array $classes |
|
| 91 | - * @return void |
|
| 92 | - */ |
|
| 93 | - public function body_classes( $classes = array() ) { |
|
| 94 | - global $post; |
|
| 95 | - |
|
| 96 | - if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'lsx_health_plan_my_profile_block' ) ) { |
|
| 97 | - $classes[] = 'my-plan-shortcode'; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - if ( is_single() && is_singular( 'plan' ) ) { |
|
| 101 | - $args = array( |
|
| 102 | - 'post_parent' => get_the_ID(), |
|
| 103 | - 'post_type' => 'plan', |
|
| 104 | - ); |
|
| 105 | - |
|
| 106 | - $post_id = get_the_ID(); |
|
| 107 | - $has_children = get_children( $args ); |
|
| 108 | - $has_parent = wp_get_post_parent_id( $post_id ); |
|
| 109 | - |
|
| 110 | - if ( ! empty( $has_children ) ) { |
|
| 111 | - $plan_type_class = 'parent-plan-page'; |
|
| 112 | - if ( 0 !== $has_parent ) { |
|
| 113 | - $plan_type_class = 'parent-sub-plan-page'; |
|
| 114 | - } |
|
| 115 | - } else { |
|
| 116 | - $plan_type_class = 'unique-plan-page'; |
|
| 117 | - if ( 0 !== $has_parent ) { |
|
| 118 | - $plan_type_class = 'child-plan-page'; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - $classes[] = $plan_type_class; |
|
| 122 | - } |
|
| 123 | - return $classes; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Remove the single recipe and exercise title |
|
| 128 | - */ |
|
| 129 | - public function single_title( $title ) { |
|
| 130 | - |
|
| 131 | - if ( is_single() && is_singular( 'recipe' ) ) { |
|
| 132 | - |
|
| 133 | - $title = __( 'Recipe', 'lsx-health-plan' ); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if ( is_single() && is_singular( 'exercise' ) ) { |
|
| 137 | - |
|
| 138 | - $title = __( 'Exercise', 'lsx-health-plan' ); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - return $title; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 145 | - * Removing footer for HP single pages. |
|
| 146 | - * |
|
| 147 | - * @return void |
|
| 148 | - */ |
|
| 149 | - public function remove_single_footer() { |
|
| 150 | - if ( is_single() && is_singular( array( 'exercise', 'recipe', 'workout', 'meal' ) ) ) { |
|
| 151 | - remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
| 152 | - } |
|
| 153 | - } |
|
| 11 | + /** |
|
| 12 | + * Holds class instance |
|
| 13 | + * |
|
| 14 | + * @since 1.0.0 |
|
| 15 | + * |
|
| 16 | + * @var object \lsx_health_plan\classes\frontend\General() |
|
| 17 | + */ |
|
| 18 | + protected static $instance = null; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Contructor |
|
| 22 | + */ |
|
| 23 | + public function __construct() { |
|
| 24 | + // Before Output. |
|
| 25 | + add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
| 26 | + add_filter( 'wp_kses_allowed_html', array( $this, 'allow_html_tags_attributes' ), 100, 2 ); |
|
| 27 | + |
|
| 28 | + // Output. |
|
| 29 | + add_action( 'body_class', array( $this, 'body_classes' ) ); |
|
| 30 | + add_filter( 'lsx_global_header_title', array( $this, 'single_title' ), 200, 1 ); |
|
| 31 | + add_action( 'wp_head', array( $this, 'remove_single_footer' ), 99 ); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Return an instance of this class. |
|
| 36 | + * |
|
| 37 | + * @since 1.0.0 |
|
| 38 | + * |
|
| 39 | + * @return object \lsx_health_plan\classes\frontend\General() A single instance of this class. |
|
| 40 | + */ |
|
| 41 | + public static function get_instance() { |
|
| 42 | + // If the single instance hasn't been set, set it now. |
|
| 43 | + if ( null === self::$instance ) { |
|
| 44 | + self::$instance = new self(); |
|
| 45 | + } |
|
| 46 | + return self::$instance; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Registers the plugin frontend assets |
|
| 51 | + * |
|
| 52 | + * @return void |
|
| 53 | + */ |
|
| 54 | + public function assets() { |
|
| 55 | + |
|
| 56 | + if ( is_post_type_archive( 'plan' ) && false === \lsx_health_plan\functions\plan\is_filters_disabled() ) { |
|
| 57 | + wp_enqueue_script( 'isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_HEALTH_PLAN_URL, true ); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
| 61 | + wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
| 62 | + wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
| 63 | + |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Adds the iframe and the progress HTML tags to the allowed WordPress list. |
|
| 68 | + */ |
|
| 69 | + public function allow_html_tags_attributes( $tags, $context ) { |
|
| 70 | + if ( 'post' === $context ) { |
|
| 71 | + $tags['iframe'] = array( |
|
| 72 | + 'src' => true, |
|
| 73 | + 'height' => true, |
|
| 74 | + 'width' => true, |
|
| 75 | + 'frameborder' => true, |
|
| 76 | + 'allowfullscreen' => true, |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | + $tags['progress'] = array( |
|
| 80 | + 'id' => true, |
|
| 81 | + 'value' => true, |
|
| 82 | + 'max' => true, |
|
| 83 | + ); |
|
| 84 | + return $tags; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * Add body classes to body. |
|
| 89 | + * |
|
| 90 | + * @param array $classes |
|
| 91 | + * @return void |
|
| 92 | + */ |
|
| 93 | + public function body_classes( $classes = array() ) { |
|
| 94 | + global $post; |
|
| 95 | + |
|
| 96 | + if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'lsx_health_plan_my_profile_block' ) ) { |
|
| 97 | + $classes[] = 'my-plan-shortcode'; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + if ( is_single() && is_singular( 'plan' ) ) { |
|
| 101 | + $args = array( |
|
| 102 | + 'post_parent' => get_the_ID(), |
|
| 103 | + 'post_type' => 'plan', |
|
| 104 | + ); |
|
| 105 | + |
|
| 106 | + $post_id = get_the_ID(); |
|
| 107 | + $has_children = get_children( $args ); |
|
| 108 | + $has_parent = wp_get_post_parent_id( $post_id ); |
|
| 109 | + |
|
| 110 | + if ( ! empty( $has_children ) ) { |
|
| 111 | + $plan_type_class = 'parent-plan-page'; |
|
| 112 | + if ( 0 !== $has_parent ) { |
|
| 113 | + $plan_type_class = 'parent-sub-plan-page'; |
|
| 114 | + } |
|
| 115 | + } else { |
|
| 116 | + $plan_type_class = 'unique-plan-page'; |
|
| 117 | + if ( 0 !== $has_parent ) { |
|
| 118 | + $plan_type_class = 'child-plan-page'; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + $classes[] = $plan_type_class; |
|
| 122 | + } |
|
| 123 | + return $classes; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Remove the single recipe and exercise title |
|
| 128 | + */ |
|
| 129 | + public function single_title( $title ) { |
|
| 130 | + |
|
| 131 | + if ( is_single() && is_singular( 'recipe' ) ) { |
|
| 132 | + |
|
| 133 | + $title = __( 'Recipe', 'lsx-health-plan' ); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if ( is_single() && is_singular( 'exercise' ) ) { |
|
| 137 | + |
|
| 138 | + $title = __( 'Exercise', 'lsx-health-plan' ); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + return $title; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + /** |
|
| 145 | + * Removing footer for HP single pages. |
|
| 146 | + * |
|
| 147 | + * @return void |
|
| 148 | + */ |
|
| 149 | + public function remove_single_footer() { |
|
| 150 | + if ( is_single() && is_singular( array( 'exercise', 'recipe', 'workout', 'meal' ) ) ) { |
|
| 151 | + remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | 154 | } |
@@ -8,53 +8,53 @@ |
||
| 8 | 8 | */ |
| 9 | 9 | class Plan_Status { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * Holds class instance |
|
| 13 | - * |
|
| 14 | - * @since 1.0.0 |
|
| 15 | - * |
|
| 16 | - * @var object \lsx_health_plan\classes\frontend\Plan_Status() |
|
| 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\frontend\Plan_Status() |
|
| 17 | + */ |
|
| 18 | + protected static $instance = null; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Contructor |
|
| 22 | - */ |
|
| 23 | - public function __construct() { |
|
| 24 | - add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
| 25 | - } |
|
| 20 | + /** |
|
| 21 | + * Contructor |
|
| 22 | + */ |
|
| 23 | + public function __construct() { |
|
| 24 | + add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Return an instance of this class. |
|
| 29 | - * |
|
| 30 | - * @since 1.0.0 |
|
| 31 | - * |
|
| 32 | - * @return object \lsx_health_plan\classes\frontend\Plan_Status() A single instance of this class. |
|
| 33 | - */ |
|
| 34 | - public static function get_instance() { |
|
| 35 | - // If the single instance hasn't been set, set it now. |
|
| 36 | - if ( null === self::$instance ) { |
|
| 37 | - self::$instance = new self(); |
|
| 38 | - } |
|
| 39 | - return self::$instance; |
|
| 40 | - } |
|
| 27 | + /** |
|
| 28 | + * Return an instance of this class. |
|
| 29 | + * |
|
| 30 | + * @since 1.0.0 |
|
| 31 | + * |
|
| 32 | + * @return object \lsx_health_plan\classes\frontend\Plan_Status() A single instance of this class. |
|
| 33 | + */ |
|
| 34 | + public static function get_instance() { |
|
| 35 | + // If the single instance hasn't been set, set it now. |
|
| 36 | + if ( null === self::$instance ) { |
|
| 37 | + self::$instance = new self(); |
|
| 38 | + } |
|
| 39 | + return self::$instance; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Registers the rewrites. |
|
| 44 | - */ |
|
| 45 | - public function handle_day_action() { |
|
| 46 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
| 47 | - update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
| 48 | - $plan_id = sanitize_key( $_POST['lsx-health-plan-id'] ); |
|
| 49 | - $plan_parent = wp_get_post_parent_id( $plan_id ); |
|
| 50 | - if ( 0 !== $plan_parent ) { |
|
| 51 | - $plan_id = $plan_parent; |
|
| 52 | - } |
|
| 53 | - wp_safe_redirect( get_permalink( $plan_id ) ); |
|
| 54 | - } |
|
| 42 | + /** |
|
| 43 | + * Registers the rewrites. |
|
| 44 | + */ |
|
| 45 | + public function handle_day_action() { |
|
| 46 | + if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
| 47 | + update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
| 48 | + $plan_id = sanitize_key( $_POST['lsx-health-plan-id'] ); |
|
| 49 | + $plan_parent = wp_get_post_parent_id( $plan_id ); |
|
| 50 | + if ( 0 !== $plan_parent ) { |
|
| 51 | + $plan_id = $plan_parent; |
|
| 52 | + } |
|
| 53 | + wp_safe_redirect( get_permalink( $plan_id ) ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
| 57 | - delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
| 58 | - } |
|
| 59 | - } |
|
| 56 | + if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
| 57 | + delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | 60 | } |