@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function __construct() { |
55 | 55 | $this->load_classes(); |
56 | - add_action( 'admin_menu', array( $this, 'order_menus' ), 200 ); |
|
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
58 | - add_filter( 'cmb2_override_meta_save', array( $this, 'save_previous_values' ), 20, 4 ); |
|
59 | - add_filter( 'cmb2_override_meta_remove', array( $this, 'save_previous_values' ), 20, 4 ); |
|
60 | - add_action( 'cmb2_save_field', array( $this, 'post_relations' ), 20, 4 ); |
|
61 | - add_action( 'before_delete_post', array( $this, 'delete_post_meta_connections' ), 20, 1 ); |
|
56 | + add_action('admin_menu', array($this, 'order_menus'), 200); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'assets')); |
|
58 | + add_filter('cmb2_override_meta_save', array($this, 'save_previous_values'), 20, 4); |
|
59 | + add_filter('cmb2_override_meta_remove', array($this, 'save_previous_values'), 20, 4); |
|
60 | + add_action('cmb2_save_field', array($this, 'post_relations'), 20, 4); |
|
61 | + add_action('before_delete_post', array($this, 'delete_post_meta_connections'), 20, 1); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public static function get_instance() { |
70 | 70 | // If the single instance hasn't been set, set it now. |
71 | - if ( null === self::$instance ) { |
|
71 | + if (null === self::$instance) { |
|
72 | 72 | self::$instance = new self(); |
73 | 73 | } |
74 | 74 | return self::$instance; |
@@ -95,57 +95,57 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function order_menus() { |
97 | 97 | global $menu, $submenu; |
98 | - if ( ! empty( $submenu ) ) { |
|
98 | + if ( ! empty($submenu)) { |
|
99 | 99 | $parent_check = array( |
100 | 100 | 'edit.php?post_type=plan', |
101 | 101 | 'edit.php?post_type=workout', |
102 | 102 | 'edit.php?post_type=meal', |
103 | 103 | ); |
104 | - foreach ( $submenu as $menu_id => $menu_values ) { |
|
105 | - if ( in_array( $menu_id, $parent_check ) ) { |
|
106 | - foreach ( $menu_values as $sub_menu_key => $sub_menu_values ) { |
|
107 | - switch ( $sub_menu_values[0] ) { |
|
104 | + foreach ($submenu as $menu_id => $menu_values) { |
|
105 | + if (in_array($menu_id, $parent_check)) { |
|
106 | + foreach ($menu_values as $sub_menu_key => $sub_menu_values) { |
|
107 | + switch ($sub_menu_values[0]) { |
|
108 | 108 | |
109 | - case __( 'Add New', 'lsx-health-plan' ): |
|
110 | - unset( $submenu[ $menu_id ][ $sub_menu_key ] ); |
|
109 | + case __('Add New', 'lsx-health-plan'): |
|
110 | + unset($submenu[$menu_id][$sub_menu_key]); |
|
111 | 111 | break; |
112 | 112 | |
113 | - case __( 'All', 'lsx-health-plan' ): |
|
113 | + case __('All', 'lsx-health-plan'): |
|
114 | 114 | $title = $sub_menu_values[0]; |
115 | 115 | // Check and change the label. |
116 | - switch ( $sub_menu_values[2] ) { |
|
116 | + switch ($sub_menu_values[2]) { |
|
117 | 117 | case 'edit.php?post_type=meal': |
118 | - $title = esc_attr__( 'Meals', 'lsx-health-plan' ); |
|
118 | + $title = esc_attr__('Meals', 'lsx-health-plan'); |
|
119 | 119 | break; |
120 | 120 | |
121 | 121 | case 'edit.php?post_type=recipe': |
122 | - $title = esc_attr__( 'Recipes', 'lsx-health-plan' ); |
|
122 | + $title = esc_attr__('Recipes', 'lsx-health-plan'); |
|
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'edit.php?post_type=workout': |
126 | - $title = esc_attr__( 'Workouts', 'lsx-health-plan' ); |
|
126 | + $title = esc_attr__('Workouts', 'lsx-health-plan'); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | case 'edit.php?post_type=plan': |
130 | - $title = esc_attr__( 'Plans', 'lsx-health-plan' ); |
|
130 | + $title = esc_attr__('Plans', 'lsx-health-plan'); |
|
131 | 131 | break; |
132 | 132 | |
133 | 133 | case 'edit.php?post_type=video': |
134 | - $title = esc_attr__( 'Videos', 'lsx-health-plan' ); |
|
134 | + $title = esc_attr__('Videos', 'lsx-health-plan'); |
|
135 | 135 | break; |
136 | 136 | |
137 | 137 | case 'edit.php?post_type=exercise': |
138 | - $title = esc_attr__( 'Exercises', 'lsx-health-plan' ); |
|
138 | + $title = esc_attr__('Exercises', 'lsx-health-plan'); |
|
139 | 139 | break; |
140 | 140 | |
141 | 141 | case 'edit.php?post_type=tip': |
142 | - $title = esc_attr__( 'Tips', 'lsx-health-plan' ); |
|
142 | + $title = esc_attr__('Tips', 'lsx-health-plan'); |
|
143 | 143 | break; |
144 | 144 | |
145 | 145 | default: |
146 | 146 | break; |
147 | 147 | } |
148 | - $submenu[ $menu_id ][ $sub_menu_key ][0] = $title; // @codingStandardsIgnoreLine |
|
148 | + $submenu[$menu_id][$sub_menu_key][0] = $title; // @codingStandardsIgnoreLine |
|
149 | 149 | break; |
150 | 150 | |
151 | 151 | default: |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | * @return void |
164 | 164 | */ |
165 | 165 | public function assets() { |
166 | - wp_enqueue_script( 'media-upload' ); |
|
167 | - wp_enqueue_script( 'thickbox' ); |
|
168 | - wp_enqueue_style( 'thickbox' ); |
|
166 | + wp_enqueue_script('media-upload'); |
|
167 | + wp_enqueue_script('thickbox'); |
|
168 | + wp_enqueue_style('thickbox'); |
|
169 | 169 | |
170 | - wp_enqueue_script( 'lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-admin.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
171 | - wp_enqueue_style( 'lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan-admin.css', array(), LSX_HEALTH_PLAN_VER ); |
|
170 | + wp_enqueue_script('lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/js/lsx-health-plan-admin.min.js', array('jquery'), LSX_HEALTH_PLAN_VER, true); |
|
171 | + wp_enqueue_style('lsx-health-plan-admin', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan-admin.css', array(), LSX_HEALTH_PLAN_VER); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | * @return void |
178 | 178 | */ |
179 | 179 | public function get_connections() { |
180 | - return apply_filters( 'lsx_health_plan_connections', $this->connections ); |
|
180 | + return apply_filters('lsx_health_plan_connections', $this->connections); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | * @param [type] $cmb2 |
190 | 190 | * @return void |
191 | 191 | */ |
192 | - public function save_previous_values( $value_to_save, $a, $args, $cmb2 ) { |
|
193 | - if ( isset( $cmb2->data_to_save['ID'] ) ) { |
|
192 | + public function save_previous_values($value_to_save, $a, $args, $cmb2) { |
|
193 | + if (isset($cmb2->data_to_save['ID'])) { |
|
194 | 194 | $connections = $this->get_connections(); |
195 | - $post_type = get_post_type( $cmb2->data_to_save['ID'] ); |
|
196 | - if ( isset( $connections[ $post_type ] ) && array_key_exists( $a['field_id'], $connections[ $post_type ] ) ) { |
|
195 | + $post_type = get_post_type($cmb2->data_to_save['ID']); |
|
196 | + if (isset($connections[$post_type]) && array_key_exists($a['field_id'], $connections[$post_type])) { |
|
197 | 197 | // Get the previous values if the field, so we can run through them and remove the current ID from them later. |
198 | - $this->previous_values = get_post_meta( $a['id'], $a['field_id'], true ); |
|
198 | + $this->previous_values = get_post_meta($a['id'], $a['field_id'], true); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | return $value_to_save; |
@@ -206,30 +206,30 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return void |
208 | 208 | */ |
209 | - public function post_relations( $field_id, $updated, $action, $cmb2 ) { |
|
209 | + public function post_relations($field_id, $updated, $action, $cmb2) { |
|
210 | 210 | // If the connections are empty then skip this function. |
211 | 211 | $connections = $this->get_connections(); |
212 | - if ( empty( $connections ) ) { |
|
212 | + if (empty($connections)) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | 216 | // If the field has been updated. |
217 | - if ( isset( $cmb2->data_to_save['ID'] ) ) { |
|
218 | - $post_type = get_post_type( $cmb2->data_to_save['ID'] ); |
|
219 | - if ( isset( $connections[ $post_type ] ) && array_key_exists( $field_id, $connections[ $post_type ] ) ) { |
|
220 | - $saved_values = get_post_meta( $cmb2->data_to_save['ID'], $field_id, true ); |
|
217 | + if (isset($cmb2->data_to_save['ID'])) { |
|
218 | + $post_type = get_post_type($cmb2->data_to_save['ID']); |
|
219 | + if (isset($connections[$post_type]) && array_key_exists($field_id, $connections[$post_type])) { |
|
220 | + $saved_values = get_post_meta($cmb2->data_to_save['ID'], $field_id, true); |
|
221 | 221 | |
222 | - if ( 'updated' === $action ) { |
|
223 | - $this->add_connected_posts( $saved_values, $cmb2->data_to_save['ID'], $connections[ $post_type ][ $field_id ] ); |
|
222 | + if ('updated' === $action) { |
|
223 | + $this->add_connected_posts($saved_values, $cmb2->data_to_save['ID'], $connections[$post_type][$field_id]); |
|
224 | 224 | // Check if any posts have been removed. |
225 | - if ( count( $this->previous_values ) > count( $saved_values ) ) { |
|
226 | - $posts_to_remove = array_diff( $this->previous_values, $saved_values ); |
|
227 | - if ( ! empty( $posts_to_remove ) ) { |
|
228 | - $this->remove_connected_posts( $posts_to_remove, $cmb2->data_to_save['ID'], $connections[ $post_type ][ $field_id ] ); |
|
225 | + if (count($this->previous_values) > count($saved_values)) { |
|
226 | + $posts_to_remove = array_diff($this->previous_values, $saved_values); |
|
227 | + if ( ! empty($posts_to_remove)) { |
|
228 | + $this->remove_connected_posts($posts_to_remove, $cmb2->data_to_save['ID'], $connections[$post_type][$field_id]); |
|
229 | 229 | } |
230 | 230 | } |
231 | - } else if ( 'removed' === $action && ! empty( $this->previous_values ) ) { |
|
232 | - $this->remove_connected_posts( $this->previous_values, $cmb2->data_to_save['ID'], $connections[ $post_type ][ $field_id ] ); |
|
231 | + } else if ('removed' === $action && ! empty($this->previous_values)) { |
|
232 | + $this->remove_connected_posts($this->previous_values, $cmb2->data_to_save['ID'], $connections[$post_type][$field_id]); |
|
233 | 233 | } |
234 | 234 | } |
235 | 235 | } |
@@ -243,26 +243,26 @@ discard block |
||
243 | 243 | * @param [type] $connected_key |
244 | 244 | * @return void |
245 | 245 | */ |
246 | - public function add_connected_posts( $values, $current_id, $connected_key ) { |
|
247 | - foreach ( $values as $value ) { |
|
248 | - $current_post_array = get_post_meta( $value, $connected_key, true ); |
|
246 | + public function add_connected_posts($values, $current_id, $connected_key) { |
|
247 | + foreach ($values as $value) { |
|
248 | + $current_post_array = get_post_meta($value, $connected_key, true); |
|
249 | 249 | $previous_values = $current_post_array; |
250 | 250 | |
251 | - if ( ! empty( $current_post_array ) ) { |
|
252 | - $current_post_array = array_map( 'strval', $current_post_array ); |
|
253 | - array_unique( $current_post_array ); |
|
251 | + if ( ! empty($current_post_array)) { |
|
252 | + $current_post_array = array_map('strval', $current_post_array); |
|
253 | + array_unique($current_post_array); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | // If the current connected post has no saved connections then we create it. |
257 | - if ( false === $current_post_array || empty( $current_post_array ) ) { |
|
258 | - $current_post_array = array( $current_id ); |
|
259 | - } elseif ( ! in_array( (string) $current_id, $current_post_array, true ) ) { |
|
257 | + if (false === $current_post_array || empty($current_post_array)) { |
|
258 | + $current_post_array = array($current_id); |
|
259 | + } elseif ( ! in_array((string) $current_id, $current_post_array, true)) { |
|
260 | 260 | $current_post_array[] = $current_id; |
261 | 261 | } |
262 | 262 | |
263 | 263 | // Check if the values are empty, if not update them. |
264 | - if ( ! empty( $current_post_array ) ) { |
|
265 | - update_post_meta( $value, $connected_key, $current_post_array, $previous_values ); |
|
264 | + if ( ! empty($current_post_array)) { |
|
265 | + update_post_meta($value, $connected_key, $current_post_array, $previous_values); |
|
266 | 266 | } |
267 | 267 | } |
268 | 268 | } |
@@ -275,25 +275,25 @@ discard block |
||
275 | 275 | * @param [type] $connected_key |
276 | 276 | * @return void |
277 | 277 | */ |
278 | - public function remove_connected_posts( $values, $current_ID, $connected_key ) { |
|
279 | - foreach ( $values as $value ) { |
|
280 | - $current_post_array = get_post_meta( $value, $connected_key, true ); |
|
278 | + public function remove_connected_posts($values, $current_ID, $connected_key) { |
|
279 | + foreach ($values as $value) { |
|
280 | + $current_post_array = get_post_meta($value, $connected_key, true); |
|
281 | 281 | $new_array = array(); |
282 | 282 | // Loop through only if the current ID has been saved against the post. |
283 | - if ( in_array( $current_ID, $current_post_array, false ) ) { |
|
283 | + if (in_array($current_ID, $current_post_array, false)) { |
|
284 | 284 | |
285 | 285 | // Loop through all the connected saved IDS. |
286 | - foreach ( $current_post_array as $cpa ) { |
|
287 | - if ( (int) $cpa !== (int) $current_ID ) { |
|
286 | + foreach ($current_post_array as $cpa) { |
|
287 | + if ((int) $cpa !== (int) $current_ID) { |
|
288 | 288 | $new_array[] = $cpa; |
289 | 289 | } |
290 | 290 | } |
291 | - if ( ! empty( $new_array ) ) { |
|
292 | - $new_array = array_unique( $new_array ); |
|
293 | - delete_post_meta( $value, $connected_key ); |
|
294 | - add_post_meta( $value, $connected_key, $new_array, true ); |
|
291 | + if ( ! empty($new_array)) { |
|
292 | + $new_array = array_unique($new_array); |
|
293 | + delete_post_meta($value, $connected_key); |
|
294 | + add_post_meta($value, $connected_key, $new_array, true); |
|
295 | 295 | } else { |
296 | - delete_post_meta( $value, $connected_key ); |
|
296 | + delete_post_meta($value, $connected_key); |
|
297 | 297 | } |
298 | 298 | } |
299 | 299 | } |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | * @param string $item_id |
306 | 306 | * @return void |
307 | 307 | */ |
308 | - public function delete_post_meta_connections( $item_id = '' ) { |
|
309 | - if ( '' !== $item_id ) { |
|
310 | - $post_type = get_post_type( $item_id ); |
|
308 | + public function delete_post_meta_connections($item_id = '') { |
|
309 | + if ('' !== $item_id) { |
|
310 | + $post_type = get_post_type($item_id); |
|
311 | 311 | $connections = $this->get_connections(); |
312 | - if ( isset( $connections[ $post_type ] ) && ! empty( $connections[ $post_type ] ) && is_array( $connections[ $post_type ] ) ) { |
|
313 | - foreach ( $connections[ $post_type ] as $this_key => $connected_key ) { |
|
314 | - $this->delete_connected_items( $item_id, $this_key, $connected_key ); |
|
312 | + if (isset($connections[$post_type]) && ! empty($connections[$post_type]) && is_array($connections[$post_type])) { |
|
313 | + foreach ($connections[$post_type] as $this_key => $connected_key) { |
|
314 | + $this->delete_connected_items($item_id, $this_key, $connected_key); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | } |
@@ -325,23 +325,23 @@ discard block |
||
325 | 325 | * @param string $connected_key |
326 | 326 | * @return void |
327 | 327 | */ |
328 | - public function delete_connected_items( $item_id = '', $this_key, $connected_key ) { |
|
329 | - if ( '' !== $item_id ) { |
|
330 | - $connected_items = get_post_meta( $item_id, $this_key, true ); |
|
331 | - if ( ! empty( $connected_items ) ) { |
|
332 | - foreach ( $connected_items as $con_id ) { |
|
328 | + public function delete_connected_items($item_id = '', $this_key, $connected_key) { |
|
329 | + if ('' !== $item_id) { |
|
330 | + $connected_items = get_post_meta($item_id, $this_key, true); |
|
331 | + if ( ! empty($connected_items)) { |
|
332 | + foreach ($connected_items as $con_id) { |
|
333 | 333 | // Get the connected item array from the connected item. |
334 | - $their_connections = get_post_meta( $con_id, $connected_key, true ); |
|
335 | - if ( ! empty( $their_connections ) ) { |
|
334 | + $their_connections = get_post_meta($con_id, $connected_key, true); |
|
335 | + if ( ! empty($their_connections)) { |
|
336 | 336 | $new_connections = $their_connections; |
337 | 337 | // Run through the array and remove the post to be deleteds ID. |
338 | - foreach ( $their_connections as $ckey => $cvalue ) { |
|
339 | - if ( (int) $item_id === (int) $cvalue ) { |
|
340 | - unset( $new_connections[ $ckey ] ); |
|
338 | + foreach ($their_connections as $ckey => $cvalue) { |
|
339 | + if ((int) $item_id === (int) $cvalue) { |
|
340 | + unset($new_connections[$ckey]); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | // Now we save the field. |
344 | - update_post_meta( $con_id, $connected_key, $new_connections, $their_connections ); |
|
344 | + update_post_meta($con_id, $connected_key, $new_connections, $their_connections); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
@@ -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', |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * Contructor |
27 | 27 | */ |
28 | 28 | public function __construct() { |
29 | - add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); |
|
30 | - add_action( 'wp_head', array( $this, 'load_shortcodes' ) ); |
|
29 | + add_action('init', array($this, 'load_plugin_textdomain')); |
|
30 | + add_action('wp_head', array($this, 'load_shortcodes')); |
|
31 | 31 | $this->load_classes(); |
32 | 32 | } |
33 | 33 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public static function get_instance() { |
42 | 42 | |
43 | 43 | // If the single instance hasn't been set, set it now. |
44 | - if ( null === self::$instance ) { |
|
44 | + if (null === self::$instance) { |
|
45 | 45 | self::$instance = new self(); |
46 | 46 | } |
47 | 47 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * Adds text domain. |
54 | 54 | */ |
55 | 55 | public function load_plugin_textdomain() { |
56 | - load_plugin_textdomain( 'lsx-health-plan', false, basename( LSX_HEALTH_PLAN_PATH ) . '/languages' ); |
|
56 | + load_plugin_textdomain('lsx-health-plan', false, basename(LSX_HEALTH_PLAN_PATH) . '/languages'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -72,21 +72,21 @@ discard block |
||
72 | 72 | * @return void |
73 | 73 | */ |
74 | 74 | public function load_shortcodes() { |
75 | - add_shortcode( 'lsx_health_plan_restricted_content', '\lsx_health_plan\shortcodes\restricted_content' ); |
|
76 | - add_shortcode( 'lsx_health_plan_my_profile_tabs', '\lsx_health_plan\shortcodes\my_profile_tabs' ); |
|
77 | - add_shortcode( 'lsx_health_plan_my_profile_block', '\lsx_health_plan\shortcodes\my_profile_box' ); |
|
78 | - add_shortcode( 'lsx_health_plan_day_plan_block', '\lsx_health_plan\shortcodes\day_plan_box' ); |
|
79 | - add_shortcode( 'lsx_health_plan_account_notices', '\lsx_health_plan\shortcodes\account_notices' ); |
|
75 | + add_shortcode('lsx_health_plan_restricted_content', '\lsx_health_plan\shortcodes\restricted_content'); |
|
76 | + add_shortcode('lsx_health_plan_my_profile_tabs', '\lsx_health_plan\shortcodes\my_profile_tabs'); |
|
77 | + add_shortcode('lsx_health_plan_my_profile_block', '\lsx_health_plan\shortcodes\my_profile_box'); |
|
78 | + add_shortcode('lsx_health_plan_day_plan_block', '\lsx_health_plan\shortcodes\day_plan_box'); |
|
79 | + add_shortcode('lsx_health_plan_account_notices', '\lsx_health_plan\shortcodes\account_notices'); |
|
80 | 80 | |
81 | - if ( post_type_exists( 'video' ) ) { |
|
82 | - add_shortcode( 'lsx_health_plan_featured_video_block', '\lsx_health_plan\shortcodes\feature_video_box' ); |
|
81 | + if (post_type_exists('video')) { |
|
82 | + add_shortcode('lsx_health_plan_featured_video_block', '\lsx_health_plan\shortcodes\feature_video_box'); |
|
83 | 83 | } |
84 | - if ( post_type_exists( 'recipe' ) ) { |
|
85 | - add_shortcode( 'lsx_health_plan_featured_recipes_block', '\lsx_health_plan\shortcodes\feature_recipes_box' ); |
|
84 | + if (post_type_exists('recipe')) { |
|
85 | + add_shortcode('lsx_health_plan_featured_recipes_block', '\lsx_health_plan\shortcodes\feature_recipes_box'); |
|
86 | 86 | } |
87 | - if ( post_type_exists( 'tip' ) ) { |
|
88 | - add_shortcode( 'lsx_health_plan_featured_tips_block', '\lsx_health_plan\shortcodes\feature_tips_box' ); |
|
87 | + if (post_type_exists('tip')) { |
|
88 | + add_shortcode('lsx_health_plan_featured_tips_block', '\lsx_health_plan\shortcodes\feature_tips_box'); |
|
89 | 89 | } |
90 | - add_shortcode( 'lsx_health_plan_items', '\lsx_health_plan\shortcodes\exercise_box' ); |
|
90 | + add_shortcode('lsx_health_plan_items', '\lsx_health_plan\shortcodes\exercise_box'); |
|
91 | 91 | } |
92 | 92 | } |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // If this file is called directly, abort. |
15 | -if ( ! defined( 'WPINC' ) ) { |
|
15 | +if ( ! defined('WPINC')) { |
|
16 | 16 | die; |
17 | 17 | } |
18 | -define( 'LSX_HEALTH_PLAN_PATH', plugin_dir_path( __FILE__ ) ); |
|
19 | -define( 'LSX_HEALTH_PLAN_CORE', __FILE__ ); |
|
20 | -define( 'LSX_HEALTH_PLAN_URL', plugin_dir_url( __FILE__ ) ); |
|
21 | -define( 'LSX_HEALTH_PLAN_VER', '1.4.0' ); |
|
18 | +define('LSX_HEALTH_PLAN_PATH', plugin_dir_path(__FILE__)); |
|
19 | +define('LSX_HEALTH_PLAN_CORE', __FILE__); |
|
20 | +define('LSX_HEALTH_PLAN_URL', plugin_dir_url(__FILE__)); |
|
21 | +define('LSX_HEALTH_PLAN_VER', '1.4.0'); |
|
22 | 22 | |
23 | 23 | /* ======================= Below is the Plugin Class init ========================= */ |
24 | 24 | |
@@ -31,22 +31,22 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function lsx_remove_extra_meta_box() { |
33 | 33 | global $wp_meta_boxes; |
34 | - $all_post_types = [ 'plan', 'video', 'workout', 'tip', 'recipe', 'meal' ]; |
|
34 | + $all_post_types = ['plan', 'video', 'workout', 'tip', 'recipe', 'meal']; |
|
35 | 35 | //remove_meta_box( 'wpseo_meta', $all_post_types, 'normal' ); |
36 | - remove_meta_box( 'commentsdiv', $all_post_types, 'normal' ); |
|
37 | - remove_meta_box( 'commentstatusdiv', $all_post_types, 'normal' ); |
|
38 | - remove_meta_box( 'lsx_blocks_title_meta', $all_post_types, 'side' ); |
|
36 | + remove_meta_box('commentsdiv', $all_post_types, 'normal'); |
|
37 | + remove_meta_box('commentstatusdiv', $all_post_types, 'normal'); |
|
38 | + remove_meta_box('lsx_blocks_title_meta', $all_post_types, 'side'); |
|
39 | 39 | } |
40 | -add_action( 'add_meta_boxes', 'lsx_remove_extra_meta_box', 100 ); |
|
40 | +add_action('add_meta_boxes', 'lsx_remove_extra_meta_box', 100); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Create Login page with woocommerce shortcode if the page is not created |
44 | 44 | */ |
45 | -if ( ( isset( $_GET['activated'] ) && function_exists( 'wp_verify_nonce' ) && wp_verify_nonce( sanitize_key( $_GET['activated'] ) ) ) && is_admin() ) { |
|
45 | +if ((isset($_GET['activated']) && function_exists('wp_verify_nonce') && wp_verify_nonce(sanitize_key($_GET['activated']))) && is_admin()) { |
|
46 | 46 | |
47 | 47 | $new_page_title = 'Login'; |
48 | 48 | // Content to add spacing and woocommerce login shortcode |
49 | - $new_page_content = '<!-- wp:lsx-blocks/lsx-container {"containerMaxWidth":600} --> |
|
49 | + $new_page_content = '<!-- wp:lsx-blocks/lsx-container {"containerMaxWidth":600} --> |
|
50 | 50 | <div style="background-color:transparent;padding-left:3%;padding-right:3%;padding-bottom:3%;padding-top:3%;margin-top:3%;margin-bottom:3%" class="wp-block-lsx-blocks-lsx-container aligncenter lsx-block-container"><div class="lsx-container-inside"><div class="lsx-container-content" style="max-width:600px"><!-- wp:paragraph --> |
51 | 51 | <p></p> |
52 | 52 | <!-- /wp:paragraph --> |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | <!-- /wp:lsx-blocks/lsx-container -->'; |
58 | 58 | $new_page_template = ''; |
59 | 59 | |
60 | - $page_check = get_page_by_title( $new_page_title ); |
|
60 | + $page_check = get_page_by_title($new_page_title); |
|
61 | 61 | $new_page = array( |
62 | 62 | 'post_type' => 'page', |
63 | 63 | 'post_title' => $new_page_title, |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | 'post_status' => 'publish', |
66 | 66 | 'post_author' => 1, |
67 | 67 | ); |
68 | - if ( ! isset( $page_check->ID ) ) { |
|
69 | - $new_page_id = wp_insert_post( $new_page ); |
|
70 | - if ( ! empty( $new_page_template ) ) { |
|
71 | - update_post_meta( $new_page_id, '_wp_page_template', $new_page_template ); |
|
68 | + if ( ! isset($page_check->ID)) { |
|
69 | + $new_page_id = wp_insert_post($new_page); |
|
70 | + if ( ! empty($new_page_template)) { |
|
71 | + update_post_meta($new_page_id, '_wp_page_template', $new_page_template); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
@@ -80,18 +80,18 @@ discard block |
||
80 | 80 | * @param [type] $args |
81 | 81 | * @return void |
82 | 82 | */ |
83 | -function lsx_add_login_logout_register_menu( $items, $args ) { |
|
84 | - if ( 'primary' === $args->theme_location ) { |
|
83 | +function lsx_add_login_logout_register_menu($items, $args) { |
|
84 | + if ('primary' === $args->theme_location) { |
|
85 | 85 | ob_start(); |
86 | - wp_loginout( get_permalink() ); |
|
86 | + wp_loginout(get_permalink()); |
|
87 | 87 | $loginoutlink = ob_get_contents(); |
88 | 88 | ob_end_clean(); |
89 | - if ( ! is_user_logged_in() ) { |
|
90 | - $login_slug = \lsx_health_plan\functions\get_option( 'login_slug', false ); |
|
91 | - if ( false === $login_slug ) { |
|
89 | + if ( ! is_user_logged_in()) { |
|
90 | + $login_slug = \lsx_health_plan\functions\get_option('login_slug', false); |
|
91 | + if (false === $login_slug) { |
|
92 | 92 | $login_slug = 'login'; |
93 | 93 | } |
94 | - $items .= '<li class="my-login menu-item"><a rel="nofollow" href="/' . $login_slug . '/">' . __( 'Login', 'lsx-health-plan' ) . '</a></li>'; |
|
94 | + $items .= '<li class="my-login menu-item"><a rel="nofollow" href="/' . $login_slug . '/">' . __('Login', 'lsx-health-plan') . '</a></li>'; |
|
95 | 95 | } else { |
96 | 96 | $items .= '<li class="my-login menu-item">' . $loginoutlink . '</li>'; |
97 | 97 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return $items; |
101 | 101 | } |
102 | 102 | } |
103 | -add_filter( 'wp_nav_menu_items', 'lsx_add_login_logout_register_menu', 199, 2 ); |
|
103 | +add_filter('wp_nav_menu_items', 'lsx_add_login_logout_register_menu', 199, 2); |
|
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Redirect user after login or redirect |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | * @return void |
109 | 109 | */ |
110 | 110 | function lsx_login_redirect() { |
111 | - $plan_slug = \lsx_health_plan\functions\get_option( 'my_plan_slug', false ); |
|
112 | - if ( false === $plan_slug ) { |
|
111 | + $plan_slug = \lsx_health_plan\functions\get_option('my_plan_slug', false); |
|
112 | + if (false === $plan_slug) { |
|
113 | 113 | $plan_slug = 'my-plan'; |
114 | 114 | } |
115 | - return home_url( $plan_slug ); |
|
115 | + return home_url($plan_slug); |
|
116 | 116 | } |
117 | -add_filter( 'woocommerce_login_redirect', 'lsx_login_redirect' ); |
|
117 | +add_filter('woocommerce_login_redirect', 'lsx_login_redirect'); |
|
118 | 118 | |
119 | 119 | /** |
120 | 120 | * Undocumented function |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return void |
133 | 133 | */ |
134 | -function lsx_get_svg_icon( $icon ) { |
|
134 | +function lsx_get_svg_icon($icon) { |
|
135 | 135 | $path = '/assets/images/'; |
136 | 136 | |
137 | - if ( file_exists( LSX_HEALTH_PLAN_PATH . $path . $icon ) ) { |
|
137 | + if (file_exists(LSX_HEALTH_PLAN_PATH . $path . $icon)) { |
|
138 | 138 | // Load and return the contents of the file |
139 | 139 | return include LSX_HEALTH_PLAN_PATH . $path . $icon; |
140 | 140 | } |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return void |
150 | 150 | */ |
151 | -function lsx_workout_snacks( $snack ) { |
|
152 | - $workout_snack = get_post_meta( get_the_ID(), $snack . '_workout_snack', true ); |
|
153 | - if ( ! empty( $workout_snack ) ) { |
|
151 | +function lsx_workout_snacks($snack) { |
|
152 | + $workout_snack = get_post_meta(get_the_ID(), $snack . '_workout_snack', true); |
|
153 | + if ( ! empty($workout_snack)) { |
|
154 | 154 | ?> |
155 | - <div class="<?php echo esc_html( $snack ); ?>-workout workout-snacks"> |
|
155 | + <div class="<?php echo esc_html($snack); ?>-workout workout-snacks"> |
|
156 | 156 | <div class="content-box"> |
157 | 157 | <?php |
158 | - $snack_title = ucfirst( $snack ); |
|
159 | - if ( 'pre' === $snack ) { |
|
158 | + $snack_title = ucfirst($snack); |
|
159 | + if ('pre' === $snack) { |
|
160 | 160 | /* Translators: %s: snack */ |
161 | - $title_text = esc_attr_x( 'Pre-Workout Snack', 'pre workout', 'lsx-health-plan' ); |
|
161 | + $title_text = esc_attr_x('Pre-Workout Snack', 'pre workout', 'lsx-health-plan'); |
|
162 | 162 | } else { |
163 | 163 | /* Translators: %s: snack */ |
164 | - $title_text = esc_attr_x( 'Post-Workout Snack', 'post workout', 'lsx-health-plan' ); |
|
164 | + $title_text = esc_attr_x('Post-Workout Snack', 'post workout', 'lsx-health-plan'); |
|
165 | 165 | } |
166 | - $title = sprintf( $title_text, $snack_title ); |
|
166 | + $title = sprintf($title_text, $snack_title); |
|
167 | 167 | ?> |
168 | - <h3 class="title-lined"><?php echo esc_html( $title ); ?></h3> |
|
169 | - <?php echo wp_kses_post( apply_filters( 'the_content', $workout_snack ) ); ?> |
|
168 | + <h3 class="title-lined"><?php echo esc_html($title); ?></h3> |
|
169 | + <?php echo wp_kses_post(apply_filters('the_content', $workout_snack)); ?> |
|
170 | 170 | </div> |
171 | 171 | </div> |
172 | 172 | <?php |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public static function get_instance() { |
81 | 81 | // If the single instance hasn't been set, set it now. |
82 | - if ( null === self::$instance ) { |
|
82 | + if (null === self::$instance) { |
|
83 | 83 | self::$instance = new self(); |
84 | 84 | } |
85 | 85 | return self::$instance; |
@@ -92,24 +92,24 @@ discard block |
||
92 | 92 | * @param string $post_type |
93 | 93 | * @return boolean |
94 | 94 | */ |
95 | - public function has_gallery( $item_id = '', $post_type = '' ) { |
|
95 | + public function has_gallery($item_id = '', $post_type = '') { |
|
96 | 96 | $this->gallery = array(); |
97 | 97 | $this->has_gallery = false; |
98 | - if ( '' === $item_id ) { |
|
98 | + if ('' === $item_id) { |
|
99 | 99 | $this->item_id = get_the_ID(); |
100 | 100 | } else { |
101 | 101 | $this->item_id = $item_id; |
102 | 102 | } |
103 | 103 | |
104 | - if ( '' === $post_type ) { |
|
105 | - $this->post_type = get_post_type( $this->item_id ); |
|
104 | + if ('' === $post_type) { |
|
105 | + $this->post_type = get_post_type($this->item_id); |
|
106 | 106 | } |
107 | - $gallery = get_post_meta( $this->item_id, $this->post_type . '_gallery', true ); |
|
108 | - if ( ! empty( $gallery ) ) { |
|
107 | + $gallery = get_post_meta($this->item_id, $this->post_type . '_gallery', true); |
|
108 | + if ( ! empty($gallery)) { |
|
109 | 109 | $this->gallery = $gallery; |
110 | 110 | $this->has_gallery = true; |
111 | - wp_enqueue_script( 'slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array( 'jquery' ), LSX_HEALTH_PLAN_VER, true ); |
|
112 | - wp_enqueue_script( 'lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array( 'slick' ), LSX_HEALTH_PLAN_VER, true ); |
|
111 | + wp_enqueue_script('slick', LSX_HEALTH_PLAN_URL . 'assets/js/src/slick.min.js', array('jquery'), LSX_HEALTH_PLAN_VER, true); |
|
112 | + wp_enqueue_script('lsx-health-plan-slider', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-slider.js', array('slick'), LSX_HEALTH_PLAN_VER, true); |
|
113 | 113 | } |
114 | 114 | return $this->has_gallery; |
115 | 115 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | * @param string $post_type |
122 | 122 | * @return array |
123 | 123 | */ |
124 | - public function get_defaults( $item_id = '', $post_type = '' ) { |
|
125 | - if ( '' === $item_id ) { |
|
124 | + public function get_defaults($item_id = '', $post_type = '') { |
|
125 | + if ('' === $item_id) { |
|
126 | 126 | $item_id = $this->item_id; |
127 | 127 | } |
128 | - if ( '' === $post_type ) { |
|
128 | + if ('' === $post_type) { |
|
129 | 129 | $post_type = $this->post_type; |
130 | 130 | } |
131 | 131 | $this->defaults = array( |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | 'interval' => false, |
135 | 135 | 'css_class' => false, |
136 | 136 | ); |
137 | - foreach ( $this->defaults as $key => $default ) { |
|
138 | - $override = get_post_meta( $item_id, $this->post_type . '_gallery_' . $key, true ); |
|
139 | - if ( '' !== $override && false !== $override && ! empty( $override ) ) { |
|
140 | - $this->defaults[ $key ] = $override; |
|
137 | + foreach ($this->defaults as $key => $default) { |
|
138 | + $override = get_post_meta($item_id, $this->post_type . '_gallery_' . $key, true); |
|
139 | + if ('' !== $override && false !== $override && ! empty($override)) { |
|
140 | + $this->defaults[$key] = $override; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | return $this->defaults; |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * @param string $post_type |
151 | 151 | * @return void |
152 | 152 | */ |
153 | - public function get_gallery( $item_id = '', $post_type = '', $args = array() ) { |
|
153 | + public function get_gallery($item_id = '', $post_type = '', $args = array()) { |
|
154 | 154 | $return = ''; |
155 | 155 | $this->html = array(); |
156 | - $this->args = wp_parse_args( $args, $this->get_defaults( $item_id, $post_type ) ); |
|
157 | - if ( ! empty( $this->gallery ) ) { |
|
156 | + $this->args = wp_parse_args($args, $this->get_defaults($item_id, $post_type)); |
|
157 | + if ( ! empty($this->gallery)) { |
|
158 | 158 | $this->args['count'] = 1; |
159 | - if ( '' !== $post_type ) { |
|
159 | + if ('' !== $post_type) { |
|
160 | 160 | $this->args['post_type'] = $post_type; |
161 | 161 | } else { |
162 | 162 | $this->args['post_type'] = $this->post_type; |
@@ -165,20 +165,20 @@ discard block |
||
165 | 165 | // output the opening boostrap row divs. |
166 | 166 | $this->before_loop(); |
167 | 167 | |
168 | - foreach ( $this->gallery as $key => $gallery ) { |
|
168 | + foreach ($this->gallery as $key => $gallery) { |
|
169 | 169 | |
170 | 170 | $this->loop_start(); |
171 | 171 | |
172 | - if ( isset( $gallery['exercise_gallery_image_id'] ) && ! empty( $gallery['exercise_gallery_image_id'] ) ) { |
|
173 | - $this->html[] = '<img alt="' . get_the_title( $gallery['exercise_gallery_image_id'] ) . '" src="' . $gallery['exercise_gallery_image'] . '" />'; |
|
174 | - } elseif ( isset( $gallery['exercise_gallery_external'] ) && ! empty( $gallery['exercise_gallery_external'] ) ) { |
|
172 | + if (isset($gallery['exercise_gallery_image_id']) && ! empty($gallery['exercise_gallery_image_id'])) { |
|
173 | + $this->html[] = '<img alt="' . get_the_title($gallery['exercise_gallery_image_id']) . '" src="' . $gallery['exercise_gallery_image'] . '" />'; |
|
174 | + } elseif (isset($gallery['exercise_gallery_external']) && ! empty($gallery['exercise_gallery_external'])) { |
|
175 | 175 | $this->html[] = $gallery['exercise_gallery_external']; // WPCS: XSS OK. |
176 | - } elseif ( isset( $gallery['exercise_gallery_embed'] ) && ! empty( $gallery['exercise_gallery_embed'] ) ) { |
|
176 | + } elseif (isset($gallery['exercise_gallery_embed']) && ! empty($gallery['exercise_gallery_embed'])) { |
|
177 | 177 | $embed_args = array( |
178 | 178 | 'width' => '530', |
179 | 179 | ); |
180 | - $embed = wp_oembed_get( $gallery['exercise_gallery_embed'], $embed_args ); |
|
181 | - $this->html[] = str_replace( 'width="530"', 'width="100%"', $embed ); // WPCS: XSS OK. |
|
180 | + $embed = wp_oembed_get($gallery['exercise_gallery_embed'], $embed_args); |
|
181 | + $this->html[] = str_replace('width="530"', 'width="100%"', $embed); // WPCS: XSS OK. |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | $this->loop_end(); |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | } |
192 | 192 | |
193 | 193 | // Join the html output if its not empty. |
194 | - if ( ! empty( $this->html ) ) { |
|
195 | - $return = implode( '', $this->html ); |
|
194 | + if ( ! empty($this->html)) { |
|
195 | + $return = implode('', $this->html); |
|
196 | 196 | } |
197 | 197 | return $return; |
198 | 198 | } |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | * Runs just after the if and before the while statement in $this->output() |
214 | 214 | */ |
215 | 215 | public function before_loop() { |
216 | - if ( 'slider' === $this->args['layout'] ) { |
|
217 | - $this->carousel_id = wp_rand( 20, 20000 ); |
|
216 | + if ('slider' === $this->args['layout']) { |
|
217 | + $this->carousel_id = wp_rand(20, 20000); |
|
218 | 218 | $this->html[] = "<div class='lsx-hp-widget-items slick-slider slick-dotted slick-has-arrows {$this->args['css_class']} ' data-interval='{$this->args['interval']}' data-slick='{ \"slidesToShow\": {$this->args['columns']}, \"slidesToScroll\": {$this->args['columns']} }'>"; |
219 | 219 | } else { |
220 | 220 | $this->html[] = "<div class='lsx-hp-widget-items widget-item-grid-layout'>"; |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function loop_start() { |
228 | 228 | // Get the call for the active slide. |
229 | - if ( 'slider' === $this->args['layout'] ) { |
|
229 | + if ('slider' === $this->args['layout']) { |
|
230 | 230 | $this->html[] = "<div class='lsx-hp-widget-item-wrap lsx-{$this->args['post_type']}'>"; |
231 | 231 | } else { |
232 | - if ( 1 === $this->args['count'] ) { |
|
232 | + if (1 === $this->args['count']) { |
|
233 | 233 | $this->html[] = "<div class='row'>"; |
234 | 234 | } |
235 | 235 | $this->html[] = '<div class="' . $this->column_class() . '">'; |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * Runs at the very end of the loop before it runs again. |
241 | 241 | */ |
242 | 242 | public function loop_end() { |
243 | - if ( 'slider' !== $this->args['layout'] ) { |
|
243 | + if ('slider' !== $this->args['layout']) { |
|
244 | 244 | $this->html[] = '</div>'; |
245 | 245 | } |
246 | 246 | // Close the current slide panel. |
247 | - if ( 'slider' === $this->args['layout'] ) { |
|
247 | + if ('slider' === $this->args['layout']) { |
|
248 | 248 | $this->html[] = '</div>'; |
249 | - } elseif ( 0 === $this->args['count'] % $this->args['columns'] || count( $this->gallery ) === $this->args['count'] ) { |
|
249 | + } elseif (0 === $this->args['count'] % $this->args['columns'] || count($this->gallery) === $this->args['count']) { |
|
250 | 250 | $this->html[] = '</div>'; |
251 | 251 | |
252 | - if ( $this->args['count'] < count( $this->gallery ) ) { |
|
252 | + if ($this->args['count'] < count($this->gallery)) { |
|
253 | 253 | $this->html[] = "<div class='row'>"; |
254 | 254 | } |
255 | 255 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | */ |
261 | 261 | public function after_loop() { |
262 | 262 | // Slider output Closing. |
263 | - if ( 'slider' === $this->args['layout'] ) { |
|
263 | + if ('slider' === $this->args['layout']) { |
|
264 | 264 | $this->html[] = '</div>'; |
265 | 265 | } else { |
266 | 266 | $this->html[] = '</div>'; |
@@ -11,8 +11,8 @@ discard block |
||
11 | 11 | * @return exercise_type |
12 | 12 | */ |
13 | 13 | function lsx_health_plan_exercise_type() { |
14 | - $term_obj_list = get_the_term_list( get_the_ID(), 'exercise-type', '', ', ' ); |
|
15 | - if ( ! empty( $term_obj_list ) ) { |
|
14 | + $term_obj_list = get_the_term_list(get_the_ID(), 'exercise-type', '', ', '); |
|
15 | + if ( ! empty($term_obj_list)) { |
|
16 | 16 | return $term_obj_list; |
17 | 17 | } |
18 | 18 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * @return muscle_group_equipment |
24 | 24 | */ |
25 | 25 | function lsx_health_plan_muscle_group_equipment() { |
26 | - $term_obj_list = get_the_term_list( get_the_ID(), 'muscle-group', '', ', ' ); |
|
27 | - if ( ! empty( $term_obj_list ) ) { |
|
26 | + $term_obj_list = get_the_term_list(get_the_ID(), 'muscle-group', '', ', '); |
|
27 | + if ( ! empty($term_obj_list)) { |
|
28 | 28 | return $term_obj_list; |
29 | 29 | } |
30 | 30 | } |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | * @return exercise_equipment |
36 | 36 | */ |
37 | 37 | function lsx_health_plan_exercise_equipment() { |
38 | - $term_obj_list = get_the_term_list( get_the_ID(), 'equipment', '', ', ' ); |
|
39 | - if ( ! empty( $term_obj_list ) ) { |
|
38 | + $term_obj_list = get_the_term_list(get_the_ID(), 'equipment', '', ', '); |
|
39 | + if ( ! empty($term_obj_list)) { |
|
40 | 40 | return $term_obj_list; |
41 | 41 | } |
42 | 42 | } |
@@ -59,61 +59,61 @@ discard block |
||
59 | 59 | * @param array $args |
60 | 60 | * @return void |
61 | 61 | */ |
62 | -function lsx_health_plan_workout_exercise_button( $m, $group, $echo = true, $args = array() ) { |
|
62 | +function lsx_health_plan_workout_exercise_button($m, $group, $echo = true, $args = array()) { |
|
63 | 63 | $defaults = array( |
64 | 64 | 'modal_trigger' => 'button', |
65 | 65 | 'modal_content' => 'excerpt', |
66 | 66 | ); |
67 | - $args = wp_parse_args( $args, $defaults ); |
|
67 | + $args = wp_parse_args($args, $defaults); |
|
68 | 68 | |
69 | 69 | $exercise_id = ''; |
70 | - if ( isset( $group['connected_exercises'] ) && '' !== $group['connected_exercises'] ) { |
|
71 | - $exercise_id = esc_html( $group['connected_exercises'] ); |
|
72 | - $content = get_post_field( 'post_content', $exercise_id ); |
|
73 | - $url = get_permalink( $exercise_id ); |
|
74 | - $equipment_group = get_the_term_list( $exercise_id, 'equipment', '', ', ' ); |
|
75 | - $muscle_group = get_the_term_list( $exercise_id, 'muscle-group', '', ', ' ); |
|
70 | + if (isset($group['connected_exercises']) && '' !== $group['connected_exercises']) { |
|
71 | + $exercise_id = esc_html($group['connected_exercises']); |
|
72 | + $content = get_post_field('post_content', $exercise_id); |
|
73 | + $url = get_permalink($exercise_id); |
|
74 | + $equipment_group = get_the_term_list($exercise_id, 'equipment', '', ', '); |
|
75 | + $muscle_group = get_the_term_list($exercise_id, 'muscle-group', '', ', '); |
|
76 | 76 | $lsx_hp = lsx_health_plan(); |
77 | 77 | |
78 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
79 | - $content = wp_trim_words( $content, 40 ); |
|
78 | + if ('excerpt' === $args['modal_content']) { |
|
79 | + $content = wp_trim_words($content, 40); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( 'link' ) { |
|
83 | - $play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title( $exercise_id ) . '</a>'; |
|
82 | + if ('link') { |
|
83 | + $play_button = '<a data-toggle="modal" href="#workout-exercise-modal-' . $m . '">' . get_the_title($exercise_id) . '</a>'; |
|
84 | 84 | } else { |
85 | 85 | $play_button = '<button data-toggle="modal" data-target="#workout-exercise-modal-' . $m . '"><span class="fa fa-play-circle"></span></button>'; |
86 | 86 | } |
87 | 87 | |
88 | - $modal_body = ''; |
|
89 | - if ( $lsx_hp->frontend->gallery->has_gallery( $exercise_id ) ) { |
|
88 | + $modal_body = ''; |
|
89 | + if ($lsx_hp->frontend->gallery->has_gallery($exercise_id)) { |
|
90 | 90 | $gallery_args = array( |
91 | 91 | 'css_class' => 'modal-slider', |
92 | 92 | ); |
93 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
93 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery('', '', $gallery_args); |
|
94 | 94 | } else { |
95 | - $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail( $exercise_id, 'large' ) . '</div>'; |
|
95 | + $modal_body .= '<div class="modal-image"/>' . get_the_post_thumbnail($exercise_id, 'large') . '</div>'; |
|
96 | 96 | } |
97 | 97 | |
98 | - $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title( $exercise_id ) . '</h5>'; |
|
98 | + $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . get_the_title($exercise_id) . '</h5>'; |
|
99 | 99 | |
100 | - if ( ! empty( $equipment_group ) ) { |
|
101 | - $modal_body .= '<span class="equipment-terms">' . __( 'Equipment', 'lsx-health-plan' ) . ': ' . $equipment_group . '</span>'; |
|
100 | + if ( ! empty($equipment_group)) { |
|
101 | + $modal_body .= '<span class="equipment-terms">' . __('Equipment', 'lsx-health-plan') . ': ' . $equipment_group . '</span>'; |
|
102 | 102 | } |
103 | - if ( ! empty( $muscle_group ) ) { |
|
104 | - $modal_body .= '<span class="muscle-terms">' . __( 'Muscle Group', 'lsx-health-plan' ) . ': ' . $muscle_group . '</span>'; |
|
103 | + if ( ! empty($muscle_group)) { |
|
104 | + $modal_body .= '<span class="muscle-terms">' . __('Muscle Group', 'lsx-health-plan') . ': ' . $muscle_group . '</span>'; |
|
105 | 105 | } |
106 | 106 | $modal_body .= '</div>'; |
107 | - if ( '' !== $args['modal_content'] ) { |
|
107 | + if ('' !== $args['modal_content']) { |
|
108 | 108 | $modal_body .= '<div class="modal-excerpt"/>' . $content . '</div>'; |
109 | 109 | } |
110 | - if ( 'excerpt' === $args['modal_content'] ) { |
|
111 | - $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __( 'Read More', 'lsx-health-plan' ) . '</a>'; |
|
110 | + if ('excerpt' === $args['modal_content']) { |
|
111 | + $modal_body .= '<a class="moretag" target="_blank" href="' . $url . '">' . __('Read More', 'lsx-health-plan') . '</a>'; |
|
112 | 112 | } |
113 | - \lsx_health_plan\functions\register_modal( 'workout-exercise-modal-' . $m, '', $modal_body ); |
|
113 | + \lsx_health_plan\functions\register_modal('workout-exercise-modal-' . $m, '', $modal_body); |
|
114 | 114 | |
115 | - if ( true === $echo ) { |
|
116 | - echo wp_kses_post( $play_button ); |
|
115 | + if (true === $echo) { |
|
116 | + echo wp_kses_post($play_button); |
|
117 | 117 | } else { |
118 | 118 | return $play_button; |
119 | 119 | } |
@@ -127,39 +127,39 @@ discard block |
||
127 | 127 | * @param array $group |
128 | 128 | * @return void |
129 | 129 | */ |
130 | -function lsx_health_plan_shortcode_exercise_button( $m, $content = true ) { |
|
131 | - $equipment_group = get_the_term_list( $m, 'equipment', '', ', ' ); |
|
132 | - $muscle_group = get_the_term_list( $m, 'muscle-group', '', ', ' ); |
|
130 | +function lsx_health_plan_shortcode_exercise_button($m, $content = true) { |
|
131 | + $equipment_group = get_the_term_list($m, 'equipment', '', ', '); |
|
132 | + $muscle_group = get_the_term_list($m, 'muscle-group', '', ', '); |
|
133 | 133 | $title = get_the_title(); |
134 | 134 | $lsx_hp = lsx_health_plan(); |
135 | - $button = '<a data-toggle="modal" href="#exercise-modal-' . $m . '" data-target="#exercise-modal-' . $m . '"></a>'; |
|
135 | + $button = '<a data-toggle="modal" href="#exercise-modal-' . $m . '" data-target="#exercise-modal-' . $m . '"></a>'; |
|
136 | 136 | |
137 | - if ( true === $content ) { |
|
137 | + if (true === $content) { |
|
138 | 138 | $content = get_the_content(); |
139 | 139 | } |
140 | 140 | |
141 | 141 | $modal_body = ''; |
142 | - if ( $lsx_hp->frontend->gallery->has_gallery( $m ) ) { |
|
142 | + if ($lsx_hp->frontend->gallery->has_gallery($m)) { |
|
143 | 143 | $gallery_args = array( |
144 | 144 | 'css_class' => 'modal-slider', |
145 | 145 | ); |
146 | - $modal_body .= $lsx_hp->frontend->gallery->get_gallery( '', '', $gallery_args ); |
|
146 | + $modal_body .= $lsx_hp->frontend->gallery->get_gallery('', '', $gallery_args); |
|
147 | 147 | } else { |
148 | - $modal_body .= '<div class="modal-image">' . get_the_post_thumbnail( $m, 'large' ) . '</div>'; |
|
148 | + $modal_body .= '<div class="modal-image">' . get_the_post_thumbnail($m, 'large') . '</div>'; |
|
149 | 149 | } |
150 | 150 | $modal_body .= '<div class="title-lined exercise-modal"><h5 class="modal-title">' . $title . '</h5>'; |
151 | 151 | |
152 | - if ( ! empty( $equipment_group ) ) { |
|
152 | + if ( ! empty($equipment_group)) { |
|
153 | 153 | $modal_body .= '<span class="equipment-terms">Equipment: ' . $equipment_group . '</span>'; |
154 | 154 | } |
155 | - if ( ! empty( $muscle_group ) ) { |
|
155 | + if ( ! empty($muscle_group)) { |
|
156 | 156 | $modal_body .= '<span class="muscle-terms">Muscle Group: ' . $muscle_group . '</span>'; |
157 | 157 | } |
158 | 158 | $modal_body .= '</div>'; |
159 | 159 | $modal_body .= $content; |
160 | - \lsx_health_plan\functions\register_modal( 'exercise-modal-' . $m, '', $modal_body ); |
|
160 | + \lsx_health_plan\functions\register_modal('exercise-modal-' . $m, '', $modal_body); |
|
161 | 161 | |
162 | - return ( $button ); |
|
162 | + return ($button); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | * @param boolean $echo |
171 | 171 | * @return string |
172 | 172 | */ |
173 | -function lsx_health_plan_exercise_title( $before = '', $after = '', $echo = true, $exercise_id = false ) { |
|
174 | - if ( false === $exercise_id ) { |
|
173 | +function lsx_health_plan_exercise_title($before = '', $after = '', $echo = true, $exercise_id = false) { |
|
174 | + if (false === $exercise_id) { |
|
175 | 175 | $exercise_id = get_the_ID(); |
176 | 176 | } |
177 | - $title = get_the_title( $exercise_id ); |
|
178 | - $side = get_post_meta( $exercise_id, 'exercise_side', true ); |
|
179 | - if ( '' !== $side ) { |
|
180 | - $title .= ' - ' . ucwords( $side ); |
|
177 | + $title = get_the_title($exercise_id); |
|
178 | + $side = get_post_meta($exercise_id, 'exercise_side', true); |
|
179 | + if ('' !== $side) { |
|
180 | + $title .= ' - ' . ucwords($side); |
|
181 | 181 | } |
182 | - $title = apply_filters( 'lsx_health_plan_exercise_title', $before . $title . $after, $title, $before, $after, $exercise_id ); |
|
183 | - if ( true === $echo ) { |
|
184 | - echo wp_kses_post( $title ); |
|
182 | + $title = apply_filters('lsx_health_plan_exercise_title', $before . $title . $after, $title, $before, $after, $exercise_id); |
|
183 | + if (true === $echo) { |
|
184 | + echo wp_kses_post($title); |
|
185 | 185 | } else { |
186 | 186 | return $title; |
187 | 187 | } |