@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __construct() { |
| 34 | 34 | |
| 35 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
| 35 | + add_action('wp_enqueue_scripts', array($this, 'assets'), 5); |
|
| 36 | 36 | |
| 37 | 37 | require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php'; |
| 38 | 38 | $this->endpoints = Endpoints::get_instance(); |
@@ -43,22 +43,22 @@ discard block |
||
| 43 | 43 | require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php'; |
| 44 | 44 | $this->gallery = frontend\Gallery::get_instance(); |
| 45 | 45 | |
| 46 | - if ( is_admin() ) { |
|
| 47 | - add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
| 46 | + if (is_admin()) { |
|
| 47 | + add_filter('lsx_customizer_colour_selectors_body', array($this, 'customizer_body_colours_handler'), 15, 2); |
|
| 48 | 48 | } else { |
| 49 | - add_action( 'body_class', array( $this, 'hp_add_body_classes' ) ); |
|
| 49 | + add_action('body_class', array($this, 'hp_add_body_classes')); |
|
| 50 | 50 | // Handle the template redirects. |
| 51 | - add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
| 52 | - add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
| 53 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
| 54 | - add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
| 55 | - |
|
| 56 | - add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
| 57 | - add_filter( 'wp_kses_allowed_html', array( $this, 'wpkses_post_tags' ), 100, 2 ); |
|
| 58 | - add_filter( 'lsx_global_header_title', array( $this, 'single_title' ), 200, 1 ); |
|
| 51 | + add_filter('template_include', array($this, 'archive_template_include'), 99); |
|
| 52 | + add_filter('template_include', array($this, 'single_template_include'), 99); |
|
| 53 | + add_filter('template_include', array($this, 'taxonomy_template_include'), 99); |
|
| 54 | + add_action('template_redirect', array($this, 'redirect')); |
|
| 55 | + |
|
| 56 | + add_action('init', array($this, 'handle_day_action'), 100); |
|
| 57 | + add_filter('wp_kses_allowed_html', array($this, 'wpkses_post_tags'), 100, 2); |
|
| 58 | + add_filter('lsx_global_header_title', array($this, 'single_title'), 200, 1); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - add_action( 'wp_head', array( $this, 'remove_hp_single_posts_footer' ), 99 ); |
|
| 61 | + add_action('wp_head', array($this, 'remove_hp_single_posts_footer'), 99); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | 69 | public function remove_hp_single_posts_footer() { |
| 70 | - if ( is_single() && ( is_singular( 'exercise' ) || is_singular( 'recipe' ) ) ) { |
|
| 71 | - remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
| 70 | + if (is_single() && (is_singular('exercise') || is_singular('recipe'))) { |
|
| 71 | + remove_action('lsx_footer_before', 'lsx_add_footer_sidebar_area'); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public static function get_instance() { |
| 83 | 83 | // If the single instance hasn't been set, set it now. |
| 84 | - if ( null === self::$instance ) { |
|
| 84 | + if (null === self::$instance) { |
|
| 85 | 85 | self::$instance = new self(); |
| 86 | 86 | } |
| 87 | 87 | return self::$instance; |
@@ -94,20 +94,20 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function assets() { |
| 96 | 96 | |
| 97 | - if ( is_archive() ) { |
|
| 98 | - wp_enqueue_script( 'isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_HEALTH_PLAN_URL, true ); |
|
| 97 | + if (is_archive()) { |
|
| 98 | + wp_enqueue_script('isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array('jquery'), null, LSX_HEALTH_PLAN_URL, true); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
| 102 | - wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
| 103 | - wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
| 101 | + wp_enqueue_style('lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER); |
|
| 102 | + wp_style_add_data('lsx-health-plan', 'rtl', 'replace'); |
|
| 103 | + wp_enqueue_script('lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array('jquery')); |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Handle body colours that might be change by LSX Customizer. |
| 109 | 109 | */ |
| 110 | - public function customizer_body_colours_handler( $css, $colors ) { |
|
| 110 | + public function customizer_body_colours_handler($css, $colors) { |
|
| 111 | 111 | $css .= ' |
| 112 | 112 | @import "' . LSX_HEALTH_PLAN_PATH . '/assets/css/scss/partials/customizer-health-plan-body-colours"; |
| 113 | 113 | |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | /** |
| 131 | 131 | * Archive template. |
| 132 | 132 | */ |
| 133 | - public function archive_template_include( $template ) { |
|
| 134 | - $applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() ); |
|
| 135 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) { |
|
| 133 | + public function archive_template_include($template) { |
|
| 134 | + $applicable_post_types = apply_filters('lsx_health_plan_archive_template', array()); |
|
| 135 | + if ( ! empty($applicable_post_types) && is_main_query() && is_post_type_archive($applicable_post_types)) { |
|
| 136 | 136 | $post_type = get_post_type(); |
| 137 | - if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) { |
|
| 137 | + if (empty(locate_template(array('archive-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php')) { |
|
| 138 | 138 | $template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php'; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -147,31 +147,31 @@ discard block |
||
| 147 | 147 | * @param array $classes |
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | - public function hp_add_body_classes( $classes = array() ) { |
|
| 150 | + public function hp_add_body_classes($classes = array()) { |
|
| 151 | 151 | global $post; |
| 152 | 152 | |
| 153 | - if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'lsx_health_plan_my_profile_block' ) ) { |
|
| 153 | + if (isset($post->post_content) && has_shortcode($post->post_content, 'lsx_health_plan_my_profile_block')) { |
|
| 154 | 154 | $classes[] = 'my-plan-shortcode'; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( is_single() && is_singular( 'plan' ) ) { |
|
| 157 | + if (is_single() && is_singular('plan')) { |
|
| 158 | 158 | $args = array( |
| 159 | 159 | 'post_parent' => get_the_ID(), |
| 160 | 160 | 'post_type' => 'plan', |
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | 163 | $post_id = get_the_ID(); |
| 164 | - $has_children = get_children( $args ); |
|
| 165 | - $has_parent = wp_get_post_parent_id( $post_id ); |
|
| 164 | + $has_children = get_children($args); |
|
| 165 | + $has_parent = wp_get_post_parent_id($post_id); |
|
| 166 | 166 | |
| 167 | - if ( ! empty( $has_children ) ) { |
|
| 167 | + if ( ! empty($has_children)) { |
|
| 168 | 168 | $plan_type_class = 'parent-plan-page'; |
| 169 | - if ( 0 !== $has_parent ) { |
|
| 169 | + if (0 !== $has_parent) { |
|
| 170 | 170 | $plan_type_class = 'parent-sub-plan-page'; |
| 171 | 171 | } |
| 172 | 172 | } else { |
| 173 | 173 | $plan_type_class = 'unique-plan-page'; |
| 174 | - if ( 0 !== $has_parent ) { |
|
| 174 | + if (0 !== $has_parent) { |
|
| 175 | 175 | $plan_type_class = 'child-plan-page'; |
| 176 | 176 | } |
| 177 | 177 | } |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | /** |
| 184 | 184 | * Single template. |
| 185 | 185 | */ |
| 186 | - public function single_template_include( $template ) { |
|
| 187 | - $applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() ); |
|
| 188 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) { |
|
| 186 | + public function single_template_include($template) { |
|
| 187 | + $applicable_post_types = apply_filters('lsx_health_plan_single_template', array()); |
|
| 188 | + if ( ! empty($applicable_post_types) && is_main_query() && is_singular($applicable_post_types)) { |
|
| 189 | 189 | $post_type = get_post_type(); |
| 190 | - if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) { |
|
| 190 | + if (empty(locate_template(array('single-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php')) { |
|
| 191 | 191 | $template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php'; |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | * @param $template string |
| 201 | 201 | * @return string |
| 202 | 202 | */ |
| 203 | - public function taxonomy_template_include( $template ) { |
|
| 204 | - $applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() ); |
|
| 205 | - if ( is_main_query() && is_tax( $applicable_taxonomies ) ) { |
|
| 206 | - $current_taxonomy = get_query_var( 'taxonomy' ); |
|
| 207 | - if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
| 203 | + public function taxonomy_template_include($template) { |
|
| 204 | + $applicable_taxonomies = apply_filters('lsx_health_plan_taxonomies_template', array()); |
|
| 205 | + if (is_main_query() && is_tax($applicable_taxonomies)) { |
|
| 206 | + $current_taxonomy = get_query_var('taxonomy'); |
|
| 207 | + if ('' === locate_template(array('taxonomy-' . $current_taxonomy . '.php')) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php')) { |
|
| 208 | 208 | $template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -217,17 +217,17 @@ discard block |
||
| 217 | 217 | * @return void |
| 218 | 218 | */ |
| 219 | 219 | public function redirect() { |
| 220 | - if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
| 220 | + if ( ! is_user_logged_in() || ! function_exists('wc_get_page_id') || is_home()) { |
|
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | - if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
| 224 | - wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
| 223 | + if (lsx_health_plan_user_has_purchase() && (is_page(wc_get_page_id('cart')) || is_page(wc_get_page_id('checkout')))) { |
|
| 224 | + wp_redirect(get_permalink(wc_get_page_id('myaccount'))); |
|
| 225 | 225 | die; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
| 229 | - if ( false !== $product_id && is_single( $product_id ) ) { |
|
| 230 | - wp_redirect( home_url() ); |
|
| 228 | + $product_id = \lsx_health_plan\functions\get_option('membership_product', false); |
|
| 229 | + if (false !== $product_id && is_single($product_id)) { |
|
| 230 | + wp_redirect(home_url()); |
|
| 231 | 231 | die; |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -236,26 +236,26 @@ discard block |
||
| 236 | 236 | * Registers the rewrites. |
| 237 | 237 | */ |
| 238 | 238 | public function handle_day_action() { |
| 239 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
| 240 | - update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
| 241 | - $plan_id = sanitize_key( $_POST['lsx-health-plan-id'] ); |
|
| 242 | - $plan_parent = wp_get_post_parent_id( $plan_id ); |
|
| 243 | - if ( 0 !== $plan_parent ) { |
|
| 239 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'complete')) { |
|
| 240 | + update_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete', true); |
|
| 241 | + $plan_id = sanitize_key($_POST['lsx-health-plan-id']); |
|
| 242 | + $plan_parent = wp_get_post_parent_id($plan_id); |
|
| 243 | + if (0 !== $plan_parent) { |
|
| 244 | 244 | $plan_id = $plan_parent; |
| 245 | 245 | } |
| 246 | - wp_safe_redirect( get_permalink( $plan_id ) ); |
|
| 246 | + wp_safe_redirect(get_permalink($plan_id)); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
| 250 | - delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
| 249 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'unlock')) { |
|
| 250 | + delete_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete'); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | 255 | * Registers the rewrites. |
| 256 | 256 | */ |
| 257 | - public function wpkses_post_tags( $tags, $context ) { |
|
| 258 | - if ( 'post' === $context ) { |
|
| 257 | + public function wpkses_post_tags($tags, $context) { |
|
| 258 | + if ('post' === $context) { |
|
| 259 | 259 | $tags['iframe'] = array( |
| 260 | 260 | 'src' => true, |
| 261 | 261 | 'height' => true, |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | /** |
| 276 | 276 | * Remove the single recipe and exercise title |
| 277 | 277 | */ |
| 278 | - public function single_title( $title ) { |
|
| 278 | + public function single_title($title) { |
|
| 279 | 279 | |
| 280 | - if ( is_single() && is_singular( 'recipe' ) ) { |
|
| 280 | + if (is_single() && is_singular('recipe')) { |
|
| 281 | 281 | |
| 282 | - $title = __( 'Recipe', 'lsx-health-plan' ); |
|
| 282 | + $title = __('Recipe', 'lsx-health-plan'); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - if ( is_single() && is_singular( 'exercise' ) ) { |
|
| 285 | + if (is_single() && is_singular('exercise')) { |
|
| 286 | 286 | |
| 287 | - $title = __( 'Exercise', 'lsx-health-plan' ); |
|
| 287 | + $title = __('Exercise', 'lsx-health-plan'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | return $title; |