1 | <?php |
||
2 | /** |
||
3 | * Template used to display post content on widgets and archive pages. |
||
4 | * |
||
5 | * @package lsx-health-plan |
||
6 | */ |
||
7 | global $shortcode_args, $product; |
||
8 | ?> |
||
9 | |||
10 | <?php lsx_entry_before(); ?> |
||
11 | |||
12 | <?php |
||
13 | $content_setting = ''; |
||
14 | $column_class = '4'; |
||
15 | $completed_class = '4'; |
||
16 | $link_html = ''; |
||
17 | $link_close = ''; |
||
18 | $linked_product = false; |
||
19 | $restricted = ''; |
||
20 | if ( function_exists( 'lsx_health_plan\functions\woocommerce\plan_has_products' ) && \lsx_health_plan\functions\woocommerce\plan_has_products() ) { |
||
21 | $products = \lsx_health_plan\functions\woocommerce\get_plan_products(); |
||
22 | $linked_product = wc_get_product( $products[0] ); |
||
23 | $product = $linked_product; |
||
24 | |||
25 | if ( function_exists( 'wc_memberships_is_post_content_restricted' ) && wc_memberships_is_post_content_restricted( get_the_ID() ) ) { |
||
26 | $restricted = ! current_user_can( 'wc_memberships_view_restricted_post_content', get_the_ID() ); |
||
27 | } |
||
28 | } |
||
29 | |||
30 | // Check for shortcode overrides. |
||
31 | if ( null !== $shortcode_args ) { |
||
32 | if ( isset( $shortcode_args['columns'] ) ) { |
||
33 | $column_class = $shortcode_args['columns']; |
||
34 | $column_class = \lsx_health_plan\functions\column_class( $column_class ); |
||
35 | } |
||
36 | if ( isset( $shortcode_args['link'] ) ) { |
||
37 | $link_setting = $shortcode_args['link']; |
||
38 | // Setup our link and content. |
||
39 | switch ( $link_setting ) { |
||
40 | case 'single': |
||
41 | $link_html = '<a href="' . get_permalink( $group['connected_plans'] ) . '">'; |
||
42 | $link_close = '</a>'; |
||
43 | break; |
||
44 | |||
45 | case 'modal': |
||
46 | $link_html = '<a data-toggle="modal" href="#workout-plan-modal-' . $group['connected_plans'] . '">'; |
||
47 | $link_close = '</a>'; |
||
48 | $modal_content_setting = \lsx_health_plan\functions\get_option( 'workout_tab_modal_content', 'excerpt' ); |
||
49 | $modal_args = array( |
||
50 | 'modal_content' => $modal_content_setting, |
||
51 | ); |
||
52 | // We call the button to register the modal, but we do not output it. |
||
53 | lsx_health_plan_workout_plan_button( $group['connected_plans'], $group, false, $modal_args ); |
||
54 | break; |
||
55 | |||
56 | case 'none': |
||
57 | default: |
||
58 | $link_html = ''; |
||
59 | $link_close = ''; |
||
60 | break; |
||
61 | } |
||
62 | } |
||
63 | if ( isset( $shortcode_args['description'] ) ) { |
||
64 | $content_setting = $shortcode_args['description']; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | $featured = get_post_meta( get_the_ID(), 'plan_featured_plan', true ); |
||
69 | ?> |
||
70 | |||
71 | <div class="lsx-plan-column col-xs-12 col-sm-6 col-md-<?php echo esc_attr( $column_class ); ?> <?php echo esc_attr( lsx_hp_plan_get_classes() ); ?>"> |
||
72 | <article class="lsx-slot box-shadow"> |
||
73 | <?php lsx_entry_top(); ?> |
||
74 | |||
75 | <div class="plan-feature-img"> |
||
76 | <?php if ( $featured ) { ?> |
||
77 | <span class="featured-plan"><?php //lsx_get_svg_icon( 'icon-featured.svg' ); ?></span> |
||
0 ignored issues
–
show
|
|||
78 | <?php } ?> |
||
79 | <a href="<?php echo esc_url( get_permalink() ); ?>"> |
||
80 | <?php |
||
81 | $featured_image = get_the_post_thumbnail(); |
||
82 | if ( ! empty( $featured_image ) && '' !== $featured_image ) { |
||
83 | the_post_thumbnail( 'lsx-thumbnail', array( |
||
84 | 'class' => 'aligncenter', |
||
85 | ) ); |
||
86 | } else { |
||
87 | ?> |
||
88 | <img loading="lazy" class="placeholder" src="<?php echo esc_attr( plugin_dir_url( __FILE__ ) . '../assets/images/placeholder.jpg' ); ?>"> |
||
89 | <?php |
||
90 | } |
||
91 | ?> |
||
92 | </a> |
||
93 | </div> |
||
94 | <div class="content-box plan-content-box white-bg"> |
||
95 | <h3 class="plan id-<?php the_ID(); ?> <?php echo esc_attr( $completed_class ); ?>"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?></a></h3> |
||
96 | <?php |
||
97 | echo wp_kses_post( \lsx_health_plan\functions\hp_get_plan_type_meta( $post ) ); |
||
98 | ?> |
||
99 | <?php |
||
100 | if ( false !== $linked_product ) { |
||
101 | echo '<div class="plan-price">'; |
||
102 | echo wp_kses_post( $linked_product->get_price_html() ); |
||
103 | echo '</div>'; |
||
104 | } |
||
105 | ?> |
||
106 | <div class="excerpt"> |
||
107 | <?php |
||
108 | if ( ! has_excerpt() ) { |
||
109 | $content = wp_trim_words( get_the_content(), 20 ); |
||
110 | $content = '<p>' . $content . '</p>'; |
||
111 | } else { |
||
112 | $content = apply_filters( 'the_excerpt', get_the_excerpt() ); |
||
113 | } |
||
114 | echo wp_kses_post( $content ); |
||
115 | ?> |
||
116 | </div> |
||
117 | |||
118 | <?php |
||
119 | $button_link = get_permalink(); |
||
120 | $button_text = __( 'Sign Up', 'lsx-health-plan' ); |
||
121 | $button_class = ''; |
||
122 | |||
123 | if ( true === $restricted ) { |
||
124 | if ( 1 < count( $products ) ) { |
||
125 | $button_text = __( 'Select Options', 'lsx-health-plan' ); |
||
126 | } else { |
||
127 | $button_link = $linked_product->add_to_cart_url() . '&plan_id=' . get_the_ID(); |
||
128 | $button_text = $linked_product->add_to_cart_text(); |
||
129 | } |
||
130 | ?> |
||
131 | <?php |
||
132 | } elseif ( false === $restricted ) { |
||
133 | $button_text = __( 'Already Signed Up', 'lsx-health-plan' ); |
||
134 | $button_class = 'btn-disabled'; |
||
135 | } |
||
136 | ?> |
||
137 | <a class="btn <?php echo esc_attr( $button_class ); ?>" href="<?php echo esc_attr( $button_link ); ?>"><?php echo esc_attr( $button_text ); ?></a> |
||
138 | </div> |
||
139 | <?php lsx_entry_bottom(); ?> |
||
140 | </article> |
||
141 | </div> |
||
142 | |||
143 | <?php |
||
144 | lsx_entry_after(); |
||
145 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.