Failed Conditions
Push — develop ( 9d33a0...66fedd )
by Reüel
08:59
created

admin/meta-box-form-options.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Meta Box Form Options
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\Money\Money;
12
13
wp_nonce_field( 'pronamic_pay_save_form_options', 'pronamic_pay_nonce' );
14
15
?>
16
<table class="form-table">
17
	<tr>
18
		<th scope="row">
19
			<label for="_pronamic_payment_form_config_id">
20
				<?php esc_html_e( 'Gateway', 'pronamic_ideal' ); ?>
21
			</label>
22
		</th>
23
		<td>
24
			<?php
25
26
			$config_id = get_post_meta( $post->ID, '_pronamic_payment_form_config_id', true );
27
28
			\Pronamic\WordPress\Pay\Admin\AdminModule::dropdown_configs(
29
				array(
30
					'name'     => '_pronamic_payment_form_config_id',
31
					'selected' => $config_id,
32
				)
33
			);
34
35
			?>
36
		</td>
37
	</tr>
38
	<tr>
39
		<th scope="row">
40
			<label for="_pronamic_payment_form_button_text">
41
				<?php esc_html_e( 'Button Text', 'pronamic_ideal' ); ?>
42
			</label>
43
		</th>
44
		<td>
45
			<?php $button_text = get_post_meta( $post->ID, '_pronamic_payment_form_button_text', true ); ?>
46
47
			<input class="regular-text" type="text" name="_pronamic_payment_form_button_text" value="<?php echo esc_attr( $button_text ); ?>" placeholder="<?php esc_attr_e( 'Pay Now', 'pronamic_ideal' ); ?>" />
0 ignored issues
show
It seems like $button_text can also be of type false; however, parameter $text of esc_attr() 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

47
			<input class="regular-text" type="text" name="_pronamic_payment_form_button_text" value="<?php echo esc_attr( /** @scrutinizer ignore-type */ $button_text ); ?>" placeholder="<?php esc_attr_e( 'Pay Now', 'pronamic_ideal' ); ?>" />
Loading history...
48
		</td>
49
	</tr>
50
	<tr>
51
		<th scope="row">
52
			<label for="_pronamic_payment_form_amount_method">
53
				<?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?>
54
			</label>
55
		</th>
56
		<td>
57
			<select name="_pronamic_payment_form_amount_method">
58
				<?php
59
60
				$amount_method = get_post_meta( $post->ID, '_pronamic_payment_form_amount_method', true );
61
62
				$options = array(
63
					\Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_INPUT_ONLY        => __( 'Show as input field', 'pronamic_ideal' ),
64
					\Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_CHOICES_ONLY      => __( 'Show as choices', 'pronamic_ideal' ),
65
					\Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_CHOICES_AND_INPUT => __( 'Show as choices with input field', 'pronamic_ideal' ),
66
				);
67
68
				foreach ( $options as $value => $name ) {
69
					printf(
70
						'<option value="%s" %s>%s</option>',
71
						esc_attr( $value ),
72
						selected( $value, $amount_method, false ),
73
						esc_html( $name )
74
					);
75
				}
76
				?>
77
			</select>
78
		</td>
79
	</tr>
80
	<tr>
81
		<th scope="row">
82
		</th>
83
		<td>
84
			<?php
85
86
			$choices = get_post_meta( $post->ID, '_pronamic_payment_form_amount_choices', true );
87
88
			// Start with an empty field.
89
			if ( empty( $choices ) ) {
90
				$choices = array( '' );
91
			}
92
93
			// Add empty input field.
94
			$choices[] = '';
95
96
			foreach ( $choices as $i => $amount ) {
97
				$value = '';
98
99
				if ( $amount ) {
100
					$money = new Money();
101
102
					$value = number_format_i18n( $amount / 100, 2 );
103
				}
104
105
				printf(
106
					'<div>
107
						<label for="_pronamic_payment_form_amount_choice_%d">
108
							€ <input id="_pronamic_payment_form_amount_choice_%d" type="text" name="_pronamic_payment_form_amount_choices[]" value="%s" />
109
						</label>
110
					</div>',
111
					esc_attr( $i ),
112
					esc_attr( $i ),
113
					esc_attr( $value )
114
				);
115
			}
116
			?>
117
		</td>
118
	</tr>
119
</table>
120