@@ -22,74 +22,74 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function get_instance() { |
24 | 24 | // If the single instance hasn't been set, set it now. |
25 | - if ( null == self::$instance ) { |
|
25 | + if (null == self::$instance) { |
|
26 | 26 | self::$instance = new self; |
27 | 27 | } |
28 | 28 | return self::$instance; |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function __construct() { |
32 | - if ( ! get_option( 'lsx_to_scporder_install' ) ) { |
|
32 | + if ( ! get_option('lsx_to_scporder_install')) { |
|
33 | 33 | $this->lsx_to_scporder_install(); |
34 | 34 | } |
35 | 35 | |
36 | - add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
37 | - add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
36 | + add_action('admin_init', array($this, 'refresh')); |
|
37 | + add_action('admin_init', array($this, 'load_script_css')); |
|
38 | 38 | |
39 | - add_action( 'wp_ajax_update-menu-order', array( |
|
39 | + add_action('wp_ajax_update-menu-order', array( |
|
40 | 40 | $this, |
41 | 41 | 'update_menu_order', |
42 | - ) ); |
|
43 | - add_action( 'wp_ajax_update-menu-order-tags', array( |
|
42 | + )); |
|
43 | + add_action('wp_ajax_update-menu-order-tags', array( |
|
44 | 44 | $this, |
45 | 45 | 'update_menu_order_tags', |
46 | - ) ); |
|
46 | + )); |
|
47 | 47 | |
48 | - add_action( 'pre_get_posts', array( |
|
48 | + add_action('pre_get_posts', array( |
|
49 | 49 | $this, |
50 | 50 | 'lsx_to_scporder_pre_get_posts', |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | |
53 | - add_filter( 'get_previous_post_where', array( |
|
53 | + add_filter('get_previous_post_where', array( |
|
54 | 54 | $this, |
55 | 55 | 'lsx_to_scporder_previous_post_where', |
56 | - ) ); |
|
57 | - add_filter( 'get_previous_post_sort', array( |
|
56 | + )); |
|
57 | + add_filter('get_previous_post_sort', array( |
|
58 | 58 | $this, |
59 | 59 | 'lsx_to_scporder_previous_post_sort', |
60 | - ) ); |
|
61 | - add_filter( 'get_next_post_where', array( |
|
60 | + )); |
|
61 | + add_filter('get_next_post_where', array( |
|
62 | 62 | $this, |
63 | 63 | 'lsx_to_scporder_next_post_where', |
64 | - ) ); |
|
65 | - add_filter( 'get_next_post_sort', array( |
|
64 | + )); |
|
65 | + add_filter('get_next_post_sort', array( |
|
66 | 66 | $this, |
67 | 67 | 'lsx_to_scporder_next_post_sort', |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | - add_filter( 'get_terms_orderby', array( |
|
70 | + add_filter('get_terms_orderby', array( |
|
71 | 71 | $this, |
72 | 72 | 'lsx_to_scporder_get_terms_orderby', |
73 | - ), 10, 3 ); |
|
74 | - add_filter( 'wp_get_object_terms', array( |
|
73 | + ), 10, 3); |
|
74 | + add_filter('wp_get_object_terms', array( |
|
75 | 75 | $this, |
76 | 76 | 'lsx_to_scporder_get_object_terms', |
77 | - ), 10, 4 ); |
|
78 | - add_filter( 'get_terms', array( |
|
77 | + ), 10, 4); |
|
78 | + add_filter('get_terms', array( |
|
79 | 79 | $this, |
80 | 80 | 'lsx_to_scporder_get_object_terms', |
81 | - ), 10, 4 ); |
|
81 | + ), 10, 4); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | public function lsx_to_scporder_install() { |
85 | 85 | global $wpdb; |
86 | - $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_to_term_order`" ); |
|
86 | + $result = $wpdb->query("DESCRIBE $wpdb->terms `lsx_to_term_order`"); |
|
87 | 87 | |
88 | - if ( ! $result ) { |
|
89 | - $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'" ); |
|
88 | + if ( ! $result) { |
|
89 | + $result = $wpdb->query("ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'"); |
|
90 | 90 | } |
91 | 91 | |
92 | - update_option( 'lsx_to_scporder_install', 1 ); |
|
92 | + update_option('lsx_to_scporder_install', 1); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | public function _check_load_script_css() { |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | $objects = $this->get_to_scporder_options_objects(); |
99 | 99 | $tags = $this->get_to_scporder_options_tags(); |
100 | 100 | |
101 | - if ( empty( $objects ) && empty( $tags ) ) { |
|
101 | + if (empty($objects) && empty($tags)) { |
|
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | |
105 | - if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'action=edit' ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/post-new.php' ) ) { |
|
105 | + if (isset($_GET['orderby']) || strstr(sanitize_text_field($_SERVER['REQUEST_URI']), 'action=edit') || strstr(sanitize_text_field($_SERVER['REQUEST_URI']), 'wp-admin/post-new.php')) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | |
109 | - if ( ! empty( $objects ) ) { |
|
110 | - if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['post_type'] ), $objects ) ) { // if page or custom post types |
|
109 | + if ( ! empty($objects)) { |
|
110 | + if (isset($_GET['post_type']) && ! isset($_GET['taxonomy']) && array_key_exists(sanitize_text_field($_GET['post_type']), $objects)) { // if page or custom post types |
|
111 | 111 | $active = true; |
112 | 112 | } |
113 | - if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post |
|
113 | + if ( ! isset($_GET['post_type']) && strstr(sanitize_text_field($_SERVER['REQUEST_URI']), 'wp-admin/edit.php') && array_key_exists('post', $objects)) { // if post |
|
114 | 114 | $active = true; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - if ( ! empty( $tags ) ) { |
|
119 | - if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['taxonomy'] ), $tags ) ) { |
|
118 | + if ( ! empty($tags)) { |
|
119 | + if (isset($_GET['taxonomy']) && array_key_exists(sanitize_text_field($_GET['taxonomy']), $tags)) { |
|
120 | 120 | $active = true; |
121 | 121 | } |
122 | 122 | } |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | public function load_script_css() { |
128 | - if ( $this->_check_load_script_css() ) { |
|
129 | - wp_enqueue_script( 'scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
128 | + if ($this->_check_load_script_css()) { |
|
129 | + wp_enqueue_script('scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array('jquery', 'jquery-ui-sortable'), null, true); |
|
130 | 130 | |
131 | 131 | $scporderjs_params = array( |
132 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
133 | - 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
132 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
133 | + 'ajax_nonce' => wp_create_nonce('scporder'), |
|
134 | 134 | ); |
135 | 135 | |
136 | - wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
136 | + wp_localize_script('scporderjs', 'scporderjs_params', $scporderjs_params); |
|
137 | 137 | |
138 | - wp_enqueue_style( 'scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null ); |
|
139 | - wp_style_add_data( 'scporder', 'rtl', 'replace' ); |
|
138 | + wp_enqueue_style('scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null); |
|
139 | + wp_style_add_data('scporder', 'rtl', 'replace'); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -145,26 +145,26 @@ discard block |
||
145 | 145 | $objects = $this->get_to_scporder_options_objects(); |
146 | 146 | $tags = $this->get_to_scporder_options_tags(); |
147 | 147 | |
148 | - if ( ! empty( $objects ) ) { |
|
149 | - foreach ( $objects as $object => $object_data ) { |
|
150 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
148 | + if ( ! empty($objects)) { |
|
149 | + foreach ($objects as $object => $object_data) { |
|
150 | + $result = $wpdb->get_results($wpdb->prepare(" |
|
151 | 151 | SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min |
152 | 152 | FROM $wpdb->posts |
153 | 153 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
154 | - ", $object ) ); |
|
154 | + ", $object)); |
|
155 | 155 | |
156 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
156 | + if (0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max) { |
|
157 | 157 | continue; |
158 | 158 | } |
159 | 159 | |
160 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
160 | + $results = $wpdb->get_results($wpdb->prepare(" |
|
161 | 161 | SELECT ID |
162 | 162 | FROM $wpdb->posts |
163 | 163 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
164 | 164 | ORDER BY menu_order ASC |
165 | - ", $object ) ); |
|
165 | + ", $object)); |
|
166 | 166 | |
167 | - foreach ( $results as $key => $result ) { |
|
167 | + foreach ($results as $key => $result) { |
|
168 | 168 | $wpdb->update( |
169 | 169 | $wpdb->posts, |
170 | 170 | array( |
@@ -178,28 +178,28 @@ discard block |
||
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - if ( ! empty( $tags ) ) { |
|
182 | - foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
183 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
181 | + if ( ! empty($tags)) { |
|
182 | + foreach ($tags as $taxonomy => $taxonomy_data) { |
|
183 | + $result = $wpdb->get_results($wpdb->prepare(" |
|
184 | 184 | SELECT count(*) as cnt, max(lsx_to_term_order) as max, min(lsx_to_term_order) as min |
185 | 185 | FROM $wpdb->terms AS terms |
186 | 186 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
187 | 187 | WHERE term_taxonomy.taxonomy = '%s' |
188 | - ", $taxonomy ) ); |
|
188 | + ", $taxonomy)); |
|
189 | 189 | |
190 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
190 | + if (0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max) { |
|
191 | 191 | continue; |
192 | 192 | } |
193 | 193 | |
194 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
194 | + $results = $wpdb->get_results($wpdb->prepare(" |
|
195 | 195 | SELECT terms.term_id |
196 | 196 | FROM $wpdb->terms AS terms |
197 | 197 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
198 | 198 | WHERE term_taxonomy.taxonomy = '%s' |
199 | 199 | ORDER BY lsx_to_term_order ASC |
200 | - ", $taxonomy ) ); |
|
200 | + ", $taxonomy)); |
|
201 | 201 | |
202 | - foreach ( $results as $key => $result ) { |
|
202 | + foreach ($results as $key => $result) { |
|
203 | 203 | $wpdb->update( |
204 | 204 | $wpdb->terms, |
205 | 205 | array( |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | public function update_menu_order() { |
218 | - check_ajax_referer( 'scporder', 'security' ); |
|
218 | + check_ajax_referer('scporder', 'security'); |
|
219 | 219 | |
220 | 220 | global $wpdb; |
221 | 221 | |
222 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
222 | + parse_str(sanitize_text_field($_POST['order']), $data); |
|
223 | 223 | |
224 | - if ( ! is_array( $data ) ) { |
|
224 | + if ( ! is_array($data)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | |
245 | 245 | sort( $menu_order_arr );*/ |
246 | 246 | |
247 | - foreach ( $data as $key => $values ) { |
|
248 | - foreach ( $values as $position => $id ) { |
|
247 | + foreach ($data as $key => $values) { |
|
248 | + foreach ($values as $position => $id) { |
|
249 | 249 | $wpdb->update( |
250 | 250 | $wpdb->posts, |
251 | 251 | array( |
252 | 252 | 'menu_order' => $position, |
253 | 253 | ), |
254 | 254 | array( |
255 | - 'ID' => intval( $id ), |
|
255 | + 'ID' => intval($id), |
|
256 | 256 | ) |
257 | 257 | ); |
258 | 258 | } |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | public function update_menu_order_tags() { |
263 | - check_ajax_referer( 'scporder', 'security' ); |
|
263 | + check_ajax_referer('scporder', 'security'); |
|
264 | 264 | |
265 | 265 | global $wpdb; |
266 | 266 | |
267 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
267 | + parse_str(sanitize_text_field($_POST['order']), $data); |
|
268 | 268 | |
269 | - if ( ! is_array( $data ) ) { |
|
269 | + if ( ! is_array($data)) { |
|
270 | 270 | return false; |
271 | 271 | } |
272 | 272 | |
@@ -294,33 +294,33 @@ discard block |
||
294 | 294 | |
295 | 295 | sort( $menu_order_arr );*/ |
296 | 296 | |
297 | - foreach ( $data as $key => $values ) { |
|
297 | + foreach ($data as $key => $values) { |
|
298 | 298 | $term_ids = array(); |
299 | - foreach ( $values as $position => $id ) { |
|
299 | + foreach ($values as $position => $id) { |
|
300 | 300 | $wpdb->update( |
301 | 301 | $wpdb->terms, |
302 | 302 | array( |
303 | 303 | 'lsx_to_term_order' => $position + 1, |
304 | 304 | ), |
305 | 305 | array( |
306 | - 'term_id' => intval( $id ), |
|
306 | + 'term_id' => intval($id), |
|
307 | 307 | ) |
308 | 308 | ); |
309 | - $term_ids[] = intval( $id ); |
|
309 | + $term_ids[] = intval($id); |
|
310 | 310 | } |
311 | - clean_term_cache( $term_ids ); |
|
311 | + clean_term_cache($term_ids); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | - public function lsx_to_scporder_previous_post_where( $where ) { |
|
315 | + public function lsx_to_scporder_previous_post_where($where) { |
|
316 | 316 | global $post; |
317 | 317 | $objects = $this->get_to_scporder_options_objects(); |
318 | 318 | |
319 | - if ( empty( $objects ) ) { |
|
319 | + if (empty($objects)) { |
|
320 | 320 | return $where; |
321 | 321 | } |
322 | 322 | |
323 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
323 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
324 | 324 | $current_menu_order = $post->menu_order; |
325 | 325 | $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
326 | 326 | } |
@@ -328,30 +328,30 @@ discard block |
||
328 | 328 | return $where; |
329 | 329 | } |
330 | 330 | |
331 | - public function lsx_to_scporder_previous_post_sort( $orderby ) { |
|
331 | + public function lsx_to_scporder_previous_post_sort($orderby) { |
|
332 | 332 | global $post; |
333 | 333 | $objects = $this->get_to_scporder_options_objects(); |
334 | 334 | |
335 | - if ( empty( $objects ) ) { |
|
335 | + if (empty($objects)) { |
|
336 | 336 | return $orderby; |
337 | 337 | } |
338 | 338 | |
339 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
339 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
340 | 340 | $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
341 | 341 | } |
342 | 342 | |
343 | 343 | return $orderby; |
344 | 344 | } |
345 | 345 | |
346 | - public function lsx_to_scporder_next_post_where( $where ) { |
|
346 | + public function lsx_to_scporder_next_post_where($where) { |
|
347 | 347 | global $post; |
348 | 348 | $objects = $this->get_to_scporder_options_objects(); |
349 | 349 | |
350 | - if ( empty( $objects ) ) { |
|
350 | + if (empty($objects)) { |
|
351 | 351 | return $where; |
352 | 352 | } |
353 | 353 | |
354 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
354 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
355 | 355 | $current_menu_order = $post->menu_order; |
356 | 356 | $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
357 | 357 | } |
@@ -359,97 +359,97 @@ discard block |
||
359 | 359 | return $where; |
360 | 360 | } |
361 | 361 | |
362 | - public function lsx_to_scporder_next_post_sort( $orderby ) { |
|
362 | + public function lsx_to_scporder_next_post_sort($orderby) { |
|
363 | 363 | global $post; |
364 | 364 | $objects = $this->get_to_scporder_options_objects(); |
365 | 365 | |
366 | - if ( empty( $objects ) ) { |
|
366 | + if (empty($objects)) { |
|
367 | 367 | return $orderby; |
368 | 368 | } |
369 | 369 | |
370 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
370 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
371 | 371 | $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
372 | 372 | } |
373 | 373 | |
374 | 374 | return $orderby; |
375 | 375 | } |
376 | 376 | |
377 | - public function lsx_to_scporder_pre_get_posts( $wp_query ) { |
|
377 | + public function lsx_to_scporder_pre_get_posts($wp_query) { |
|
378 | 378 | $objects = $this->get_to_scporder_options_objects(); |
379 | 379 | |
380 | - if ( empty( $objects ) ) { |
|
380 | + if (empty($objects)) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
384 | - if ( is_admin() ) { |
|
385 | - if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
386 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
387 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
388 | - $wp_query->set( 'order', 'ASC' ); |
|
384 | + if (is_admin()) { |
|
385 | + if (isset($wp_query->query['post_type']) && ! isset($_GET['orderby'])) { |
|
386 | + if (array_key_exists($wp_query->query['post_type'], $objects)) { |
|
387 | + $wp_query->set('orderby', 'menu_order'); |
|
388 | + $wp_query->set('order', 'ASC'); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | } else { |
392 | 392 | $active = false; |
393 | 393 | |
394 | - if ( isset( $wp_query->query['post_type'] ) ) { |
|
395 | - if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
396 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
394 | + if (isset($wp_query->query['post_type'])) { |
|
395 | + if ( ! is_array($wp_query->query['post_type'])) { |
|
396 | + if (array_key_exists($wp_query->query['post_type'], $objects)) { |
|
397 | 397 | $active = true; |
398 | 398 | } |
399 | 399 | } |
400 | 400 | } else { |
401 | - if ( array_key_exists( 'post', $objects ) ) { |
|
401 | + if (array_key_exists('post', $objects)) { |
|
402 | 402 | $active = true; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | - if ( ! $active ) { |
|
406 | + if ( ! $active) { |
|
407 | 407 | return false; |
408 | 408 | } |
409 | 409 | |
410 | - if ( isset( $wp_query->query['disabled_custom_post_order'] ) ) { |
|
410 | + if (isset($wp_query->query['disabled_custom_post_order'])) { |
|
411 | 411 | return false; |
412 | 412 | } |
413 | 413 | |
414 | - if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
415 | - if ( $wp_query->get( 'orderby' ) == 'date' ) { |
|
416 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
414 | + if (isset($wp_query->query['suppress_filters'])) { |
|
415 | + if ($wp_query->get('orderby') == 'date') { |
|
416 | + $wp_query->set('orderby', 'menu_order'); |
|
417 | 417 | } |
418 | - if ( $wp_query->get( 'order' ) == 'DESC' ) { |
|
419 | - $wp_query->set( 'order', 'ASC' ); |
|
418 | + if ($wp_query->get('order') == 'DESC') { |
|
419 | + $wp_query->set('order', 'ASC'); |
|
420 | 420 | } |
421 | 421 | } else { |
422 | - if ( ! $wp_query->get( 'orderby' ) ) { |
|
423 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
422 | + if ( ! $wp_query->get('orderby')) { |
|
423 | + $wp_query->set('orderby', 'menu_order'); |
|
424 | 424 | } |
425 | - if ( ! $wp_query->get( 'order' ) ) { |
|
426 | - $wp_query->set( 'order', 'ASC' ); |
|
425 | + if ( ! $wp_query->get('order')) { |
|
426 | + $wp_query->set('order', 'ASC'); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - public function lsx_to_scporder_get_terms_orderby( $orderby, $args ) { |
|
432 | + public function lsx_to_scporder_get_terms_orderby($orderby, $args) { |
|
433 | 433 | |
434 | - if ( is_admin() ) { |
|
434 | + if (is_admin()) { |
|
435 | 435 | return $orderby; |
436 | 436 | } |
437 | 437 | |
438 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
438 | + if (isset($args['disabled_custom_post_order'])) { |
|
439 | 439 | return $orderby; |
440 | 440 | } |
441 | 441 | |
442 | 442 | $tags = $this->get_to_scporder_options_tags(); |
443 | 443 | |
444 | - if ( ! isset( $args['taxonomy'] ) ) { |
|
444 | + if ( ! isset($args['taxonomy'])) { |
|
445 | 445 | return $orderby; |
446 | 446 | } |
447 | 447 | |
448 | 448 | $taxonomy = $args['taxonomy']; |
449 | - if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) { |
|
449 | + if (is_array($taxonomy) && count($taxonomy) == 1) { |
|
450 | 450 | $taxonomy = $taxonomy[0]; |
451 | 451 | } |
452 | - if ( ! is_array( $taxonomy ) && ! array_key_exists( $taxonomy, $tags ) ) { |
|
452 | + if ( ! is_array($taxonomy) && ! array_key_exists($taxonomy, $tags)) { |
|
453 | 453 | return $orderby; |
454 | 454 | } |
455 | 455 | |
@@ -458,38 +458,38 @@ discard block |
||
458 | 458 | return $orderby; |
459 | 459 | } |
460 | 460 | |
461 | - public function lsx_to_scporder_get_object_terms( $terms, $not_used, $args_1, $args_2 = null ) { |
|
461 | + public function lsx_to_scporder_get_object_terms($terms, $not_used, $args_1, $args_2 = null) { |
|
462 | 462 | $tags = $this->get_to_scporder_options_tags(); |
463 | 463 | |
464 | - if ( is_admin() && isset( $_GET['orderby'] ) ) { |
|
464 | + if (is_admin() && isset($_GET['orderby'])) { |
|
465 | 465 | return $terms; |
466 | 466 | } |
467 | 467 | |
468 | - $args = is_null( $args_2 ) || ! is_array( $args_2 ) ? $args_1 : $args_2; |
|
468 | + $args = is_null($args_2) || ! is_array($args_2) ? $args_1 : $args_2; |
|
469 | 469 | |
470 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
470 | + if (isset($args['disabled_custom_post_order'])) { |
|
471 | 471 | return $terms; |
472 | 472 | } |
473 | 473 | |
474 | - foreach ( $terms as $key => $term ) { |
|
475 | - if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
474 | + foreach ($terms as $key => $term) { |
|
475 | + if (is_object($term) && isset($term->taxonomy)) { |
|
476 | 476 | $taxonomy = $term->taxonomy; |
477 | - if ( ! array_key_exists( $taxonomy, $tags ) ) { |
|
477 | + if ( ! array_key_exists($taxonomy, $tags)) { |
|
478 | 478 | return $terms; |
479 | 479 | } |
480 | 480 | } else { |
481 | 481 | return $terms; |
482 | 482 | } |
483 | 483 | } |
484 | - usort( $terms, array( $this, 'taxcmp' ) ); |
|
484 | + usort($terms, array($this, 'taxcmp')); |
|
485 | 485 | return $terms; |
486 | 486 | } |
487 | 487 | |
488 | - public function taxcmp( $a, $b ) { |
|
489 | - if ( $a->lsx_to_term_order == $b->lsx_to_term_order ) { |
|
488 | + public function taxcmp($a, $b) { |
|
489 | + if ($a->lsx_to_term_order == $b->lsx_to_term_order) { |
|
490 | 490 | return 0; |
491 | 491 | } |
492 | - return ( $a->lsx_to_term_order < $b->lsx_to_term_order ) ? - 1 : 1; |
|
492 | + return ($a->lsx_to_term_order < $b->lsx_to_term_order) ? -1 : 1; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | public function get_to_scporder_options_objects() { |
@@ -4,194 +4,194 @@ discard block |
||
4 | 4 | |
5 | 5 | class SCPO_Engine { |
6 | 6 | |
7 | - /** |
|
8 | - * Holds class instance |
|
9 | - * |
|
10 | - * @since 1.0.0 |
|
11 | - * |
|
12 | - * @var object \lsx_health_plan\classes\SCPO_Engine() |
|
13 | - */ |
|
14 | - protected static $instance = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Return an instance of this class. |
|
18 | - * |
|
19 | - * @since 1.0.0 |
|
20 | - * |
|
21 | - * @return object \lsx_health_plan\classes\SCPO_Engine() A single instance of this class. |
|
22 | - */ |
|
23 | - public static function get_instance() { |
|
24 | - // If the single instance hasn't been set, set it now. |
|
25 | - if ( null == self::$instance ) { |
|
26 | - self::$instance = new self; |
|
27 | - } |
|
28 | - return self::$instance; |
|
29 | - } |
|
30 | - |
|
31 | - public function __construct() { |
|
32 | - if ( ! get_option( 'lsx_to_scporder_install' ) ) { |
|
33 | - $this->lsx_to_scporder_install(); |
|
34 | - } |
|
35 | - |
|
36 | - add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
37 | - add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
38 | - |
|
39 | - add_action( 'wp_ajax_update-menu-order', array( |
|
40 | - $this, |
|
41 | - 'update_menu_order', |
|
42 | - ) ); |
|
43 | - add_action( 'wp_ajax_update-menu-order-tags', array( |
|
44 | - $this, |
|
45 | - 'update_menu_order_tags', |
|
46 | - ) ); |
|
47 | - |
|
48 | - add_action( 'pre_get_posts', array( |
|
49 | - $this, |
|
50 | - 'lsx_to_scporder_pre_get_posts', |
|
51 | - ) ); |
|
52 | - |
|
53 | - add_filter( 'get_previous_post_where', array( |
|
54 | - $this, |
|
55 | - 'lsx_to_scporder_previous_post_where', |
|
56 | - ) ); |
|
57 | - add_filter( 'get_previous_post_sort', array( |
|
58 | - $this, |
|
59 | - 'lsx_to_scporder_previous_post_sort', |
|
60 | - ) ); |
|
61 | - add_filter( 'get_next_post_where', array( |
|
62 | - $this, |
|
63 | - 'lsx_to_scporder_next_post_where', |
|
64 | - ) ); |
|
65 | - add_filter( 'get_next_post_sort', array( |
|
66 | - $this, |
|
67 | - 'lsx_to_scporder_next_post_sort', |
|
68 | - ) ); |
|
69 | - |
|
70 | - add_filter( 'get_terms_orderby', array( |
|
71 | - $this, |
|
72 | - 'lsx_to_scporder_get_terms_orderby', |
|
73 | - ), 10, 3 ); |
|
74 | - add_filter( 'wp_get_object_terms', array( |
|
75 | - $this, |
|
76 | - 'lsx_to_scporder_get_object_terms', |
|
77 | - ), 10, 4 ); |
|
78 | - add_filter( 'get_terms', array( |
|
79 | - $this, |
|
80 | - 'lsx_to_scporder_get_object_terms', |
|
81 | - ), 10, 4 ); |
|
82 | - } |
|
83 | - |
|
84 | - public function lsx_to_scporder_install() { |
|
85 | - global $wpdb; |
|
86 | - $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_to_term_order`" ); |
|
87 | - |
|
88 | - if ( ! $result ) { |
|
89 | - $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'" ); |
|
90 | - } |
|
91 | - |
|
92 | - update_option( 'lsx_to_scporder_install', 1 ); |
|
93 | - } |
|
94 | - |
|
95 | - public function _check_load_script_css() { |
|
96 | - $active = false; |
|
97 | - |
|
98 | - $objects = $this->get_to_scporder_options_objects(); |
|
99 | - $tags = $this->get_to_scporder_options_tags(); |
|
100 | - |
|
101 | - if ( empty( $objects ) && empty( $tags ) ) { |
|
102 | - return false; |
|
103 | - } |
|
104 | - |
|
105 | - if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'action=edit' ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/post-new.php' ) ) { |
|
106 | - return false; |
|
107 | - } |
|
108 | - |
|
109 | - if ( ! empty( $objects ) ) { |
|
110 | - if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['post_type'] ), $objects ) ) { // if page or custom post types |
|
111 | - $active = true; |
|
112 | - } |
|
113 | - if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post |
|
114 | - $active = true; |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - if ( ! empty( $tags ) ) { |
|
119 | - if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['taxonomy'] ), $tags ) ) { |
|
120 | - $active = true; |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - return $active; |
|
125 | - } |
|
126 | - |
|
127 | - public function load_script_css() { |
|
128 | - if ( $this->_check_load_script_css() ) { |
|
129 | - wp_enqueue_script( 'scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
130 | - |
|
131 | - $scporderjs_params = array( |
|
132 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
133 | - 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
134 | - ); |
|
135 | - |
|
136 | - wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
137 | - |
|
138 | - wp_enqueue_style( 'scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null ); |
|
139 | - wp_style_add_data( 'scporder', 'rtl', 'replace' ); |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - public function refresh() { |
|
144 | - global $wpdb; |
|
145 | - $objects = $this->get_to_scporder_options_objects(); |
|
146 | - $tags = $this->get_to_scporder_options_tags(); |
|
147 | - |
|
148 | - if ( ! empty( $objects ) ) { |
|
149 | - foreach ( $objects as $object => $object_data ) { |
|
150 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
7 | + /** |
|
8 | + * Holds class instance |
|
9 | + * |
|
10 | + * @since 1.0.0 |
|
11 | + * |
|
12 | + * @var object \lsx_health_plan\classes\SCPO_Engine() |
|
13 | + */ |
|
14 | + protected static $instance = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Return an instance of this class. |
|
18 | + * |
|
19 | + * @since 1.0.0 |
|
20 | + * |
|
21 | + * @return object \lsx_health_plan\classes\SCPO_Engine() A single instance of this class. |
|
22 | + */ |
|
23 | + public static function get_instance() { |
|
24 | + // If the single instance hasn't been set, set it now. |
|
25 | + if ( null == self::$instance ) { |
|
26 | + self::$instance = new self; |
|
27 | + } |
|
28 | + return self::$instance; |
|
29 | + } |
|
30 | + |
|
31 | + public function __construct() { |
|
32 | + if ( ! get_option( 'lsx_to_scporder_install' ) ) { |
|
33 | + $this->lsx_to_scporder_install(); |
|
34 | + } |
|
35 | + |
|
36 | + add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
37 | + add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
38 | + |
|
39 | + add_action( 'wp_ajax_update-menu-order', array( |
|
40 | + $this, |
|
41 | + 'update_menu_order', |
|
42 | + ) ); |
|
43 | + add_action( 'wp_ajax_update-menu-order-tags', array( |
|
44 | + $this, |
|
45 | + 'update_menu_order_tags', |
|
46 | + ) ); |
|
47 | + |
|
48 | + add_action( 'pre_get_posts', array( |
|
49 | + $this, |
|
50 | + 'lsx_to_scporder_pre_get_posts', |
|
51 | + ) ); |
|
52 | + |
|
53 | + add_filter( 'get_previous_post_where', array( |
|
54 | + $this, |
|
55 | + 'lsx_to_scporder_previous_post_where', |
|
56 | + ) ); |
|
57 | + add_filter( 'get_previous_post_sort', array( |
|
58 | + $this, |
|
59 | + 'lsx_to_scporder_previous_post_sort', |
|
60 | + ) ); |
|
61 | + add_filter( 'get_next_post_where', array( |
|
62 | + $this, |
|
63 | + 'lsx_to_scporder_next_post_where', |
|
64 | + ) ); |
|
65 | + add_filter( 'get_next_post_sort', array( |
|
66 | + $this, |
|
67 | + 'lsx_to_scporder_next_post_sort', |
|
68 | + ) ); |
|
69 | + |
|
70 | + add_filter( 'get_terms_orderby', array( |
|
71 | + $this, |
|
72 | + 'lsx_to_scporder_get_terms_orderby', |
|
73 | + ), 10, 3 ); |
|
74 | + add_filter( 'wp_get_object_terms', array( |
|
75 | + $this, |
|
76 | + 'lsx_to_scporder_get_object_terms', |
|
77 | + ), 10, 4 ); |
|
78 | + add_filter( 'get_terms', array( |
|
79 | + $this, |
|
80 | + 'lsx_to_scporder_get_object_terms', |
|
81 | + ), 10, 4 ); |
|
82 | + } |
|
83 | + |
|
84 | + public function lsx_to_scporder_install() { |
|
85 | + global $wpdb; |
|
86 | + $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_to_term_order`" ); |
|
87 | + |
|
88 | + if ( ! $result ) { |
|
89 | + $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'" ); |
|
90 | + } |
|
91 | + |
|
92 | + update_option( 'lsx_to_scporder_install', 1 ); |
|
93 | + } |
|
94 | + |
|
95 | + public function _check_load_script_css() { |
|
96 | + $active = false; |
|
97 | + |
|
98 | + $objects = $this->get_to_scporder_options_objects(); |
|
99 | + $tags = $this->get_to_scporder_options_tags(); |
|
100 | + |
|
101 | + if ( empty( $objects ) && empty( $tags ) ) { |
|
102 | + return false; |
|
103 | + } |
|
104 | + |
|
105 | + if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'action=edit' ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/post-new.php' ) ) { |
|
106 | + return false; |
|
107 | + } |
|
108 | + |
|
109 | + if ( ! empty( $objects ) ) { |
|
110 | + if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['post_type'] ), $objects ) ) { // if page or custom post types |
|
111 | + $active = true; |
|
112 | + } |
|
113 | + if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post |
|
114 | + $active = true; |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + if ( ! empty( $tags ) ) { |
|
119 | + if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['taxonomy'] ), $tags ) ) { |
|
120 | + $active = true; |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + return $active; |
|
125 | + } |
|
126 | + |
|
127 | + public function load_script_css() { |
|
128 | + if ( $this->_check_load_script_css() ) { |
|
129 | + wp_enqueue_script( 'scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
130 | + |
|
131 | + $scporderjs_params = array( |
|
132 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
133 | + 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
134 | + ); |
|
135 | + |
|
136 | + wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
137 | + |
|
138 | + wp_enqueue_style( 'scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null ); |
|
139 | + wp_style_add_data( 'scporder', 'rtl', 'replace' ); |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + public function refresh() { |
|
144 | + global $wpdb; |
|
145 | + $objects = $this->get_to_scporder_options_objects(); |
|
146 | + $tags = $this->get_to_scporder_options_tags(); |
|
147 | + |
|
148 | + if ( ! empty( $objects ) ) { |
|
149 | + foreach ( $objects as $object => $object_data ) { |
|
150 | + $result = $wpdb->get_results( $wpdb->prepare( " |
|
151 | 151 | SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min |
152 | 152 | FROM $wpdb->posts |
153 | 153 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
154 | 154 | ", $object ) ); |
155 | 155 | |
156 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
157 | - continue; |
|
158 | - } |
|
156 | + if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
157 | + continue; |
|
158 | + } |
|
159 | 159 | |
160 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
160 | + $results = $wpdb->get_results( $wpdb->prepare( " |
|
161 | 161 | SELECT ID |
162 | 162 | FROM $wpdb->posts |
163 | 163 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
164 | 164 | ORDER BY menu_order ASC |
165 | 165 | ", $object ) ); |
166 | 166 | |
167 | - foreach ( $results as $key => $result ) { |
|
168 | - $wpdb->update( |
|
169 | - $wpdb->posts, |
|
170 | - array( |
|
171 | - 'menu_order' => $key + 1, |
|
172 | - ), |
|
173 | - array( |
|
174 | - 'ID' => $result->ID, |
|
175 | - ) |
|
176 | - ); |
|
177 | - } |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - if ( ! empty( $tags ) ) { |
|
182 | - foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
183 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
167 | + foreach ( $results as $key => $result ) { |
|
168 | + $wpdb->update( |
|
169 | + $wpdb->posts, |
|
170 | + array( |
|
171 | + 'menu_order' => $key + 1, |
|
172 | + ), |
|
173 | + array( |
|
174 | + 'ID' => $result->ID, |
|
175 | + ) |
|
176 | + ); |
|
177 | + } |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + if ( ! empty( $tags ) ) { |
|
182 | + foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
183 | + $result = $wpdb->get_results( $wpdb->prepare( " |
|
184 | 184 | SELECT count(*) as cnt, max(lsx_to_term_order) as max, min(lsx_to_term_order) as min |
185 | 185 | FROM $wpdb->terms AS terms |
186 | 186 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
187 | 187 | WHERE term_taxonomy.taxonomy = '%s' |
188 | 188 | ", $taxonomy ) ); |
189 | 189 | |
190 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
191 | - continue; |
|
192 | - } |
|
190 | + if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
191 | + continue; |
|
192 | + } |
|
193 | 193 | |
194 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
194 | + $results = $wpdb->get_results( $wpdb->prepare( " |
|
195 | 195 | SELECT terms.term_id |
196 | 196 | FROM $wpdb->terms AS terms |
197 | 197 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
@@ -199,33 +199,33 @@ discard block |
||
199 | 199 | ORDER BY lsx_to_term_order ASC |
200 | 200 | ", $taxonomy ) ); |
201 | 201 | |
202 | - foreach ( $results as $key => $result ) { |
|
203 | - $wpdb->update( |
|
204 | - $wpdb->terms, |
|
205 | - array( |
|
206 | - 'lsx_to_term_order' => $key + 1, |
|
207 | - ), |
|
208 | - array( |
|
209 | - 'term_id' => $result->term_id, |
|
210 | - ) |
|
211 | - ); |
|
212 | - } |
|
213 | - } |
|
214 | - } |
|
215 | - } |
|
202 | + foreach ( $results as $key => $result ) { |
|
203 | + $wpdb->update( |
|
204 | + $wpdb->terms, |
|
205 | + array( |
|
206 | + 'lsx_to_term_order' => $key + 1, |
|
207 | + ), |
|
208 | + array( |
|
209 | + 'term_id' => $result->term_id, |
|
210 | + ) |
|
211 | + ); |
|
212 | + } |
|
213 | + } |
|
214 | + } |
|
215 | + } |
|
216 | 216 | |
217 | - public function update_menu_order() { |
|
218 | - check_ajax_referer( 'scporder', 'security' ); |
|
217 | + public function update_menu_order() { |
|
218 | + check_ajax_referer( 'scporder', 'security' ); |
|
219 | 219 | |
220 | - global $wpdb; |
|
220 | + global $wpdb; |
|
221 | 221 | |
222 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
222 | + parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
223 | 223 | |
224 | - if ( ! is_array( $data ) ) { |
|
225 | - return false; |
|
226 | - } |
|
224 | + if ( ! is_array( $data ) ) { |
|
225 | + return false; |
|
226 | + } |
|
227 | 227 | |
228 | - /*$id_arr = array(); |
|
228 | + /*$id_arr = array(); |
|
229 | 229 | |
230 | 230 | foreach ( $data as $key => $values ) { |
231 | 231 | foreach ( $values as $position => $id ) { |
@@ -244,38 +244,38 @@ discard block |
||
244 | 244 | |
245 | 245 | sort( $menu_order_arr );*/ |
246 | 246 | |
247 | - foreach ( $data as $key => $values ) { |
|
248 | - foreach ( $values as $position => $id ) { |
|
249 | - $wpdb->update( |
|
250 | - $wpdb->posts, |
|
251 | - array( |
|
252 | - 'menu_order' => $position, |
|
253 | - ), |
|
254 | - array( |
|
255 | - 'ID' => intval( $id ), |
|
256 | - ) |
|
257 | - ); |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - public function update_menu_order_tags() { |
|
263 | - check_ajax_referer( 'scporder', 'security' ); |
|
264 | - |
|
265 | - global $wpdb; |
|
266 | - |
|
267 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
268 | - |
|
269 | - if ( ! is_array( $data ) ) { |
|
270 | - return false; |
|
271 | - } |
|
272 | - |
|
273 | - /*$current_user = wp_get_current_user(); |
|
247 | + foreach ( $data as $key => $values ) { |
|
248 | + foreach ( $values as $position => $id ) { |
|
249 | + $wpdb->update( |
|
250 | + $wpdb->posts, |
|
251 | + array( |
|
252 | + 'menu_order' => $position, |
|
253 | + ), |
|
254 | + array( |
|
255 | + 'ID' => intval( $id ), |
|
256 | + ) |
|
257 | + ); |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + public function update_menu_order_tags() { |
|
263 | + check_ajax_referer( 'scporder', 'security' ); |
|
264 | + |
|
265 | + global $wpdb; |
|
266 | + |
|
267 | + parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
268 | + |
|
269 | + if ( ! is_array( $data ) ) { |
|
270 | + return false; |
|
271 | + } |
|
272 | + |
|
273 | + /*$current_user = wp_get_current_user(); |
|
274 | 274 | if ( false === $current_user || 'lightspeed' !== $current_user->data->user_login ) { |
275 | 275 | return false; |
276 | 276 | }*/ |
277 | 277 | |
278 | - /*$id_arr = array(); |
|
278 | + /*$id_arr = array(); |
|
279 | 279 | |
280 | 280 | foreach ( $data as $key => $values ) { |
281 | 281 | foreach ( $values as $position => $id ) { |
@@ -294,217 +294,217 @@ discard block |
||
294 | 294 | |
295 | 295 | sort( $menu_order_arr );*/ |
296 | 296 | |
297 | - foreach ( $data as $key => $values ) { |
|
298 | - $term_ids = array(); |
|
299 | - foreach ( $values as $position => $id ) { |
|
300 | - $wpdb->update( |
|
301 | - $wpdb->terms, |
|
302 | - array( |
|
303 | - 'lsx_to_term_order' => $position + 1, |
|
304 | - ), |
|
305 | - array( |
|
306 | - 'term_id' => intval( $id ), |
|
307 | - ) |
|
308 | - ); |
|
309 | - $term_ids[] = intval( $id ); |
|
310 | - } |
|
311 | - clean_term_cache( $term_ids ); |
|
312 | - } |
|
313 | - } |
|
314 | - |
|
315 | - public function lsx_to_scporder_previous_post_where( $where ) { |
|
316 | - global $post; |
|
317 | - $objects = $this->get_to_scporder_options_objects(); |
|
318 | - |
|
319 | - if ( empty( $objects ) ) { |
|
320 | - return $where; |
|
321 | - } |
|
322 | - |
|
323 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
324 | - $current_menu_order = $post->menu_order; |
|
325 | - $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
326 | - } |
|
327 | - |
|
328 | - return $where; |
|
329 | - } |
|
330 | - |
|
331 | - public function lsx_to_scporder_previous_post_sort( $orderby ) { |
|
332 | - global $post; |
|
333 | - $objects = $this->get_to_scporder_options_objects(); |
|
334 | - |
|
335 | - if ( empty( $objects ) ) { |
|
336 | - return $orderby; |
|
337 | - } |
|
338 | - |
|
339 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
340 | - $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
|
341 | - } |
|
342 | - |
|
343 | - return $orderby; |
|
344 | - } |
|
345 | - |
|
346 | - public function lsx_to_scporder_next_post_where( $where ) { |
|
347 | - global $post; |
|
348 | - $objects = $this->get_to_scporder_options_objects(); |
|
349 | - |
|
350 | - if ( empty( $objects ) ) { |
|
351 | - return $where; |
|
352 | - } |
|
353 | - |
|
354 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
355 | - $current_menu_order = $post->menu_order; |
|
356 | - $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
357 | - } |
|
358 | - |
|
359 | - return $where; |
|
360 | - } |
|
361 | - |
|
362 | - public function lsx_to_scporder_next_post_sort( $orderby ) { |
|
363 | - global $post; |
|
364 | - $objects = $this->get_to_scporder_options_objects(); |
|
365 | - |
|
366 | - if ( empty( $objects ) ) { |
|
367 | - return $orderby; |
|
368 | - } |
|
369 | - |
|
370 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
371 | - $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
|
372 | - } |
|
373 | - |
|
374 | - return $orderby; |
|
375 | - } |
|
376 | - |
|
377 | - public function lsx_to_scporder_pre_get_posts( $wp_query ) { |
|
378 | - $objects = $this->get_to_scporder_options_objects(); |
|
379 | - |
|
380 | - if ( empty( $objects ) ) { |
|
381 | - return false; |
|
382 | - } |
|
383 | - |
|
384 | - if ( is_admin() ) { |
|
385 | - if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
386 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
387 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
388 | - $wp_query->set( 'order', 'ASC' ); |
|
389 | - } |
|
390 | - } |
|
391 | - } else { |
|
392 | - $active = false; |
|
393 | - |
|
394 | - if ( isset( $wp_query->query['post_type'] ) ) { |
|
395 | - if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
396 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
397 | - $active = true; |
|
398 | - } |
|
399 | - } |
|
400 | - } else { |
|
401 | - if ( array_key_exists( 'post', $objects ) ) { |
|
402 | - $active = true; |
|
403 | - } |
|
404 | - } |
|
405 | - |
|
406 | - if ( ! $active ) { |
|
407 | - return false; |
|
408 | - } |
|
409 | - |
|
410 | - if ( isset( $wp_query->query['disabled_custom_post_order'] ) ) { |
|
411 | - return false; |
|
412 | - } |
|
413 | - |
|
414 | - if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
415 | - if ( $wp_query->get( 'orderby' ) == 'date' ) { |
|
416 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
417 | - } |
|
418 | - if ( $wp_query->get( 'order' ) == 'DESC' ) { |
|
419 | - $wp_query->set( 'order', 'ASC' ); |
|
420 | - } |
|
421 | - } else { |
|
422 | - if ( ! $wp_query->get( 'orderby' ) ) { |
|
423 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
424 | - } |
|
425 | - if ( ! $wp_query->get( 'order' ) ) { |
|
426 | - $wp_query->set( 'order', 'ASC' ); |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - } |
|
431 | - |
|
432 | - public function lsx_to_scporder_get_terms_orderby( $orderby, $args ) { |
|
433 | - |
|
434 | - if ( is_admin() ) { |
|
435 | - return $orderby; |
|
436 | - } |
|
437 | - |
|
438 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
439 | - return $orderby; |
|
440 | - } |
|
441 | - |
|
442 | - $tags = $this->get_to_scporder_options_tags(); |
|
443 | - |
|
444 | - if ( ! isset( $args['taxonomy'] ) ) { |
|
445 | - return $orderby; |
|
446 | - } |
|
447 | - |
|
448 | - $taxonomy = $args['taxonomy']; |
|
449 | - if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) { |
|
450 | - $taxonomy = $taxonomy[0]; |
|
451 | - } |
|
452 | - if ( ! is_array( $taxonomy ) && ! array_key_exists( $taxonomy, $tags ) ) { |
|
453 | - return $orderby; |
|
454 | - } |
|
455 | - |
|
456 | - $orderby = 't.lsx_to_term_order'; |
|
457 | - |
|
458 | - return $orderby; |
|
459 | - } |
|
460 | - |
|
461 | - public function lsx_to_scporder_get_object_terms( $terms, $not_used, $args_1, $args_2 = null ) { |
|
462 | - $tags = $this->get_to_scporder_options_tags(); |
|
463 | - |
|
464 | - if ( is_admin() && isset( $_GET['orderby'] ) ) { |
|
465 | - return $terms; |
|
466 | - } |
|
467 | - |
|
468 | - $args = is_null( $args_2 ) || ! is_array( $args_2 ) ? $args_1 : $args_2; |
|
469 | - |
|
470 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
471 | - return $terms; |
|
472 | - } |
|
473 | - |
|
474 | - foreach ( $terms as $key => $term ) { |
|
475 | - if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
476 | - $taxonomy = $term->taxonomy; |
|
477 | - if ( ! array_key_exists( $taxonomy, $tags ) ) { |
|
478 | - return $terms; |
|
479 | - } |
|
480 | - } else { |
|
481 | - return $terms; |
|
482 | - } |
|
483 | - } |
|
484 | - usort( $terms, array( $this, 'taxcmp' ) ); |
|
485 | - return $terms; |
|
486 | - } |
|
487 | - |
|
488 | - public function taxcmp( $a, $b ) { |
|
489 | - if ( $a->lsx_to_term_order == $b->lsx_to_term_order ) { |
|
490 | - return 0; |
|
491 | - } |
|
492 | - return ( $a->lsx_to_term_order < $b->lsx_to_term_order ) ? - 1 : 1; |
|
493 | - } |
|
494 | - |
|
495 | - public function get_to_scporder_options_objects() { |
|
496 | - $ordering = array( |
|
497 | - 'plan' => 'plan', |
|
498 | - ); |
|
499 | - return $ordering; |
|
500 | - } |
|
501 | - |
|
502 | - public function get_to_scporder_options_tags() { |
|
503 | - $ordering = array( |
|
504 | - 'week' => 'week', |
|
505 | - 'recipe-type' => 'recipe-type', |
|
506 | - ); |
|
507 | - return $ordering; |
|
508 | - } |
|
297 | + foreach ( $data as $key => $values ) { |
|
298 | + $term_ids = array(); |
|
299 | + foreach ( $values as $position => $id ) { |
|
300 | + $wpdb->update( |
|
301 | + $wpdb->terms, |
|
302 | + array( |
|
303 | + 'lsx_to_term_order' => $position + 1, |
|
304 | + ), |
|
305 | + array( |
|
306 | + 'term_id' => intval( $id ), |
|
307 | + ) |
|
308 | + ); |
|
309 | + $term_ids[] = intval( $id ); |
|
310 | + } |
|
311 | + clean_term_cache( $term_ids ); |
|
312 | + } |
|
313 | + } |
|
314 | + |
|
315 | + public function lsx_to_scporder_previous_post_where( $where ) { |
|
316 | + global $post; |
|
317 | + $objects = $this->get_to_scporder_options_objects(); |
|
318 | + |
|
319 | + if ( empty( $objects ) ) { |
|
320 | + return $where; |
|
321 | + } |
|
322 | + |
|
323 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
324 | + $current_menu_order = $post->menu_order; |
|
325 | + $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
326 | + } |
|
327 | + |
|
328 | + return $where; |
|
329 | + } |
|
330 | + |
|
331 | + public function lsx_to_scporder_previous_post_sort( $orderby ) { |
|
332 | + global $post; |
|
333 | + $objects = $this->get_to_scporder_options_objects(); |
|
334 | + |
|
335 | + if ( empty( $objects ) ) { |
|
336 | + return $orderby; |
|
337 | + } |
|
338 | + |
|
339 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
340 | + $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
|
341 | + } |
|
342 | + |
|
343 | + return $orderby; |
|
344 | + } |
|
345 | + |
|
346 | + public function lsx_to_scporder_next_post_where( $where ) { |
|
347 | + global $post; |
|
348 | + $objects = $this->get_to_scporder_options_objects(); |
|
349 | + |
|
350 | + if ( empty( $objects ) ) { |
|
351 | + return $where; |
|
352 | + } |
|
353 | + |
|
354 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
355 | + $current_menu_order = $post->menu_order; |
|
356 | + $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
357 | + } |
|
358 | + |
|
359 | + return $where; |
|
360 | + } |
|
361 | + |
|
362 | + public function lsx_to_scporder_next_post_sort( $orderby ) { |
|
363 | + global $post; |
|
364 | + $objects = $this->get_to_scporder_options_objects(); |
|
365 | + |
|
366 | + if ( empty( $objects ) ) { |
|
367 | + return $orderby; |
|
368 | + } |
|
369 | + |
|
370 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
371 | + $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
|
372 | + } |
|
373 | + |
|
374 | + return $orderby; |
|
375 | + } |
|
376 | + |
|
377 | + public function lsx_to_scporder_pre_get_posts( $wp_query ) { |
|
378 | + $objects = $this->get_to_scporder_options_objects(); |
|
379 | + |
|
380 | + if ( empty( $objects ) ) { |
|
381 | + return false; |
|
382 | + } |
|
383 | + |
|
384 | + if ( is_admin() ) { |
|
385 | + if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
386 | + if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
387 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
388 | + $wp_query->set( 'order', 'ASC' ); |
|
389 | + } |
|
390 | + } |
|
391 | + } else { |
|
392 | + $active = false; |
|
393 | + |
|
394 | + if ( isset( $wp_query->query['post_type'] ) ) { |
|
395 | + if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
396 | + if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
397 | + $active = true; |
|
398 | + } |
|
399 | + } |
|
400 | + } else { |
|
401 | + if ( array_key_exists( 'post', $objects ) ) { |
|
402 | + $active = true; |
|
403 | + } |
|
404 | + } |
|
405 | + |
|
406 | + if ( ! $active ) { |
|
407 | + return false; |
|
408 | + } |
|
409 | + |
|
410 | + if ( isset( $wp_query->query['disabled_custom_post_order'] ) ) { |
|
411 | + return false; |
|
412 | + } |
|
413 | + |
|
414 | + if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
415 | + if ( $wp_query->get( 'orderby' ) == 'date' ) { |
|
416 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
417 | + } |
|
418 | + if ( $wp_query->get( 'order' ) == 'DESC' ) { |
|
419 | + $wp_query->set( 'order', 'ASC' ); |
|
420 | + } |
|
421 | + } else { |
|
422 | + if ( ! $wp_query->get( 'orderby' ) ) { |
|
423 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
424 | + } |
|
425 | + if ( ! $wp_query->get( 'order' ) ) { |
|
426 | + $wp_query->set( 'order', 'ASC' ); |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + } |
|
431 | + |
|
432 | + public function lsx_to_scporder_get_terms_orderby( $orderby, $args ) { |
|
433 | + |
|
434 | + if ( is_admin() ) { |
|
435 | + return $orderby; |
|
436 | + } |
|
437 | + |
|
438 | + if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
439 | + return $orderby; |
|
440 | + } |
|
441 | + |
|
442 | + $tags = $this->get_to_scporder_options_tags(); |
|
443 | + |
|
444 | + if ( ! isset( $args['taxonomy'] ) ) { |
|
445 | + return $orderby; |
|
446 | + } |
|
447 | + |
|
448 | + $taxonomy = $args['taxonomy']; |
|
449 | + if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) { |
|
450 | + $taxonomy = $taxonomy[0]; |
|
451 | + } |
|
452 | + if ( ! is_array( $taxonomy ) && ! array_key_exists( $taxonomy, $tags ) ) { |
|
453 | + return $orderby; |
|
454 | + } |
|
455 | + |
|
456 | + $orderby = 't.lsx_to_term_order'; |
|
457 | + |
|
458 | + return $orderby; |
|
459 | + } |
|
460 | + |
|
461 | + public function lsx_to_scporder_get_object_terms( $terms, $not_used, $args_1, $args_2 = null ) { |
|
462 | + $tags = $this->get_to_scporder_options_tags(); |
|
463 | + |
|
464 | + if ( is_admin() && isset( $_GET['orderby'] ) ) { |
|
465 | + return $terms; |
|
466 | + } |
|
467 | + |
|
468 | + $args = is_null( $args_2 ) || ! is_array( $args_2 ) ? $args_1 : $args_2; |
|
469 | + |
|
470 | + if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
471 | + return $terms; |
|
472 | + } |
|
473 | + |
|
474 | + foreach ( $terms as $key => $term ) { |
|
475 | + if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
476 | + $taxonomy = $term->taxonomy; |
|
477 | + if ( ! array_key_exists( $taxonomy, $tags ) ) { |
|
478 | + return $terms; |
|
479 | + } |
|
480 | + } else { |
|
481 | + return $terms; |
|
482 | + } |
|
483 | + } |
|
484 | + usort( $terms, array( $this, 'taxcmp' ) ); |
|
485 | + return $terms; |
|
486 | + } |
|
487 | + |
|
488 | + public function taxcmp( $a, $b ) { |
|
489 | + if ( $a->lsx_to_term_order == $b->lsx_to_term_order ) { |
|
490 | + return 0; |
|
491 | + } |
|
492 | + return ( $a->lsx_to_term_order < $b->lsx_to_term_order ) ? - 1 : 1; |
|
493 | + } |
|
494 | + |
|
495 | + public function get_to_scporder_options_objects() { |
|
496 | + $ordering = array( |
|
497 | + 'plan' => 'plan', |
|
498 | + ); |
|
499 | + return $ordering; |
|
500 | + } |
|
501 | + |
|
502 | + public function get_to_scporder_options_tags() { |
|
503 | + $ordering = array( |
|
504 | + 'week' => 'week', |
|
505 | + 'recipe-type' => 'recipe-type', |
|
506 | + ); |
|
507 | + return $ordering; |
|
508 | + } |
|
509 | 509 | } |
510 | 510 |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct() { |
39 | 39 | $this->enable_post_types(); |
40 | - add_filter( 'lsx_health_plan_post_types', array( $this, 'enable_post_types' ) ); |
|
41 | - foreach ( $this->post_types as $index => $post_type ) { |
|
42 | - $is_disabled = \lsx_health_plan\functions\get_option( $post_type . '_disabled', false ); |
|
40 | + add_filter('lsx_health_plan_post_types', array($this, 'enable_post_types')); |
|
41 | + foreach ($this->post_types as $index => $post_type) { |
|
42 | + $is_disabled = \lsx_health_plan\functions\get_option($post_type . '_disabled', false); |
|
43 | 43 | // Check if exercises is enabled, if so disable the videos. |
44 | - if ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
44 | + if ('video' === $post_type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
45 | 45 | $is_disabled = true; |
46 | 46 | } |
47 | 47 | |
48 | - if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
49 | - unset( $this->post_types[ $index ] ); |
|
48 | + if (true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled) { |
|
49 | + unset($this->post_types[$index]); |
|
50 | 50 | } else { |
51 | 51 | require_once LSX_HEALTH_PLAN_PATH . 'classes/post-types/class-' . $post_type . '.php'; |
52 | - $classname = ucwords( $post_type ); |
|
53 | - $this->$post_type = call_user_func_array( '\\lsx_health_plan\classes\\' . $classname . '::get_instance', array() ); |
|
52 | + $classname = ucwords($post_type); |
|
53 | + $this->$post_type = call_user_func_array('\\lsx_health_plan\classes\\' . $classname . '::get_instance', array()); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | */ |
65 | 65 | public static function get_instance() { |
66 | 66 | // If the single instance hasn't been set, set it now. |
67 | - if ( null === self::$instance ) { |
|
67 | + if (null === self::$instance) { |
|
68 | 68 | self::$instance = new self(); |
69 | 69 | } |
70 | 70 | return self::$instance; |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return void |
77 | 77 | */ |
78 | - public function enable_post_types( $post_types = array() ) { |
|
79 | - $post_types = array( |
|
78 | + public function enable_post_types($post_types = array()) { |
|
79 | + $post_types = array( |
|
80 | 80 | 'plan', |
81 | 81 | 'workout', |
82 | 82 | 'meal', |
@@ -9,83 +9,83 @@ |
||
9 | 9 | */ |
10 | 10 | class Post_Type { |
11 | 11 | |
12 | - /** |
|
13 | - * Holds class instance |
|
14 | - * |
|
15 | - * @since 1.0.0 |
|
16 | - * |
|
17 | - * @var object \lsx_health_plan\classes\Post_Type() |
|
18 | - */ |
|
19 | - protected static $instance = null; |
|
12 | + /** |
|
13 | + * Holds class instance |
|
14 | + * |
|
15 | + * @since 1.0.0 |
|
16 | + * |
|
17 | + * @var object \lsx_health_plan\classes\Post_Type() |
|
18 | + */ |
|
19 | + protected static $instance = null; |
|
20 | 20 | |
21 | - /** |
|
22 | - * The post types available |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - public $post_types = array(); |
|
21 | + /** |
|
22 | + * The post types available |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + public $post_types = array(); |
|
27 | 27 | |
28 | - /** |
|
29 | - * The related post type connections |
|
30 | - * |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - public $connections = array(); |
|
28 | + /** |
|
29 | + * The related post type connections |
|
30 | + * |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + public $connections = array(); |
|
34 | 34 | |
35 | - /** |
|
36 | - * Constructor |
|
37 | - */ |
|
38 | - public function __construct() { |
|
39 | - $this->enable_post_types(); |
|
40 | - add_filter( 'lsx_health_plan_post_types', array( $this, 'enable_post_types' ) ); |
|
41 | - foreach ( $this->post_types as $index => $post_type ) { |
|
42 | - $is_disabled = \lsx_health_plan\functions\get_option( $post_type . '_disabled', false ); |
|
43 | - // Check if exercises is enabled, if so disable the videos. |
|
44 | - if ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
45 | - $is_disabled = true; |
|
46 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + */ |
|
38 | + public function __construct() { |
|
39 | + $this->enable_post_types(); |
|
40 | + add_filter( 'lsx_health_plan_post_types', array( $this, 'enable_post_types' ) ); |
|
41 | + foreach ( $this->post_types as $index => $post_type ) { |
|
42 | + $is_disabled = \lsx_health_plan\functions\get_option( $post_type . '_disabled', false ); |
|
43 | + // Check if exercises is enabled, if so disable the videos. |
|
44 | + if ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
45 | + $is_disabled = true; |
|
46 | + } |
|
47 | 47 | |
48 | - if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
49 | - unset( $this->post_types[ $index ] ); |
|
50 | - } else { |
|
51 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/post-types/class-' . $post_type . '.php'; |
|
52 | - $classname = ucwords( $post_type ); |
|
53 | - $this->$post_type = call_user_func_array( '\\lsx_health_plan\classes\\' . $classname . '::get_instance', array() ); |
|
54 | - } |
|
55 | - } |
|
56 | - } |
|
48 | + if ( true === $is_disabled || 1 === $is_disabled || 'on' === $is_disabled ) { |
|
49 | + unset( $this->post_types[ $index ] ); |
|
50 | + } else { |
|
51 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/post-types/class-' . $post_type . '.php'; |
|
52 | + $classname = ucwords( $post_type ); |
|
53 | + $this->$post_type = call_user_func_array( '\\lsx_health_plan\classes\\' . $classname . '::get_instance', array() ); |
|
54 | + } |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - /** |
|
59 | - * Return an instance of this class. |
|
60 | - * |
|
61 | - * @since 1.0.0 |
|
62 | - * |
|
63 | - * @return object \lsx_health_plan\classes\Post_Type() A single instance of this class. |
|
64 | - */ |
|
65 | - public static function get_instance() { |
|
66 | - // If the single instance hasn't been set, set it now. |
|
67 | - if ( null === self::$instance ) { |
|
68 | - self::$instance = new self(); |
|
69 | - } |
|
70 | - return self::$instance; |
|
71 | - } |
|
58 | + /** |
|
59 | + * Return an instance of this class. |
|
60 | + * |
|
61 | + * @since 1.0.0 |
|
62 | + * |
|
63 | + * @return object \lsx_health_plan\classes\Post_Type() A single instance of this class. |
|
64 | + */ |
|
65 | + public static function get_instance() { |
|
66 | + // If the single instance hasn't been set, set it now. |
|
67 | + if ( null === self::$instance ) { |
|
68 | + self::$instance = new self(); |
|
69 | + } |
|
70 | + return self::$instance; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Enable our post types |
|
75 | - * |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public function enable_post_types( $post_types = array() ) { |
|
79 | - $post_types = array( |
|
80 | - 'plan', |
|
81 | - 'workout', |
|
82 | - 'meal', |
|
83 | - 'recipe', |
|
84 | - 'tip', |
|
85 | - 'video', |
|
86 | - 'exercise', |
|
87 | - ); |
|
88 | - $this->post_types = $post_types; |
|
89 | - return $post_types; |
|
90 | - } |
|
73 | + /** |
|
74 | + * Enable our post types |
|
75 | + * |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public function enable_post_types( $post_types = array() ) { |
|
79 | + $post_types = array( |
|
80 | + 'plan', |
|
81 | + 'workout', |
|
82 | + 'meal', |
|
83 | + 'recipe', |
|
84 | + 'tip', |
|
85 | + 'video', |
|
86 | + 'exercise', |
|
87 | + ); |
|
88 | + $this->post_types = $post_types; |
|
89 | + return $post_types; |
|
90 | + } |
|
91 | 91 | } |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id; |
15 | 15 | ?> |
16 | 16 | |
17 | - <div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>"> |
|
17 | + <div id="primary" class="content-area <?php echo esc_attr(lsx_main_class()); ?>"> |
|
18 | 18 | |
19 | 19 | <?php lsx_content_before(); ?> |
20 | 20 | |
21 | 21 | <!-- Begining restricted content --> |
22 | 22 | <?php |
23 | - if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) { |
|
23 | + if (current_user_can('wc_memberships_view_restricted_post_content', $post_id)) { |
|
24 | 24 | ?> |
25 | 25 | <main id="main" role="main"> |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | <div class="post-wrapper exercise-archive-plan archive-plan"> |
30 | 30 | <div class="row"> |
31 | - <?php if ( have_posts() ) : ?> |
|
31 | + <?php if (have_posts()) : ?> |
|
32 | 32 | <?php |
33 | - while ( have_posts() ) : |
|
33 | + while (have_posts()) : |
|
34 | 34 | the_post(); |
35 | 35 | ?> |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | <?php else : ?> |
42 | 42 | |
43 | - <?php get_template_part( 'partials/content', 'none' ); ?> |
|
43 | + <?php get_template_part('partials/content', 'none'); ?> |
|
44 | 44 | |
45 | 45 | <?php endif; ?> |
46 | 46 | </div> |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | <?php |
54 | 54 | } else { |
55 | - wp_redirect( $redirect ); |
|
55 | + wp_redirect($redirect); |
|
56 | 56 | exit; |
57 | 57 | } |
58 | 58 | ?> |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | <?php lsx_content_wrap_before(); ?> |
11 | 11 | |
12 | 12 | <?php |
13 | - $page_id = get_the_ID(); |
|
14 | - $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id; |
|
13 | + $page_id = get_the_ID(); |
|
14 | + $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id; |
|
15 | 15 | ?> |
16 | 16 | |
17 | 17 | <div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>"> |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | <!-- Begining restricted content --> |
22 | 22 | <?php |
23 | - if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) { |
|
24 | - ?> |
|
23 | + if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) { |
|
24 | + ?> |
|
25 | 25 | <main id="main" role="main"> |
26 | 26 | |
27 | 27 | <?php lsx_content_top(); ?> |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | <div class="row"> |
31 | 31 | <?php if ( have_posts() ) : ?> |
32 | 32 | <?php |
33 | - while ( have_posts() ) : |
|
34 | - the_post(); |
|
35 | - ?> |
|
33 | + while ( have_posts() ) : |
|
34 | + the_post(); |
|
35 | + ?> |
|
36 | 36 | |
37 | 37 | <?php include LSX_HEALTH_PLAN_PATH . '/templates/content-archive-exercise.php'; ?> |
38 | 38 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | </main><!-- #main --> |
52 | 52 | |
53 | 53 | <?php |
54 | - } else { |
|
55 | - wp_redirect( $redirect ); |
|
56 | - exit; |
|
57 | - } |
|
58 | - ?> |
|
54 | + } else { |
|
55 | + wp_redirect( $redirect ); |
|
56 | + exit; |
|
57 | + } |
|
58 | + ?> |
|
59 | 59 | |
60 | 60 | <?php lsx_content_after(); ?> |
61 | 61 |
@@ -38,9 +38,12 @@ |
||
38 | 38 | |
39 | 39 | <?php endwhile; ?> |
40 | 40 | |
41 | - <?php else : ?> |
|
41 | + <?php else { |
|
42 | + : ?> |
|
42 | 43 | |
43 | - <?php get_template_part( 'partials/content', 'none' ); ?> |
|
44 | + <?php get_template_part( 'partials/content', 'none' ); |
|
45 | +} |
|
46 | +?> |
|
44 | 47 | |
45 | 48 | <?php endif; ?> |
46 | 49 | </div> |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id; |
15 | 15 | ?> |
16 | 16 | |
17 | - <div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>"> |
|
17 | + <div id="primary" class="content-area <?php echo esc_attr(lsx_main_class()); ?>"> |
|
18 | 18 | |
19 | 19 | <?php lsx_content_before(); ?> |
20 | 20 | |
21 | 21 | <!-- Begining restricted content --> |
22 | 22 | <?php |
23 | - if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) { |
|
23 | + if (current_user_can('wc_memberships_view_restricted_post_content', $post_id)) { |
|
24 | 24 | ?> |
25 | 25 | <main id="main" role="main"> |
26 | 26 | |
@@ -28,9 +28,9 @@ discard block |
||
28 | 28 | |
29 | 29 | <div class="post-wrapper exercise-archive-plan archive-plan"> |
30 | 30 | <div class="row"> |
31 | - <?php if ( have_posts() ) : ?> |
|
31 | + <?php if (have_posts()) : ?> |
|
32 | 32 | <?php |
33 | - while ( have_posts() ) : |
|
33 | + while (have_posts()) : |
|
34 | 34 | the_post(); |
35 | 35 | ?> |
36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | <?php else : ?> |
42 | 42 | |
43 | - <?php get_template_part( 'partials/content', 'none' ); ?> |
|
43 | + <?php get_template_part('partials/content', 'none'); ?> |
|
44 | 44 | |
45 | 45 | <?php endif; ?> |
46 | 46 | </div> |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | <?php |
54 | 54 | } else { |
55 | - wp_redirect( $redirect ); |
|
55 | + wp_redirect($redirect); |
|
56 | 56 | exit; |
57 | 57 | } |
58 | 58 | ?> |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | <?php lsx_content_wrap_before(); ?> |
11 | 11 | |
12 | 12 | <?php |
13 | - $page_id = get_the_ID(); |
|
14 | - $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id; |
|
13 | + $page_id = get_the_ID(); |
|
14 | + $redirect = '/content-restricted/?r=' . $page_id . '&wcm_redirect_to=archive&wcm_redirect_id=' . $page_id; |
|
15 | 15 | ?> |
16 | 16 | |
17 | 17 | <div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>"> |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | |
21 | 21 | <!-- Begining restricted content --> |
22 | 22 | <?php |
23 | - if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) { |
|
24 | - ?> |
|
23 | + if ( current_user_can( 'wc_memberships_view_restricted_post_content', $post_id ) ) { |
|
24 | + ?> |
|
25 | 25 | <main id="main" role="main"> |
26 | 26 | |
27 | 27 | <?php lsx_content_top(); ?> |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | <div class="row"> |
31 | 31 | <?php if ( have_posts() ) : ?> |
32 | 32 | <?php |
33 | - while ( have_posts() ) : |
|
34 | - the_post(); |
|
35 | - ?> |
|
33 | + while ( have_posts() ) : |
|
34 | + the_post(); |
|
35 | + ?> |
|
36 | 36 | |
37 | 37 | <?php include LSX_HEALTH_PLAN_PATH . '/templates/content-archive-exercise.php'; ?> |
38 | 38 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | </main><!-- #main --> |
52 | 52 | |
53 | 53 | <?php |
54 | - } else { |
|
55 | - wp_redirect( $redirect ); |
|
56 | - exit; |
|
57 | - } |
|
58 | - ?> |
|
54 | + } else { |
|
55 | + wp_redirect( $redirect ); |
|
56 | + exit; |
|
57 | + } |
|
58 | + ?> |
|
59 | 59 | |
60 | 60 | <?php lsx_content_after(); ?> |
61 | 61 |
@@ -38,9 +38,12 @@ |
||
38 | 38 | |
39 | 39 | <?php endwhile; ?> |
40 | 40 | |
41 | - <?php else : ?> |
|
41 | + <?php else { |
|
42 | + : ?> |
|
42 | 43 | |
43 | - <?php get_template_part( 'partials/content', 'none' ); ?> |
|
44 | + <?php get_template_part( 'partials/content', 'none' ); |
|
45 | +} |
|
46 | +?> |
|
44 | 47 | |
45 | 48 | <?php endif; ?> |
46 | 49 | </div> |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | |
10 | 10 | <?php lsx_content_wrap_before(); ?> |
11 | 11 | |
12 | -<div id="primary" class="content-area <?php echo esc_attr( lsx_main_class() ); ?>"> |
|
12 | +<div id="primary" class="content-area <?php echo esc_attr(lsx_main_class()); ?>"> |
|
13 | 13 | |
14 | 14 | <?php lsx_content_before(); ?> |
15 | 15 | |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | |
18 | 18 | <?php lsx_content_top(); ?> |
19 | 19 | |
20 | - <?php if ( have_posts() ) : ?> |
|
20 | + <?php if (have_posts()) : ?> |
|
21 | 21 | |
22 | 22 | <?php |
23 | - while ( have_posts() ) : |
|
23 | + while (have_posts()) : |
|
24 | 24 | the_post(); |
25 | 25 | ?> |
26 | 26 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | <?php lsx_content_after(); ?> |
38 | 38 | |
39 | 39 | <?php |
40 | - if ( is_singular( 'post' ) ) { |
|
40 | + if (is_singular('post')) { |
|
41 | 41 | lsx_post_nav(); |
42 | 42 | } |
43 | 43 | ?> |
@@ -20,9 +20,9 @@ discard block |
||
20 | 20 | <?php if ( have_posts() ) : ?> |
21 | 21 | |
22 | 22 | <?php |
23 | - while ( have_posts() ) : |
|
24 | - the_post(); |
|
25 | - ?> |
|
23 | + while ( have_posts() ) : |
|
24 | + the_post(); |
|
25 | + ?> |
|
26 | 26 | |
27 | 27 | <?php include LSX_HEALTH_PLAN_PATH . '/templates/content-recipe.php'; ?> |
28 | 28 | |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | <?php lsx_content_after(); ?> |
38 | 38 | |
39 | 39 | <?php |
40 | - if ( is_singular( 'post' ) ) { |
|
41 | - lsx_post_nav(); |
|
42 | - } |
|
43 | - ?> |
|
40 | + if ( is_singular( 'post' ) ) { |
|
41 | + lsx_post_nav(); |
|
42 | + } |
|
43 | + ?> |
|
44 | 44 | |
45 | 45 | </div><!-- #primary --> |
46 | 46 |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | */ |
15 | 15 | function restricted_content() { |
16 | 16 | $content = ''; |
17 | - if ( ! is_user_logged_in() ) { |
|
17 | + if ( ! is_user_logged_in()) { |
|
18 | 18 | ob_start(); |
19 | - echo do_shortcode( '[woocommerce_my_account]' ); |
|
19 | + echo do_shortcode('[woocommerce_my_account]'); |
|
20 | 20 | $content = ob_get_clean(); |
21 | 21 | } |
22 | 22 | return $content; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return void |
53 | 53 | */ |
54 | -function all_plans_box( $args = array() ) { |
|
54 | +function all_plans_box($args = array()) { |
|
55 | 55 | |
56 | 56 | ob_start(); |
57 | 57 | echo lsx_health_plan_all_plans_block(); // WPCS: XSS OK. |
@@ -64,18 +64,18 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return void |
66 | 66 | */ |
67 | -function day_plan_box( $args = array() ) { |
|
67 | +function day_plan_box($args = array()) { |
|
68 | 68 | $defaults = array( |
69 | 69 | 'week_view' => false, |
70 | 70 | 'show_downloads' => false, |
71 | 71 | 'plan' => '', |
72 | 72 | ); |
73 | - $args = wp_parse_args( $args, $defaults ); |
|
73 | + $args = wp_parse_args($args, $defaults); |
|
74 | 74 | ob_start(); |
75 | - if ( false === $args['week_view'] ) { |
|
76 | - echo lsx_health_plan_day_plan_block( $args ); // WPCS: XSS OK. |
|
75 | + if (false === $args['week_view']) { |
|
76 | + echo lsx_health_plan_day_plan_block($args); // WPCS: XSS OK. |
|
77 | 77 | } else { |
78 | - echo lsx_health_plan_week_plan_block( $args ); // WPCS: XSS OK. |
|
78 | + echo lsx_health_plan_week_plan_block($args); // WPCS: XSS OK. |
|
79 | 79 | } |
80 | 80 | $content = ob_get_clean(); |
81 | 81 | return $content; |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param array $args |
88 | 88 | * @return void |
89 | 89 | */ |
90 | -function exercise_box( $args = array() ) { |
|
90 | +function exercise_box($args = array()) { |
|
91 | 91 | $defaults = array( |
92 | 92 | 'include' => '', |
93 | 93 | 'term' => '', |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | 'parent' => false, |
107 | 107 | 'modal_content' => 'excerpt', |
108 | 108 | ); |
109 | - $args = wp_parse_args( $args, $defaults ); |
|
109 | + $args = wp_parse_args($args, $defaults); |
|
110 | 110 | ob_start(); |
111 | - echo lsx_health_plan_items( $args ); // WPCS: XSS OK. |
|
111 | + echo lsx_health_plan_items($args); // WPCS: XSS OK. |
|
112 | 112 | $content = ob_get_clean(); |
113 | 113 | return $content; |
114 | 114 | } |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | echo lsx_health_plan_featured_video_block(); // WPCS: XSS OK. |
124 | 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 ); |
|
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 | 128 | return $content; |
129 | 129 | } |
130 | 130 | |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | ob_start(); |
138 | 138 | echo lsx_health_plan_featured_recipes_block(); // WPCS: XSS OK. |
139 | 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 ); |
|
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 | 142 | return $content; |
143 | 143 | } |
144 | 144 | |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | ob_start(); |
152 | 152 | echo lsx_health_plan_featured_tips_block(); // WPCS: XSS OK. |
153 | 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 ); |
|
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 | 156 | return $content; |
157 | 157 | } |
158 | 158 | |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | */ |
164 | 164 | function account_notices() { |
165 | 165 | $content = ''; |
166 | - if ( function_exists( 'wc_print_notices' ) ) { |
|
167 | - $content = wc_print_notices( true ); |
|
166 | + if (function_exists('wc_print_notices')) { |
|
167 | + $content = wc_print_notices(true); |
|
168 | 168 | } |
169 | 169 | return $content; |
170 | 170 | } |
@@ -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 | } |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | global $product; |
11 | 11 | |
12 | 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() ); |
|
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 | 15 | } |
16 | - if ( true === $restricted && \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
|
16 | + if (true === $restricted && \lsx_health_plan\functions\woocommerce\plan_has_products()) { |
|
17 | 17 | $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
18 | - $product_count = count( $products ); |
|
19 | - if ( 1 === (int) $product_count ) { |
|
18 | + $product_count = count($products); |
|
19 | + if (1 === (int) $product_count) { |
|
20 | 20 | $class = 'col-md-12'; |
21 | 21 | } else { |
22 | 22 | $class = 'col-md-6'; |
@@ -24,25 +24,25 @@ discard block |
||
24 | 24 | ?> |
25 | 25 | <div class="plans-products-wrapper row"> |
26 | 26 | <?php |
27 | - foreach ( $products as $product ) { |
|
28 | - $product = wc_get_product( $product ); |
|
27 | + foreach ($products as $product) { |
|
28 | + $product = wc_get_product($product); |
|
29 | 29 | ?> |
30 | - <div class="plan-product <?php echo esc_attr( $class ); ?>"> |
|
31 | - <h3 class="title"><a href="<?php echo esc_html( $product->get_permalink() ); ?>"><?php echo esc_html( $product->get_title() ); ?></a></h3> |
|
30 | + <div class="plan-product <?php echo esc_attr($class); ?>"> |
|
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 ) { |
|
33 | + $description = $product->is_type('variation') ? $product->get_description() : $product->get_short_description(); |
|
34 | + if ('' !== $description) { |
|
35 | 35 | ?> |
36 | 36 | <div class="description"> |
37 | - <?php echo esc_html( $description ); ?> |
|
37 | + <?php echo esc_html($description); ?> |
|
38 | 38 | </div> |
39 | 39 | <?php |
40 | 40 | } |
41 | 41 | ?> |
42 | - <?php echo wp_kses_post( $product->get_price_html() ); ?> |
|
42 | + <?php echo wp_kses_post($product->get_price_html()); ?> |
|
43 | 43 | |
44 | 44 | <div class="add-to-cart"> |
45 | - <a class="btn cta-btn" href="<?php echo esc_attr( $product->add_to_cart_url() ); ?>"><?php echo esc_attr( $product->add_to_cart_text() ); ?></a> |
|
45 | + <a class="btn cta-btn" href="<?php echo esc_attr($product->add_to_cart_url()); ?>"><?php echo esc_attr($product->add_to_cart_text()); ?></a> |
|
46 | 46 | </div> |
47 | 47 | </div> |
48 | 48 | <?php |
@@ -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 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | function plan_has_products() { |
16 | 16 | $lsx_hp = lsx_health_plan(); |
17 | 17 | $has_products = false; |
18 | - if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) { |
|
18 | + if ( ! empty($lsx_hp->integrations->woocommerce->plans->product_ids)) { |
|
19 | 19 | $has_products = true; |
20 | 20 | } |
21 | 21 | return $has_products; |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | function get_plan_products() { |
30 | 30 | $lsx_hp = lsx_health_plan(); |
31 | 31 | $has_products = array(); |
32 | - if ( ! empty( $lsx_hp->integrations->woocommerce->plans->product_ids ) ) { |
|
32 | + if ( ! empty($lsx_hp->integrations->woocommerce->plans->product_ids)) { |
|
33 | 33 | $has_products = $lsx_hp->integrations->woocommerce->plans->product_ids; |
34 | 34 | } |
35 | 35 | return $has_products; |
@@ -42,20 +42,20 @@ discard block |
||
42 | 42 | */ |
43 | 43 | function get_membership_products() { |
44 | 44 | $product_ids = array(); |
45 | - if ( function_exists( 'wc_memberships_get_user_memberships' ) ) { |
|
45 | + if (function_exists('wc_memberships_get_user_memberships')) { |
|
46 | 46 | $user_memberships = wc_memberships_get_user_memberships(); |
47 | 47 | |
48 | - if ( ! empty( $user_memberships ) ) { |
|
49 | - foreach ( $user_memberships as $membership ) { |
|
48 | + if ( ! empty($user_memberships)) { |
|
49 | + foreach ($user_memberships as $membership) { |
|
50 | 50 | $current_products = $membership->plan->get_product_ids(); |
51 | - if ( ! empty( $current_products ) ) { |
|
52 | - $product_ids = array_merge( $product_ids, $current_products ); |
|
51 | + if ( ! empty($current_products)) { |
|
52 | + $product_ids = array_merge($product_ids, $current_products); |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
57 | - if ( ! empty( $product_ids ) ) { |
|
58 | - $product_ids = array_unique( $product_ids ); |
|
57 | + if ( ! empty($product_ids)) { |
|
58 | + $product_ids = array_unique($product_ids); |
|
59 | 59 | } |
60 | 60 | return $product_ids; |
61 | 61 | } |
@@ -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 ); |
|
17 | + remove_action('lsx_content_sharing', 'lsx_sharing_output', 20); |
|
18 | 18 | ob_start(); |
19 | 19 | include LSX_HEALTH_PLAN_PATH . '/templates/content-recipe.php'; |
20 | 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 ); |
|
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 | } |
@@ -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 | } |