Failed Conditions
Push — develop ( 7671b8...0351bb )
by Reüel
03:52
created

admin/meta-box-subscription-info.php (2 issues)

Labels
Severity
1
<?php
2
/**
3
 * Meta Box Subscription Info
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 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( 'Description', 'pronamic_ideal' ); ?>
44
		</th>
45
		<td>
46
			<?php echo esc_html( $subscription->get_description() ); ?>
47
		</td>
48
	</tr>
49
	<tr>
50
		<th scope="row">
51
			<?php esc_html_e( 'Gateway', 'pronamic_ideal' ); ?>
52
		</th>
53
		<td>
54
			<?php edit_post_link( get_the_title( $subscription->config_id ), '', '', $subscription->config_id ); ?>
55
		</td>
56
	</tr>
57
	<tr>
58
		<th scope="row">
59
			<?php esc_html_e( 'Payment Method', 'pronamic_ideal' ); ?>
60
		</th>
61
		<td>
62
			<?php echo esc_html( PaymentMethods::get_name( $subscription->payment_method ) ); ?>
63
		</td>
64
	</tr>
65
	<tr>
66
		<th scope="row">
67
			<?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?>
68
		</th>
69
		<td>
70
			<?php
71
72
			if ( current_user_can( 'edit_post', $post_id ) && apply_filters( 'pronamic_pay_subscription_amount_editable_' . $subscription->get_source(), false ) ) :
73
74
				echo esc_html( $subscription->get_amount()->get_currency()->get_symbol() );
75
76
				$amount = $subscription->get_amount()->format_i18n( '%2$s' );
77
78
				?>
79
80
				<input type="text" name="_pronamic_subscription_amount" value="<?php echo esc_attr( $amount ); ?>" size="12" />
81
82
				<?php
83
84
			else :
85
86
				echo esc_html( $subscription->get_amount()->format_i18n() );
87
88
			endif;
89
90
			?>
91
		</td>
92
	</tr>
93
	<tr>
94
		<th scope="row">
95
			<?php echo esc_html_x( 'Interval', 'Recurring payment', 'pronamic_ideal' ); ?>
96
		</th>
97
		<td>
98
			<?php echo esc_html( Util::format_interval( $subscription->get_interval(), $subscription->get_interval_period() ) ); ?>
99
		</td>
100
	</tr>
101
	<tr>
102
		<th scope="row">
103
			<?php echo esc_html_x( 'Frequency', 'Recurring payment', 'pronamic_ideal' ); ?>
104
		</th>
105
		<td>
106
			<?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 ignore-type  annotation

106
			<?php echo esc_html( Util::format_frequency( /** @scrutinizer ignore-type */ $subscription->get_frequency() ) ); ?>
Loading history...
107
		</td>
108
	</tr>
109
	<tr>
110
		<th scope="row">
111
			<?php esc_html_e( 'Start Date', 'pronamic_ideal' ); ?>
112
		</th>
113
		<td>
114
			<?php
115
116
			$start_date = $subscription->get_start_date();
117
118
			echo empty( $start_date ) ? '—' : esc_html( $start_date->format_i18n() );
119
120
			?>
121
		</td>
122
	</tr>
123
124
	<?php
125
126
	$frequency = $subscription->get_frequency();
127
128
	// Show end date if frequency is limited.
129
	if ( ! empty( $frequency ) ) :
130
131
	?>
132
133
		<tr>
134
			<th scope="row">
135
				<?php esc_html_e( 'End Date', 'pronamic_ideal' ); ?>
136
			</th>
137
			<td>
138
				<?php
139
140
				$end_date = $subscription->get_end_date();
141
142
				echo empty( $end_date ) ? '—' : esc_html( $end_date->format_i18n() );
143
144
				?>
145
			</td>
146
		</tr>
147
148
	<?php endif; ?>
149
150
	<?php
151
152
	// Show next payment date if subscription is not cancelled or completed.
153
	if ( ! in_array( $subscription->get_status(), array( Statuses::CANCELLED, Statuses::COMPLETED ), true ) ) :
154
155
	?>
156
157
		<tr>
158
			<th scope="row">
159
				<?php esc_html_e( 'Next Payment Date', 'pronamic_ideal' ); ?>
160
			</th>
161
			<td>
162
				<?php
163
164
				$next_payment = $subscription->get_next_payment_date();
165
166
				echo empty( $next_payment ) ? '—' : esc_html( $next_payment->format_i18n() );
167
168
				?>
169
			</td>
170
		</tr>
171
172
	<?php endif; ?>
173
174
	<tr>
175
		<th scope="row">
176
			<?php esc_html_e( 'Expiry Date', 'pronamic_ideal' ); ?>
177
		</th>
178
		<td>
179
			<?php
180
181
			$expiry_date = $subscription->get_expiry_date();
182
183
			echo empty( $expiry_date ) ? '—' : esc_html( $expiry_date->format_i18n() );
184
185
			?>
186
		</td>
187
	</tr>
188
	<tr>
189
		<th scope="row">
190
			<?php esc_html_e( 'Consumer', 'pronamic_ideal' ); ?>
191
		</th>
192
		<td>
193
			<?php
194
195
			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 ignore-type  annotation

195
			echo esc_html( /** @scrutinizer ignore-type */ get_post_meta( $post_id, '_pronamic_subscription_consumer_name', true ) );
Loading history...
196
			echo '<br />';
197
			echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_iban', true ) );
198
			echo '<br />';
199
			echo esc_html( get_post_meta( $post_id, '_pronamic_subscription_consumer_bic', true ) );
200
201
			?>
202
		</td>
203
	</tr>
204
	<tr>
205
		<th scope="row">
206
			<?php esc_html_e( 'Source', 'pronamic_ideal' ); ?>
207
		</th>
208
		<td>
209
			<?php
210
211
			echo $subscription->get_source_text(); // WPCS: XSS ok.
212
213
			?>
214
		</td>
215
	</tr>
216
217
	<?php if ( 's2member' === $subscription->get_source() ) : ?>
218
219
		<tr>
220
			<th scope="row">
221
				<?php esc_html_e( 'Period', 'pronamic_ideal' ); ?>
222
			</th>
223
			<td>
224
				<?php echo esc_html( get_post_meta( $subscription->get_id(), '_pronamic_subscription_s2member_period', true ) ); ?>
225
			</td>
226
		</tr>
227
		<tr>
228
			<th scope="row">
229
				<?php esc_html_e( 'Level', 'pronamic_ideal' ); ?>
230
			</th>
231
			<td>
232
				<?php echo esc_html( get_post_meta( $subscription->get_id(), '_pronamic_subscription_s2member_level', true ) ); ?>
233
			</td>
234
		</tr>
235
236
	<?php endif; ?>
237
</table>
238