Пример #1
0
 /**
  * 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)));
 }