1 | <?php |
||
2 | /** |
||
3 | * Tab System Status |
||
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 | namespace Pronamic\WordPress\Pay; |
||
12 | |||
13 | use Pronamic\WordPress\DateTime\DateTime; |
||
14 | use Pronamic\WordPress\DateTime\DateTimeZone; |
||
15 | |||
16 | ?> |
||
17 | <table class="pronamic-pay-table pronamic-pay-status-table widefat"> |
||
18 | <thead> |
||
19 | <tr> |
||
20 | <th colspan="3"><?php esc_html_e( 'License', 'pronamic_ideal' ); ?></th> |
||
21 | </tr> |
||
22 | </thead> |
||
23 | |||
24 | <tbody> |
||
25 | <tr> |
||
26 | <th scope="row"> |
||
27 | <?php esc_html_e( 'License Status', 'pronamic_ideal' ); ?> |
||
28 | </th> |
||
29 | <td> |
||
30 | <?php |
||
31 | |||
32 | $status = get_option( 'pronamic_pay_license_status' ); |
||
33 | |||
34 | switch ( $status ) { |
||
35 | case 'valid': |
||
36 | esc_html_e( 'Valid', 'pronamic_ideal' ); |
||
37 | |||
38 | break; |
||
39 | case 'invalid': |
||
40 | esc_html_e( 'Invalid', 'pronamic_ideal' ); |
||
41 | |||
42 | break; |
||
43 | case 'site_inactive': |
||
44 | esc_html_e( 'Site Inactive', 'pronamic_ideal' ); |
||
45 | |||
46 | break; |
||
47 | default: |
||
48 | echo esc_html( $status ); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
49 | |||
50 | break; |
||
51 | } |
||
52 | |||
53 | ?> |
||
54 | </td> |
||
55 | </tr> |
||
56 | <tr> |
||
57 | <th scope="row"> |
||
58 | <?php esc_html_e( 'Next License Check', 'pronamic_ideal' ); ?> |
||
59 | </th> |
||
60 | <td> |
||
61 | <?php |
||
62 | |||
63 | $timestamp = wp_next_scheduled( 'pronamic_pay_license_check' ); |
||
64 | |||
65 | if ( false !== $timestamp ) { |
||
66 | $date = new DateTime( '@' . $timestamp, new DateTimeZone( 'UTC' ) ); |
||
67 | |||
68 | echo esc_html( $date->format_i18n() ); |
||
69 | } else { |
||
70 | esc_html_e( 'Not scheduled', 'pronamic_ideal' ); |
||
71 | } |
||
72 | |||
73 | ?> |
||
74 | </td> |
||
75 | </tr> |
||
76 | </tbody> |
||
77 | </table> |
||
78 | |||
79 | <table class="pronamic-pay-table pronamic-pay-status-table widefat striped"> |
||
80 | <thead> |
||
81 | <tr> |
||
82 | <th colspan="3"><?php esc_html_e( 'WordPress Environment', 'pronamic_ideal' ); ?></th> |
||
83 | </tr> |
||
84 | </thead> |
||
85 | |||
86 | <tbody> |
||
87 | <tr> |
||
88 | <th scope="row"> |
||
89 | <?php esc_html_e( 'Site URL', 'pronamic_ideal' ); ?> |
||
90 | </th> |
||
91 | <td> |
||
92 | <?php echo esc_html( site_url() ); ?> |
||
93 | </td> |
||
94 | <td> |
||
95 | ✓ |
||
96 | </td> |
||
97 | </tr> |
||
98 | <tr> |
||
99 | <th scope="row"> |
||
100 | <?php esc_html_e( 'Home URL', 'pronamic_ideal' ); ?> |
||
101 | </th> |
||
102 | <td> |
||
103 | <?php echo esc_html( home_url() ); ?> |
||
104 | </td> |
||
105 | <td> |
||
106 | ✓ |
||
107 | </td> |
||
108 | </tr> |
||
109 | <tr> |
||
110 | <th scope="row"> |
||
111 | <?php esc_html_e( 'PHP Version', 'pronamic_ideal' ); ?> |
||
112 | </th> |
||
113 | <td> |
||
114 | <?php echo esc_html( phpversion() ); ?> |
||
115 | </td> |
||
116 | <td> |
||
117 | <?php |
||
118 | |||
119 | if ( version_compare( phpversion(), '5.2', '>' ) ) { |
||
120 | echo '✓'; |
||
121 | } else { |
||
122 | esc_html_e( 'Pronamic Pay requires PHP 5.2 or above.', 'pronamic_ideal' ); |
||
123 | } |
||
124 | |||
125 | ?> |
||
126 | </td> |
||
127 | </tr> |
||
128 | <tr> |
||
129 | <th scope="row"> |
||
130 | <?php esc_html_e( 'MySQL Version', 'pronamic_ideal' ); ?> |
||
131 | </th> |
||
132 | <td> |
||
133 | <?php |
||
134 | |||
135 | global $wpdb; |
||
136 | |||
137 | echo esc_html( $wpdb->db_version() ); |
||
138 | |||
139 | ?> |
||
140 | </td> |
||
141 | <td> |
||
142 | <?php |
||
143 | |||
144 | if ( version_compare( $wpdb->db_version(), '5', '>' ) ) { |
||
145 | echo '✓'; |
||
146 | } else { |
||
147 | esc_html_e( 'Pronamic Pay requires MySQL 5 or above.', 'pronamic_ideal' ); |
||
148 | } |
||
149 | |||
150 | ?> |
||
151 | </td> |
||
152 | </tr> |
||
153 | <tr> |
||
154 | <th scope="row"> |
||
155 | <?php esc_html_e( 'WordPress Version', 'pronamic_ideal' ); ?> |
||
156 | </th> |
||
157 | <td> |
||
158 | <?php echo esc_html( get_bloginfo( 'version' ) ); ?> |
||
159 | </td> |
||
160 | <td> |
||
161 | <?php |
||
162 | |||
163 | if ( version_compare( get_bloginfo( 'version' ), '3.2', '>' ) ) { |
||
164 | echo '✓'; |
||
165 | } else { |
||
166 | esc_html_e( 'Pronamic Pay requires WordPress 3.2 or above.', 'pronamic_ideal' ); |
||
167 | } |
||
168 | |||
169 | ?> |
||
170 | </td> |
||
171 | </tr> |
||
172 | <tr> |
||
173 | <th scope="row"> |
||
174 | <?php esc_html_e( 'WP Memory Limit', 'pronamic_ideal' ); ?> |
||
175 | </th> |
||
176 | <td> |
||
177 | <?php |
||
178 | |||
179 | $memory = pronamic_pay_let_to_num( WP_MEMORY_LIMIT ); |
||
180 | |||
181 | echo esc_html( size_format( $memory ) ); |
||
182 | |||
183 | ?> |
||
184 | </td> |
||
185 | <td> |
||
186 | <?php |
||
187 | |||
188 | if ( $memory >= 67108864 ) { // 64 MB |
||
189 | echo '✓'; |
||
190 | } else { |
||
191 | echo wp_kses( |
||
192 | sprintf( |
||
193 | /* translators: %s: WordPress Codex link */ |
||
194 | __( 'We recommend setting memory to at least 64MB. See: <a href="%s" target="_blank">Increasing memory allocated to PHP</a>', 'pronamic_ideal' ), |
||
195 | esc_attr( 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP' ) |
||
196 | ), |
||
197 | array( |
||
198 | 'a' => array( |
||
199 | 'href' => true, |
||
200 | 'target' => true, |
||
201 | ), |
||
202 | ) |
||
203 | ); |
||
204 | } |
||
205 | |||
206 | ?> |
||
207 | </td> |
||
208 | </tr> |
||
209 | <tr> |
||
210 | <th scope="row"> |
||
211 | <?php esc_html_e( 'Character Set', 'pronamic_ideal' ); ?> |
||
212 | </th> |
||
213 | <td> |
||
214 | <?php bloginfo( 'charset' ); ?> |
||
215 | </td> |
||
216 | <td> |
||
217 | <?php |
||
218 | |||
219 | // @link http://codex.wordpress.org/Function_Reference/bloginfo#Show_Character_Set |
||
220 | if ( 0 === strcasecmp( get_bloginfo( 'charset' ), 'UTF-8' ) ) { |
||
221 | echo '✓'; |
||
222 | } else { |
||
223 | esc_html_e( 'Pronamic Pay advices to set the character encoding to UTF-8.', 'pronamic_ideal' ); |
||
224 | } |
||
225 | |||
226 | ?> |
||
227 | </td> |
||
228 | </tr> |
||
229 | <tr> |
||
230 | <th scope="row"> |
||
231 | <?php esc_html_e( 'Time', 'pronamic_ideal' ); ?> |
||
232 | </th> |
||
233 | <td> |
||
234 | <?php echo esc_html( date( __( 'Y/m/d g:i:s A', 'pronamic_ideal' ) ) ); ?> |
||
235 | </td> |
||
236 | <td> |
||
237 | ✓ |
||
238 | </td> |
||
239 | </tr> |
||
240 | <tr> |
||
241 | <th scope="row"> |
||
242 | <?php esc_html_e( 'cURL', 'pronamic_ideal' ); ?> |
||
243 | </th> |
||
244 | <td> |
||
245 | <?php |
||
246 | |||
247 | if ( function_exists( 'curl_version' ) ) { |
||
248 | // @codingStandardsIgnoreStart |
||
249 | // Using cURL functions is highly discouraged within VIP context |
||
250 | // We only use this cURL function for on the system status page |
||
251 | $version = curl_version(); |
||
252 | // @codingStandardsIgnoreEnd |
||
253 | |||
254 | if ( isset( $version['version'] ) ) { |
||
255 | echo esc_html( $version['version'] ); |
||
256 | } |
||
257 | } |
||
258 | |||
259 | ?> |
||
260 | </td> |
||
261 | <td> |
||
262 | ✓ |
||
263 | </td> |
||
264 | </tr> |
||
265 | <tr> |
||
266 | <th scope="row"> |
||
267 | <?php esc_html_e( 'OpenSSL', 'pronamic_ideal' ); ?> |
||
268 | </th> |
||
269 | <td> |
||
270 | <?php |
||
271 | |||
272 | if ( defined( 'OPENSSL_VERSION_TEXT' ) ) { |
||
273 | echo esc_html( OPENSSL_VERSION_TEXT ); |
||
274 | } |
||
275 | |||
276 | // @link https://www.openssl.org/docs/crypto/OPENSSL_VERSION_NUMBER.html |
||
277 | $version_required = 0x000908000; |
||
278 | |||
279 | ?> |
||
280 | </td> |
||
281 | <td> |
||
282 | <?php |
||
283 | |||
284 | if ( version_compare( OPENSSL_VERSION_NUMBER, 0x000908000, '>' ) ) { |
||
285 | echo '✓'; |
||
286 | } else { |
||
287 | esc_html_e( 'Pronamic Pay requires OpenSSL 0.9.8 or above.', 'pronamic_ideal' ); |
||
288 | } |
||
289 | |||
290 | ?> |
||
291 | </td> |
||
292 | </tr> |
||
293 | <tr> |
||
294 | <th scope="row"> |
||
295 | <?php esc_html_e( 'Registered Hashing Algorithms', 'pronamic_ideal' ); ?> |
||
296 | </th> |
||
297 | <td> |
||
298 | <?php |
||
299 | |||
300 | $algorithms = hash_algos(); |
||
301 | |||
302 | echo esc_html( implode( ', ', $algorithms ) ); |
||
303 | |||
304 | ?> |
||
305 | </td> |
||
306 | <td> |
||
307 | <?php |
||
308 | |||
309 | if ( in_array( 'sha1', $algorithms, true ) ) { |
||
310 | echo '✓'; |
||
311 | } else { |
||
312 | esc_html_e( 'Pronamic Pay requires the "sha1" hashing algorithm.', 'pronamic_ideal' ); |
||
313 | } |
||
314 | |||
315 | ?> |
||
316 | </td> |
||
317 | </tr> |
||
318 | <tr> |
||
319 | <th scope="row"> |
||
320 | <?php esc_html_e( 'Travis CI build status', 'pronamic_ideal' ); ?> |
||
321 | </th> |
||
322 | <td> |
||
323 | <?php |
||
324 | |||
325 | $url = add_query_arg( 'branch', $this->plugin->get_version(), 'https://travis-ci.org/pronamic/wp-pronamic-ideal.png' ); |
||
326 | |||
327 | ?> |
||
328 | <a href="https://travis-ci.org/pronamic/wp-pronamic-ideal"> |
||
329 | <img src="<?php echo esc_attr( $url ); ?>" alt="" /> |
||
330 | </a> |
||
331 | </td> |
||
332 | <td> |
||
333 | |||
334 | </td> |
||
335 | </tr> |
||
336 | </tbody> |
||
337 | </table> |
||
338 | |||
339 | <?php |
||
340 | |||
341 | $data = get_transient( 'pronamic_pay_ideal_issuers_status' ); |
||
342 | |||
343 | if ( ! $data ) { |
||
344 | |||
345 | $url = 'http://www.ideal-status.nl/static/issuers_current.json'; |
||
346 | |||
347 | $response = wp_remote_get( $url ); |
||
348 | |||
349 | $status_data = null; |
||
350 | |||
351 | if ( ! is_wp_error( $response ) ) { |
||
352 | if ( 200 === wp_remote_retrieve_response_code( $response ) ) { |
||
353 | $body = wp_remote_retrieve_body( $response ); |
||
354 | |||
355 | $data = json_decode( $body ); |
||
356 | |||
357 | if ( false !== $data ) { |
||
358 | set_transient( 'pronamic_pay_ideal_issuers_status', $data, 30 ); |
||
359 | } |
||
360 | } |
||
361 | } |
||
362 | } |
||
363 | |||
364 | ?> |
||
365 | |||
366 | <table class="wp-list-table widefat pronamic-pay-table pronamic-pay-status-table"> |
||
367 | <thead> |
||
368 | <tr> |
||
369 | <th colspan="5"> |
||
370 | <?php esc_html_e( 'iDEAL issuers status', 'pronamic_ideal' ); ?> |
||
371 | |||
372 | — |
||
373 | |||
374 | <?php |
||
375 | |||
376 | echo wp_kses( |
||
377 | sprintf( |
||
378 | /* translators: %s: iDEAL-status.nl link */ |
||
379 | __( 'monitored by <a href="%s" target="_blank">iDEAL-status.nl</a>', 'pronamic_ideal' ), |
||
380 | 'http://www.ideal-status.nl/' |
||
381 | ), |
||
382 | array( |
||
383 | 'a' => array( |
||
384 | 'href' => true, |
||
385 | 'target' => true, |
||
386 | ), |
||
387 | ) |
||
388 | ); |
||
389 | |||
390 | ?> |
||
391 | </th> |
||
392 | </tr> |
||
393 | <tr class="alternate"> |
||
394 | <th scope="col"> |
||
395 | <?php esc_html_e( 'Issuer', 'pronamic_ideal' ); ?> |
||
396 | </th> |
||
397 | <th scope="col"> |
||
398 | <?php esc_html_e( 'Success', 'pronamic_ideal' ); ?> |
||
399 | </th> |
||
400 | <th scope="col"> |
||
401 | <?php esc_html_e( 'Failure', 'pronamic_ideal' ); ?> |
||
402 | </th> |
||
403 | <th scope="col"> |
||
404 | <?php esc_html_e( 'Date', 'pronamic_ideal' ); ?> |
||
405 | </th> |
||
406 | </tr> |
||
407 | </thead> |
||
408 | |||
409 | <tbody> |
||
410 | |||
411 | <?php if ( is_object( $data ) ) : ?> |
||
412 | |||
413 | <?php $alternate = true; ?> |
||
414 | |||
415 | <?php foreach ( $data as $status ) : ?> |
||
416 | |||
417 | <?php $alternate = ! $alternate; ?> |
||
418 | |||
419 | <tr<?php if ( $alternate ) : ?> class="alternate"<?php endif; ?>> |
||
420 | <td> |
||
421 | <small><?php echo esc_html( $status->issuer_id ); ?></small> |
||
422 | |||
423 | – |
||
424 | |||
425 | <?php echo esc_html( $status->issuer_name ); ?> |
||
426 | </td> |
||
427 | <td> |
||
428 | <?php echo esc_html( number_format( $status->rate_success * 100, 1, ',', '.' ) ); ?>% |
||
429 | </td> |
||
430 | <td> |
||
431 | <?php echo esc_html( number_format( $status->rate_failure * 100, 1, ',', '.' ) ); ?>% |
||
432 | </td> |
||
433 | <td> |
||
434 | <?php echo esc_html( $status->datetime ); ?> |
||
435 | </td> |
||
436 | </tr> |
||
437 | |||
438 | <?php endforeach; ?> |
||
439 | |||
440 | <?php endif; ?> |
||
441 | |||
442 | </tbody> |
||
443 | </table> |
||
444 |