1 | <?php |
||||
2 | /** |
||||
3 | * Meta Box Subscription Info |
||||
4 | * |
||||
5 | * @author Pronamic <[email protected]> |
||||
6 | * @copyright 2005-2019 Pronamic |
||||
7 | * @license GPL-3.0-or-later |
||||
8 | * @package Pronamic\WordPress\Pay |
||||
9 | */ |
||||
10 | |||||
11 | use Pronamic\WordPress\Pay\Core\PaymentMethods; |
||||
12 | use Pronamic\WordPress\Pay\Core\Statuses; |
||||
13 | use Pronamic\WordPress\Pay\Util; |
||||
14 | |||||
15 | $post_id = get_the_ID(); |
||||
16 | |||||
17 | if ( empty( $post_id ) ) { |
||||
18 | return; |
||||
19 | } |
||||
20 | |||||
21 | $subscription = get_pronamic_subscription( $post_id ); |
||||
22 | |||||
23 | ?> |
||||
24 | <table class="form-table"> |
||||
25 | <tr> |
||||
26 | <th scope="row"> |
||||
27 | <?php esc_html_e( 'Date', 'pronamic_ideal' ); ?> |
||||
28 | </th> |
||||
29 | <td> |
||||
30 | <?php the_time( __( 'l jS \o\f F Y, h:ia', 'pronamic_ideal' ) ); ?> |
||||
31 | </td> |
||||
32 | </tr> |
||||
33 | <tr> |
||||
34 | <th scope="row"> |
||||
35 | <?php esc_html_e( 'ID', 'pronamic_ideal' ); ?> |
||||
36 | </th> |
||||
37 | <td> |
||||
38 | <?php echo esc_html( $post_id ); ?> |
||||
39 | </td> |
||||
40 | </tr> |
||||
41 | <tr> |
||||
42 | <th scope="row"> |
||||
43 | <?php esc_html_e( 'Status', 'pronamic_ideal' ); ?> |
||||
44 | </th> |
||||
45 | <td> |
||||
46 | <?php |
||||
47 | |||||
48 | $status_object = get_post_status_object( get_post_status( $post_id ) ); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
49 | |||||
50 | if ( isset( $status_object, $status_object->label ) ) { |
||||
51 | echo esc_html( $status_object->label ); |
||||
52 | } else { |
||||
53 | echo '—'; |
||||
54 | } |
||||
55 | |||||
56 | ?> |
||||
57 | </td> |
||||
58 | </tr> |
||||
59 | <tr> |
||||
60 | <th scope="row"> |
||||
61 | <?php esc_html_e( 'Description', 'pronamic_ideal' ); ?> |
||||
62 | </th> |
||||
63 | <td> |
||||
64 | <?php echo esc_html( $subscription->get_description() ); ?> |
||||
65 | </td> |
||||
66 | </tr> |
||||
67 | <tr> |
||||
68 | <th scope="row"> |
||||
69 | <?php esc_html_e( 'Gateway', 'pronamic_ideal' ); ?> |
||||
70 | </th> |
||||
71 | <td> |
||||
72 | <?php edit_post_link( get_the_title( $subscription->config_id ), '', '', $subscription->config_id ); ?> |
||||
73 | </td> |
||||
74 | </tr> |
||||
75 | <tr> |
||||
76 | <th scope="row"> |
||||
77 | <?php esc_html_e( 'Payment Method', 'pronamic_ideal' ); ?> |
||||
78 | </th> |
||||
79 | <td> |
||||
80 | <?php echo esc_html( PaymentMethods::get_name( $subscription->payment_method ) ); ?> |
||||
81 | </td> |
||||
82 | </tr> |
||||
83 | <tr> |
||||
84 | <th scope="row"> |
||||
85 | <?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?> |
||||
86 | </th> |
||||
87 | <td> |
||||
88 | <?php |
||||
89 | |||||
90 | if ( current_user_can( 'edit_post', $post_id ) && apply_filters( 'pronamic_pay_subscription_amount_editable_' . $subscription->get_source(), false ) ) : |
||||
91 | |||||
92 | echo esc_html( $subscription->get_amount()->get_currency()->get_symbol() ); |
||||
93 | |||||
94 | $amount = $subscription->get_amount()->format_i18n( '%2$s' ); |
||||
95 | |||||
96 | ?> |
||||
97 | |||||
98 | <input type="text" name="_pronamic_subscription_amount" value="<?php echo esc_attr( $amount ); ?>" size="12" /> |
||||
99 | |||||
100 | <?php |
||||
101 | |||||
102 | else : |
||||
103 | |||||
104 | echo esc_html( $subscription->get_amount()->format_i18n() ); |
||||
105 | |||||
106 | endif; |
||||
107 | |||||
108 | ?> |
||||
109 | </td> |
||||
110 | </tr> |
||||
111 | <tr> |
||||
112 | <th scope="row"> |
||||
113 | <?php echo esc_html_x( 'Interval', 'Recurring payment', 'pronamic_ideal' ); ?> |
||||
114 | </th> |
||||
115 | <td> |
||||
116 | <?php echo esc_html( Util::format_interval( $subscription->get_interval(), $subscription->get_interval_period() ) ); ?> |
||||
117 | </td> |
||||
118 | </tr> |
||||
119 | <tr> |
||||
120 | <th scope="row"> |
||||
121 | <?php echo esc_html_x( 'Frequency', 'Recurring payment', 'pronamic_ideal' ); ?> |
||||
122 | </th> |
||||
123 | <td> |
||||
124 | <?php echo esc_html( Util::format_frequency( $subscription->get_frequency() ) ); ?> |
||||
0 ignored issues
–
show
$subscription->get_frequency() of type string is incompatible with the type integer expected by parameter $frequency of Pronamic\WordPress\Pay\Util::format_frequency() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
125 | </td> |
||||
126 | </tr> |
||||
127 | <tr> |
||||
128 | <th scope="row"> |
||||
129 | <?php esc_html_e( 'Start Date', 'pronamic_ideal' ); ?> |
||||
130 | </th> |
||||
131 | <td> |
||||
132 | <?php |
||||
133 | |||||
134 | $start_date = $subscription->get_start_date(); |
||||
135 | |||||
136 | echo empty( $start_date ) ? '—' : esc_html( $start_date->format_i18n() ); |
||||
137 | |||||
138 | ?> |
||||
139 | </td> |
||||
140 | </tr> |
||||
141 | |||||
142 | <?php |
||||
143 | |||||
144 | $frequency = $subscription->get_frequency(); |
||||
145 | |||||
146 | // Show end date if frequency is limited. |
||||
147 | if ( ! empty( $frequency ) ) : |
||||
148 | |||||
149 | ?> |
||||
150 | |||||
151 | <tr> |
||||
152 | <th scope="row"> |
||||
153 | <?php esc_html_e( 'End Date', 'pronamic_ideal' ); ?> |
||||
154 | </th> |
||||
155 | <td> |
||||
156 | <?php |
||||
157 | |||||
158 | $end_date = $subscription->get_end_date(); |
||||
159 | |||||
160 | echo empty( $end_date ) ? '—' : esc_html( $end_date->format_i18n() ); |
||||
161 | |||||
162 | ?> |
||||
163 | </td> |
||||
164 | </tr> |
||||
165 | |||||
166 | <?php endif; ?> |
||||
167 | |||||
168 | <?php |
||||
169 | |||||
170 | // Show next payment date if subscription is not cancelled or completed. |
||||
171 | if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) : |
||||
172 | |||||
173 | ?> |
||||
174 | |||||
175 | <tr> |
||||
176 | <th scope="row"> |
||||
177 | <?php esc_html_e( 'Next Payment Date', 'pronamic_ideal' ); ?> |
||||
178 | </th> |
||||
179 | <td> |
||||
180 | <?php |
||||
181 | |||||
182 | $next_payment = $subscription->get_next_payment_date(); |
||||
183 | |||||
184 | echo empty( $next_payment ) ? '—' : esc_html( $next_payment->format_i18n() ); |
||||
185 | |||||
186 | ?> |
||||
187 | </td> |
||||
188 | </tr> |
||||
189 | |||||
190 | <?php endif; ?> |
||||
191 | |||||
192 | <tr> |
||||
193 | <th scope="row"> |
||||
194 | <?php esc_html_e( 'Expiry Date', 'pronamic_ideal' ); ?> |
||||
195 | </th> |
||||
196 | <td> |
||||
197 | <?php |
||||
198 | |||||
199 | $expiry_date = $subscription->get_expiry_date(); |
||||
200 | |||||
201 | echo empty( $expiry_date ) ? '—' : esc_html( $expiry_date->format_i18n() ); |
||||
202 | |||||
203 | ?> |
||||
204 | </td> |
||||
205 | </tr> |
||||
206 | <tr> |
||||
207 | <th scope="row"> |
||||
208 | <?php esc_html_e( 'Consumer', 'pronamic_ideal' ); ?> |
||||
209 | </th> |
||||
210 | <td> |
||||
211 | <?php |
||||
212 | |||||
213 | echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_name', true ) ); |
||||
0 ignored issues
–
show
It seems like
get_post_meta($post_id, ...n_consumer_name', true) can also be of type false ; however, parameter $text of esc_html() does only seem to accept string , 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
![]() |
|||||
214 | echo '<br />'; |
||||
215 | echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_iban', true ) ); |
||||
216 | echo '<br />'; |
||||
217 | echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_bic', true ) ); |
||||
218 | |||||
219 | ?> |
||||
220 | </td> |
||||
221 | </tr> |
||||
222 | <tr> |
||||
223 | <th scope="row"> |
||||
224 | <?php esc_html_e( 'Source', 'pronamic_ideal' ); ?> |
||||
225 | </th> |
||||
226 | <td> |
||||
227 | <?php |
||||
228 | |||||
229 | echo $subscription->get_source_text(); // WPCS: XSS ok. |
||||
230 | |||||
231 | ?> |
||||
232 | </td> |
||||
233 | </tr> |
||||
234 | |||||
235 | <?php if ( 's2member' === $subscription->get_source() ) : ?> |
||||
236 | |||||
237 | <tr> |
||||
238 | <th scope="row"> |
||||
239 | <?php esc_html_e( 'Period', 'pronamic_ideal' ); ?> |
||||
240 | </th> |
||||
241 | <td> |
||||
242 | <?php echo esc_html( get_post_meta( $subscription->get_id(), '_pronamic_subscription_s2member_period', true ) ); ?> |
||||
243 | </td> |
||||
244 | </tr> |
||||
245 | <tr> |
||||
246 | <th scope="row"> |
||||
247 | <?php esc_html_e( 'Level', 'pronamic_ideal' ); ?> |
||||
248 | </th> |
||||
249 | <td> |
||||
250 | <?php echo esc_html( get_post_meta( $subscription->get_id(), '_pronamic_subscription_s2member_level', true ) ); ?> |
||||
251 | </td> |
||||
252 | </tr> |
||||
253 | |||||
254 | <?php endif; ?> |
||||
255 | </table> |
||||
256 |