Exemplo n.º 1
0
 /**
  * Acquirrer field input
  *
  * @param string $field_content
  * @param string $field
  * @param string $value
  * @param string $lead_id
  * @param string $form_id
  */
 public static function acquirer_field_input($field_content, $field, $value, $lead_id, $form_id)
 {
     $type = RGFormsModel::get_input_type($field);
     if (Pronamic_WP_Pay_Extensions_GravityForms_IssuerDropDown::TYPE === $type) {
         $id = $field['id'];
         $field_id = IS_ADMIN || 0 === $form_id ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
         $class_suffix = RG_CURRENT_VIEW === 'entry' ? '_admin' : '';
         $size = rgar($field, 'size');
         $class = $size . $class_suffix;
         $css_class = trim(esc_attr($class) . ' gfield_ideal_acquirer_select');
         $tab_index = GFCommon::get_tabindex();
         $disabled_text = IS_ADMIN && 'entry' !== RG_CURRENT_VIEW ? "disabled='disabled'" : '';
         $html = '';
         $feed = get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, true);
         /**
          * Developing warning:
          * Don't use single quotes in the HTML you output, it is buggy in combination with SACK
          */
         if (IS_ADMIN) {
             if (null === $feed) {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", add_query_arg('post_type', 'pronamic_pay_gf', admin_url('post-new.php')), __('Create iDEAL feed', 'pronamic_ideal'));
             } else {
                 $html .= sprintf("<a class='ideal-edit-link' href='%s' target='_blank'>%s</a>", get_edit_post_link($feed->id), __('Edit iDEAL feed', 'pronamic_ideal'));
             }
         }
         $html_input = '';
         $html_error = '';
         if (null !== $feed) {
             $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
             if ($gateway) {
                 $issuer_field = $gateway->get_issuer_field();
                 $error = $gateway->get_error();
                 if (is_wp_error($error)) {
                     $html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
                     $html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
                 } elseif ($issuer_field) {
                     $choices = $issuer_field['choices'];
                     $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices, $value);
                     // Double quotes are not working, se we replace them with an single quote
                     $options = str_replace('"', '\'', $options);
                     $html_input = '';
                     $html_input .= sprintf("<select name='input_%d' id='%s' class='%s' %s %s>", $id, $field_id, $css_class, $tab_index, $disabled_text);
                     $html_input .= sprintf('%s', $options);
                     $html_input .= sprintf('</select>');
                 }
             }
         }
         if ($html_error) {
             $html .= sprintf("<div class='gfield_description validation_message'>");
             $html .= sprintf('%s', $html_error);
             $html .= sprintf('</div>');
         } else {
             $html .= sprintf("<div class='ginput_container ginput_ideal'>");
             $html .= sprintf('%s', $html_input);
             $html .= sprintf('</div>');
         }
         $field_content = $html;
     }
     return $field_content;
 }
 /**
  * Admin configuration form
  */
 public static function admin_config_form()
 {
     $html = '';
     $html .= '<tr>';
     $html .= '	<td class="wpsc_CC_details">';
     $html .= '		' . __('Configuration', 'pronamic_ideal');
     $html .= '	</td>';
     $html .= '	<td>';
     $html .= Pronamic_WP_Pay_Admin::dropdown_configs(array('name' => Pronamic_WP_Pay_Extensions_WPeCommerce_Extension::OPTION_PRONAMIC_CONFIG_ID, 'echo' => false));
     $html .= '	</td>';
     $html .= '</tr>';
     $config_id = get_option(Pronamic_WP_Pay_Extensions_WPeCommerce_Extension::OPTION_PRONAMIC_CONFIG_ID);
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         $payment_method_field = $gateway->get_payment_method_field();
         if ($payment_method_field) {
             $choices = $payment_method_field['choices'];
             $name = Pronamic_WP_Pay_Extensions_WPeCommerce_Extension::OPTION_PRONAMIC_PAYMENT_METHOD;
             $payment_method = get_option($name);
             $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices, $payment_method);
             // Double quotes are not working, se we replace them with an single quote
             $options = str_replace('"', '\'', $options);
             $html .= '<tr>';
             $html .= '	<td class="wpsc_CC_details">';
             $html .= '		' . __('Payment Method', 'pronamic_ideal');
             $html .= '	</td>';
             $html .= '	<td>';
             $html .= sprintf("<select name='%s' id='%s'>", $name, $name);
             $html .= sprintf('%s', $options);
             $html .= sprintf('</select>');
             $html .= '	</td>';
             $html .= '</tr>';
         }
     }
     return $html;
 }
Exemplo n.º 3
0
Arquivo: Util.php Projeto: wp-pay/core
 /**
  * Convert input fields array to HTML.
  *
  * @param array $fields
  * @return string
  */
 public static function input_fields_html(array $fields)
 {
     $html = '';
     foreach ($fields as $field) {
         if (!isset($field['type'])) {
             continue;
         }
         switch ($field['type']) {
             case 'select':
                 $html .= sprintf('<label for="%s">%s</label> ', esc_attr($field['id']), $field['label']);
                 $html .= sprintf('<select id="%s" name="%s">%s</select>', esc_attr($field['id']), esc_attr($field['name']), Pronamic_WP_HTML_Helper::select_options_grouped($field['choices']));
                 break;
         }
     }
     return $html;
 }
Exemplo n.º 4
0
								<span class="pronamic-pay-required-indicator">*</span>
							</label>

							<?php 
            if ('select' === $field['type']) {
                ?>

								<select id="<?php 
                echo esc_attr($field['id']);
                ?>
" name="<?php 
                echo esc_attr($field['name']);
                ?>
">
									<?php 
                echo Pronamic_WP_HTML_Helper::select_options_grouped($field['choices']);
                ?>
								</select>

							<?php 
            }
            ?>
						</p>

					<?php 
        }
        ?>

				</fieldset>

			<?php 
 /**
  * Render field.
  *
  * @param array $field
  */
 private function render_field($field)
 {
     $config_id = get_option('pronamic_pay_config_id');
     $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id);
     if ($gateway) {
         // Always use iDEAL payment method for issuer field
         $payment_method = $gateway->get_payment_method();
         $gateway->set_payment_method(Pronamic_WP_Pay_PaymentMethods::IDEAL);
         $issuer_field = $gateway->get_issuer_field();
         $error = $gateway->get_error();
         if (is_wp_error($error)) {
             $html_error .= Pronamic_WP_Pay_Plugin::get_default_error_message();
             $html_error .= '<br /><em>' . $error->get_error_message() . '</em>';
         } elseif ($issuer_field) {
             $choices = $issuer_field['choices'];
             $options = Pronamic_WP_HTML_Helper::select_options_grouped($choices);
             printf('<select name="%s" id="%s">', esc_attr(sprintf('item_meta[%s]', $field['id'])), esc_attr(sprintf('field_%s', $field['field_key'])));
             echo $options;
             echo '</select>';
         }
         // Reset payment method to original value
         $gateway->set_payment_method($payment_method);
     }
 }
         $attributes['value'] = '1';
         printf('<input %s %s />', Pronamic_WP_HTML_Helper::array_to_html_attributes($attributes), checked($value, true, false));
         printf(' ');
         printf('<label for="%s">%s</label>', esc_attr($attributes['id']), esc_html($field['label']));
         break;
     case 'textarea':
         $attributes['rows'] = 4;
         $attributes['cols'] = 65;
         printf('<textarea %s />%s</textarea>', Pronamic_WP_HTML_Helper::array_to_html_attributes($attributes), esc_textarea($value));
         break;
     case 'file':
         $attributes['type'] = 'file';
         printf('<input %s />', Pronamic_WP_HTML_Helper::array_to_html_attributes($attributes));
         break;
     case 'select':
         printf('<select %s>%s</select>', Pronamic_WP_HTML_Helper::array_to_html_attributes($attributes), Pronamic_WP_HTML_Helper::select_options_grouped($field['options'], $value));
         break;
     case 'optgroup':
         printf('<fieldset>');
         printf('<legend class="screen-reader-text">%s</legend>', esc_html($field['title']));
         foreach ($field['options'] as $key => $label) {
             printf('<label>%s %s</label><br />', sprintf('<input type="radio" value="%s" name="%s" %s />', esc_attr($key), esc_attr($attributes['name']), checked($value, $key, false)), esc_html($label));
         }
         break;
 }
 if (isset($field['description'])) {
     printf('<span class="description"><br />%s</span>', $field['description']);
 }
 if (isset($field['callback'])) {
     $callback = $field['callback'];
     $callback($field);
Exemplo n.º 7
0
 /**
  * Get the input HTML
  *
  * This function will convert all input fields to an HTML notation
  *
  * @return string
  */
 public function get_input_html()
 {
     $html = '';
     $fields = $this->get_input_fields();
     foreach ($fields as $field) {
         if (isset($field['type'])) {
             $type = $field['type'];
             switch ($type) {
                 case 'select':
                     $html .= sprintf('<label for="%s">%s</label> ', esc_attr($field['id']), $field['label']);
                     $html .= sprintf('<select id="%s" name="%s">%s</select>', esc_attr($field['id']), esc_attr($field['name']), Pronamic_WP_HTML_Helper::select_options_grouped($field['choices']));
                     break;
             }
         }
     }
     return $html;
 }