1 | <?php |
||||
2 | /** |
||||
3 | * Meta Box Payment Subscription |
||||
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\Util; |
||||
12 | |||||
13 | $post_id = get_the_ID(); |
||||
14 | |||||
15 | if ( empty( $post_id ) ) { |
||||
16 | return; |
||||
17 | } |
||||
18 | |||||
19 | $payment = get_pronamic_payment( $post_id ); |
||||
20 | |||||
21 | if ( null === $payment ) { |
||||
22 | return; |
||||
23 | } |
||||
24 | |||||
25 | $subscription = $payment->get_subscription(); |
||||
26 | |||||
27 | if ( $subscription ) : ?> |
||||
28 | |||||
29 | <table class="form-table"> |
||||
30 | <tr> |
||||
31 | <th scope="row"> |
||||
32 | <?php esc_html_e( 'Subscription', 'pronamic_ideal' ); ?> |
||||
33 | </th> |
||||
34 | <td> |
||||
35 | <?php edit_post_link( get_the_title( $subscription->post->ID ), '', '', $subscription->post->ID ); ?> |
||||
36 | </td> |
||||
37 | </tr> |
||||
38 | <tr> |
||||
39 | <th scope="row"> |
||||
40 | <?php esc_html_e( 'Status', 'pronamic_ideal' ); ?> |
||||
41 | </th> |
||||
42 | <td> |
||||
43 | <?php |
||||
44 | |||||
45 | $status_object = get_post_status_object( get_post_status( $subscription->post->ID ) ); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
46 | |||||
47 | if ( isset( $status_object, $status_object->label ) ) { |
||||
48 | echo esc_html( $status_object->label ); |
||||
49 | } else { |
||||
50 | echo '—'; |
||||
51 | } |
||||
52 | |||||
53 | ?> |
||||
54 | </td> |
||||
55 | </tr> |
||||
56 | <tr> |
||||
57 | <th scope="row"> |
||||
58 | <?php esc_html_e( 'Description', 'pronamic_ideal' ); ?> |
||||
59 | </th> |
||||
60 | <td> |
||||
61 | <?php echo esc_html( $subscription->get_description() ); ?> |
||||
62 | </td> |
||||
63 | </tr> |
||||
64 | <tr> |
||||
65 | <th scope="row"> |
||||
66 | <?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?> |
||||
67 | </th> |
||||
68 | <td> |
||||
69 | <?php |
||||
70 | |||||
71 | echo esc_html( $subscription->get_total_amount()->format_i18n() ); |
||||
72 | |||||
73 | ?> |
||||
74 | </td> |
||||
75 | </tr> |
||||
76 | <tr> |
||||
77 | <th scope="row"> |
||||
78 | <?php echo esc_html_x( 'Interval', 'Recurring payment', 'pronamic_ideal' ); ?> |
||||
79 | </th> |
||||
80 | <td> |
||||
81 | <?php echo esc_html( Util::format_interval( $subscription->get_interval(), $subscription->get_interval_period() ) ); ?> |
||||
82 | </td> |
||||
83 | </tr> |
||||
84 | <tr> |
||||
85 | <th scope="row"> |
||||
86 | <?php echo esc_html_x( 'Frequency', 'Recurring payment', 'pronamic_ideal' ); ?> |
||||
87 | </th> |
||||
88 | <td> |
||||
89 | <?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
![]() |
|||||
90 | </td> |
||||
91 | </tr> |
||||
92 | <tr> |
||||
93 | <th scope="row"> |
||||
94 | <?php esc_html_e( 'Source', 'pronamic_ideal' ); ?> |
||||
95 | </th> |
||||
96 | <td> |
||||
97 | <?php |
||||
98 | |||||
99 | echo $subscription->get_source_text(); // WPCS: XSS ok. |
||||
100 | |||||
101 | ?> |
||||
102 | </td> |
||||
103 | </tr> |
||||
104 | </table> |
||||
105 | |||||
106 | <?php else : ?> |
||||
107 | |||||
108 | <p> |
||||
109 | <?php esc_html_e( 'This payment is not related to a subscription.', 'pronamic_ideal' ); ?> |
||||
110 | </p> |
||||
111 | |||||
112 | <?php endif; ?> |
||||
113 |