@@ -8,87 +8,87 @@ discard block |
||
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\Endpoints(); |
|
22 | - */ |
|
23 | - public $endpoints; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var object \lsx_health_plan\classes\Modals(); |
|
27 | - */ |
|
28 | - public $modals; |
|
29 | - |
|
30 | - /** |
|
31 | - * Contructor |
|
32 | - */ |
|
33 | - public function __construct() { |
|
34 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
35 | - |
|
36 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php'; |
|
37 | - $this->endpoints = Endpoints::get_instance(); |
|
38 | - |
|
39 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-modals.php'; |
|
40 | - $this->modals = Modals::get_instance(); |
|
41 | - |
|
42 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php'; |
|
43 | - $this->gallery = frontend\Gallery::get_instance(); |
|
44 | - |
|
45 | - if ( is_admin() ) { |
|
46 | - add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
47 | - } |
|
48 | - |
|
49 | - // Handle the template redirects. |
|
50 | - add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
51 | - add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
52 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
53 | - add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
54 | - |
|
55 | - add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
56 | - add_filter( 'wp_kses_allowed_html', array( $this, 'wpkses_post_tags' ), 100, 2 ); |
|
57 | - |
|
58 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 99, 1 ); |
|
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 | - * Registers the plugin frontend assets |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public function assets() { |
|
82 | - wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
83 | - wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
84 | - wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Handle body colours that might be change by LSX Customizer. |
|
89 | - */ |
|
90 | - public function customizer_body_colours_handler( $css, $colors ) { |
|
91 | - $css .= ' |
|
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\Endpoints(); |
|
22 | + */ |
|
23 | + public $endpoints; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var object \lsx_health_plan\classes\Modals(); |
|
27 | + */ |
|
28 | + public $modals; |
|
29 | + |
|
30 | + /** |
|
31 | + * Contructor |
|
32 | + */ |
|
33 | + public function __construct() { |
|
34 | + add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
35 | + |
|
36 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php'; |
|
37 | + $this->endpoints = Endpoints::get_instance(); |
|
38 | + |
|
39 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-modals.php'; |
|
40 | + $this->modals = Modals::get_instance(); |
|
41 | + |
|
42 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php'; |
|
43 | + $this->gallery = frontend\Gallery::get_instance(); |
|
44 | + |
|
45 | + if ( is_admin() ) { |
|
46 | + add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
47 | + } |
|
48 | + |
|
49 | + // Handle the template redirects. |
|
50 | + add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
51 | + add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
52 | + add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
53 | + add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
54 | + |
|
55 | + add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
56 | + add_filter( 'wp_kses_allowed_html', array( $this, 'wpkses_post_tags' ), 100, 2 ); |
|
57 | + |
|
58 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 99, 1 ); |
|
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 | + * Registers the plugin frontend assets |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public function assets() { |
|
82 | + wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
83 | + wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
84 | + wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Handle body colours that might be change by LSX Customizer. |
|
89 | + */ |
|
90 | + public function customizer_body_colours_handler( $css, $colors ) { |
|
91 | + $css .= ' |
|
92 | 92 | @import "' . LSX_HEALTH_PLAN_PATH . '/assets/css/scss/partials/customizer-health-plan-body-colours"; |
93 | 93 | |
94 | 94 | /** |
@@ -104,117 +104,117 @@ discard block |
||
104 | 104 | ); |
105 | 105 | '; |
106 | 106 | |
107 | - return $css; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Archive template. |
|
112 | - */ |
|
113 | - public function archive_template_include( $template ) { |
|
114 | - $applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() ); |
|
115 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) { |
|
116 | - $post_type = get_post_type(); |
|
117 | - if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) { |
|
118 | - $template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php'; |
|
119 | - } |
|
120 | - } |
|
121 | - return $template; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Single template. |
|
126 | - */ |
|
127 | - public function single_template_include( $template ) { |
|
128 | - $applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() ); |
|
129 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) { |
|
130 | - $post_type = get_post_type(); |
|
131 | - if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) { |
|
132 | - $template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php'; |
|
133 | - } |
|
134 | - } |
|
135 | - return $template; |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Redirect WordPress to the taxonomy located in the plugin |
|
140 | - * |
|
141 | - * @param $template string |
|
142 | - * @return string |
|
143 | - */ |
|
144 | - public function taxonomy_template_include( $template ) { |
|
145 | - $applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() ); |
|
146 | - if ( is_main_query() && is_tax( $applicable_taxonomies ) ) { |
|
147 | - $current_taxonomy = get_query_var( 'taxonomy' ); |
|
148 | - if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
149 | - $template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
150 | - } |
|
151 | - } |
|
152 | - return $template; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * Redirect the user from the cart or checkout page if they have purchased the product already. |
|
157 | - * |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public function redirect() { |
|
161 | - if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
162 | - return; |
|
163 | - } |
|
164 | - if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
165 | - wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
166 | - die; |
|
167 | - } |
|
168 | - |
|
169 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
170 | - if ( false !== $product_id && is_single( $product_id ) ) { |
|
171 | - wp_redirect( home_url() ); |
|
172 | - die; |
|
173 | - } |
|
174 | - } |
|
175 | - |
|
176 | - /** |
|
177 | - * Registers the rewrites. |
|
178 | - */ |
|
179 | - public function handle_day_action() { |
|
180 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
181 | - update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
182 | - wp_safe_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
183 | - } |
|
184 | - |
|
185 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
186 | - delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Registers the rewrites. |
|
192 | - */ |
|
193 | - public function wpkses_post_tags( $tags, $context ) { |
|
194 | - if ( 'post' === $context ) { |
|
195 | - $tags['iframe'] = array( |
|
196 | - 'src' => true, |
|
197 | - 'height' => true, |
|
198 | - 'width' => true, |
|
199 | - 'frameborder' => true, |
|
200 | - 'allowfullscreen' => true, |
|
201 | - ); |
|
202 | - } |
|
203 | - return $tags; |
|
204 | - } |
|
205 | - /** |
|
206 | - * Remove the "Archives:" from the post type recipes. |
|
207 | - * |
|
208 | - * @param string $title the term title. |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - public function get_the_archive_title( $title ) { |
|
212 | - if ( is_tax() ) { |
|
213 | - $queried_object = get_queried_object(); |
|
214 | - if ( isset( $queried_object->name ) ) { |
|
215 | - $title = $queried_object->name; |
|
216 | - } |
|
217 | - } |
|
218 | - return $title; |
|
219 | - } |
|
107 | + return $css; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Archive template. |
|
112 | + */ |
|
113 | + public function archive_template_include( $template ) { |
|
114 | + $applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() ); |
|
115 | + if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) { |
|
116 | + $post_type = get_post_type(); |
|
117 | + if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) { |
|
118 | + $template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php'; |
|
119 | + } |
|
120 | + } |
|
121 | + return $template; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Single template. |
|
126 | + */ |
|
127 | + public function single_template_include( $template ) { |
|
128 | + $applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() ); |
|
129 | + if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) { |
|
130 | + $post_type = get_post_type(); |
|
131 | + if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) { |
|
132 | + $template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php'; |
|
133 | + } |
|
134 | + } |
|
135 | + return $template; |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Redirect WordPress to the taxonomy located in the plugin |
|
140 | + * |
|
141 | + * @param $template string |
|
142 | + * @return string |
|
143 | + */ |
|
144 | + public function taxonomy_template_include( $template ) { |
|
145 | + $applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() ); |
|
146 | + if ( is_main_query() && is_tax( $applicable_taxonomies ) ) { |
|
147 | + $current_taxonomy = get_query_var( 'taxonomy' ); |
|
148 | + if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
149 | + $template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
|
150 | + } |
|
151 | + } |
|
152 | + return $template; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * Redirect the user from the cart or checkout page if they have purchased the product already. |
|
157 | + * |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public function redirect() { |
|
161 | + if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
162 | + return; |
|
163 | + } |
|
164 | + if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
165 | + wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
166 | + die; |
|
167 | + } |
|
168 | + |
|
169 | + $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
170 | + if ( false !== $product_id && is_single( $product_id ) ) { |
|
171 | + wp_redirect( home_url() ); |
|
172 | + die; |
|
173 | + } |
|
174 | + } |
|
175 | + |
|
176 | + /** |
|
177 | + * Registers the rewrites. |
|
178 | + */ |
|
179 | + public function handle_day_action() { |
|
180 | + if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
181 | + update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
182 | + wp_safe_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
183 | + } |
|
184 | + |
|
185 | + if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
186 | + delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Registers the rewrites. |
|
192 | + */ |
|
193 | + public function wpkses_post_tags( $tags, $context ) { |
|
194 | + if ( 'post' === $context ) { |
|
195 | + $tags['iframe'] = array( |
|
196 | + 'src' => true, |
|
197 | + 'height' => true, |
|
198 | + 'width' => true, |
|
199 | + 'frameborder' => true, |
|
200 | + 'allowfullscreen' => true, |
|
201 | + ); |
|
202 | + } |
|
203 | + return $tags; |
|
204 | + } |
|
205 | + /** |
|
206 | + * Remove the "Archives:" from the post type recipes. |
|
207 | + * |
|
208 | + * @param string $title the term title. |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + public function get_the_archive_title( $title ) { |
|
212 | + if ( is_tax() ) { |
|
213 | + $queried_object = get_queried_object(); |
|
214 | + if ( isset( $queried_object->name ) ) { |
|
215 | + $title = $queried_object->name; |
|
216 | + } |
|
217 | + } |
|
218 | + return $title; |
|
219 | + } |
|
220 | 220 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * Contructor |
32 | 32 | */ |
33 | 33 | public function __construct() { |
34 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
34 | + add_action('wp_enqueue_scripts', array($this, 'assets'), 5); |
|
35 | 35 | |
36 | 36 | require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php'; |
37 | 37 | $this->endpoints = Endpoints::get_instance(); |
@@ -42,20 +42,20 @@ discard block |
||
42 | 42 | require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php'; |
43 | 43 | $this->gallery = frontend\Gallery::get_instance(); |
44 | 44 | |
45 | - if ( is_admin() ) { |
|
46 | - add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
45 | + if (is_admin()) { |
|
46 | + add_filter('lsx_customizer_colour_selectors_body', array($this, 'customizer_body_colours_handler'), 15, 2); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // Handle the template redirects. |
50 | - add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
51 | - add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
52 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
53 | - add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
50 | + add_filter('template_include', array($this, 'archive_template_include'), 99); |
|
51 | + add_filter('template_include', array($this, 'single_template_include'), 99); |
|
52 | + add_filter('template_include', array($this, 'taxonomy_template_include'), 99); |
|
53 | + add_action('template_redirect', array($this, 'redirect')); |
|
54 | 54 | |
55 | - add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
56 | - add_filter( 'wp_kses_allowed_html', array( $this, 'wpkses_post_tags' ), 100, 2 ); |
|
55 | + add_action('init', array($this, 'handle_day_action'), 100); |
|
56 | + add_filter('wp_kses_allowed_html', array($this, 'wpkses_post_tags'), 100, 2); |
|
57 | 57 | |
58 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 99, 1 ); |
|
58 | + add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 99, 1); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public static function get_instance() { |
69 | 69 | // If the single instance hasn't been set, set it now. |
70 | - if ( null === self::$instance ) { |
|
70 | + if (null === self::$instance) { |
|
71 | 71 | self::$instance = new self(); |
72 | 72 | } |
73 | 73 | return self::$instance; |
@@ -79,15 +79,15 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public function assets() { |
82 | - wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
83 | - wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
84 | - wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
82 | + wp_enqueue_style('lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER); |
|
83 | + wp_style_add_data('lsx-health-plan', 'rtl', 'replace'); |
|
84 | + wp_enqueue_script('lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array('jquery')); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
88 | 88 | * Handle body colours that might be change by LSX Customizer. |
89 | 89 | */ |
90 | - public function customizer_body_colours_handler( $css, $colors ) { |
|
90 | + public function customizer_body_colours_handler($css, $colors) { |
|
91 | 91 | $css .= ' |
92 | 92 | @import "' . LSX_HEALTH_PLAN_PATH . '/assets/css/scss/partials/customizer-health-plan-body-colours"; |
93 | 93 | |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | /** |
111 | 111 | * Archive template. |
112 | 112 | */ |
113 | - public function archive_template_include( $template ) { |
|
114 | - $applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() ); |
|
115 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) { |
|
113 | + public function archive_template_include($template) { |
|
114 | + $applicable_post_types = apply_filters('lsx_health_plan_archive_template', array()); |
|
115 | + if ( ! empty($applicable_post_types) && is_main_query() && is_post_type_archive($applicable_post_types)) { |
|
116 | 116 | $post_type = get_post_type(); |
117 | - if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) { |
|
117 | + if (empty(locate_template(array('archive-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php')) { |
|
118 | 118 | $template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php'; |
119 | 119 | } |
120 | 120 | } |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * Single template. |
126 | 126 | */ |
127 | - public function single_template_include( $template ) { |
|
128 | - $applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() ); |
|
129 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) { |
|
127 | + public function single_template_include($template) { |
|
128 | + $applicable_post_types = apply_filters('lsx_health_plan_single_template', array()); |
|
129 | + if ( ! empty($applicable_post_types) && is_main_query() && is_singular($applicable_post_types)) { |
|
130 | 130 | $post_type = get_post_type(); |
131 | - if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) { |
|
131 | + if (empty(locate_template(array('single-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php')) { |
|
132 | 132 | $template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php'; |
133 | 133 | } |
134 | 134 | } |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * @param $template string |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function taxonomy_template_include( $template ) { |
|
145 | - $applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() ); |
|
146 | - if ( is_main_query() && is_tax( $applicable_taxonomies ) ) { |
|
147 | - $current_taxonomy = get_query_var( 'taxonomy' ); |
|
148 | - if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
144 | + public function taxonomy_template_include($template) { |
|
145 | + $applicable_taxonomies = apply_filters('lsx_health_plan_taxonomies_template', array()); |
|
146 | + if (is_main_query() && is_tax($applicable_taxonomies)) { |
|
147 | + $current_taxonomy = get_query_var('taxonomy'); |
|
148 | + if ('' === locate_template(array('taxonomy-' . $current_taxonomy . '.php')) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php')) { |
|
149 | 149 | $template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
150 | 150 | } |
151 | 151 | } |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | * @return void |
159 | 159 | */ |
160 | 160 | public function redirect() { |
161 | - if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
161 | + if ( ! is_user_logged_in() || ! function_exists('wc_get_page_id') || is_home()) { |
|
162 | 162 | return; |
163 | 163 | } |
164 | - if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
165 | - wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
164 | + if (lsx_health_plan_user_has_purchase() && (is_page(wc_get_page_id('cart')) || is_page(wc_get_page_id('checkout')))) { |
|
165 | + wp_redirect(get_permalink(wc_get_page_id('myaccount'))); |
|
166 | 166 | die; |
167 | 167 | } |
168 | 168 | |
169 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
170 | - if ( false !== $product_id && is_single( $product_id ) ) { |
|
171 | - wp_redirect( home_url() ); |
|
169 | + $product_id = \lsx_health_plan\functions\get_option('membership_product', false); |
|
170 | + if (false !== $product_id && is_single($product_id)) { |
|
171 | + wp_redirect(home_url()); |
|
172 | 172 | die; |
173 | 173 | } |
174 | 174 | } |
@@ -177,21 +177,21 @@ discard block |
||
177 | 177 | * Registers the rewrites. |
178 | 178 | */ |
179 | 179 | public function handle_day_action() { |
180 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
181 | - update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
182 | - wp_safe_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
180 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'complete')) { |
|
181 | + update_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete', true); |
|
182 | + wp_safe_redirect(get_permalink(wc_get_page_id('myaccount'))); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
186 | - delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
185 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'unlock')) { |
|
186 | + delete_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete'); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * Registers the rewrites. |
192 | 192 | */ |
193 | - public function wpkses_post_tags( $tags, $context ) { |
|
194 | - if ( 'post' === $context ) { |
|
193 | + public function wpkses_post_tags($tags, $context) { |
|
194 | + if ('post' === $context) { |
|
195 | 195 | $tags['iframe'] = array( |
196 | 196 | 'src' => true, |
197 | 197 | 'height' => true, |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | * @param string $title the term title. |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - public function get_the_archive_title( $title ) { |
|
212 | - if ( is_tax() ) { |
|
211 | + public function get_the_archive_title($title) { |
|
212 | + if (is_tax()) { |
|
213 | 213 | $queried_object = get_queried_object(); |
214 | - if ( isset( $queried_object->name ) ) { |
|
214 | + if (isset($queried_object->name)) { |
|
215 | 215 | $title = $queried_object->name; |
216 | 216 | } |
217 | 217 | } |