/**
     * Field standard settings.
     *
     * @see https://github.com/wp-premium/gravityforms/blob/1.9.19/form_detail.php#L525
     * @param int $position position of the field settings
     * @param int $form_id current form ID
     */
    public function field_standard_settings($position, $form_id)
    {
        if (10 !== $position) {
            return;
        }
        $feeds = get_pronamic_gf_pay_feeds_by_form_id($form_id);
        if (empty($feeds)) {
            return;
        }
        ?>
		<li class="pronamic_pay_config_field_setting field_setting">
			<label for="pronamic_pay_config_field">
				<?php 
        esc_html_e('Payment Gateway Configuration', 'pronamic_ideal');
        ?>

				<?php 
        gform_tooltip('form_field_pronamic_pay_config');
        ?>
			</label>

			<select id="pronamic_pay_config_field" onchange="SetFieldProperty( 'pronamicPayConfigId', jQuery( this ).val() );" class="fieldwidth-3">
				<option value=""><?php 
        esc_html_e('— Use Payment Feed Setting —', 'pronamic_ideal');
        ?>
</option>
				<?php 
        foreach ($feeds as $feed) {
            printf('<option value="%s">%s</option>', esc_attr($feed->config_id), get_the_title($feed->config_id));
        }
        ?>
			</select>
		</li>
		<?php 
    }
function get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id)
{
    $feeds = get_pronamic_gf_pay_feeds_by_form_id($form_id);
    if (!empty($feeds)) {
        $form = RGFormsModel::get_form_meta($form_id);
        foreach ($feeds as $feed) {
            if (Pronamic_WP_Pay_Extensions_GravityForms_Util::is_condition_true($form, $feed)) {
                return $feed;
            }
        }
    }
    return null;
}
Example #3
0
function get_pronamic_gf_pay_conditioned_feed_by_form_id($form_id, $with_ideal_issuers = false)
{
    $feeds = get_pronamic_gf_pay_feeds_by_form_id($form_id);
    if (!empty($feeds)) {
        $form = RGFormsModel::get_form_meta($form_id);
        if ($with_ideal_issuers) {
            foreach ($feeds as $feed) {
                $gateway = Pronamic_WP_Pay_Plugin::get_gateway($feed->config_id);
                if ($gateway && null !== $gateway->get_issuers()) {
                    return $feed;
                }
            }
        } else {
            foreach ($feeds as $feed) {
                if (Pronamic_WP_Pay_Extensions_GravityForms_Util::is_condition_true($form, $feed)) {
                    return $feed;
                }
            }
        }
    }
    return null;
}
 /**
  * Get the field input.
  *
  * @see https://github.com/wp-premium/gravityforms/blob/2.0.3/includes/fields/class-gf-field-select.php#L41-L60
  * @see https://github.com/wp-premium/gravityforms/blob/2.0.3/includes/fields/class-gf-field.php#L182-L193
  * @param array $form
  * @param string $value
  * @param array $entry
  * @return string
  */
 public function get_field_input($form, $value = '', $entry = null)
 {
     // Error handling
     if (is_wp_error($this->error)) {
         return $this->error->get_error_message();
     }
     // Input
     $input = parent::get_field_input($form, $value, $entry);
     if (is_admin()) {
         $feeds = get_pronamic_gf_pay_feeds_by_form_id($form['id']);
         $new_feed_url = add_query_arg('post_type', 'pronamic_pay_gf', admin_url('post-new.php'));
         if (empty($feeds)) {
             $link = sprintf('<a class="ideal-edit-link" href="%s" target="_blank">%s</a>', esc_attr($new_feed_url), __('New Payment Feed', 'pronamic_ideal'));
             $input = $link . $input;
         }
         if (!empty($feeds) && empty($this->choices)) {
             // If there are feeds and no choices it's very likely this field is no supported by the gateway.
             $error = sprintf('<p class="pronamic-pay-error"><strong>%s</strong><br><em>%s</em></p>', __('This field is not supported by your payment gateway.', 'pronamic_ideal'), sprintf(__('Please remove it from this form or <a href="%s" target="_blank">add a supported payment gateway</a>.', 'pronamic_ideal'), esc_attr($new_feed_url)));
             $input = $error . $input;
         }
     }
     return $input;
 }
 /**
  * Get the field input.
  *
  * @see https://github.com/wp-premium/gravityforms/blob/2.0.3/includes/fields/class-gf-field-select.php#L41-L60
  * @see https://github.com/wp-premium/gravityforms/blob/2.0.3/includes/fields/class-gf-field.php#L182-L193
  * @param array $form
  * @param string $value
  * @param array $entry
  * @return string
  */
 public function get_field_input($form, $value = '', $entry = null)
 {
     // Error handling
     if (is_wp_error($this->error)) {
         return $this->error->get_error_message();
     }
     // Input
     $input = parent::get_field_input($form, $value, $entry);
     if (is_admin()) {
         $feeds = get_pronamic_gf_pay_feeds_by_form_id($form['id']);
         if (empty($feeds)) {
             $link = 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 pay feed', 'pronamic_ideal'));
             $input = $link . $input;
         }
     }
     return $input;
 }