| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display the Simple Payments Form. |
| 4 |
* |
| 5 |
* @package Jetpack |
| 6 |
*/ |
| 7 |
|
| 8 |
?> |
| 9 |
<p> |
| 10 |
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"> |
| 11 |
<?php esc_html_e( 'Widget Title', 'jetpack' ); ?> |
| 12 |
</label> |
| 13 |
<input |
| 14 |
type="text" |
| 15 |
class="widefat jetpack-simple-payments-widget-title" |
| 16 |
id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" |
| 17 |
name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" |
| 18 |
value="<?php echo esc_attr( $instance['title'] ); ?>" /> |
| 19 |
</p> |
| 20 |
<p class="jetpack-simple-payments-products-fieldset" <?php if ( empty( $product_posts ) ) { echo 'style="display:none;"'; } ?>> |
| 21 |
<label for="<?php echo esc_attr( $this->get_field_id( 'product_post_id' ) ); ?>"> |
| 22 |
<?php esc_html_e( 'Select a Simple Payments Button:', 'jetpack' ); ?> |
| 23 |
</label> |
| 24 |
<select |
| 25 |
class="widefat jetpack-simple-payments-products" |
| 26 |
id="<?php echo esc_attr( $this->get_field_id( 'product_post_id' ) ); ?>" |
| 27 |
name="<?php echo esc_attr( $this->get_field_name( 'product_post_id' ) ); ?>"> |
| 28 |
<?php foreach ( $product_posts as $product_post ) { ?> |
| 29 |
<option value="<?php echo esc_attr( $product_post->ID ); ?>" <?php selected( (int) $instance['product_post_id'], $product_post->ID ); ?>> |
| 30 |
<?php echo esc_attr( get_the_title( $product_post ) ); ?> |
| 31 |
</option> |
| 32 |
<?php } ?> |
| 33 |
</select> |
| 34 |
</p> |
| 35 |
<?php if ( is_customize_preview() ) { ?> |
| 36 |
<p class="jetpack-simple-payments-products-warning" <?php if ( ! empty( $product_posts ) ) { echo 'style="display:none;"'; } ?>> |
| 37 |
<?php esc_html_e( "Looks like you don't have any products. You can create one using the Add New button below.", 'jetpack' ); ?> |
| 38 |
</p> |
| 39 |
<p> |
| 40 |
<div class="alignleft"> |
| 41 |
<button class="button jetpack-simple-payments-edit-product" <?php disabled( empty( $product_posts ), true ); ?>> |
| 42 |
<?php esc_html_e( 'Edit Selected', 'jetpack' ); ?> |
| 43 |
</button> |
| 44 |
</div> |
| 45 |
<div class="alignright"> |
| 46 |
<button class="button jetpack-simple-payments-add-product"><?php esc_html_e( 'Add New', 'jetpack' ); ?></button> |
| 47 |
</div> |
| 48 |
<br class="clear"> |
| 49 |
</p> |
| 50 |
<hr /> |
| 51 |
<div class="jetpack-simple-payments-form" style="display: none;"> |
| 52 |
<input |
| 53 |
type="hidden" |
| 54 |
id="<?php echo esc_attr( $this->get_field_id( 'form_action' ) ); ?>" |
| 55 |
name="<?php echo esc_attr( $this->get_field_name( 'form_action' ) ); ?>" |
| 56 |
value="<?php echo esc_attr( $instance['form_action'] ); ?>" |
| 57 |
class="jetpack-simple-payments-form-action" /> |
| 58 |
<input |
| 59 |
type="hidden" |
| 60 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_id' ) ); ?>" |
| 61 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_id' ) ); ?>" |
| 62 |
value="<?php echo esc_attr( $instance['form_product_id'] ); ?>" |
| 63 |
class="jetpack-simple-payments-form-product-id" /> |
| 64 |
<input |
| 65 |
type="hidden" |
| 66 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_image_id' ) ); ?>" |
| 67 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_image_id' ) ); ?>" |
| 68 |
value="<?php echo esc_attr( $instance['form_product_image_id'] ); ?>" |
| 69 |
class="jetpack-simple-payments-form-image-id" /> |
| 70 |
<input |
| 71 |
type="hidden" |
| 72 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_image_src' ) ); ?>" |
| 73 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_image_src' ) ); ?>" |
| 74 |
value="<?php echo esc_attr( $instance['form_product_image_src'] ); ?>" |
| 75 |
class="jetpack-simple-payments-form-image-src" /> |
| 76 |
<p> |
| 77 |
<label for="<?php echo esc_attr( $this->get_field_id( 'form_product_title' ) ); ?>"> |
| 78 |
<?php esc_html_e( 'What is this payment for?', 'jetpack' ); ?> |
| 79 |
</label> |
| 80 |
<input |
| 81 |
type="text" |
| 82 |
class="widefat field-title jetpack-simple-payments-form-product-title" |
| 83 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_title' ) ); ?>" |
| 84 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_title' ) ); ?>" |
| 85 |
value="<?php echo esc_attr( $instance['form_product_title'] ); ?>" /> |
| 86 |
<br /> |
| 87 |
<small> |
| 88 |
<?php esc_html_e( 'For example: event tickets, charitable donations, training courses, coaching fees, etc.', 'jetpack' ); ?> |
| 89 |
</small> |
| 90 |
</p> |
| 91 |
<div class="jetpack-simple-payments-image-fieldset"> |
| 92 |
<label><?php esc_html_e( 'Product image', 'jetpack' ); ?></label> |
| 93 |
<div class="placeholder" <?php if ( ! empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>> |
| 94 |
<?php esc_html_e( 'Select an image', 'jetpack' ); ?> |
| 95 |
</div> |
| 96 |
<div class="jetpack-simple-payments-image" <?php if ( empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>> |
| 97 |
<img src="<?php echo esc_url( $instance['form_product_image_src'] ); ?>" /> |
| 98 |
<button class="button jetpack-simple-payments-remove-image"><?php esc_html_e( 'Remove image', 'jetpack' ); ?></button> |
| 99 |
</div> |
| 100 |
</div> |
| 101 |
<p> |
| 102 |
<label for="<?php echo esc_attr( $this->get_field_id( 'form_product_description' ) ); ?>"> |
| 103 |
<?php esc_html_e( 'Description', 'jetpack' ); ?> |
| 104 |
</label> |
| 105 |
<textarea |
| 106 |
class="field-description widefat jetpack-simple-payments-form-product-description" |
| 107 |
rows=5 |
| 108 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_description' ) ); ?>" |
| 109 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_description' ) ); ?>"><?php echo esc_textarea( $instance['form_product_description'] ); ?></textarea> |
| 110 |
</p> |
| 111 |
<p class="cost"> |
| 112 |
<label for="<?php echo esc_attr( $this->get_field_id( 'form_product_price' ) ); ?>"> |
| 113 |
<?php esc_html_e( 'Price', 'jetpack' ); ?> |
| 114 |
</label> |
| 115 |
<select |
| 116 |
class="field-currency widefat jetpack-simple-payments-form-product-currency" |
| 117 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_currency' ) ); ?>" |
| 118 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_currency' ) ); ?>"> |
| 119 |
<?php foreach ( Jetpack_Simple_Payments_Widget::$supported_currency_list as $code => $currency ) { ?> |
| 120 |
<option value="<?php echo esc_attr( $code ); ?>"<?php selected( $instance['form_product_currency'], $code ); ?>> |
| 121 |
<?php echo esc_html( "$code $currency" ); ?> |
| 122 |
</option> |
| 123 |
<?php } ?> |
| 124 |
</select> |
| 125 |
<input |
| 126 |
type="text" |
| 127 |
class="field-price widefat jetpack-simple-payments-form-product-price" |
| 128 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_price' ) ); ?>" |
| 129 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_price' ) ); ?>" |
| 130 |
value="<?php echo esc_attr( $instance['form_product_price'] ); ?>" |
| 131 |
placeholder="1.00" /> |
| 132 |
</p> |
| 133 |
<p> |
| 134 |
<input |
| 135 |
class="field-multiple jetpack-simple-payments-form-product-multiple" |
| 136 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_multiple' ) ); ?>" |
| 137 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_multiple' ) ); ?>" |
| 138 |
type="checkbox" |
| 139 |
value="1" |
| 140 |
<?php checked( $instance['form_product_multiple'], '1' ); ?> /> |
| 141 |
<label for="<?php echo esc_attr( $this->get_field_id( 'form_product_multiple' ) ); ?>"> |
| 142 |
<?php esc_html_e( 'Allow people to buy more than one item at a time.', 'jetpack' ); ?> |
| 143 |
</label> |
| 144 |
</p> |
| 145 |
<p> |
| 146 |
<label for="<?php echo esc_attr( $this->get_field_id( 'form_product_email' ) ); ?>"> |
| 147 |
<?php esc_html_e( 'Email', 'jetpack' ); ?> |
| 148 |
</label> |
| 149 |
<input |
| 150 |
class="field-email widefat jetpack-simple-payments-form-product-email" |
| 151 |
id="<?php echo esc_attr( $this->get_field_id( 'form_product_email' ) ); ?>" |
| 152 |
name="<?php echo esc_attr( $this->get_field_name( 'form_product_email' ) ); ?>" |
| 153 |
type="email" |
| 154 |
value="<?php echo esc_attr( $instance['form_product_email'] ); ?>" /> |
| 155 |
<small> |
| 156 |
<?php |
| 157 |
printf( |
| 158 |
wp_kses( |
| 159 |
/* Translators: placeholders are a link to Paypal website and a target attribute. */ |
| 160 |
__( 'This is where PayPal will send your money. To claim a payment, you\'ll need a <a href="%1$s" %2$s>PayPal account</a> connected to a bank account.', 'jetpack' ), |
| 161 |
array( |
| 162 |
'a' => array( |
| 163 |
'href' => array(), |
| 164 |
'target' => array(), |
| 165 |
), |
| 166 |
) |
| 167 |
), |
| 168 |
'https://paypal.com', |
| 169 |
'target="_blank"' |
| 170 |
); |
| 171 |
?> |
| 172 |
</small> |
| 173 |
</p> |
| 174 |
<p> |
| 175 |
<div class="alignleft"> |
| 176 |
<button type="button" class="button-link button-link-delete jetpack-simple-payments-delete-product"> |
| 177 |
<?php esc_html_e( 'Delete Product', 'jetpack' ); ?> |
| 178 |
</button> |
| 179 |
</div> |
| 180 |
<div class="alignright"> |
| 181 |
<button name="<?php echo esc_attr( $this->get_field_name( 'save' ) ); ?>" class="button jetpack-simple-payments-save-product"><?php esc_html_e( 'Save', 'jetpack' ); ?></button> |
| 182 |
<span> | <button type="button" class="button-link jetpack-simple-payments-cancel-form"><?php esc_html_e( 'Cancel', 'jetpack' ); ?></button></span> |
| 183 |
</div> |
| 184 |
<br class="clear"> |
| 185 |
</p> |
| 186 |
<hr /> |
| 187 |
</div> |
| 188 |
<?php } else { ?> |
| 189 |
<p class="jetpack-simple-payments-products-warning"> |
| 190 |
<?php |
| 191 |
printf( |
| 192 |
wp_kses( |
| 193 |
/* Translators: placeholder is a link to the customizer. */ |
| 194 |
__( 'This widget adds a payment button of your choice to your sidebar. To create or edit the payment buttons themselves, <a href="%s">use the Customizer</a>.', 'jetpack' ), |
| 195 |
array( |
| 196 |
'a' => array( |
| 197 |
'href' => array(), |
| 198 |
), |
| 199 |
) |
| 200 |
), |
| 201 |
esc_url( add_query_arg( array( 'autofocus[panel]' => 'widgets' ), admin_url( 'customize.php' ) ) ) |
| 202 |
); |
| 203 |
?> |
| 204 |
</p> |
| 205 |
<?php } ?> |
| 206 |
|