1 | <?php |
||
2 | /** |
||
3 | * Meta Box Form Options |
||
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 | wp_nonce_field( 'pronamic_pay_save_form_options', 'pronamic_pay_nonce' ); |
||
12 | |||
13 | ?> |
||
14 | <table class="form-table"> |
||
15 | <tr> |
||
16 | <th scope="row"> |
||
17 | <label for="_pronamic_payment_form_config_id"> |
||
18 | <?php esc_html_e( 'Gateway', 'pronamic_ideal' ); ?> |
||
19 | </label> |
||
20 | </th> |
||
21 | <td> |
||
22 | <?php |
||
23 | |||
24 | $config_id = get_post_meta( $post->ID, '_pronamic_payment_form_config_id', true ); |
||
25 | |||
26 | \Pronamic\WordPress\Pay\Admin\AdminModule::dropdown_configs( |
||
27 | array( |
||
28 | 'name' => '_pronamic_payment_form_config_id', |
||
29 | 'selected' => $config_id, |
||
30 | ) |
||
31 | ); |
||
32 | |||
33 | ?> |
||
34 | </td> |
||
35 | </tr> |
||
36 | <tr> |
||
37 | <th scope="row"> |
||
38 | <label for="_pronamic_payment_form_button_text"> |
||
39 | <?php esc_html_e( 'Button Text', 'pronamic_ideal' ); ?> |
||
40 | </label> |
||
41 | </th> |
||
42 | <td> |
||
43 | <?php $button_text = get_post_meta( $post->ID, '_pronamic_payment_form_button_text', true ); ?> |
||
44 | |||
45 | <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
Bug
introduced
by
![]() |
|||
46 | </td> |
||
47 | </tr> |
||
48 | <tr> |
||
49 | <th scope="row"> |
||
50 | <label for="_pronamic_payment_form_amount_method"> |
||
51 | <?php esc_html_e( 'Amount', 'pronamic_ideal' ); ?> |
||
52 | </label> |
||
53 | </th> |
||
54 | <td> |
||
55 | <select name="_pronamic_payment_form_amount_method"> |
||
56 | <?php |
||
57 | |||
58 | $amount_method = get_post_meta( $post->ID, '_pronamic_payment_form_amount_method', true ); |
||
59 | |||
60 | $options = array( |
||
61 | \Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_INPUT_ONLY => __( 'Show as input field', 'pronamic_ideal' ), |
||
62 | \Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_CHOICES_ONLY => __( 'Show as choices', 'pronamic_ideal' ), |
||
63 | \Pronamic\WordPress\Pay\Forms\FormPostType::AMOUNT_METHOD_CHOICES_AND_INPUT => __( 'Show as choices with input field', 'pronamic_ideal' ), |
||
64 | ); |
||
65 | |||
66 | foreach ( $options as $value => $name ) { |
||
67 | printf( |
||
68 | '<option value="%s" %s>%s</option>', |
||
69 | esc_attr( $value ), |
||
70 | selected( $value, $amount_method, false ), |
||
71 | esc_html( $name ) |
||
72 | ); |
||
73 | } |
||
74 | ?> |
||
75 | </select> |
||
76 | </td> |
||
77 | </tr> |
||
78 | <tr> |
||
79 | <th scope="row"> |
||
80 | </th> |
||
81 | <td> |
||
82 | <?php |
||
83 | |||
84 | $choices = get_post_meta( $post->ID, '_pronamic_payment_form_amount_choices', true ); |
||
85 | |||
86 | // Start with an empty field. |
||
87 | if ( empty( $choices ) ) { |
||
88 | $choices = array( '' ); |
||
89 | } |
||
90 | |||
91 | // Add empty input field. |
||
92 | $choices[] = ''; |
||
93 | |||
94 | foreach ( $choices as $i => $amount ) { |
||
95 | if ( ! empty( $amount ) ) { |
||
96 | $decimals = ( $amount % 100 > 0 ? 2 : 0 ); |
||
97 | |||
98 | $amount = number_format( ( $amount / 100 ), $decimals, pronamic_pay_get_decimal_separator(), pronamic_pay_get_thousands_separator() ); |
||
99 | } |
||
100 | |||
101 | printf( |
||
102 | '<div> |
||
103 | <label for="_pronamic_payment_form_amount_choice_%d"> |
||
104 | € <input id="_pronamic_payment_form_amount_choice_%d" type="text" name="_pronamic_payment_form_amount_choices[]" value="%s" /> |
||
105 | </label> |
||
106 | </div>', |
||
107 | esc_attr( $i ), |
||
108 | esc_attr( $i ), |
||
109 | esc_attr( $amount ) |
||
110 | ); |
||
111 | } |
||
112 | ?> |
||
113 | </td> |
||
114 | </tr> |
||
115 | </table> |
||
116 |