1 | <?php |
||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||
2 | $prep_time = get_post_meta( get_the_ID(), 'recipe_prep_time', true ); |
||||
0 ignored issues
–
show
It seems like
get_the_ID() can also be of type false ; however, parameter $post_id of get_post_meta() does only seem to accept integer , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
3 | $cooking_time = get_post_meta( get_the_ID(), 'recipe_cooking_time', true ); |
||||
4 | $serves = get_post_meta( get_the_ID(), 'recipe_serves', true ); |
||||
5 | $portion = get_post_meta( get_the_ID(), 'recipe_portion', true ); |
||||
6 | $energy = get_post_meta( get_the_ID(), 'recipe_energy', true ); |
||||
7 | $protein = get_post_meta( get_the_ID(), 'recipe_protein', true ); |
||||
8 | $carbohydrates = get_post_meta( get_the_ID(), 'recipe_carbohydrates', true ); |
||||
9 | $fibre = get_post_meta( get_the_ID(), 'recipe_fibre', true ); |
||||
10 | $fat = get_post_meta( get_the_ID(), 'recipe_fat', true ); |
||||
11 | ?> |
||||
12 | <?php if ( ( ! empty( $prep_time ) ) || ( ! empty( $cooking_time ) ) || ( ! empty( $serves ) ) || ( ! empty( $portion ) ) ) { ?> |
||||
0 ignored issues
–
show
|
|||||
13 | <table class="recipe-table cooking-info-table"> |
||||
14 | <?php if ( is_single() && is_singular( 'recipe' ) ) { ?> |
||||
0 ignored issues
–
show
|
|||||
15 | <thead> |
||||
16 | <tr> |
||||
17 | <th>Cooking Info</th> |
||||
18 | </tr> |
||||
19 | </thead> |
||||
20 | <?php } ?> |
||||
21 | <tbody> |
||||
22 | <?php |
||||
23 | if ( 1 >= (int) $serves ) { |
||||
0 ignored issues
–
show
|
|||||
24 | $serves = '1'; |
||||
25 | $serves_label = __( 'Person', 'lsx-health-plan' ); |
||||
26 | } else { |
||||
27 | $serves_label = __( 'People', 'lsx-health-plan' ); |
||||
28 | } |
||||
29 | ?> |
||||
30 | <tr class="serves"> |
||||
31 | <td><?php esc_html_e( 'Serves:', 'lsx-health-plan' ); ?> </td> |
||||
32 | <td> |
||||
33 | <?php |
||||
34 | echo wp_kses_post( $serves ) . ' ' . esc_html( $serves_label ); |
||||
35 | ?> |
||||
36 | </td> |
||||
37 | </tr> |
||||
38 | <?php |
||||
39 | if ( ! empty( $prep_time ) ) { |
||||
0 ignored issues
–
show
|
|||||
40 | ?> |
||||
41 | <tr class="prep-time"> |
||||
42 | <td><?php esc_html_e( 'Prep time: ', 'lsx-health-plan' ); ?> </td> |
||||
43 | <td> |
||||
44 | <?php |
||||
45 | echo wp_kses_post( $prep_time ); |
||||
46 | ?> |
||||
47 | </td> |
||||
48 | </tr> |
||||
49 | <?php |
||||
50 | } |
||||
51 | ?> |
||||
52 | <?php |
||||
53 | if ( ! empty( $cooking_time ) ) { |
||||
0 ignored issues
–
show
|
|||||
54 | ?> |
||||
55 | <tr class="cooking-time"> |
||||
56 | <td><?php esc_html_e( 'Cooking time: ', 'lsx-health-plan' ); ?> </td> |
||||
57 | <td> |
||||
58 | <?php |
||||
59 | echo wp_kses_post( $cooking_time ); |
||||
60 | ?> |
||||
61 | </td> |
||||
62 | </tr> |
||||
63 | <?php |
||||
64 | } |
||||
65 | ?> |
||||
66 | <?php |
||||
67 | if ( ! empty( $portion ) ) { |
||||
0 ignored issues
–
show
|
|||||
68 | ?> |
||||
69 | <tr class="portion-size"> |
||||
70 | <td><?php esc_html_e( 'Portion size: ', 'lsx-health-plan' ); ?> </td> |
||||
71 | <td> |
||||
72 | <?php |
||||
73 | echo wp_kses_post( $portion ); |
||||
74 | ?> |
||||
75 | </td> |
||||
76 | </tr> |
||||
77 | <?php |
||||
78 | } |
||||
79 | ?> |
||||
80 | </tbody> |
||||
81 | </table> |
||||
82 | <?php } ?> |
||||
83 | <?php if ( is_single() && is_singular( 'recipe' ) && ( ( ! empty( $energy ) ) || ( ! empty( $protein ) ) || ( ! empty( $carbohydrates ) ) || ( ! empty( $fibre ) ) || ( ! empty( $fat ) ) ) ) { ?> |
||||
0 ignored issues
–
show
|
|||||
84 | <table class="recipe-table nutritional-info-table"> |
||||
85 | <thead> |
||||
86 | <tr> |
||||
87 | <th>Nutritional Info (per portion)</th> |
||||
88 | </tr> |
||||
89 | </thead> |
||||
90 | <tbody> |
||||
91 | <?php |
||||
92 | if ( ! empty( $energy ) ) { |
||||
0 ignored issues
–
show
|
|||||
93 | ?> |
||||
94 | <tr class="energy"> |
||||
95 | <td><?php esc_html_e( 'Energy: ', 'lsx-health-plan' ); ?> </td> |
||||
96 | <td> |
||||
97 | <?php |
||||
98 | echo wp_kses_post( $energy ); |
||||
99 | ?> |
||||
100 | </td> |
||||
101 | </tr> |
||||
102 | <?php |
||||
103 | } |
||||
104 | ?> |
||||
105 | <?php |
||||
106 | if ( ! empty( $protein ) ) { |
||||
0 ignored issues
–
show
|
|||||
107 | ?> |
||||
108 | <tr class="protein"> |
||||
109 | <td><?php esc_html_e( 'Protein: ', 'lsx-health-plan' ); ?> </td> |
||||
110 | <td> |
||||
111 | <?php |
||||
112 | echo wp_kses_post( $protein ); |
||||
113 | ?> |
||||
114 | </td> |
||||
115 | </tr> |
||||
116 | <?php |
||||
117 | } |
||||
118 | ?> |
||||
119 | <?php |
||||
120 | if ( ! empty( $carbohydrates ) ) { |
||||
0 ignored issues
–
show
|
|||||
121 | ?> |
||||
122 | <tr class="carbohydrates"> |
||||
123 | <td><?php esc_html_e( 'Carbohydrates: ', 'lsx-health-plan' ); ?> </td> |
||||
124 | <td> |
||||
125 | <?php |
||||
126 | echo wp_kses_post( $carbohydrates ); |
||||
127 | ?> |
||||
128 | </td> |
||||
129 | </tr> |
||||
130 | <?php |
||||
131 | } |
||||
132 | ?> |
||||
133 | <?php |
||||
134 | if ( ! empty( $fibre ) ) { |
||||
0 ignored issues
–
show
|
|||||
135 | ?> |
||||
136 | <tr class="fibre"> |
||||
137 | <td><?php esc_html_e( 'Fibre: ', 'lsx-health-plan' ); ?> </td> |
||||
138 | <td> |
||||
139 | <?php |
||||
140 | echo wp_kses_post( $fibre ); |
||||
141 | ?> |
||||
142 | </td> |
||||
143 | </tr> |
||||
144 | <?php |
||||
145 | } |
||||
146 | ?> |
||||
147 | <?php |
||||
148 | if ( ! empty( $fat ) ) { |
||||
0 ignored issues
–
show
|
|||||
149 | ?> |
||||
150 | <tr class="fat"> |
||||
151 | <td><?php esc_html_e( 'Fat: ', 'lsx-health-plan' ); ?> </td> |
||||
152 | <td> |
||||
153 | <?php |
||||
154 | echo wp_kses_post( $fat ); |
||||
155 | ?> |
||||
156 | </td> |
||||
157 | </tr> |
||||
158 | <?php |
||||
159 | } |
||||
160 | ?> |
||||
161 | </tbody> |
||||
162 | </table> |
||||
163 | <?php } ?> |
||||
164 |