@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | * @return boolean |
| 14 | 14 | */ |
| 15 | 15 | function plan_has_products() { |
| 16 | - $lsx_hp = lsx_health_plan(); |
|
| 17 | - $has_products = false; |
|
| 18 | - if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) { |
|
| 19 | - $has_products = true; |
|
| 20 | - } |
|
| 21 | - return $has_products; |
|
| 16 | + $lsx_hp = lsx_health_plan(); |
|
| 17 | + $has_products = false; |
|
| 18 | + if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) { |
|
| 19 | + $has_products = true; |
|
| 20 | + } |
|
| 21 | + return $has_products; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -27,12 +27,12 @@ discard block |
||
| 27 | 27 | * @return array |
| 28 | 28 | */ |
| 29 | 29 | function get_plan_products() { |
| 30 | - $lsx_hp = lsx_health_plan(); |
|
| 31 | - $has_products = array(); |
|
| 32 | - if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) { |
|
| 33 | - $has_products = $lsx_hp->integrations->woocommerce->plans->product_ids; |
|
| 34 | - } |
|
| 35 | - return $has_products; |
|
| 30 | + $lsx_hp = lsx_health_plan(); |
|
| 31 | + $has_products = array(); |
|
| 32 | + if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) { |
|
| 33 | + $has_products = $lsx_hp->integrations->woocommerce->plans->product_ids; |
|
| 34 | + } |
|
| 35 | + return $has_products; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -41,21 +41,21 @@ discard block |
||
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | 43 | function get_membership_products() { |
| 44 | - $product_ids = array(); |
|
| 45 | - if ( function_exists( 'wc_memberships_get_user_memberships' ) ) { |
|
| 46 | - $user_memberships = wc_memberships_get_user_memberships(); |
|
| 44 | + $product_ids = array(); |
|
| 45 | + if ( function_exists( 'wc_memberships_get_user_memberships' ) ) { |
|
| 46 | + $user_memberships = wc_memberships_get_user_memberships(); |
|
| 47 | 47 | |
| 48 | - if ( ! empty( $user_memberships ) ) { |
|
| 49 | - foreach ( $user_memberships as $membership ) { |
|
| 50 | - $current_products = $membership->plan->get_product_ids(); |
|
| 51 | - if ( ! empty( $current_products ) ) { |
|
| 52 | - $product_ids = array_merge( $product_ids, $current_products ); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - if ( ! empty( $product_ids ) ) { |
|
| 58 | - $product_ids = array_unique( $product_ids ); |
|
| 59 | - } |
|
| 60 | - return $product_ids; |
|
| 48 | + if ( ! empty( $user_memberships ) ) { |
|
| 49 | + foreach ( $user_memberships as $membership ) { |
|
| 50 | + $current_products = $membership->plan->get_product_ids(); |
|
| 51 | + if ( ! empty( $current_products ) ) { |
|
| 52 | + $product_ids = array_merge( $product_ids, $current_products ); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | + if ( ! empty( $product_ids ) ) { |
|
| 58 | + $product_ids = array_unique( $product_ids ); |
|
| 59 | + } |
|
| 60 | + return $product_ids; |
|
| 61 | 61 | } |
@@ -14,10 +14,10 @@ |
||
| 14 | 14 | * @return boolean |
| 15 | 15 | */ |
| 16 | 16 | function register_recipe_modal() { |
| 17 | - remove_action( 'lsx_content_sharing', 'lsx_sharing_output', 20 ); |
|
| 18 | - ob_start(); |
|
| 19 | - include LSX_HEALTH_PLAN_PATH . '/templates/content-recipe.php'; |
|
| 20 | - $modal_body = ob_get_clean(); |
|
| 21 | - add_action( 'lsx_content_sharing', 'lsx_sharing_output', 20 ); |
|
| 22 | - \lsx_health_plan\functions\register_modal( 'recipe-modal-' . get_the_ID(), '', $modal_body ); |
|
| 17 | + remove_action( 'lsx_content_sharing', 'lsx_sharing_output', 20 ); |
|
| 18 | + ob_start(); |
|
| 19 | + include LSX_HEALTH_PLAN_PATH . '/templates/content-recipe.php'; |
|
| 20 | + $modal_body = ob_get_clean(); |
|
| 21 | + add_action( 'lsx_content_sharing', 'lsx_sharing_output', 20 ); |
|
| 22 | + \lsx_health_plan\functions\register_modal( 'recipe-modal-' . get_the_ID(), '', $modal_body ); |
|
| 23 | 23 | } |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | * @return string |
| 14 | 14 | */ |
| 15 | 15 | function restricted_content() { |
| 16 | - $content = ''; |
|
| 17 | - if ( ! is_user_logged_in() ) { |
|
| 18 | - ob_start(); |
|
| 19 | - echo do_shortcode( '[woocommerce_my_account]' ); |
|
| 20 | - $content = ob_get_clean(); |
|
| 21 | - } |
|
| 22 | - return $content; |
|
| 16 | + $content = ''; |
|
| 17 | + if ( ! is_user_logged_in() ) { |
|
| 18 | + ob_start(); |
|
| 19 | + echo do_shortcode( '[woocommerce_my_account]' ); |
|
| 20 | + $content = ob_get_clean(); |
|
| 21 | + } |
|
| 22 | + return $content; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
@@ -28,10 +28,10 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function my_profile_tabs() { |
| 31 | - ob_start(); |
|
| 32 | - echo lsx_health_plan_my_profile_tabs(); // WPCS: XSS OK. |
|
| 33 | - $content = ob_get_clean(); |
|
| 34 | - return $content; |
|
| 31 | + ob_start(); |
|
| 32 | + echo lsx_health_plan_my_profile_tabs(); // WPCS: XSS OK. |
|
| 33 | + $content = ob_get_clean(); |
|
| 34 | + return $content; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
@@ -40,10 +40,10 @@ discard block |
||
| 40 | 40 | * @return void |
| 41 | 41 | */ |
| 42 | 42 | function my_profile_box() { |
| 43 | - ob_start(); |
|
| 44 | - echo lsx_health_plan_my_profile_box(); // WPCS: XSS OK. |
|
| 45 | - $content = ob_get_clean(); |
|
| 46 | - return $content; |
|
| 43 | + ob_start(); |
|
| 44 | + echo lsx_health_plan_my_profile_box(); // WPCS: XSS OK. |
|
| 45 | + $content = ob_get_clean(); |
|
| 46 | + return $content; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function all_plans_box( $args = array() ) { |
| 55 | 55 | |
| 56 | - ob_start(); |
|
| 57 | - echo lsx_health_plan_all_plans_block(); // WPCS: XSS OK. |
|
| 58 | - $content = ob_get_clean(); |
|
| 59 | - return $content; |
|
| 56 | + ob_start(); |
|
| 57 | + echo lsx_health_plan_all_plans_block(); // WPCS: XSS OK. |
|
| 58 | + $content = ob_get_clean(); |
|
| 59 | + return $content; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -65,20 +65,20 @@ discard block |
||
| 65 | 65 | * @return void |
| 66 | 66 | */ |
| 67 | 67 | function day_plan_box( $args = array() ) { |
| 68 | - $defaults = array( |
|
| 69 | - 'week_view' => false, |
|
| 70 | - 'show_downloads' => false, |
|
| 71 | - 'plan' => '', |
|
| 72 | - ); |
|
| 73 | - $args = wp_parse_args( $args, $defaults ); |
|
| 74 | - ob_start(); |
|
| 75 | - if ( false === $args['week_view'] ) { |
|
| 76 | - echo lsx_health_plan_day_plan_block( $args ); // WPCS: XSS OK. |
|
| 77 | - } else { |
|
| 78 | - echo lsx_health_plan_week_plan_block( $args ); // WPCS: XSS OK. |
|
| 79 | - } |
|
| 80 | - $content = ob_get_clean(); |
|
| 81 | - return $content; |
|
| 68 | + $defaults = array( |
|
| 69 | + 'week_view' => false, |
|
| 70 | + 'show_downloads' => false, |
|
| 71 | + 'plan' => '', |
|
| 72 | + ); |
|
| 73 | + $args = wp_parse_args( $args, $defaults ); |
|
| 74 | + ob_start(); |
|
| 75 | + if ( false === $args['week_view'] ) { |
|
| 76 | + echo lsx_health_plan_day_plan_block( $args ); // WPCS: XSS OK. |
|
| 77 | + } else { |
|
| 78 | + echo lsx_health_plan_week_plan_block( $args ); // WPCS: XSS OK. |
|
| 79 | + } |
|
| 80 | + $content = ob_get_clean(); |
|
| 81 | + return $content; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -88,29 +88,29 @@ discard block |
||
| 88 | 88 | * @return void |
| 89 | 89 | */ |
| 90 | 90 | function exercise_box( $args = array() ) { |
| 91 | - $defaults = array( |
|
| 92 | - 'include' => '', |
|
| 93 | - 'term' => '', |
|
| 94 | - 'taxonomy' => '', |
|
| 95 | - 'view_more' => false, |
|
| 96 | - 'columns' => 3, |
|
| 97 | - 'limit' => 4, |
|
| 98 | - 'post_type' => 'exercise', |
|
| 99 | - 'orderby' => 'date', |
|
| 100 | - 'order' => 'DESC', |
|
| 101 | - 'description' => 'none', |
|
| 102 | - 'link' => 'item', |
|
| 103 | - 'link_class' => 'btn border-btn', |
|
| 104 | - 'layout' => 'grid', |
|
| 105 | - 'image_size' => 'lsx-thumbnail-square', |
|
| 106 | - 'parent' => false, |
|
| 107 | - 'modal_content' => 'excerpt', |
|
| 108 | - ); |
|
| 109 | - $args = wp_parse_args( $args, $defaults ); |
|
| 110 | - ob_start(); |
|
| 111 | - echo lsx_health_plan_items( $args ); // WPCS: XSS OK. |
|
| 112 | - $content = ob_get_clean(); |
|
| 113 | - return $content; |
|
| 91 | + $defaults = array( |
|
| 92 | + 'include' => '', |
|
| 93 | + 'term' => '', |
|
| 94 | + 'taxonomy' => '', |
|
| 95 | + 'view_more' => false, |
|
| 96 | + 'columns' => 3, |
|
| 97 | + 'limit' => 4, |
|
| 98 | + 'post_type' => 'exercise', |
|
| 99 | + 'orderby' => 'date', |
|
| 100 | + 'order' => 'DESC', |
|
| 101 | + 'description' => 'none', |
|
| 102 | + 'link' => 'item', |
|
| 103 | + 'link_class' => 'btn border-btn', |
|
| 104 | + 'layout' => 'grid', |
|
| 105 | + 'image_size' => 'lsx-thumbnail-square', |
|
| 106 | + 'parent' => false, |
|
| 107 | + 'modal_content' => 'excerpt', |
|
| 108 | + ); |
|
| 109 | + $args = wp_parse_args( $args, $defaults ); |
|
| 110 | + ob_start(); |
|
| 111 | + echo lsx_health_plan_items( $args ); // WPCS: XSS OK. |
|
| 112 | + $content = ob_get_clean(); |
|
| 113 | + return $content; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | * @return void |
| 120 | 120 | */ |
| 121 | 121 | function feature_video_box() { |
| 122 | - ob_start(); |
|
| 123 | - echo lsx_health_plan_featured_video_block(); // WPCS: XSS OK. |
|
| 124 | - $content = ob_get_clean(); |
|
| 122 | + ob_start(); |
|
| 123 | + echo lsx_health_plan_featured_video_block(); // WPCS: XSS OK. |
|
| 124 | + $content = ob_get_clean(); |
|
| 125 | 125 | |
| 126 | - wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 127 | - wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-slider.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 128 | - return $content; |
|
| 126 | + wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 127 | + wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-slider.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 128 | + return $content; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -134,12 +134,12 @@ discard block |
||
| 134 | 134 | * @return void |
| 135 | 135 | */ |
| 136 | 136 | function feature_recipes_box() { |
| 137 | - ob_start(); |
|
| 138 | - echo lsx_health_plan_featured_recipes_block(); // WPCS: XSS OK. |
|
| 139 | - $content = ob_get_clean(); |
|
| 140 | - wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 141 | - wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-slider.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 142 | - return $content; |
|
| 137 | + ob_start(); |
|
| 138 | + echo lsx_health_plan_featured_recipes_block(); // WPCS: XSS OK. |
|
| 139 | + $content = ob_get_clean(); |
|
| 140 | + wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 141 | + wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-slider.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 142 | + return $content; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | /** |
@@ -148,12 +148,12 @@ discard block |
||
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | 150 | function feature_tips_box() { |
| 151 | - ob_start(); |
|
| 152 | - echo lsx_health_plan_featured_tips_block(); // WPCS: XSS OK. |
|
| 153 | - $content = ob_get_clean(); |
|
| 154 | - wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 155 | - wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-slider.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 156 | - return $content; |
|
| 151 | + ob_start(); |
|
| 152 | + echo lsx_health_plan_featured_tips_block(); // WPCS: XSS OK. |
|
| 153 | + $content = ob_get_clean(); |
|
| 154 | + wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 155 | + wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-slider.min.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
| 156 | + return $content; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | * @return string |
| 163 | 163 | */ |
| 164 | 164 | function account_notices() { |
| 165 | - $content = ''; |
|
| 166 | - if ( function_exists( 'wc_print_notices' ) ) { |
|
| 167 | - $content = wc_print_notices( true ); |
|
| 168 | - } |
|
| 169 | - return $content; |
|
| 165 | + $content = ''; |
|
| 166 | + if ( function_exists( 'wc_print_notices' ) ) { |
|
| 167 | + $content = wc_print_notices( true ); |
|
| 168 | + } |
|
| 169 | + return $content; |
|
| 170 | 170 | } |
@@ -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,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 | } |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | <?php } ?> |
| 23 | 23 | <a href="<?php echo esc_url( get_permalink() ); ?>"> |
| 24 | 24 | <?php |
| 25 | - $featured_image = get_the_post_thumbnail(); |
|
| 26 | - if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 27 | - the_post_thumbnail( 'lsx-thumbnail-square', array( |
|
| 28 | - 'class' => 'aligncenter', |
|
| 29 | - ) ); |
|
| 30 | - } else { |
|
| 31 | - ?> |
|
| 25 | + $featured_image = get_the_post_thumbnail(); |
|
| 26 | + if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 27 | + the_post_thumbnail( 'lsx-thumbnail-square', array( |
|
| 28 | + 'class' => 'aligncenter', |
|
| 29 | + ) ); |
|
| 30 | + } else { |
|
| 31 | + ?> |
|
| 32 | 32 | <img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
| 33 | 33 | <?php |
| 34 | - } |
|
| 35 | - ?> |
|
| 34 | + } |
|
| 35 | + ?> |
|
| 36 | 36 | </a> |
| 37 | 37 | </div> |
| 38 | 38 | <div class="content-box workout-content-box white-bg"> |
@@ -40,14 +40,14 @@ discard block |
||
| 40 | 40 | <?php the_title( '<h3 class="workout-title">', '</h3>' ); ?> |
| 41 | 41 | </a> |
| 42 | 42 | <?php |
| 43 | - if ( ! has_excerpt() ) { |
|
| 44 | - $content = wp_trim_words( get_the_content(), 20 ); |
|
| 45 | - $content = '<p>' . $content . '</p>'; |
|
| 46 | - } else { |
|
| 47 | - $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
| 48 | - } |
|
| 49 | - echo wp_kses_post( $content ); |
|
| 50 | - ?> |
|
| 43 | + if ( ! has_excerpt() ) { |
|
| 44 | + $content = wp_trim_words( get_the_content(), 20 ); |
|
| 45 | + $content = '<p>' . $content . '</p>'; |
|
| 46 | + } else { |
|
| 47 | + $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
| 48 | + } |
|
| 49 | + echo wp_kses_post( $content ); |
|
| 50 | + ?> |
|
| 51 | 51 | <a href="<?php echo esc_url( get_permalink() ); ?>" class="btn border-btn"><?php esc_html_e( 'See workout', 'lsx-health-plan' ); ?></a> |
| 52 | 52 | </div> |
| 53 | 53 | <?php lsx_entry_bottom(); ?> |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | global $group_name,$shortcode_args; |
| 9 | 9 | $groups = get_post_meta( get_the_ID(), $group_name, true ); |
| 10 | 10 | if ( is_singular( 'workout' ) ) { |
| 11 | - $groups = get_post_meta( get_queried_object_id(), $group_name, true ); |
|
| 11 | + $groups = get_post_meta( get_queried_object_id(), $group_name, true ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | $link_setting = \lsx_health_plan\functions\get_option( 'workout_tab_link', 'single' ); |
@@ -18,167 +18,167 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | // Check for shortcode overrides. |
| 20 | 20 | if ( null !== $shortcode_args ) { |
| 21 | - if ( isset( $shortcode_args['link'] ) ) { |
|
| 22 | - $link_setting = $shortcode_args['link']; |
|
| 23 | - } |
|
| 24 | - if ( isset( $shortcode_args['description'] ) ) { |
|
| 25 | - $content_setting = $shortcode_args['description']; |
|
| 26 | - } |
|
| 27 | - if ( isset( $shortcode_args['columns'] ) ) { |
|
| 28 | - $column_setting = $shortcode_args['columns']; |
|
| 29 | - $column_setting = \lsx_health_plan\functions\column_class( $column_setting ); |
|
| 30 | - } |
|
| 31 | - if ( isset( $shortcode_args['modal_content'] ) ) { |
|
| 32 | - $modal_content_setting = $shortcode_args['modal_content']; |
|
| 33 | - } |
|
| 21 | + if ( isset( $shortcode_args['link'] ) ) { |
|
| 22 | + $link_setting = $shortcode_args['link']; |
|
| 23 | + } |
|
| 24 | + if ( isset( $shortcode_args['description'] ) ) { |
|
| 25 | + $content_setting = $shortcode_args['description']; |
|
| 26 | + } |
|
| 27 | + if ( isset( $shortcode_args['columns'] ) ) { |
|
| 28 | + $column_setting = $shortcode_args['columns']; |
|
| 29 | + $column_setting = \lsx_health_plan\functions\column_class( $column_setting ); |
|
| 30 | + } |
|
| 31 | + if ( isset( $shortcode_args['modal_content'] ) ) { |
|
| 32 | + $modal_content_setting = $shortcode_args['modal_content']; |
|
| 33 | + } |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $modal_args = array( |
| 37 | - 'modal_content' => $modal_content_setting, |
|
| 37 | + 'modal_content' => $modal_content_setting, |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | $counter = 1; |
| 41 | 41 | |
| 42 | 42 | if ( ! empty( $groups ) ) { |
| 43 | - ?> |
|
| 43 | + ?> |
|
| 44 | 44 | <div class="set-grid"> |
| 45 | 45 | <div class="workout-grid row"> |
| 46 | 46 | <?php |
| 47 | - foreach ( $groups as $group ) { |
|
| 48 | - $connected_exercise = false; |
|
| 49 | - if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
| 50 | - $connected_exercise = true; |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - if ( ! $connected_exercise ) { |
|
| 54 | - $group['connected_exercises'] = ''; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if ( ( $connected_exercise ) || ( ( ! $connected_exercise ) && '' !== $group['alt_title'] && isset( $group['alt_title'] ) ) ) { |
|
| 58 | - |
|
| 59 | - $alt_title = ''; |
|
| 60 | - if ( isset( $group['alt_title'] ) && '' !== $group['alt_title'] ) { |
|
| 61 | - $alt_title = '<span class="alt-title">' . esc_html( $group['alt_title'] ) . '</span>'; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - $alt_description = ''; |
|
| 65 | - if ( isset( $group['alt_description'] ) && '' !== $group['alt_description'] ) { |
|
| 66 | - $alt_description = '<span class="alt-description">' . esc_html( $group['alt_description'] ) . '</span>'; |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - $alt_image = ''; |
|
| 70 | - if ( isset( $group['exercise_alt_thumbnail'] ) && '' !== $group['exercise_alt_thumbnail'] ) { |
|
| 71 | - $alt_image = $group['exercise_alt_thumbnail']; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - $reps = ''; |
|
| 75 | - if ( isset( $group['reps'] ) && '' !== $group['reps'] ) { |
|
| 76 | - $reps = '<span class="reps">' . esc_html( $group['reps'] ) . '</span>'; |
|
| 77 | - } |
|
| 78 | - $class_excerpt = 'no-excerpt'; |
|
| 79 | - if ( 'excerpt' === $content_setting ) { |
|
| 80 | - $class_excerpt = 'has-excerpt'; |
|
| 81 | - } |
|
| 82 | - // Setup our link and content. |
|
| 83 | - switch ( $link_setting ) { |
|
| 84 | - case 'single': |
|
| 85 | - $link_html = '<a href="' . get_permalink( $group['connected_exercises'] ) . '">'; |
|
| 86 | - $link_close = '</a>'; |
|
| 87 | - break; |
|
| 88 | - |
|
| 89 | - case 'modal': |
|
| 90 | - if ( ( '' !== $alt_title ) || ( '' !== $alt_description ) || ( '' !== $alt_image ) ) { |
|
| 91 | - $link_html = '<a class="alt-modal" data-toggle="modal" href="#workout-alt-exercise-modal-' . $group['connected_exercises'] . '">'; |
|
| 92 | - $link_close = '</a>'; |
|
| 93 | - // We call the button to register the alt modal, but we do not output it. |
|
| 94 | - lsx_health_plan_workout_exercise_alt_button( $group['connected_exercises'], $group, false, $modal_args, $alt_title, $alt_description, $alt_image ); |
|
| 95 | - } else { |
|
| 96 | - $link_html = '<a data-toggle="modal" href="#workout-exercise-modal-' . $group['connected_exercises'] . '">'; |
|
| 97 | - $link_close = '</a>'; |
|
| 98 | - // We call the button to register the modal, but we do not output it. |
|
| 99 | - lsx_health_plan_workout_exercise_button( $group['connected_exercises'], $group, false, $modal_args ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - break; |
|
| 103 | - |
|
| 104 | - case 'none': |
|
| 105 | - default: |
|
| 106 | - $link_html = ''; |
|
| 107 | - $link_close = ''; |
|
| 108 | - break; |
|
| 109 | - } |
|
| 110 | - ?> |
|
| 47 | + foreach ( $groups as $group ) { |
|
| 48 | + $connected_exercise = false; |
|
| 49 | + if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
| 50 | + $connected_exercise = true; |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + if ( ! $connected_exercise ) { |
|
| 54 | + $group['connected_exercises'] = ''; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if ( ( $connected_exercise ) || ( ( ! $connected_exercise ) && '' !== $group['alt_title'] && isset( $group['alt_title'] ) ) ) { |
|
| 58 | + |
|
| 59 | + $alt_title = ''; |
|
| 60 | + if ( isset( $group['alt_title'] ) && '' !== $group['alt_title'] ) { |
|
| 61 | + $alt_title = '<span class="alt-title">' . esc_html( $group['alt_title'] ) . '</span>'; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + $alt_description = ''; |
|
| 65 | + if ( isset( $group['alt_description'] ) && '' !== $group['alt_description'] ) { |
|
| 66 | + $alt_description = '<span class="alt-description">' . esc_html( $group['alt_description'] ) . '</span>'; |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + $alt_image = ''; |
|
| 70 | + if ( isset( $group['exercise_alt_thumbnail'] ) && '' !== $group['exercise_alt_thumbnail'] ) { |
|
| 71 | + $alt_image = $group['exercise_alt_thumbnail']; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + $reps = ''; |
|
| 75 | + if ( isset( $group['reps'] ) && '' !== $group['reps'] ) { |
|
| 76 | + $reps = '<span class="reps">' . esc_html( $group['reps'] ) . '</span>'; |
|
| 77 | + } |
|
| 78 | + $class_excerpt = 'no-excerpt'; |
|
| 79 | + if ( 'excerpt' === $content_setting ) { |
|
| 80 | + $class_excerpt = 'has-excerpt'; |
|
| 81 | + } |
|
| 82 | + // Setup our link and content. |
|
| 83 | + switch ( $link_setting ) { |
|
| 84 | + case 'single': |
|
| 85 | + $link_html = '<a href="' . get_permalink( $group['connected_exercises'] ) . '">'; |
|
| 86 | + $link_close = '</a>'; |
|
| 87 | + break; |
|
| 88 | + |
|
| 89 | + case 'modal': |
|
| 90 | + if ( ( '' !== $alt_title ) || ( '' !== $alt_description ) || ( '' !== $alt_image ) ) { |
|
| 91 | + $link_html = '<a class="alt-modal" data-toggle="modal" href="#workout-alt-exercise-modal-' . $group['connected_exercises'] . '">'; |
|
| 92 | + $link_close = '</a>'; |
|
| 93 | + // We call the button to register the alt modal, but we do not output it. |
|
| 94 | + lsx_health_plan_workout_exercise_alt_button( $group['connected_exercises'], $group, false, $modal_args, $alt_title, $alt_description, $alt_image ); |
|
| 95 | + } else { |
|
| 96 | + $link_html = '<a data-toggle="modal" href="#workout-exercise-modal-' . $group['connected_exercises'] . '">'; |
|
| 97 | + $link_close = '</a>'; |
|
| 98 | + // We call the button to register the modal, but we do not output it. |
|
| 99 | + lsx_health_plan_workout_exercise_button( $group['connected_exercises'], $group, false, $modal_args ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + break; |
|
| 103 | + |
|
| 104 | + case 'none': |
|
| 105 | + default: |
|
| 106 | + $link_html = ''; |
|
| 107 | + $link_close = ''; |
|
| 108 | + break; |
|
| 109 | + } |
|
| 110 | + ?> |
|
| 111 | 111 | <div class="col-xs-12 col-sm-6 col-md-<?php echo esc_attr( $column_setting ); ?>"> |
| 112 | 112 | <article class="lsx-slot box-shadow"> |
| 113 | 113 | <div class="exercise-feature-img"> |
| 114 | 114 | <span class="exercise-counter"><?php echo esc_html( $counter ); ?>.</span> |
| 115 | 115 | <?php echo wp_kses_post( $link_html ); ?> |
| 116 | 116 | <?php |
| 117 | - $thumbnail_args = array( |
|
| 118 | - 'class' => 'aligncenter', |
|
| 119 | - ); |
|
| 120 | - $featured_image = get_the_post_thumbnail( $group['connected_exercises'], 'medium', $thumbnail_args ); |
|
| 121 | - if ( $alt_image ) { |
|
| 122 | - $featured_image = '<img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '">'; |
|
| 123 | - } |
|
| 124 | - if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 125 | - echo wp_kses_post( $featured_image ); |
|
| 126 | - } else { |
|
| 127 | - ?> |
|
| 117 | + $thumbnail_args = array( |
|
| 118 | + 'class' => 'aligncenter', |
|
| 119 | + ); |
|
| 120 | + $featured_image = get_the_post_thumbnail( $group['connected_exercises'], 'medium', $thumbnail_args ); |
|
| 121 | + if ( $alt_image ) { |
|
| 122 | + $featured_image = '<img alt="thumbnail" loading="lazy" class="aligncenter wp-post-image" src="' . $alt_image . '">'; |
|
| 123 | + } |
|
| 124 | + if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
|
| 125 | + echo wp_kses_post( $featured_image ); |
|
| 126 | + } else { |
|
| 127 | + ?> |
|
| 128 | 128 | <img loading="lazy" src="<?php echo esc_attr( plugin_dir_url( __DIR__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
| 129 | 129 | <?php |
| 130 | - } |
|
| 131 | - ?> |
|
| 130 | + } |
|
| 131 | + ?> |
|
| 132 | 132 | <?php echo wp_kses_post( $link_close ); ?> |
| 133 | 133 | </div> |
| 134 | 134 | <div class="content-box exercise-content-box white-bg"> |
| 135 | 135 | <h3 class="content-box-title <?php echo esc_html( $class_excerpt ); ?>"> |
| 136 | 136 | <?php echo wp_kses_post( $link_html ); ?> |
| 137 | 137 | <?php |
| 138 | - $exercise_title = lsx_health_plan_exercise_title( '', '', false, $group['connected_exercises'] ); |
|
| 139 | - if ( '' !== $alt_title ) { |
|
| 140 | - $exercise_title = $alt_title; |
|
| 141 | - } |
|
| 142 | - echo wp_kses_post( $exercise_title ); |
|
| 143 | - ?> |
|
| 138 | + $exercise_title = lsx_health_plan_exercise_title( '', '', false, $group['connected_exercises'] ); |
|
| 139 | + if ( '' !== $alt_title ) { |
|
| 140 | + $exercise_title = $alt_title; |
|
| 141 | + } |
|
| 142 | + echo wp_kses_post( $exercise_title ); |
|
| 143 | + ?> |
|
| 144 | 144 | </a> |
| 145 | 145 | <?php echo wp_kses_post( $link_close ); ?> |
| 146 | 146 | </h3> |
| 147 | 147 | <?php |
| 148 | - if ( '' !== $content_setting ) { |
|
| 149 | - ?> |
|
| 148 | + if ( '' !== $content_setting ) { |
|
| 149 | + ?> |
|
| 150 | 150 | <p class="lsx-exercises-excerpt"> |
| 151 | 151 | <?php |
| 152 | - if ( 'excerpt' === $content_setting ) { |
|
| 153 | - $excerpt = \lsx_health_plan\functions\hp_excerpt( $group['connected_exercises'] ); |
|
| 154 | - |
|
| 155 | - if ( '' !== $alt_description ) { |
|
| 156 | - $excerpt = $alt_description; |
|
| 157 | - } |
|
| 158 | - echo wp_kses_post( $excerpt ); |
|
| 159 | - } |
|
| 160 | - if ( 'full' === $content_setting ) { |
|
| 161 | - echo wp_kses_post( get_the_content( null, null, $group['connected_exercises'] ) ); |
|
| 162 | - } |
|
| 163 | - ?> |
|
| 152 | + if ( 'excerpt' === $content_setting ) { |
|
| 153 | + $excerpt = \lsx_health_plan\functions\hp_excerpt( $group['connected_exercises'] ); |
|
| 154 | + |
|
| 155 | + if ( '' !== $alt_description ) { |
|
| 156 | + $excerpt = $alt_description; |
|
| 157 | + } |
|
| 158 | + echo wp_kses_post( $excerpt ); |
|
| 159 | + } |
|
| 160 | + if ( 'full' === $content_setting ) { |
|
| 161 | + echo wp_kses_post( get_the_content( null, null, $group['connected_exercises'] ) ); |
|
| 162 | + } |
|
| 163 | + ?> |
|
| 164 | 164 | </p> |
| 165 | 165 | <?php |
| 166 | - } |
|
| 167 | - ?> |
|
| 166 | + } |
|
| 167 | + ?> |
|
| 168 | 168 | <?php |
| 169 | - $repsclass = ''; |
|
| 170 | - if ( '' !== $reps ) { |
|
| 171 | - $repsclass = 'have-reps'; |
|
| 172 | - } |
|
| 173 | - ?> |
|
| 169 | + $repsclass = ''; |
|
| 170 | + if ( '' !== $reps ) { |
|
| 171 | + $repsclass = 'have-reps'; |
|
| 172 | + } |
|
| 173 | + ?> |
|
| 174 | 174 | <div class="reps-container <?php echo esc_html( $repsclass ); ?>"> |
| 175 | 175 | <?php |
| 176 | - if ( '' !== $reps ) { |
|
| 177 | - ?> |
|
| 176 | + if ( '' !== $reps ) { |
|
| 177 | + ?> |
|
| 178 | 178 | <?php echo wp_kses_post( $reps ); ?> |
| 179 | 179 | <?php |
| 180 | - } |
|
| 181 | - ?> |
|
| 180 | + } |
|
| 181 | + ?> |
|
| 182 | 182 | <?php if ( ( '' !== $link_html ) && ( $connected_exercise ) ) { ?> |
| 183 | 183 | <?php echo wp_kses_post( str_replace( '<a', '<a class="btn-simple" ', $link_html ) ); ?> |
| 184 | 184 | <?php echo wp_kses_post( $link_close ); ?> |
@@ -188,10 +188,10 @@ discard block |
||
| 188 | 188 | </article> |
| 189 | 189 | </div> |
| 190 | 190 | <?php |
| 191 | - $counter ++; |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - ?> |
|
| 191 | + $counter ++; |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + ?> |
|
| 195 | 195 | </div> |
| 196 | 196 | </div> |
| 197 | 197 | <?php |
@@ -15,12 +15,12 @@ discard block |
||
| 15 | 15 | <div class="lsx-tips-shortcode lsx-tips-slider slick-slider slick-dotted" > |
| 16 | 16 | <?php |
| 17 | 17 | |
| 18 | - foreach ( $connected_tips as $tip ) { |
|
| 19 | - $tip_link = get_permalink( $tip ); |
|
| 20 | - $tip_name = get_the_title( $tip ); |
|
| 21 | - $tip_content = get_post_field( 'post_content', $tip ); |
|
| 22 | - $icon = LSX_HEALTH_PLAN_URL . 'assets/images/tips-icon.svg'; |
|
| 23 | - ?> |
|
| 18 | + foreach ( $connected_tips as $tip ) { |
|
| 19 | + $tip_link = get_permalink( $tip ); |
|
| 20 | + $tip_name = get_the_title( $tip ); |
|
| 21 | + $tip_content = get_post_field( 'post_content', $tip ); |
|
| 22 | + $icon = LSX_HEALTH_PLAN_URL . 'assets/images/tips-icon.svg'; |
|
| 23 | + ?> |
|
| 24 | 24 | <div class="content-box diet-tip-wrapper quick-tip"> |
| 25 | 25 | <div class="row"> |
| 26 | 26 | <div class="col-xs-2"> |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | </div> |
| 34 | 34 | </div> |
| 35 | 35 | <?php |
| 36 | - } |
|
| 37 | - ?> |
|
| 36 | + } |
|
| 37 | + ?> |
|
| 38 | 38 | </div> |
| 39 | 39 | </div> |
| 40 | 40 | <?php |
@@ -14,152 +14,152 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class Tip { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Holds class instance |
|
| 19 | - * |
|
| 20 | - * @since 1.0.0 |
|
| 21 | - * |
|
| 22 | - * @var object \lsx_health_plan\classes\Tip() |
|
| 23 | - */ |
|
| 24 | - protected static $instance = null; |
|
| 17 | + /** |
|
| 18 | + * Holds class instance |
|
| 19 | + * |
|
| 20 | + * @since 1.0.0 |
|
| 21 | + * |
|
| 22 | + * @var object \lsx_health_plan\classes\Tip() |
|
| 23 | + */ |
|
| 24 | + protected static $instance = null; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Holds post_type slug used as an index |
|
| 28 | - * |
|
| 29 | - * @since 1.0.0 |
|
| 30 | - * |
|
| 31 | - * @var string |
|
| 32 | - */ |
|
| 33 | - public $slug = 'tip'; |
|
| 26 | + /** |
|
| 27 | + * Holds post_type slug used as an index |
|
| 28 | + * |
|
| 29 | + * @since 1.0.0 |
|
| 30 | + * |
|
| 31 | + * @var string |
|
| 32 | + */ |
|
| 33 | + public $slug = 'tip'; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Constructor |
|
| 37 | - */ |
|
| 38 | - public function __construct() { |
|
| 39 | - $this->default_types = array( |
|
| 40 | - \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ), |
|
| 41 | - \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
| 42 | - \lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ), |
|
| 43 | - \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
| 44 | - \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ), |
|
| 45 | - ); |
|
| 46 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
| 47 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
| 48 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
| 49 | - add_action( 'cmb2_admin_init', array( $this, 'tips_connections' ), 15 ); |
|
| 50 | - } |
|
| 35 | + /** |
|
| 36 | + * Constructor |
|
| 37 | + */ |
|
| 38 | + public function __construct() { |
|
| 39 | + $this->default_types = array( |
|
| 40 | + \lsx_health_plan\functions\get_option( 'endpoint_meal', 'meal' ), |
|
| 41 | + \lsx_health_plan\functions\get_option( 'endpoint_exercise_single', 'exercise' ), |
|
| 42 | + \lsx_health_plan\functions\get_option( 'endpoint_recipe_single', 'recipe' ), |
|
| 43 | + \lsx_health_plan\functions\get_option( 'endpoint_workout', 'workout' ), |
|
| 44 | + \lsx_health_plan\functions\get_option( 'endpoint_plan', 'plan' ), |
|
| 45 | + ); |
|
| 46 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
| 47 | + add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
| 48 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
| 49 | + add_action( 'cmb2_admin_init', array( $this, 'tips_connections' ), 15 ); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Return an instance of this class. |
|
| 54 | - * |
|
| 55 | - * @since 1.0.0 |
|
| 56 | - * |
|
| 57 | - * @return object \lsx_health_plan\classes\Tip() A single instance of this class. |
|
| 58 | - */ |
|
| 59 | - public static function get_instance() { |
|
| 60 | - // If the single instance hasn't been set, set it now. |
|
| 61 | - if ( null === self::$instance ) { |
|
| 62 | - self::$instance = new self(); |
|
| 63 | - } |
|
| 64 | - return self::$instance; |
|
| 65 | - } |
|
| 66 | - /** |
|
| 67 | - * Register the post type. |
|
| 68 | - */ |
|
| 69 | - public function register_post_type() { |
|
| 70 | - $labels = array( |
|
| 71 | - 'name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
| 72 | - 'singular_name' => esc_html__( 'Tip', 'lsx-health-plan' ), |
|
| 73 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
| 74 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
| 75 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
| 76 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
| 77 | - 'all_items' => esc_html__( 'All Tips', 'lsx-health-plan' ), |
|
| 78 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
| 79 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
| 80 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
| 81 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
| 82 | - 'parent_item_colon' => '', |
|
| 83 | - 'menu_name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
| 84 | - ); |
|
| 85 | - $args = array( |
|
| 86 | - 'labels' => $labels, |
|
| 87 | - 'public' => true, |
|
| 88 | - 'publicly_queryable' => false, |
|
| 89 | - 'show_ui' => true, |
|
| 90 | - 'show_in_menu' => false, |
|
| 91 | - 'show_in_rest' => true, |
|
| 92 | - 'menu_icon' => 'dashicons-admin-post', |
|
| 93 | - 'query_var' => true, |
|
| 94 | - 'rewrite' => false, |
|
| 95 | - 'capability_type' => 'post', |
|
| 96 | - 'has_archive' => false, |
|
| 97 | - 'hierarchical' => false, |
|
| 98 | - 'menu_position' => null, |
|
| 99 | - 'supports' => array( |
|
| 100 | - 'title', |
|
| 101 | - 'editor', |
|
| 102 | - 'thumbnail', |
|
| 103 | - 'custom-fields', |
|
| 104 | - ), |
|
| 105 | - ); |
|
| 106 | - register_post_type( 'tip', $args ); |
|
| 107 | - } |
|
| 52 | + /** |
|
| 53 | + * Return an instance of this class. |
|
| 54 | + * |
|
| 55 | + * @since 1.0.0 |
|
| 56 | + * |
|
| 57 | + * @return object \lsx_health_plan\classes\Tip() A single instance of this class. |
|
| 58 | + */ |
|
| 59 | + public static function get_instance() { |
|
| 60 | + // If the single instance hasn't been set, set it now. |
|
| 61 | + if ( null === self::$instance ) { |
|
| 62 | + self::$instance = new self(); |
|
| 63 | + } |
|
| 64 | + return self::$instance; |
|
| 65 | + } |
|
| 66 | + /** |
|
| 67 | + * Register the post type. |
|
| 68 | + */ |
|
| 69 | + public function register_post_type() { |
|
| 70 | + $labels = array( |
|
| 71 | + 'name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
| 72 | + 'singular_name' => esc_html__( 'Tip', 'lsx-health-plan' ), |
|
| 73 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
| 74 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
| 75 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
| 76 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
| 77 | + 'all_items' => esc_html__( 'All Tips', 'lsx-health-plan' ), |
|
| 78 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
| 79 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
| 80 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
| 81 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
| 82 | + 'parent_item_colon' => '', |
|
| 83 | + 'menu_name' => esc_html__( 'Tips', 'lsx-health-plan' ), |
|
| 84 | + ); |
|
| 85 | + $args = array( |
|
| 86 | + 'labels' => $labels, |
|
| 87 | + 'public' => true, |
|
| 88 | + 'publicly_queryable' => false, |
|
| 89 | + 'show_ui' => true, |
|
| 90 | + 'show_in_menu' => false, |
|
| 91 | + 'show_in_rest' => true, |
|
| 92 | + 'menu_icon' => 'dashicons-admin-post', |
|
| 93 | + 'query_var' => true, |
|
| 94 | + 'rewrite' => false, |
|
| 95 | + 'capability_type' => 'post', |
|
| 96 | + 'has_archive' => false, |
|
| 97 | + 'hierarchical' => false, |
|
| 98 | + 'menu_position' => null, |
|
| 99 | + 'supports' => array( |
|
| 100 | + 'title', |
|
| 101 | + 'editor', |
|
| 102 | + 'thumbnail', |
|
| 103 | + 'custom-fields', |
|
| 104 | + ), |
|
| 105 | + ); |
|
| 106 | + register_post_type( 'tip', $args ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Registers the Recipes under the Meals Post type menu. |
|
| 111 | - * |
|
| 112 | - * @return void |
|
| 113 | - */ |
|
| 114 | - public function register_menus() { |
|
| 115 | - add_submenu_page( 'edit.php?post_type=plan', esc_html__( 'Tips', 'lsx-health-plan' ), esc_html__( 'Tips', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=tip' ); |
|
| 116 | - } |
|
| 109 | + /** |
|
| 110 | + * Registers the Recipes under the Meals Post type menu. |
|
| 111 | + * |
|
| 112 | + * @return void |
|
| 113 | + */ |
|
| 114 | + public function register_menus() { |
|
| 115 | + add_submenu_page( 'edit.php?post_type=plan', esc_html__( 'Tips', 'lsx-health-plan' ), esc_html__( 'Tips', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=tip' ); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /** |
|
| 119 | - * Enables the Bi Directional relationships |
|
| 120 | - * |
|
| 121 | - * @param array $connections |
|
| 122 | - * @return void |
|
| 123 | - */ |
|
| 124 | - public function enable_connections( $connections = array() ) { |
|
| 125 | - $connections['tip']['connected_plans'] = 'plan_connected_tips'; |
|
| 126 | - $connections['plan']['plan_connected_tips'] = 'connected_plans'; |
|
| 127 | - return $connections; |
|
| 128 | - } |
|
| 118 | + /** |
|
| 119 | + * Enables the Bi Directional relationships |
|
| 120 | + * |
|
| 121 | + * @param array $connections |
|
| 122 | + * @return void |
|
| 123 | + */ |
|
| 124 | + public function enable_connections( $connections = array() ) { |
|
| 125 | + $connections['tip']['connected_plans'] = 'plan_connected_tips'; |
|
| 126 | + $connections['plan']['plan_connected_tips'] = 'connected_plans'; |
|
| 127 | + return $connections; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - /** |
|
| 131 | - * Registers the workout connections on the plan post type. |
|
| 132 | - * |
|
| 133 | - * @return void |
|
| 134 | - */ |
|
| 135 | - public function tips_connections() { |
|
| 136 | - foreach ( $this->default_types as $type => $default_type ) { |
|
| 137 | - $cmb = new_cmb2_box( |
|
| 138 | - array( |
|
| 139 | - 'id' => $default_type . '_tips_connections_metabox', |
|
| 140 | - 'title' => __( 'Related Tips', 'lsx-health-plan' ), |
|
| 141 | - 'object_types' => array( $default_type ), // Post types. |
|
| 142 | - 'context' => 'normal', |
|
| 143 | - 'priority' => 'high', |
|
| 144 | - 'show_names' => false, |
|
| 145 | - ) |
|
| 146 | - ); |
|
| 147 | - $cmb->add_field( |
|
| 148 | - array( |
|
| 149 | - 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
| 150 | - 'id' => $default_type . '_connected_tips', |
|
| 151 | - 'desc' => __( 'Connect the tips that apply to this', 'lsx-health-plan' ) . $default_type, |
|
| 152 | - 'type' => 'post_search_ajax', |
|
| 153 | - 'limit' => 15, |
|
| 154 | - 'sortable' => true, |
|
| 155 | - 'query_args' => array( |
|
| 156 | - 'post_type' => array( 'tip' ), |
|
| 157 | - 'post_status' => array( 'publish' ), |
|
| 158 | - 'posts_per_page' => -1, |
|
| 159 | - ), |
|
| 160 | - ) |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 130 | + /** |
|
| 131 | + * Registers the workout connections on the plan post type. |
|
| 132 | + * |
|
| 133 | + * @return void |
|
| 134 | + */ |
|
| 135 | + public function tips_connections() { |
|
| 136 | + foreach ( $this->default_types as $type => $default_type ) { |
|
| 137 | + $cmb = new_cmb2_box( |
|
| 138 | + array( |
|
| 139 | + 'id' => $default_type . '_tips_connections_metabox', |
|
| 140 | + 'title' => __( 'Related Tips', 'lsx-health-plan' ), |
|
| 141 | + 'object_types' => array( $default_type ), // Post types. |
|
| 142 | + 'context' => 'normal', |
|
| 143 | + 'priority' => 'high', |
|
| 144 | + 'show_names' => false, |
|
| 145 | + ) |
|
| 146 | + ); |
|
| 147 | + $cmb->add_field( |
|
| 148 | + array( |
|
| 149 | + 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
| 150 | + 'id' => $default_type . '_connected_tips', |
|
| 151 | + 'desc' => __( 'Connect the tips that apply to this', 'lsx-health-plan' ) . $default_type, |
|
| 152 | + 'type' => 'post_search_ajax', |
|
| 153 | + 'limit' => 15, |
|
| 154 | + 'sortable' => true, |
|
| 155 | + 'query_args' => array( |
|
| 156 | + 'post_type' => array( 'tip' ), |
|
| 157 | + 'post_status' => array( 'publish' ), |
|
| 158 | + 'posts_per_page' => -1, |
|
| 159 | + ), |
|
| 160 | + ) |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | } |