/** * Get an payment method field * * @since 1.3.0 * @return array */ public function get_payment_method_field($other_first = false) { $choices = null; if (method_exists($this, 'get_supported_payment_methods')) { $gateway_methods = $this->get_transient_payment_methods(); if (is_array($gateway_methods)) { $choices = array(); foreach ($this->get_supported_payment_methods() as $method_id) { $choices[$method_id] = Pronamic_WP_Pay_PaymentMethods::get_name($method_id); } if (!$this->payment_method_is_required()) { if ($other_first) { $choices = array(_x('All available methods', 'Payment method field', 'pronamic_ideal')) + $choices; } else { $choices[] = _x('Other', 'Payment method field', 'pronamic_ideal'); } } } elseif (Pronamic_WP_Pay_PaymentMethods::IDEAL === $gateway_methods) { $choices[Pronamic_WP_Pay_PaymentMethods::IDEAL] = __('iDEAL', 'pronamic_ideal'); } } if (null === $choices && !$this->payment_method_is_required()) { $choices = array('' => _x('All available methods', 'Payment method field', 'pronamic_ideal')); } return array('id' => 'pronamic_pay_payment_method_id', 'name' => 'pronamic_pay_payment_method_id', 'label' => __('Choose a payment method', 'pronamic_ideal'), 'required' => true, 'type' => 'select', 'choices' => array(array('options' => $choices))); }
printf(__('Default: <code>%s</code>.', 'pronamic_ideal'), __('Pay', 'pronamic_ideal')); // WPCS: xss OK ?> </p> <p> <?php esc_html_e('Payment Method', 'pronamic_ideal'); ?> : <select class="jPronamicIdealPaymentMethodShortcode"> <option value=""><?php echo esc_html_x('All available methods', 'Payment method field', 'pronamic_ideal'); ?> </option> <?php $methods = Pronamic_WP_Pay_PaymentMethods::get_payment_methods(); foreach ($methods as $method => $name) { printf('<option value="%s">%s</option>', esc_attr($method), esc_html($name)); } ?> </select> </p> </td> </tr> <tr> <th><?php esc_html_e('Shortcode', 'pronamic_ideal'); ?> </th> <td>
/** * Editor JavaScript default field values. * * @see https://github.com/wp-premium/gravityforms/blob/2.0.3/js.php#L587-L599 * @see https://github.com/wp-premium/gravityforms/blob/2.0.3/js/forms.js#L38-L43 */ static function editor_js_set_default_values() { ?> case '<?php echo esc_js(self::TYPE); ?> ' : if ( ! field.label ) { field.label = '<?php echo esc_js(__('Choose a payment method', 'pronamic_ideal')); ?> '; } field.enableChoiceValue = true; if ( ! field.choices ) { field.choices = new Array(); <?php foreach (Pronamic_WP_Pay_PaymentMethods::get_payment_methods() as $value => $label) { ?> var choice = new Choice( <?php echo json_encode($label); ?> , <?php echo json_encode($value); ?> ); choice.isSelected = true; choice.builtin = true; field.choices.push( choice ); <?php } ?> } break; <?php }