public static function select_form() { check_ajax_referer("gf_user_select_form", "gf_user_select_form"); $form_id = intval(RGForms::post("form_id")); $config_id = intval(RGForms::post("config_id")); $is_update_feed = rgpost('feed_type') == 'update'; $options_meta = array(); // fields meta $form = RGFormsModel::get_form_meta($form_id); $options_meta['set_post_author'] = GFCommon::has_post_field($form['fields'], $is_update_feed) ? true : false; $form_fields = self::get_form_fields($form); $password_fields = self::get_fields_by_type($form, 'password'); $email_fields = self::get_fields_by_type($form, 'email'); $bp_gform_fields = self::get_bp_gform_fields($form); $form_dropdown_items = self::get_field_drop_down_items($form_fields, ""); $password_dropdown_items = self::get_field_drop_down_items($password_fields, "", false); $email_dropdown_items = self::get_field_drop_down_items($email_fields, ""); $output = array(); $output['form'] = $form; $output['form_fields'] = $form_fields; $output['field_options'] = $form_dropdown_items; $output['password_options'] = $password_dropdown_items; $output['email_options'] = $email_dropdown_items; $output['options_meta'] = $options_meta; $output['bp_gform_options'] = $bp_gform_fields; echo json_encode($output); die; }
private static function edit_page() { ?> <style> #paypal_submit_container{clear:both;} .paypal_col_heading{padding-bottom:2px; border-bottom: 1px solid #ccc; font-weight:bold; width:120px;} .paypal_field_cell {padding: 6px 17px 0 0; margin-right:15px;} .paypal_validation_error{ background-color:#FFDFDF; margin-top:4px; margin-bottom:6px; padding-top:6px; padding-bottom:6px; border:1px dotted #C89797;} .paypal_validation_error span {color: red;} .left_header{float:left; width:200px;} .margin_vertical_10{margin: 10px 0; padding-left:5px;} .margin_vertical_30{margin: 30px 0; padding-left:5px;} .width-1{width:300px;} .gf_paypal_invalid_form{margin-top:30px; background-color:#FFEBE8;border:1px solid #CC0000; padding:10px; width:600px;} </style> <script type="text/javascript"> var form = Array(); function ToggleNotifications(){ var container = jQuery("#gf_paypal_notification_container"); var isChecked = jQuery("#gf_paypal_delay_notifications").is(":checked"); if(isChecked){ container.slideDown(); var isLoaded = jQuery(".gf_paypal_notification").length > 0 if(!isLoaded){ container.html("<li><img src='<?php echo self::get_base_url(); ?> /images/loading.gif' title='<?php _e("Please wait...", "gravityformspaypal"); ?> '></li>"); jQuery.post(ajaxurl, { action: "gf_paypal_load_notifications", form_id: form["id"], }, function(response){ var notifications = jQuery.parseJSON(response); if(!notifications){ container.html("<li><div class='error' padding='20px;'><?php _e("Notifications could not be loaded. Please try again later or contact support", "gravityformspaypal"); ?> </div></li>"); } else if(notifications.length == 0){ container.html("<li><div class='error' padding='20px;'><?php _e("The form selected does not have any notifications.", "gravityformspaypal"); ?> </div></li>"); } else{ var str = ""; for(var i=0; i<notifications.length; i++){ str += "<li class='gf_paypal_notification'>" + "<input type='checkbox' value='" + notifications[i]["id"] + "' name='gf_paypal_selected_notifications[]' id='gf_paypal_selected_notifications' checked='checked' /> " + "<label class='inline' for='gf_paypal_selected_notifications'>" + notifications[i]["name"] + "</label>"; + "</li>"; } container.html(str); } } ); } jQuery(".gf_paypal_notification input").prop("checked", true); } else{ container.slideUp(); jQuery(".gf_paypal_notification input").prop("checked", false); } } </script> <div class="wrap"> <img alt="<?php _e("PayPal", "gravityformspaypal"); ?> " style="margin: 15px 7px 0pt 0pt; float: left;" src="<?php echo self::get_base_url(); ?> /images/paypal_wordpress_icon_32.png"/> <h2><?php _e("PayPal Transaction Settings", "gravityformspaypal"); ?> </h2> <?php //getting setting id (0 when creating a new one) $id = !empty($_POST["paypal_setting_id"]) ? $_POST["paypal_setting_id"] : absint($_GET["id"]); $config = empty($id) ? array("meta" => array(), "is_active" => true) : GFPayPalData::get_feed($id); $is_validation_error = false; $config["form_id"] = rgpost("gf_paypal_submit") ? absint(rgpost("gf_paypal_form")) : $config["form_id"]; $form = isset($config["form_id"]) && $config["form_id"] ? $form = RGFormsModel::get_form_meta($config["form_id"]) : array(); //updating meta information if (rgpost("gf_paypal_submit")) { $config["meta"]["email"] = trim(rgpost("gf_paypal_email")); $config["meta"]["mode"] = rgpost("gf_paypal_mode"); $config["meta"]["type"] = rgpost("gf_paypal_type"); $config["meta"]["style"] = rgpost("gf_paypal_page_style"); $config["meta"]["continue_text"] = rgpost("gf_paypal_continue_text"); $config["meta"]["cancel_url"] = rgpost("gf_paypal_cancel_url"); $config["meta"]["disable_note"] = rgpost("gf_paypal_disable_note"); $config["meta"]["disable_shipping"] = rgpost('gf_paypal_disable_shipping'); $config["meta"]["delay_post"] = rgpost('gf_paypal_delay_post'); $config["meta"]["update_post_action"] = rgpost('gf_paypal_update_action'); if (isset($form["notifications"])) { //new notification settings $config["meta"]["delay_notifications"] = rgpost('gf_paypal_delay_notifications'); $config["meta"]["selected_notifications"] = $config["meta"]["delay_notifications"] ? rgpost('gf_paypal_selected_notifications') : array(); if (isset($config["meta"]["delay_autoresponder"])) { unset($config["meta"]["delay_autoresponder"]); } if (isset($config["meta"]["delay_notification"])) { unset($config["meta"]["delay_notification"]); } } else { //legacy notification settings (for backwards compatibility) $config["meta"]["delay_autoresponder"] = rgpost('gf_paypal_delay_autoresponder'); $config["meta"]["delay_notification"] = rgpost('gf_paypal_delay_notification'); if (isset($config["meta"]["delay_notifications"])) { unset($config["meta"]["delay_notifications"]); } if (isset($config["meta"]["selected_notifications"])) { unset($config["meta"]["selected_notifications"]); } } // paypal conditional $config["meta"]["paypal_conditional_enabled"] = rgpost('gf_paypal_conditional_enabled'); $config["meta"]["paypal_conditional_field_id"] = rgpost('gf_paypal_conditional_field_id'); $config["meta"]["paypal_conditional_operator"] = rgpost('gf_paypal_conditional_operator'); $config["meta"]["paypal_conditional_value"] = rgpost('gf_paypal_conditional_value'); //recurring fields $config["meta"]["recurring_amount_field"] = rgpost("gf_paypal_recurring_amount"); $config["meta"]["billing_cycle_number"] = rgpost("gf_paypal_billing_cycle_number"); $config["meta"]["billing_cycle_type"] = rgpost("gf_paypal_billing_cycle_type"); $config["meta"]["recurring_times"] = rgpost("gf_paypal_recurring_times"); $config["meta"]["trial_period_enabled"] = rgpost('gf_paypal_trial_period'); $config["meta"]["trial_amount"] = rgpost('gf_paypal_trial_amount'); $config["meta"]["trial_period_number"] = rgpost('gf_paypal_trial_period_number'); $config["meta"]["trial_period_type"] = rgpost('gf_paypal_trial_period_type'); $config["meta"]["recurring_retry"] = rgpost('gf_paypal_recurring_retry'); //----------------- $customer_fields = self::get_customer_fields(); $config["meta"]["customer_fields"] = array(); foreach ($customer_fields as $field) { $config["meta"]["customer_fields"][$field["name"]] = $_POST["paypal_customer_field_{$field["name"]}"]; } $config = apply_filters('gform_paypal_save_config', $config); $is_validation_error = apply_filters("gform_paypal_config_validation", false, $config); if (GFCommon::is_valid_email($config["meta"]["email"]) && !$is_validation_error) { $id = GFPayPalData::update_feed($id, $config["form_id"], $config["is_active"], $config["meta"]); ?> <div class="updated fade" style="padding:6px"><?php echo sprintf(__("Feed Updated. %sback to list%s", "gravityformspaypal"), "<a href='?page=gf_paypal'>", "</a>"); ?> </div> <?php } else { $is_validation_error = true; } } ?> <form method="post" action=""> <input type="hidden" name="paypal_setting_id" value="<?php echo $id; ?> " /> <div class="margin_vertical_10 <?php echo $is_validation_error ? "paypal_validation_error" : ""; ?> "> <?php if ($is_validation_error) { ?> <span><?php _e('There was an issue saving your feed. Please address the errors below and try again.'); ?> </span> <?php } ?> </div> <!-- / validation message --> <div class="margin_vertical_10<?php echo $is_validation_error && !GFCommon::is_valid_email($config["meta"]["email"]) ? " paypal_validation_error" : ""; ?> "> <label class="left_header" for="gf_paypal_email"><?php _e("PayPal Email Address", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_email_address"); ?> </label> <input type="text" name="gf_paypal_email" id="gf_paypal_email" value="<?php echo rgar($config['meta'], 'email'); ?> " class="width-1"/> <?php if ($is_validation_error && !GFCommon::is_valid_email($config["meta"]["email"])) { ?> <span>Please enter a valid email address.</span> <?php } ?> </div> <div class="margin_vertical_10"> <label class="left_header"><?php _e("Mode", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_mode"); ?> </label> <input type="radio" name="gf_paypal_mode" id="gf_paypal_mode_production" value="production" <?php echo rgar($config['meta'], 'mode') != "test" ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_mode_production"><?php _e("Production", "gravityformspaypal"); ?> </label> <input type="radio" name="gf_paypal_mode" id="gf_paypal_mode_test" value="test" <?php echo rgar($config['meta'], 'mode') == "test" ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_mode_test"><?php _e("Test", "gravityformspaypal"); ?> </label> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_type"><?php _e("Transaction Type", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_transaction_type"); ?> </label> <select id="gf_paypal_type" name="gf_paypal_type" onchange="SelectType(jQuery(this).val());"> <option value=""><?php _e("Select a transaction type", "gravityformspaypal"); ?> </option> <option value="product" <?php echo rgar($config['meta'], 'type') == "product" ? "selected='selected'" : ""; ?> ><?php _e("Products and Services", "gravityformspaypal"); ?> </option> <option value="donation" <?php echo rgar($config['meta'], 'type') == "donation" ? "selected='selected'" : ""; ?> ><?php _e("Donations", "gravityformspaypal"); ?> </option> <option value="subscription" <?php echo rgar($config['meta'], 'type') == "subscription" ? "selected='selected'" : ""; ?> ><?php _e("Subscriptions", "gravityformspaypal"); ?> </option> </select> </div> <div id="paypal_form_container" valign="top" class="margin_vertical_10" <?php echo empty($config["meta"]["type"]) ? "style='display:none;'" : ""; ?> > <label for="gf_paypal_form" class="left_header"><?php _e("Gravity Form", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_gravity_form"); ?> </label> <select id="gf_paypal_form" name="gf_paypal_form" onchange="SelectForm(jQuery('#gf_paypal_type').val(), jQuery(this).val(), '<?php echo rgar($config, 'id'); ?> ');"> <option value=""><?php _e("Select a form", "gravityformspaypal"); ?> </option> <?php $active_form = rgar($config, 'form_id'); $available_forms = GFPayPalData::get_available_forms($active_form); foreach ($available_forms as $current_form) { $selected = absint($current_form->id) == rgar($config, 'form_id') ? 'selected="selected"' : ''; ?> <option value="<?php echo absint($current_form->id); ?> " <?php echo $selected; ?> ><?php echo esc_html($current_form->title); ?> </option> <?php } ?> </select> <img src="<?php echo GFPayPal::get_base_url(); ?> /images/loading.gif" id="paypal_wait" style="display: none;"/> <div id="gf_paypal_invalid_product_form" class="gf_paypal_invalid_form" style="display:none;"> <?php _e("The form selected does not have any Product fields. Please add a Product field to the form and try again.", "gravityformspaypal"); ?> </div> <div id="gf_paypal_invalid_donation_form" class="gf_paypal_invalid_form" style="display:none;"> <?php _e("The form selected does not have any Product fields. Please add a Product field to the form and try again.", "gravityformspaypal"); ?> </div> </div> <div id="paypal_field_group" valign="top" <?php echo empty($config["meta"]["type"]) || empty($config["form_id"]) ? "style='display:none;'" : ""; ?> > <div id="paypal_field_container_subscription" class="paypal_field_container" valign="top" <?php echo rgars($config, "meta/type") != "subscription" ? "style='display:none;'" : ""; ?> > <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_recurring_amount"><?php _e("Recurring Amount", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_recurring_amount"); ?> </label> <select id="gf_paypal_recurring_amount" name="gf_paypal_recurring_amount"> <?php echo self::get_product_options($form, rgar($config["meta"], "recurring_amount_field")); ?> </select> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_billing_cycle_number"><?php _e("Billing Cycle", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_billing_cycle"); ?> </label> <select id="gf_paypal_billing_cycle_number" name="gf_paypal_billing_cycle_number"> <?php for ($i = 1; $i <= 100; $i++) { ?> <option value="<?php echo $i; ?> " <?php echo rgar($config["meta"], "billing_cycle_number") == $i ? "selected='selected'" : ""; ?> ><?php echo $i; ?> </option> <?php } ?> </select> <select id="gf_paypal_billing_cycle_type" name="gf_paypal_billing_cycle_type" onchange="SetPeriodNumber('#gf_paypal_billing_cycle_number', jQuery(this).val());"> <option value="D" <?php echo rgars($config, "meta/billing_cycle_type") == "D" ? "selected='selected'" : ""; ?> ><?php _e("day(s)", "gravityformspaypal"); ?> </option> <option value="W" <?php echo rgars($config, "meta/billing_cycle_type") == "W" ? "selected='selected'" : ""; ?> ><?php _e("week(s)", "gravityformspaypal"); ?> </option> <option value="M" <?php echo rgars($config, "meta/billing_cycle_type") == "M" || strlen(rgars($config, "meta/billing_cycle_type")) == 0 ? "selected='selected'" : ""; ?> ><?php _e("month(s)", "gravityformspaypal"); ?> </option> <option value="Y" <?php echo rgars($config, "meta/billing_cycle_type") == "Y" ? "selected='selected'" : ""; ?> ><?php _e("year(s)", "gravityformspaypal"); ?> </option> </select> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_recurring_times"><?php _e("Recurring Times", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_recurring_times"); ?> </label> <select id="gf_paypal_recurring_times" name="gf_paypal_recurring_times"> <option value=""><?php _e("Infinite", "gravityformspaypal"); ?> </option> <?php for ($i = 2; $i <= 30; $i++) { $selected = $i == rgar($config["meta"], "recurring_times") ? 'selected="selected"' : ''; ?> <option value="<?php echo $i; ?> " <?php echo $selected; ?> ><?php echo $i; ?> </option> <?php } ?> </select> <input type="checkbox" name="gf_paypal_recurring_retry" id="gf_paypal_recurring_retry" value="1" <?php echo rgars($config, "meta/recurring_retry") ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_recurring_retry"><?php _e("Try to bill again after failed attempt.", "gravityformspaypal"); ?> </label> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_trial_period"><?php _e("Trial Period", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_trial_period_enable"); ?> </label> <input type="checkbox" name="gf_paypal_trial_period" id="gf_paypal_trial_period" value="1" onclick="if(jQuery(this).is(':checked')) jQuery('#paypal_trial_period_container').show('slow'); else jQuery('#paypal_trial_period_container').hide('slow');" <?php echo rgars($config, "meta/trial_period_enabled") ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_trial_period"><?php _e("Enable", "gravityformspaypal"); ?> </label> </div> <div id="paypal_trial_period_container" <?php echo rgars($config, "meta/trial_period_enabled") ? "" : "style='display:none;'"; ?> > <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_trial_amount"><?php _e("Trial Amount", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_trial_amount"); ?> </label> <input type="text" name="gf_paypal_trial_amount" id="gf_paypal_trial_amount" value="<?php echo rgars($config, "meta/trial_amount"); ?> "/> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_trial_period_number"><?php _e("Trial Period", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_trial_period"); ?> </label> <select id="gf_paypal_trial_period_number" name="gf_paypal_trial_period_number"> <?php for ($i = 1; $i <= 100; $i++) { ?> <option value="<?php echo $i; ?> " <?php echo rgars($config, "meta/trial_period_number") == $i ? "selected='selected'" : ""; ?> ><?php echo $i; ?> </option> <?php } ?> </select> <select id="gf_paypal_trial_period_type" name="gf_paypal_trial_period_type" onchange="SetPeriodNumber('#gf_paypal_trial_period_number', jQuery(this).val());"> <option value="D" <?php echo rgars($config, "meta/trial_period_type") == "D" ? "selected='selected'" : ""; ?> ><?php _e("day(s)", "gravityformspaypal"); ?> </option> <option value="W" <?php echo rgars($config, "meta/trial_period_type") == "W" ? "selected='selected'" : ""; ?> ><?php _e("week(s)", "gravityformspaypal"); ?> </option> <option value="M" <?php echo rgars($config, "meta/trial_period_type") == "M" || empty($config["meta"]["trial_period_type"]) ? "selected='selected'" : ""; ?> ><?php _e("month(s)", "gravityformspaypal"); ?> </option> <option value="Y" <?php echo rgars($config, "meta/trial_period_type") == "Y" ? "selected='selected'" : ""; ?> ><?php _e("year(s)", "gravityformspaypal"); ?> </option> </select> </div> </div> </div> <div class="margin_vertical_10"> <label class="left_header"><?php _e("Customer", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_customer"); ?> </label> <div id="paypal_customer_fields"> <?php if (!empty($form)) { echo self::get_customer_information($form, $config); } ?> </div> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_page_style"><?php _e("Page Style", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_page_style"); ?> </label> <input type="text" name="gf_paypal_page_style" id="gf_paypal_page_style" class="width-1" value="<?php echo rgars($config, "meta/style"); ?> "/> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_continue_text"><?php _e("Continue Button Label", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_continue_button_label"); ?> </label> <input type="text" name="gf_paypal_continue_text" id="gf_paypal_continue_text" class="width-1" value="<?php echo rgars($config, "meta/continue_text"); ?> "/> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_paypal_cancel_url"><?php _e("Cancel URL", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_cancel_url"); ?> </label> <input type="text" name="gf_paypal_cancel_url" id="gf_paypal_cancel_url" class="width-1" value="<?php echo rgars($config, "meta/cancel_url"); ?> "/> </div> <div class="margin_vertical_10"> <label class="left_header"><?php _e("Options", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_options"); ?> </label> <ul style="overflow:hidden;"> <li> <input type="checkbox" name="gf_paypal_disable_shipping" id="gf_paypal_disable_shipping" value="1" <?php echo rgar($config['meta'], 'disable_shipping') ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_disable_shipping"><?php _e("Do not prompt buyer to include a shipping address.", "gravityformspaypal"); ?> </label> </li> <li> <input type="checkbox" name="gf_paypal_disable_note" id="gf_paypal_disable_note" value="1" <?php echo rgar($config['meta'], 'disable_note') ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_disable_note"><?php _e("Do not prompt buyer to include a note with payment.", "gravityformspaypal"); ?> </label> </li> <li id="paypal_delay_notification" <?php echo isset($form["notifications"]) ? "style='display:none;'" : ""; ?> > <input type="checkbox" name="gf_paypal_delay_notification" id="gf_paypal_delay_notification" value="1" <?php echo rgar($config["meta"], 'delay_notification') ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_delay_notification"><?php _e("Send admin notification only when payment is received.", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_delay_admin_notification"); ?> </label> </li> <li id="paypal_delay_autoresponder" <?php echo isset($form["notifications"]) ? "style='display:none;'" : ""; ?> > <input type="checkbox" name="gf_paypal_delay_autoresponder" id="gf_paypal_delay_autoresponder" value="1" <?php echo rgar($config["meta"], 'delay_autoresponder') ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_delay_autoresponder"><?php _e("Send user notification only when payment is received.", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_delay_user_notification"); ?> </label> </li> <?php $display_post_fields = !empty($form) ? GFCommon::has_post_field($form["fields"]) : false; ?> <li id="paypal_post_action" <?php echo $display_post_fields ? "" : "style='display:none;'"; ?> > <input type="checkbox" name="gf_paypal_delay_post" id="gf_paypal_delay_post" value="1" <?php echo rgar($config["meta"], "delay_post") ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_paypal_delay_post"><?php _e("Create post only when payment is received.", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_delay_post"); ?> </label> </li> <li id="paypal_post_update_action" <?php echo $display_post_fields && $config["meta"]["type"] == "subscription" ? "" : "style='display:none;'"; ?> > <input type="checkbox" name="gf_paypal_update_post" id="gf_paypal_update_post" value="1" <?php echo rgar($config["meta"], "update_post_action") ? "checked='checked'" : ""; ?> onclick="var action = this.checked ? 'draft' : ''; jQuery('#gf_paypal_update_action').val(action);" /> <label class="inline" for="gf_paypal_update_post"><?php _e("Update Post when subscription is cancelled.", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_update_post"); ?> </label> <select id="gf_paypal_update_action" name="gf_paypal_update_action" onchange="var checked = jQuery(this).val() ? 'checked' : false; jQuery('#gf_paypal_update_post').attr('checked', checked);"> <option value=""></option> <option value="draft" <?php echo rgar($config["meta"], "update_post_action") == "draft" ? "selected='selected'" : ""; ?> ><?php _e("Mark Post as Draft", "gravityformspaypal"); ?> </option> <option value="delete" <?php echo rgar($config["meta"], "update_post_action") == "delete" ? "selected='selected'" : ""; ?> ><?php _e("Delete Post", "gravityformspaypal"); ?> </option> </select> </li> <?php do_action("gform_paypal_action_fields", $config, $form); ?> </ul> </div> <div class="margin_vertical_10" id="gf_paypal_notifications" <?php echo !isset($form["notifications"]) ? "style='display:none;'" : ""; ?> > <label class="left_header"><?php _e("Notifications", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_notifications"); ?> </label> <?php $has_delayed_notifications = rgar($config['meta'], 'delay_notifications') || rgar($config['meta'], 'delay_notification') || rgar($config['meta'], 'delay_autoresponder'); ?> <div style="overflow:hidden;"> <input type="checkbox" name="gf_paypal_delay_notifications" id="gf_paypal_delay_notifications" value="1" onclick="ToggleNotifications();" <?php checked("1", $has_delayed_notifications); ?> /> <label class="inline" for="gf_paypal_delay_notifications"><?php _e("Send notifications only when payment is received.", "gravityformspaypal"); ?> </label> <ul id="gf_paypal_notification_container" style="padding-left:20px; <?php echo $has_delayed_notifications ? "" : "display:none;"; ?> "> <?php if (!empty($form) && is_array($form["notifications"])) { $selected_notifications = self::get_selected_notifications($config, $form); foreach ($form["notifications"] as $notification) { ?> <li class="gf_paypal_notification"> <input type="checkbox" name="gf_paypal_selected_notifications[]" id="gf_paypal_selected_notifications" value="<?php echo $notification["id"]; ?> " <?php checked(true, in_array($notification["id"], $selected_notifications)); ?> /> <label class="inline" for="gf_paypal_selected_notifications"><?php echo $notification["name"]; ?> </label> </li> <?php } } ?> </ul> </div> </div> <?php do_action("gform_paypal_add_option_group", $config, $form); ?> <div id="gf_paypal_conditional_section" valign="top" class="margin_vertical_10"> <label for="gf_paypal_conditional_optin" class="left_header"><?php _e("PayPal Condition", "gravityformspaypal"); ?> <?php gform_tooltip("paypal_conditional"); ?> </label> <div id="gf_paypal_conditional_option"> <table cellspacing="0" cellpadding="0"> <tr> <td> <input type="checkbox" id="gf_paypal_conditional_enabled" name="gf_paypal_conditional_enabled" value="1" onclick="if(this.checked){jQuery('#gf_paypal_conditional_container').fadeIn('fast');} else{ jQuery('#gf_paypal_conditional_container').fadeOut('fast'); }" <?php echo rgar($config['meta'], 'paypal_conditional_enabled') ? "checked='checked'" : ""; ?> /> <label for="gf_paypal_conditional_enable"><?php _e("Enable", "gravityformspaypal"); ?> </label> </td> </tr> <tr> <td> <div id="gf_paypal_conditional_container" <?php echo !rgar($config['meta'], 'paypal_conditional_enabled') ? "style='display:none'" : ""; ?> > <div id="gf_paypal_conditional_fields" style="display:none"> <?php _e("Send to PayPal if ", "gravityformspaypal"); ?> <select id="gf_paypal_conditional_field_id" name="gf_paypal_conditional_field_id" class="optin_select" onchange='jQuery("#gf_paypal_conditional_value_container").html(GetFieldValues(jQuery(this).val(), "", 20));'> </select> <select id="gf_paypal_conditional_operator" name="gf_paypal_conditional_operator"> <option value="is" <?php echo rgar($config['meta'], 'paypal_conditional_operator') == "is" ? "selected='selected'" : ""; ?> ><?php _e("is", "gravityformspaypal"); ?> </option> <option value="isnot" <?php echo rgar($config['meta'], 'paypal_conditional_operator') == "isnot" ? "selected='selected'" : ""; ?> ><?php _e("is not", "gravityformspaypal"); ?> </option> <option value=">" <?php echo rgar($config['meta'], 'paypal_conditional_operator') == ">" ? "selected='selected'" : ""; ?> ><?php _e("greater than", "gravityformspaypal"); ?> </option> <option value="<" <?php echo rgar($config['meta'], 'paypal_conditional_operator') == "<" ? "selected='selected'" : ""; ?> ><?php _e("less than", "gravityformspaypal"); ?> </option> <option value="contains" <?php echo rgar($config['meta'], 'paypal_conditional_operator') == "contains" ? "selected='selected'" : ""; ?> ><?php _e("contains", "gravityformspaypal"); ?> </option> <option value="starts_with" <?php echo rgar($config['meta'], 'paypal_conditional_operator') == "starts_with" ? "selected='selected'" : ""; ?> ><?php _e("starts with", "gravityformspaypal"); ?> </option> <option value="ends_with" <?php echo rgar($config['meta'], 'paypal_conditional_operator') == "ends_with" ? "selected='selected'" : ""; ?> ><?php _e("ends with", "gravityformspaypal"); ?> </option> </select> <div id="gf_paypal_conditional_value_container" name="gf_paypal_conditional_value_container" style="display:inline;"></div> </div> <div id="gf_paypal_conditional_message" style="display:none"> <?php _e("To create a registration condition, your form must have a field supported by conditional logic.", "gravityform"); ?> </div> </div> </td> </tr> </table> </div> </div> <!-- / paypal conditional --> <div id="paypal_submit_container" class="margin_vertical_30"> <input type="submit" name="gf_paypal_submit" value="<?php echo empty($id) ? __(" Save ", "gravityformspaypal") : __("Update", "gravityformspaypal"); ?> " class="button-primary"/> <input type="button" value="<?php _e("Cancel", "gravityformspaypal"); ?> " class="button" onclick="javascript:document.location='admin.php?page=gf_paypal'" /> </div> </div> </form> </div> <script type="text/javascript"> jQuery(document).ready(function(){ SetPeriodNumber('#gf_paypal_billing_cycle_number', jQuery("#gf_paypal_billing_cycle_type").val()); SetPeriodNumber('#gf_paypal_trial_period_number', jQuery("#gf_paypal_trial_period_type").val()); }); function SelectType(type){ jQuery("#paypal_field_group").slideUp(); jQuery("#paypal_field_group input[type=\"text\"], #paypal_field_group select").val(""); jQuery("#gf_paypal_trial_period_type, #gf_paypal_billing_cycle_type").val("M"); jQuery("#paypal_field_group input:checked").attr("checked", false); if(type){ jQuery("#paypal_form_container").slideDown(); jQuery("#gf_paypal_form").val(""); } else{ jQuery("#paypal_form_container").slideUp(); } } function SelectForm(type, formId, settingId){ if(!formId){ jQuery("#paypal_field_group").slideUp(); return; } jQuery("#paypal_wait").show(); jQuery("#paypal_field_group").slideUp(); var mysack = new sack(ajaxurl); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar( "action", "gf_select_paypal_form" ); mysack.setVar( "gf_select_paypal_form", "<?php echo wp_create_nonce("gf_select_paypal_form"); ?> " ); mysack.setVar( "type", type); mysack.setVar( "form_id", formId); mysack.setVar( "setting_id", settingId); mysack.onError = function() {jQuery("#paypal_wait").hide(); alert('<?php _e("Ajax error while selecting a form", "gravityformspaypal"); ?> ' )}; mysack.runAJAX(); return true; } function EndSelectForm(form_meta, customer_fields, recurring_amount_options){ //setting global form object form = form_meta; var type = jQuery("#gf_paypal_type").val(); jQuery(".gf_paypal_invalid_form").hide(); if( (type == "product" || type =="subscription") && GetFieldsByType(["product"]).length == 0){ jQuery("#gf_paypal_invalid_product_form").show(); jQuery("#paypal_wait").hide(); return; } else if(type == "donation" && GetFieldsByType(["product", "donation"]).length == 0){ jQuery("#gf_paypal_invalid_donation_form").show(); jQuery("#paypal_wait").hide(); return; } jQuery(".paypal_field_container").hide(); jQuery("#paypal_customer_fields").html(customer_fields); jQuery("#gf_paypal_recurring_amount").html(recurring_amount_options); //displaying delayed post creation setting if current form has a post field var post_fields = GetFieldsByType(["post_title", "post_content", "post_excerpt", "post_category", "post_custom_field", "post_image", "post_tag"]); if(post_fields.length > 0){ jQuery("#paypal_post_action").show(); } else{ jQuery("#gf_paypal_delay_post").attr("checked", false); jQuery("#paypal_post_action").hide(); } if(type == "subscription" && post_fields.length > 0){ jQuery("#paypal_post_update_action").show(); } else{ jQuery("#gf_paypal_update_post").attr("checked", false); jQuery("#paypal_post_update_action").hide(); } SetPeriodNumber('#gf_paypal_billing_cycle_number', jQuery("#gf_paypal_billing_cycle_type").val()); SetPeriodNumber('#gf_paypal_trial_period_number', jQuery("#gf_paypal_trial_period_type").val()); //Calling callback functions jQuery(document).trigger('paypalFormSelected', [form]); jQuery("#gf_paypal_conditional_enabled").attr('checked', false); SetPayPalCondition("",""); if(form["notifications"]){ jQuery("#gf_paypal_notifications").show(); jQuery("#paypal_delay_autoresponder, #paypal_delay_notification").hide(); } else{ jQuery("#paypal_delay_autoresponder, #paypal_delay_notification").show(); jQuery("#gf_paypal_notifications").hide(); } jQuery("#paypal_field_container_" + type).show(); jQuery("#paypal_field_group").slideDown(); jQuery("#paypal_wait").hide(); } function SetPeriodNumber(element, type){ var prev = jQuery(element).val(); var min = 1; var max = 0; switch(type){ case "D" : max = 100; break; case "W" : max = 52; break; case "M" : max = 12; break; case "Y" : max = 5; break; } var str=""; for(var i=min; i<=max; i++){ var selected = prev == i ? "selected='selected'" : ""; str += "<option value='" + i + "' " + selected + ">" + i + "</option>"; } jQuery(element).html(str); } function GetFieldsByType(types){ var fields = new Array(); for(var i=0; i<form["fields"].length; i++){ if(IndexOf(types, form["fields"][i]["type"]) >= 0) fields.push(form["fields"][i]); } return fields; } function IndexOf(ary, item){ for(var i=0; i<ary.length; i++) if(ary[i] == item) return i; return -1; } </script> <script type="text/javascript"> // Paypal Conditional Functions <?php if (!empty($config["form_id"])) { ?> // initilize form object form = <?php echo GFCommon::json_encode($form); ?> ; // initializing registration condition drop downs jQuery(document).ready(function(){ var selectedField = "<?php echo str_replace('"', '\\"', $config["meta"]["paypal_conditional_field_id"]); ?> "; var selectedValue = "<?php echo str_replace('"', '\\"', $config["meta"]["paypal_conditional_value"]); ?> "; SetPayPalCondition(selectedField, selectedValue); }); <?php } ?> function SetPayPalCondition(selectedField, selectedValue){ // load form fields jQuery("#gf_paypal_conditional_field_id").html(GetSelectableFields(selectedField, 20)); var optinConditionField = jQuery("#gf_paypal_conditional_field_id").val(); var checked = jQuery("#gf_paypal_conditional_enabled").attr('checked'); if(optinConditionField){ jQuery("#gf_paypal_conditional_message").hide(); jQuery("#gf_paypal_conditional_fields").show(); jQuery("#gf_paypal_conditional_value_container").html(GetFieldValues(optinConditionField, selectedValue, 20)); jQuery("#gf_paypal_conditional_value").val(selectedValue); } else{ jQuery("#gf_paypal_conditional_message").show(); jQuery("#gf_paypal_conditional_fields").hide(); } if(!checked) jQuery("#gf_paypal_conditional_container").hide(); } function GetFieldValues(fieldId, selectedValue, labelMaxCharacters){ if(!fieldId) return ""; var str = ""; var field = GetFieldById(fieldId); if(!field) return ""; var isAnySelected = false; if(field["type"] == "post_category" && field["displayAllCategories"]){ str += '<?php $dd = wp_dropdown_categories(array("class" => "optin_select", "orderby" => "name", "id" => "gf_paypal_conditional_value", "name" => "gf_paypal_conditional_value", "hierarchical" => true, "hide_empty" => 0, "echo" => false)); echo str_replace("\n", "", str_replace("'", "\\'", $dd)); ?> '; } else if(field.choices){ str += '<select id="gf_paypal_conditional_value" name="gf_paypal_conditional_value" class="optin_select">' for(var i=0; i<field.choices.length; i++){ var fieldValue = field.choices[i].value ? field.choices[i].value : field.choices[i].text; var isSelected = fieldValue == selectedValue; var selected = isSelected ? "selected='selected'" : ""; if(isSelected) isAnySelected = true; str += "<option value='" + fieldValue.replace(/'/g, "'") + "' " + selected + ">" + TruncateMiddle(field.choices[i].text, labelMaxCharacters) + "</option>"; } if(!isAnySelected && selectedValue){ str += "<option value='" + selectedValue.replace(/'/g, "'") + "' selected='selected'>" + TruncateMiddle(selectedValue, labelMaxCharacters) + "</option>"; } str += "</select>"; } else { selectedValue = selectedValue ? selectedValue.replace(/'/g, "'") : ""; //create a text field for fields that don't have choices (i.e text, textarea, number, email, etc...) str += "<input type='text' placeholder='<?php _e("Enter value", "gravityforms"); ?> ' id='gf_paypal_conditional_value' name='gf_paypal_conditional_value' value='" + selectedValue.replace(/'/g, "'") + "'>"; } return str; } function GetFieldById(fieldId){ for(var i=0; i<form.fields.length; i++){ if(form.fields[i].id == fieldId) return form.fields[i]; } return null; } function TruncateMiddle(text, maxCharacters){ if(!text) return ""; if(text.length <= maxCharacters) return text; var middle = parseInt(maxCharacters / 2); return text.substr(0, middle) + "..." + text.substr(text.length - middle, middle); } function GetSelectableFields(selectedFieldId, labelMaxCharacters){ var str = ""; var inputType; for(var i=0; i<form.fields.length; i++){ fieldLabel = form.fields[i].adminLabel ? form.fields[i].adminLabel : form.fields[i].label; inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type; if (IsConditionalLogicField(form.fields[i])) { var selected = form.fields[i].id == selectedFieldId ? "selected='selected'" : ""; str += "<option value='" + form.fields[i].id + "' " + selected + ">" + TruncateMiddle(fieldLabel, labelMaxCharacters) + "</option>"; } } return str; } function IsConditionalLogicField(field){ inputType = field.inputType ? field.inputType : field.type; var supported_fields = ["checkbox", "radio", "select", "text", "website", "textarea", "email", "hidden", "number", "phone", "multiselect", "post_title", "post_tags", "post_custom_field", "post_content", "post_excerpt"]; var index = jQuery.inArray(inputType, supported_fields); return index >= 0; } </script> <?php }
private static function edit_page() { require_once GFCommon::get_base_path() . "/currency.php"; ?> <style> #authorizenet_submit_container{clear:both;} .authorizenet_col_heading{padding-bottom:2px; border-bottom: 1px solid #ccc; font-weight:bold; width:120px;} .authorizenet_field_cell {padding: 6px 17px 0 0; margin-right:15px;} .authorizenet_validation_error{ background-color:#FFDFDF; margin-top:4px; margin-bottom:6px; padding-top:6px; padding-bottom:6px; border:1px dotted #C89797;} .authorizenet_validation_error span {color: red;} .left_header{float:left; width:200px;} .margin_vertical_10{margin: 10px 0; padding-left:5px;} .margin_vertical_30{margin: 30px 0; padding-left:5px;} .width-1{width:300px;} .gf_authorizenet_invalid_form{margin-top:30px; background-color:#FFEBE8;border:1px solid #CC0000; padding:10px; width:600px;} </style> <script type="text/javascript" src="<?php echo GFCommon::get_base_url(); ?> /js/gravityforms.js"> </script> <script type="text/javascript"> var form = Array(); window['gf_currency_config'] = <?php echo json_encode(RGCurrency::get_currency("USD")); ?> ; function FormatCurrency(element){ var val = jQuery(element).val(); jQuery(element).val(gformFormatMoney(val)); } function ToggleSetupFee(){ if(jQuery('#gf_authorizenet_setup_fee').is(':checked')){ jQuery('#authorizenet_setup_fee_container').show('slow'); jQuery('#authorizenet_enable_trial_container, #authorizenet_trial_period_container').slideUp(); } else{ jQuery('#authorizenet_setup_fee_container').hide('slow'); jQuery('#authorizenet_enable_trial_container').slideDown(); ToggleTrial(); } } function ToggleTrial(){ if(jQuery('#gf_authorizenet_trial_period').is(':checked')) jQuery('#authorizenet_trial_period_container').show('slow'); else jQuery('#authorizenet_trial_period_container').hide('slow'); } </script> <div class="wrap"> <img alt="<?php _e("Authorize.Net", "gravityformsauthorizenet"); ?> " style="margin: 15px 7px 0pt 0pt; float: left;" src="<?php echo self::get_base_url(); ?> /images/authorizenet_wordpress_icon_32.png"/> <h2><?php _e("Authorize.Net Transaction Settings", "gravityformsauthorizenet"); ?> </h2> <?php //getting setting id (0 when creating a new one) $id = !empty($_POST["authorizenet_setting_id"]) ? $_POST["authorizenet_setting_id"] : absint($_GET["id"]); $config = empty($id) ? array("meta" => array(), "is_active" => true) : GFAuthorizeNetData::get_feed($id); $setup_fee_field_conflict = false; //initialize variable //updating meta information if (rgpost("gf_authorizenet_submit")) { $config["form_id"] = absint(rgpost("gf_authorizenet_form")); $config["meta"]["type"] = rgpost("gf_authorizenet_type"); $config["meta"]["enable_receipt"] = rgpost('gf_authorizenet_enable_receipt'); $config["meta"]["update_post_action"] = rgpost('gf_authorizenet_update_action'); // authorizenet conditional $config["meta"]["authorizenet_conditional_enabled"] = rgpost('gf_authorizenet_conditional_enabled'); $config["meta"]["authorizenet_conditional_field_id"] = rgpost('gf_authorizenet_conditional_field_id'); $config["meta"]["authorizenet_conditional_operator"] = rgpost('gf_authorizenet_conditional_operator'); $config["meta"]["authorizenet_conditional_value"] = rgpost('gf_authorizenet_conditional_value'); //recurring fields $config["meta"]["recurring_amount_field"] = rgpost("gf_authorizenet_recurring_amount"); $config["meta"]["billing_cycle_number"] = rgpost("gf_authorizenet_billing_cycle_number"); $config["meta"]["billing_cycle_type"] = rgpost("gf_authorizenet_billing_cycle_type"); $config["meta"]["recurring_times"] = rgpost("gf_authorizenet_recurring_times"); $config["meta"]["recurring_retry"] = rgpost('gf_authorizenet_recurring_retry'); $config["meta"]["setup_fee_enabled"] = rgpost('gf_authorizenet_setup_fee'); $config["meta"]["setup_fee_amount_field"] = rgpost('gf_authorizenet_setup_fee_amount'); $has_setup_fee = $config["meta"]["setup_fee_enabled"]; $config["meta"]["trial_period_enabled"] = $has_setup_fee ? false : rgpost('gf_authorizenet_trial_period'); $config["meta"]["trial_amount"] = $has_setup_fee ? "" : rgpost('gf_authorizenet_trial_amount'); $config["meta"]["trial_period_number"] = "1"; //$has_setup_fee ? "" : rgpost('gf_authorizenet_trial_period_number'); //api settings fields $config["meta"]["api_settings_enabled"] = rgpost('gf_authorizenet_api_settings'); $config["meta"]["api_mode"] = rgpost('gf_authorizenet_api_mode'); $config["meta"]["api_login"] = rgpost('gf_authorizenet_api_login'); $config["meta"]["api_key"] = rgpost('gf_authorizenet_api_key'); if (!empty($config["meta"]["api_settings_enabled"])) { $is_valid = self::is_valid_key(self::get_local_api_settings($config)); if ($is_valid) { $config["meta"]["api_valid"] = true; $config["meta"]["api_message"] = "Valid PayPal Payments Pro credentials."; } else { $config["meta"]["api_valid"] = false; $config["meta"]["api_message"] = "Invalid PayPal Payments Pro credentials."; } } //----------------- $customer_fields = self::get_customer_fields(); $config["meta"]["customer_fields"] = array(); foreach ($customer_fields as $field) { $config["meta"]["customer_fields"][$field["name"]] = $_POST["authorizenet_customer_field_{$field["name"]}"]; } $config = apply_filters('gform_authorizenet_save_config', $config); $setup_fee_field_conflict = $has_setup_fee && $config["meta"]["recurring_amount_field"] == $config["meta"]["setup_fee_amount_field"]; if (!$setup_fee_field_conflict) { $id = GFAuthorizeNetData::update_feed($id, $config["form_id"], $config["is_active"], $config["meta"]); ?> <div class="updated fade" style="padding:6px"><?php echo sprintf(__("Feed Updated. %sback to list%s", "gravityformsauthorizenet"), "<a href='?page=gf_authorizenet'>", "</a>"); ?> </div> <?php } else { $setup_fee_field_conflict = true; } } $form = isset($config["form_id"]) && $config["form_id"] ? $form = RGFormsModel::get_form_meta($config["form_id"]) : array(); $settings = get_option("gf_authorizenet_settings"); ?> <form method="post" action=""> <input type="hidden" name="authorizenet_setting_id" value="<?php echo $id; ?> " /> <div style="padding: 15px; margin:15px 0px" class="<?php echo $setup_fee_field_conflict ? "error" : ""; ?> "> <?php if ($setup_fee_field_conflict) { ?> <span><?php _e('There was an issue saving your feed.', 'gravityformsauthorizenet'); ?> </span> <span><?php _e('Recurring Amount and Setup Fee must be assigned to different fields.', 'gravityformsauthorizenet'); ?> </span> <?php } ?> </div> <!-- / validation message --> <?php if ($settings["arb_configured"] == "on") { ?> <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_type"><?php _e("Transaction Type", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_transaction_type"); ?> </label> <select id="gf_authorizenet_type" name="gf_authorizenet_type" onchange="SelectType(jQuery(this).val());"> <option value=""><?php _e("Select a transaction type", "gravityformsauthorizenet"); ?> </option> <option value="product" <?php echo rgar($config['meta'], 'type') == "product" ? "selected='selected'" : ""; ?> ><?php _e("Products and Services", "gravityformsauthorizenet"); ?> </option> <option value="subscription" <?php echo rgar($config['meta'], 'type') == "subscription" ? "selected='selected'" : ""; ?> ><?php _e("Subscriptions", "gravityformsauthorizenet"); ?> </option> </select> </div> <?php } else { $config["meta"]["type"] = "product"; ?> <input id="gf_authorizenet_type" type="hidden" name="gf_authorizenet_type" value="product"> <?php } ?> <div id="authorizenet_form_container" valign="top" class="margin_vertical_10" <?php echo empty($config["meta"]["type"]) ? "style='display:none;'" : ""; ?> > <label for="gf_authorizenet_form" class="left_header"><?php _e("Gravity Form", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_gravity_form"); ?> </label> <select id="gf_authorizenet_form" name="gf_authorizenet_form" onchange="SelectForm(jQuery('#gf_authorizenet_type').val(), jQuery(this).val(), '<?php echo rgar($config, 'id'); ?> ');"> <option value=""><?php _e("Select a form", "gravityformsauthorizenet"); ?> </option> <?php $active_form = rgar($config, 'form_id'); $available_forms = GFAuthorizeNetData::get_available_forms($active_form); foreach ($available_forms as $current_form) { $selected = absint($current_form->id) == rgar($config, 'form_id') ? 'selected="selected"' : ''; ?> <option value="<?php echo absint($current_form->id); ?> " <?php echo $selected; ?> ><?php echo esc_html($current_form->title); ?> </option> <?php } ?> </select> <img src="<?php echo GFAuthorizeNet::get_base_url(); ?> /images/loading.gif" id="authorizenet_wait" style="display: none;"/> <div id="gf_authorizenet_invalid_product_form" class="gf_authorizenet_invalid_form" style="display:none;"> <?php _e("The form selected does not have any Product fields. Please add a Product field to the form and try again.", "gravityformsauthorizenet"); ?> </div> <div id="gf_authorizenet_invalid_creditcard_form" class="gf_authorizenet_invalid_form" style="display:none;"> <?php _e("The form selected does not have a credit card field. Please add a credit card field to the form and try again.", "gravityformsauthorizenet"); ?> </div> </div> <div id="authorizenet_field_group" valign="top" <?php echo strlen(rgars($config, "meta/type")) == 0 || empty($config["form_id"]) ? "style='display:none;'" : ""; ?> > <div id="authorizenet_field_container_subscription" class="authorizenet_field_container" valign="top" <?php echo rgars($config, "meta/type") != "subscription" ? "style='display:none;'" : ""; ?> > <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_recurring_amount"><?php _e("Recurring Amount", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_recurring_amount"); ?> </label> <select id="gf_authorizenet_recurring_amount" name="gf_authorizenet_recurring_amount"> <?php echo self::get_product_options($form, rgar($config["meta"], "recurring_amount_field"), true); ?> </select> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_billing_cycle_number"><?php _e("Billing Cycle", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_billing_cycle"); ?> </label> <select id="gf_authorizenet_billing_cycle_number" name="gf_authorizenet_billing_cycle_number"> <?php for ($i = 1; $i <= 100; $i++) { ?> <option value="<?php echo $i; ?> " <?php echo rgar($config["meta"], "billing_cycle_number") == $i ? "selected='selected'" : ""; ?> ><?php echo $i; ?> </option> <?php } ?> </select> <select id="gf_authorizenet_billing_cycle_type" name="gf_authorizenet_billing_cycle_type" onchange="SetPeriodNumber('#gf_authorizenet_billing_cycle_number', jQuery(this).val());"> <option value="D" <?php echo rgars($config, "meta/billing_cycle_type") == "D" ? "selected='selected'" : ""; ?> ><?php _e("day(s)", "gravityformsauthorizenet"); ?> </option> <option value="M" <?php echo rgars($config, "meta/billing_cycle_type") == "M" || strlen(rgars($config, "meta/billing_cycle_type")) == 0 ? "selected='selected'" : ""; ?> ><?php _e("month(s)", "gravityformsauthorizenet"); ?> </option> </select> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_recurring_times"><?php _e("Recurring Times", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_recurring_times"); ?> </label> <select id="gf_authorizenet_recurring_times" name="gf_authorizenet_recurring_times"> <option><?php _e("Infinite", "gravityformsauthorizenet"); ?> </option> <?php for ($i = 2; $i <= 100; $i++) { $selected = $i == rgar($config["meta"], "recurring_times") ? 'selected="selected"' : ''; ?> <option value="<?php echo $i; ?> " <?php echo $selected; ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_setup_fee"><?php _e("Setup Fee", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_setup_fee_enable"); ?> </label> <input type="checkbox" onchange="if(this.checked) {jQuery('#gf_paypalpro_setup_fee_amount').val('Select a field');}" name="gf_authorizenet_setup_fee" id="gf_authorizenet_setup_fee" value="1" onclick="ToggleSetupFee();" <?php echo rgars($config, "meta/setup_fee_enabled") ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_authorizenet_setup_fee"><?php _e("Enable", "gravityformsauthorizenet"); ?> </label> <span id="authorizenet_setup_fee_container" <?php echo rgars($config, "meta/setup_fee_enabled") ? "" : "style='display:none;'"; ?> > <select id="gf_authorizenet_setup_fee_amount" name="gf_authorizenet_setup_fee_amount"> <?php echo self::get_product_options($form, rgar($config["meta"], "setup_fee_amount_field"), false); ?> </select> </span> </div> <div id="authorizenet_enable_trial_container" class="margin_vertical_10" <?php echo rgars($config, "meta/setup_fee_enabled") ? "style='display:none;'" : ""; ?> > <label class="left_header" for="gf_authorizenet_trial_period"><?php _e("Trial Period", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_trial_period_enable"); ?> </label> <input type="checkbox" name="gf_authorizenet_trial_period" id="gf_authorizenet_trial_period" value="1" onclick="ToggleTrial();" <?php echo rgars($config, "meta/trial_period_enabled") ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_authorizenet_trial_period"><?php _e("Enable", "gravityformsauthorizenet"); ?> </label> </div> <div id="authorizenet_trial_period_container" <?php echo rgars($config, "meta/trial_period_enabled") && !rgars($config, "meta/setup_fee_enabled") ? "" : "style='display:none;'"; ?> > <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_trial_amount"><?php _e("Trial Amount", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_trial_amount"); ?> </label> <input type="text" name="gf_authorizenet_trial_amount" id="gf_authorizenet_trial_amount" value="<?php echo rgar($config["meta"], "trial_amount"); ?> " onchange="FormatCurrency(this);"/> </div> <!--<div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_trial_period_number"><?php _e("Trial Recurring Times", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_trial_period"); ?> </label> <select id="gf_authorizenet_trial_period_number" name="gf_authorizenet_trial_period_number"> <?php for ($i = 1; $i <= 99; $i++) { ?> <option value="<?php echo $i; ?> " <?php echo rgars($config, "meta/trial_period_number") == $i ? "selected='selected'" : ""; ?> ><?php echo $i; ?> </option> <?php } ?> </select> </div>--> </div> </div> <div class="margin_vertical_10"> <label class="left_header"><?php _e("Billing Information", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_customer"); ?> </label> <div id="authorizenet_customer_fields"> <?php if (!empty($form)) { echo self::get_customer_information($form, $config); } ?> </div> </div> <div class="margin_vertical_10"> <label class="left_header"><?php _e("Options", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_options"); ?> </label> <ul style="overflow:hidden;"> <li id="authorizenet_enable_receipt"> <input type="checkbox" name="gf_authorizenet_enable_receipt" id="gf_authorizenet_enable_receipt" value="1" <?php echo rgar($config["meta"], 'enable_receipt') ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_authorizenet_enable_receipt"><?php _e("Send Authorize.Net email receipt.", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_disable_user_notification"); ?> </label> </li> <?php $display_post_fields = !empty($form) ? GFCommon::has_post_field($form["fields"]) : false; ?> <li id="authorizenet_post_update_action" <?php echo $display_post_fields && $config["meta"]["type"] == "subscription" ? "" : "style='display:none;'"; ?> > <input type="checkbox" name="gf_authorizenet_update_post" id="gf_authorizenet_update_post" value="1" <?php echo rgar($config["meta"], "update_post_action") ? "checked='checked'" : ""; ?> onclick="var action = this.checked ? 'draft' : ''; jQuery('#gf_authorizenet_update_action').val(action);" /> <label class="inline" for="gf_authorizenet_update_post"><?php _e("Update Post when subscription is cancelled.", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_update_post"); ?> </label> <select id="gf_authorizenet_update_action" name="gf_authorizenet_update_action" onchange="var checked = jQuery(this).val() ? 'checked' : false; jQuery('#gf_authorizenet_update_post').attr('checked', checked);"> <option value=""></option> <option value="draft" <?php echo rgar($config["meta"], "update_post_action") == "draft" ? "selected='selected'" : ""; ?> ><?php _e("Mark Post as Draft", "gravityformsauthorizenet"); ?> </option> <option value="delete" <?php echo rgar($config["meta"], "update_post_action") == "delete" ? "selected='selected'" : ""; ?> ><?php _e("Delete Post", "gravityformsauthorizenet"); ?> </option> </select> </li> <?php do_action("gform_authorizenet_action_fields", $config, $form); ?> </ul> </div> <?php do_action("gform_authorizenet_add_option_group", $config, $form); ?> <div id="gf_authorizenet_conditional_section" valign="top" class="margin_vertical_10"> <label for="gf_authorizenet_conditional_optin" class="left_header"><?php _e("Authorize.Net Condition", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_conditional"); ?> </label> <div id="gf_authorizenet_conditional_option"> <table cellspacing="0" cellpadding="0"> <tr> <td> <input type="checkbox" id="gf_authorizenet_conditional_enabled" name="gf_authorizenet_conditional_enabled" value="1" onclick="if(this.checked){jQuery('#gf_authorizenet_conditional_container').fadeIn('fast');} else{ jQuery('#gf_authorizenet_conditional_container').fadeOut('fast'); }" <?php echo rgar($config['meta'], 'authorizenet_conditional_enabled') ? "checked='checked'" : ""; ?> /> <label for="gf_authorizenet_conditional_enable"><?php _e("Enable", "gravityformsauthorizenet"); ?> </label> </td> </tr> <tr> <td> <div id="gf_authorizenet_conditional_container" <?php echo !rgar($config['meta'], 'authorizenet_conditional_enabled') ? "style='display:none'" : ""; ?> > <div id="gf_authorizenet_conditional_fields" style="display:none"> <?php _e("Send to Authorize.Net if ", "gravityformsauthorizenet"); ?> <select id="gf_authorizenet_conditional_field_id" name="gf_authorizenet_conditional_field_id" class="optin_select" onchange='jQuery("#gf_authorizenet_conditional_value_container").html(GetFieldValues(jQuery(this).val(), "", 20));'></select> <select id="gf_authorizenet_conditional_operator" name="gf_authorizenet_conditional_operator"> <option value="is" <?php echo rgar($config['meta'], 'authorizenet_conditional_operator') == "is" ? "selected='selected'" : ""; ?> ><?php _e("is", "gravityformsauthorizenet"); ?> </option> <option value="isnot" <?php echo rgar($config['meta'], 'authorizenet_conditional_operator') == "isnot" ? "selected='selected'" : ""; ?> ><?php _e("is not", "gravityformsauthorizenet"); ?> </option> <option value=">" <?php echo rgar($config['meta'], 'authorizenet_conditional_operator') == ">" ? "selected='selected'" : ""; ?> ><?php _e("greater than", "gravityformsauthorizenet"); ?> </option> <option value="<" <?php echo rgar($config['meta'], 'authorizenet_conditional_operator') == "<" ? "selected='selected'" : ""; ?> ><?php _e("less than", "gravityformsauthorizenet"); ?> </option> <option value="contains" <?php echo rgar($config['meta'], 'authorizenet_conditional_operator') == "contains" ? "selected='selected'" : ""; ?> ><?php _e("contains", "gravityformsauthorizenet"); ?> </option> <option value="starts_with" <?php echo rgar($config['meta'], 'authorizenet_conditional_operator') == "starts_with" ? "selected='selected'" : ""; ?> ><?php _e("starts with", "gravityformsauthorizenet"); ?> </option> <option value="ends_with" <?php echo rgar($config['meta'], 'authorizenet_conditional_operator') == "ends_with" ? "selected='selected'" : ""; ?> ><?php _e("ends with", "gravityformsauthorizenet"); ?> </option> </select> <div id="gf_authorizenet_conditional_value_container" name="gf_authorizenet_conditional_value_container" style="display:inline;"></div> </div> <div id="gf_authorizenet_conditional_message" style="display:none"> <?php _e("To create a registration condition, your form must have a field supported by conditional logic.", "gravityform"); ?> </div> </div> </td> </tr> </table> </div> </div> <!-- / authorizenet conditional --> <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_api_settings"><?php _e("API Settings", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_api_settings_enable"); ?> </label> <input type="checkbox" name="gf_authorizenet_api_settings" id="gf_authorizenet_api_settings" value="1" onclick="if(jQuery(this).is(':checked')) jQuery('#authorizenet_api_settings_container').show('slow'); else jQuery('#authorizenet_api_settings_container').hide('slow');" <?php echo rgars($config, "meta/api_settings_enabled") ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_authorizenet_api_settings"><?php _e("Override Default Settings", "gravityformsauthorizenet"); ?> </label> </div> <div id="authorizenet_api_settings_container" <?php echo rgars($config, "meta/api_settings_enabled") ? "" : "style='display:none;'"; ?> > <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_api_mode"><?php _e("Mode", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_api_mode"); ?> </label> <input type="radio" name="gf_authorizenet_api_mode" value="production" <?php echo rgar($config["meta"], "api_mode") != "test" ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_authorizenet_api_mode_production"><?php _e("Production", "gravityformsauthorizenet"); ?> </label> <input type="radio" name="gf_authorizenet_api_mode" value="test" <?php echo rgar($config["meta"], "api_mode") == "test" ? "checked='checked'" : ""; ?> /> <label class="inline" for="gf_authorizenet_api_mode_test"><?php _e("Test", "gravityformsauthorizenet"); ?> </label> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_api_login"><?php _e("API Login ID", "gravityformsauthorizenet"); ?> <?php gform_tooltip("authorizenet_api_login"); ?> </label> <input class="size-1" id="gf_authorizenet_api_login" name="gf_authorizenet_api_login" value="<?php echo rgar($config["meta"], "api_login"); ?> " /> <img src="<?php echo self::get_base_url(); ?> /images/<?php echo $config["meta"]["api_valid"] ? "tick.png" : "stop.png"; ?> " border="0" alt="<?php echo $config["meta"]["api_message"]; ?> " title="<?php echo $config["meta"]["api_message"]; ?> " style="display:<?php echo empty($config["meta"]["api_message"]) ? 'none;' : 'inline;'; ?> " /> </div> <div class="margin_vertical_10"> <label class="left_header" for="gf_authorizenet_api_key"><?php _e("Transaction Key", "gravityformsauthorizenet"); ?> <?php gform_tooltip("paypalpro_api_key"); ?> </label> <input class="size-1" id="gf_authorizenet_api_key" name="gf_authorizenet_api_key" value="<?php echo rgar($config["meta"], "api_key"); ?> " /> <img src="<?php echo self::get_base_url(); ?> /images/<?php echo $config["meta"]["api_valid"] ? "tick.png" : "stop.png"; ?> " border="0" alt="<?php echo $config["meta"]["api_message"]; ?> " title="<?php echo $config["meta"]["api_message"]; ?> " style="display:<?php echo empty($config["meta"]["api_message"]) ? 'none;' : 'inline;'; ?> " /> </div> </div> <div id="authorizenet_submit_container" class="margin_vertical_30"> <input type="submit" name="gf_authorizenet_submit" value="<?php echo empty($id) ? __(" Save ", "gravityformsauthorizenet") : __("Update", "gravityformsauthorizenet"); ?> " class="button-primary"/> <input type="button" value="<?php _e("Cancel", "gravityformsauthorizenet"); ?> " class="button" onclick="javascript:document.location='admin.php?page=gf_authorizenet'" /> </div> </div> </form> </div> <script type="text/javascript"> jQuery(document).ready(function(){ SetPeriodNumber('#gf_authorizenet_billing_cycle_number', jQuery("#gf_authorizenet_billing_cycle_type").val()); }); <?php if (!empty($config["form_id"])) { ?> // initiliaze form object form = <?php echo GFCommon::json_encode($form); ?> ; // initializing registration condition drop downs jQuery(document).ready(function(){ var selectedField = "<?php echo str_replace('"', '\\"', $config["meta"]["authorizenet_conditional_field_id"]); ?> "; var selectedValue = "<?php echo str_replace('"', '\\"', $config["meta"]["authorizenet_conditional_value"]); ?> "; SetAuthorizeNetCondition(selectedField, selectedValue); }); <?php } ?> function SelectType(type){ jQuery("#authorizenet_field_group").slideUp(); jQuery("#authorizenet_field_group input[type=\"text\"], #authorizenet_field_group select").val(""); jQuery("#gf_authorizenet_trial_period_type, #gf_authorizenet_billing_cycle_type").val("M"); jQuery("#authorizenet_field_group input:checked").attr("checked", false); if(type){ jQuery("#authorizenet_form_container").slideDown(); jQuery("#gf_authorizenet_form").val(""); } else{ jQuery("#authorizenet_form_container").slideUp(); } } function SelectForm(type, formId, settingId){ if(!formId){ jQuery("#authorizenet_field_group").slideUp(); return; } jQuery("#authorizenet_wait").show(); jQuery("#authorizenet_field_group").slideUp(); var mysack = new sack(ajaxurl); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar( "action", "gf_select_authorizenet_form" ); mysack.setVar( "gf_select_authorizenet_form", "<?php echo wp_create_nonce("gf_select_authorizenet_form"); ?> " ); mysack.setVar( "type", type); mysack.setVar( "form_id", formId); mysack.setVar( "setting_id", settingId); mysack.encVar( "cookie", document.cookie, false ); mysack.onError = function() {jQuery("#authorizenet_wait").hide(); alert('<?php _e("Ajax error while selecting a form", "gravityformsauthorizenet"); ?> ' )}; mysack.runAJAX(); return true; } function EndSelectForm(form_meta, customer_fields, recurring_amount_options, product_field_options){ //setting global form object form = form_meta; var type = jQuery("#gf_authorizenet_type").val(); jQuery(".gf_authorizenet_invalid_form").hide(); if( (type == "product" || type =="subscription") && GetFieldsByType(["product"]).length == 0){ jQuery("#gf_authorizenet_invalid_product_form").show(); jQuery("#authorizenet_wait").hide(); return; } else if( (type == "product" || type =="subscription") && GetFieldsByType(["creditcard"]).length == 0){ jQuery("#gf_authorizenet_invalid_creditcard_form").show(); jQuery("#authorizenet_wait").hide(); return; } jQuery(".authorizenet_field_container").hide(); jQuery("#authorizenet_customer_fields").html(customer_fields); jQuery("#gf_authorizenet_recurring_amount").html(recurring_amount_options); jQuery("#gf_authorizenet_setup_fee_amount").html(product_field_options); var post_fields = GetFieldsByType(["post_title", "post_content", "post_excerpt", "post_category", "post_custom_field", "post_image", "post_tag"]); if(type == "subscription" && post_fields.length > 0){ jQuery("#authorizenet_post_update_action").show(); } else{ jQuery("#gf_authorizenet_update_post").attr("checked", false); jQuery("#authorizenet_post_update_action").hide(); } SetPeriodNumber('#gf_authorizenet_billing_cycle_number', jQuery("#gf_authorizenet_billing_cycle_type").val()); //Calling callback functions jQuery(document).trigger('authorizenetFormSelected', [form]); jQuery("#gf_authorizenet_conditional_enabled").attr('checked', false); SetAuthorizeNetCondition("",""); jQuery("#authorizenet_field_container_" + type).show(); jQuery("#authorizenet_field_group").slideDown(); jQuery("#authorizenet_wait").hide(); } function SetPeriodNumber(element, type){ var prev = jQuery(element).val(); var min = 1; var max = 0; switch(type){ case "D" : min = 7; max = 365; break; case "M" : max = 12; break; } var str=""; for(var i=min; i<=max; i++){ var selected = prev == i ? "selected='selected'" : ""; str += "<option value='" + i + "' " + selected + ">" + i + "</option>"; } jQuery(element).html(str); } function GetFieldsByType(types){ var fields = new Array(); for(var i=0; i<form["fields"].length; i++){ if(IndexOf(types, form["fields"][i]["type"]) >= 0) fields.push(form["fields"][i]); } return fields; } function IndexOf(ary, item){ for(var i=0; i<ary.length; i++) if(ary[i] == item) return i; return -1; } function SetAuthorizeNetCondition(selectedField, selectedValue){ // load form fields jQuery("#gf_authorizenet_conditional_field_id").html(GetSelectableFields(selectedField, 20)); var optinConditionField = jQuery("#gf_authorizenet_conditional_field_id").val(); var checked = jQuery("#gf_authorizenet_conditional_enabled").attr('checked'); if(optinConditionField){ jQuery("#gf_authorizenet_conditional_message").hide(); jQuery("#gf_authorizenet_conditional_fields").show(); jQuery("#gf_authorizenet_conditional_value_container").html(GetFieldValues(optinConditionField, selectedValue, 20)); jQuery("#gf_authorizenet_conditional_value").val(selectedValue); } else{ jQuery("#gf_authorizenet_conditional_message").show(); jQuery("#gf_authorizenet_conditional_fields").hide(); } if(!checked) jQuery("#gf_authorizenet_conditional_container").hide(); } function GetFieldValues(fieldId, selectedValue, labelMaxCharacters){ if(!fieldId) return ""; var str = ""; var field = GetFieldById(fieldId); if(!field) return ""; var isAnySelected = false; if(field["type"] == "post_category" && field["displayAllCategories"]){ str += '<?php $dd = wp_dropdown_categories(array("class" => "optin_select", "orderby" => "name", "id" => "gf_authorizenet_conditional_value", "name" => "gf_authorizenet_conditional_value", "hierarchical" => true, "hide_empty" => 0, "echo" => false)); echo str_replace("\n", "", str_replace("'", "\\'", $dd)); ?> '; } else if(field.choices){ str += '<select id="gf_authorizenet_conditional_value" name="gf_authorizenet_conditional_value" class="optin_select">' for(var i=0; i<field.choices.length; i++){ var fieldValue = field.choices[i].value ? field.choices[i].value : field.choices[i].text; var isSelected = fieldValue == selectedValue; var selected = isSelected ? "selected='selected'" : ""; if(isSelected) isAnySelected = true; str += "<option value='" + fieldValue.replace(/'/g, "'") + "' " + selected + ">" + TruncateMiddle(field.choices[i].text, labelMaxCharacters) + "</option>"; } if(!isAnySelected && selectedValue){ str += "<option value='" + selectedValue.replace(/'/g, "'") + "' selected='selected'>" + TruncateMiddle(selectedValue, labelMaxCharacters) + "</option>"; } str += "</select>"; } else { selectedValue = selectedValue ? selectedValue.replace(/'/g, "'") : ""; //create a text field for fields that don't have choices (i.e text, textarea, number, email, etc...) str += "<input type='text' placeholder='<?php _e("Enter value", "gravityforms"); ?> ' id='gf_authorizenet_conditional_value' name='gf_authorizenet_conditional_value' value='" + selectedValue.replace(/'/g, "'") + "'>"; } return str; } function GetFieldById(fieldId){ for(var i=0; i<form.fields.length; i++){ if(form.fields[i].id == fieldId) return form.fields[i]; } return null; } function TruncateMiddle(text, maxCharacters){ if(text.length <= maxCharacters) return text; var middle = parseInt(maxCharacters / 2); return text.substr(0, middle) + "..." + text.substr(text.length - middle, middle); } function GetSelectableFields(selectedFieldId, labelMaxCharacters){ var str = ""; var inputType; for(var i=0; i<form.fields.length; i++){ fieldLabel = form.fields[i].adminLabel ? form.fields[i].adminLabel : form.fields[i].label; fieldLabel = typeof fieldLabel == 'undefined' ? '' : fieldLabel; inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type; if (IsConditionalLogicField(form.fields[i])) { var selected = form.fields[i].id == selectedFieldId ? "selected='selected'" : ""; str += "<option value='" + form.fields[i].id + "' " + selected + ">" + TruncateMiddle(fieldLabel, labelMaxCharacters) + "</option>"; } } return str; } function IsConditionalLogicField(field){ inputType = field.inputType ? field.inputType : field.type; var supported_fields = ["checkbox", "radio", "select", "text", "website", "textarea", "email", "hidden", "number", "phone", "multiselect", "post_title", "post_tags", "post_custom_field", "post_content", "post_excerpt"]; var index = jQuery.inArray(inputType, supported_fields); return index >= 0; } </script> <?php }
public function feed_settings_fields() { $default_settings = parent::feed_settings_fields(); //--add PayPal Email Address field $fields = array(array('name' => 'paypalEmail', 'label' => __('PayPal Email Address ', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => true, 'tooltip' => '<h6>' . __('PayPal Email Address', 'gravityformspaypal') . '</h6>' . __('Enter the PayPal email address where payment should be received.', 'gravityformspaypal')), array('name' => 'mode', 'label' => __('Mode', 'gravityformspaypal'), 'type' => 'radio', 'choices' => array(array('id' => 'gf_paypal_mode_production', 'label' => __('Production', 'gravityformspaypal'), 'value' => 'production'), array('id' => 'gf_paypal_mode_test', 'label' => __('Test', 'gravityformspaypal'), 'value' => 'test')), 'horizontal' => true, 'default_value' => 'production', 'tooltip' => '<h6>' . __('Mode', 'gravityformspaypal') . '</h6>' . __('Select Production to receive live payments. Select Test for testing purposes when using the PayPal development sandbox.', 'gravityformspaypal'))); $default_settings = parent::add_field_after('feedName', $fields, $default_settings); //-------------------------------------------------------------------------------------- //--add donation to transaction type drop down $transaction_type = parent::get_field('transactionType', $default_settings); $choices = $transaction_type['choices']; $add_donation = true; foreach ($choices as $choice) { //add donation option if it does not already exist if ($choice['value'] == 'donation') { $add_donation = false; } } if ($add_donation) { //add donation transaction type $choices[] = array('label' => __('Donations', 'gravityformspaypal'), 'value' => 'donation'); } $transaction_type['choices'] = $choices; $default_settings = $this->replace_field('transactionType', $transaction_type, $default_settings); //------------------------------------------------------------------------------------------------- //--add Page Style, Continue Button Label, Cancel URL $fields = array(array('name' => 'pageStyle', 'label' => __('Page Style', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => false, 'tooltip' => '<h6>' . __('Page Style', 'gravityformspaypal') . '</h6>' . __('This option allows you to select which PayPal page style should be used if you have setup a custom payment page style with PayPal.', 'gravityformspaypal')), array('name' => 'continueText', 'label' => __('Continue Button Label', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => false, 'tooltip' => '<h6>' . __('Continue Button Label', 'gravityformspaypal') . '</h6>' . __('Enter the text that should appear on the continue button once payment has been completed via PayPal.', 'gravityformspaypal')), array('name' => 'cancelUrl', 'label' => __('Cancel URL', 'gravityformspaypal'), 'type' => 'text', 'class' => 'medium', 'required' => false, 'tooltip' => '<h6>' . __('Cancel URL', 'gravityformspaypal') . '</h6>' . __('Enter the URL the user should be sent to should they cancel before completing their PayPal payment.', 'gravityformspaypal')), array('name' => 'options', 'label' => __('Options', 'gravityformspaypal'), 'type' => 'options', 'tooltip' => '<h6>' . __('Options', 'gravityformspaypal') . '</h6>' . __('Turn on or off the available PayPal checkout options.', 'gravityformspaypal')), array('name' => 'notifications', 'label' => __('Notifications', 'gravityformspaypal'), 'type' => 'notifications', 'tooltip' => '<h6>' . __('Notifications', 'gravityformspaypal') . '</h6>' . __("Enable this option if you would like to only send out this form's notifications after payment has been received. Leaving this option disabled will send notifications immediately after the form is submitted.", 'gravityformspaypal'))); //Add post fields if form has a post $form = $this->get_current_form(); if (GFCommon::has_post_field($form['fields'])) { $post_settings = array('name' => 'post_checkboxes', 'label' => __('Posts', 'gravityformspaypal'), 'type' => 'checkbox', 'tooltip' => '<h6>' . __('Posts', 'gravityformspaypal') . '</h6>' . __('Enable this option if you would like to only create the post after payment has been received.', 'gravityformspaypal'), 'choices' => array(array('label' => __('Create post only when payment is received.', 'gravityformspaypal'), 'name' => 'delayPost'))); if ($this->get_setting('transactionType') == 'subscription') { $post_settings['choices'][] = array('label' => __('Change post status when subscription is canceled.', 'gravityformspaypal'), 'name' => 'change_post_status', 'onChange' => 'var action = this.checked ? "draft" : ""; jQuery("#update_post_action").val(action);'); } $fields[] = $post_settings; } //Adding custom settings for backwards compatibility with hook 'gform_paypal_add_option_group' $fields[] = array('name' => 'custom_options', 'label' => '', 'type' => 'custom'); $default_settings = $this->add_field_after('billingInformation', $fields, $default_settings); //----------------------------------------------------------------------------------------- //--get billing info section and add customer first/last name $billing_info = parent::get_field('billingInformation', $default_settings); $billing_fields = $billing_info['field_map']; $add_first_name = true; $add_last_name = true; foreach ($billing_fields as $mapping) { //add first/last name if it does not already exist in billing fields if ($mapping['name'] == 'firstName') { $add_first_name = false; } else { if ($mapping['name'] == 'lastName') { $add_last_name = false; } } } if ($add_last_name) { //add last name array_unshift($billing_info['field_map'], array('name' => 'lastName', 'label' => __('Last Name', 'gravityformspaypal'), 'required' => false)); } if ($add_first_name) { array_unshift($billing_info['field_map'], array('name' => 'firstName', 'label' => __('First Name', 'gravityformspaypal'), 'required' => false)); } $default_settings = parent::replace_field('billingInformation', $billing_info, $default_settings); //---------------------------------------------------------------------------------------------------- //hide default display of setup fee, not used by PayPal Standard $default_settings = parent::remove_field('setupFee', $default_settings); //--add trial period $trial_period = array('name' => 'trialPeriod', 'label' => __('Trial Period', 'gravityformspaypal'), 'type' => 'trial_period', 'hidden' => !$this->get_setting('trial_enabled'), 'tooltip' => '<h6>' . __('Trial Period', 'gravityformspaypal') . '</h6>' . __('Select the trial period length.', 'gravityformspaypal')); $default_settings = parent::add_field_after('trial', $trial_period, $default_settings); //----------------------------------------------------------------------------------------- //--Add Try to bill again after failed attempt. $recurring_retry = array('name' => 'recurringRetry', 'label' => __('Recurring Retry', 'gravityformspaypal'), 'type' => 'checkbox', 'horizontal' => true, 'choices' => array(array('label' => __('Try to bill again after failed attempt.', 'gravityformspaypal'), 'name' => 'recurringRetry', 'value' => '1')), 'tooltip' => '<h6>' . __('Recurring Retry', 'gravityformspaypal') . '</h6>' . __('Turn on or off whether to try to bill again after failed attempt.', 'gravityformspaypal')); $default_settings = parent::add_field_after('recurringTimes', $recurring_retry, $default_settings); //----------------------------------------------------------------------------------------------------- return apply_filters('gform_paypal_feed_settings_fields', $default_settings, $form); }
public static function select_user_registration_form() { check_ajax_referer("gf_select_user_registration_form", "gf_select_user_registration_form"); $form_id = intval(RGForms::post("form_id")); $config_id = intval(RGForms::post("config_id")); $options_meta = array(); // fields meta $form = RGFormsModel::get_form_meta($form_id); $options_meta['set_post_author'] = GFCommon::has_post_field($form['fields']) ? true : false; $form_fields = self::get_form_fields($form); $password_fields = self::get_fields_by_type($form, 'password'); $email_fields = self::get_fields_by_type($form, 'email'); $bp_gform_fields = self::get_bp_gform_fields($form); $form_dropdown_items = self::get_field_drop_down_items($form_fields, ""); $password_dropdown_items = self::get_field_drop_down_items($password_fields, "", false); $email_dropdown_items = self::get_field_drop_down_items($email_fields, ""); die("EndSelectForm(" . GFCommon::json_encode($form) . ", " . GFCommon::json_encode($form_fields) . ", '" . str_replace("'", "\\'", $form_dropdown_items) . "', '" . str_replace("'", "\\'", $password_dropdown_items) . "', '" . str_replace("'", "\\'", $email_dropdown_items) . "', " . GFCommon::json_encode($options_meta) . ", " . GFCommon::json_encode($bp_gform_fields) . " );"); }
/** * */ private function edit_page() { ?> <style> #stripe_submit_container { clear: both; } .stripe_col_heading { padding-bottom: 2px; border-bottom: 1px solid #ccc; font-weight: bold; width: 120px; } .stripe_field_cell { padding: 6px 17px 0 0; margin-right: 15px; } .stripe_validation_error { background-color: #FFDFDF; margin-top: 4px; margin-bottom: 6px; padding-top: 6px; padding-bottom: 6px; border: 1px dotted #C89797; } .stripe_validation_error span { color: red; } .left_header { float: left; width: 200px; } .margin_vertical_10 { margin: 10px 0; padding-left: 5px; min-height: 17px; } .margin_vertical_30 { margin: 30px 0; padding-left: 5px; } .width-1 { width: 300px; } .gfp_stripe_invalid_form { margin-top: 30px; background-color: #FFEBE8; border: 1px solid #CC0000; padding: 10px; width: 600px; } </style> <script type="text/javascript" src="<?php echo GFCommon::get_base_url(); ?> /js/gravityforms.js"></script> <script type="text/javascript">var form = Array();</script> <div class="wrap"> <img alt="<?php _e('Stripe', 'gfp-stripe'); ?> " style="margin: 15px 7px 0pt 0pt; float: left;" src="<?php echo self::$_this->get_base_url(); ?> /images/stripe_wordpress_icon_32.png"/> <h2><?php _e('Stripe Transaction Settings', 'gfp-stripe'); ?> </h2> <?php //getting setting id (0 when creating a new one) $id = !empty($_POST['stripe_setting_id']) ? $_POST['stripe_setting_id'] : absint($_GET['id']); $feed = empty($id) ? array('meta' => array(), 'is_active' => true) : GFP_Stripe_Data::get_feed($id); $is_validation_error = false; //updating meta information if (rgpost('gfp_stripe_submit')) { $feed['form_id'] = absint(rgpost('gfp_stripe_form')); $feed['meta']['type'] = rgpost('gfp_stripe_type'); $feed['meta']['update_post_action'] = rgpost('gfp_stripe_update_action'); // stripe conditional $feed['meta']['stripe_conditional_enabled'] = rgpost('gfp_stripe_conditional_enabled'); $feed['meta']['stripe_conditional_field_id'] = rgpost('gfp_stripe_conditional_field_id'); $feed['meta']['stripe_conditional_operator'] = rgpost('gfp_stripe_conditional_operator'); $feed['meta']['stripe_conditional_value'] = rgpost('gfp_stripe_conditional_value'); //----------------- $customer_fields = $this->get_customer_fields(); $feed['meta']['customer_fields'] = array(); foreach ($customer_fields as $field) { $feed['meta']['customer_fields'][$field['name']] = $_POST["stripe_customer_field_{$field["name"]}"]; } $feed = apply_filters('gfp_stripe_save_feed', $feed); $is_validation_error = apply_filters('gfp_stripe_feed_validation', false, $feed); if (!$is_validation_error) { $id = GFP_Stripe_Data::update_feed($id, $feed["form_id"], $feed["is_active"], $feed["meta"]); ?> <div class="updated fade" style="padding:6px"><?php echo sprintf(__("Feed Updated. %sback to list%s", 'gfp-stripe'), "<a href='?page=gfp_stripe'>", '</a>'); ?> </div> <?php } else { $is_validation_error = true; } } $form = isset($feed['form_id']) && $feed['form_id'] ? $form = RGFormsModel::get_form_meta($feed['form_id']) : array(); $settings = get_option('gfp_stripe_settings'); ?> <form method="post" action=""> <input type="hidden" name="stripe_setting_id" value="<?php echo $id; ?> "/> <div class="margin_vertical_10 <?php echo $is_validation_error ? 'stripe_validation_error' : ''; ?> "> <?php if ($is_validation_error) { ?> <span><?php _e('There was an issue saving your feed. Please address the errors below and try again.'); ?> </span> <?php } ?> </div> <!-- / validation message --> <?php if (has_action('gfp_stripe_feed_transaction_type')) { do_action('gfp_stripe_feed_transaction_type', $settings, $feed); } else { $feed['meta']['type'] = 'product'; ?> <input id="gfp_stripe_type" type="hidden" name="gfp_stripe_type" value="product"> <?php } ?> <div id="stripe_form_container" valign="top" class="margin_vertical_10" <?php echo empty($feed['meta']['type']) ? "style='display:none;'" : ''; ?> > <label for="gfp_stripe_form" class="left_header"><?php _e('Gravity Form', 'gfp-stripe'); ?> <?php gform_tooltip('stripe_gravity_form'); ?> </label> <select id="gfp_stripe_form" name="gfp_stripe_form" onchange="SelectForm(jQuery('#gfp_stripe_type').val(), jQuery(this).val(), '<?php echo rgar($feed, 'id'); ?> ');"> <option value=""><?php _e('Select a form', 'gfp-stripe'); ?> </option> <?php $active_form = rgar($feed, 'form_id'); $available_forms = GFP_Stripe_Data::get_available_forms($active_form); foreach ($available_forms as $current_form) { $selected = absint($current_form->id) == rgar($feed, 'form_id') ? 'selected="selected"' : ''; ?> <option value="<?php echo absint($current_form->id); ?> " <?php echo $selected; ?> ><?php echo esc_html($current_form->title); ?> </option> <?php } ?> </select> <img src="<?php echo GFP_Stripe::get_base_url(); ?> /images/loading.gif" id="stripe_wait" style="display: none;"/> <div id="gfp_stripe_invalid_product_form" class="gfp_stripe_invalid_form" style="display:none;"> <?php _e('The form selected does not have any Product fields. Please add a Product field to the form and try again.', 'gfp-stripe'); ?> </div> <div id="gfp_stripe_invalid_creditcard_form" class="gfp_stripe_invalid_form" style="display:none;"> <?php _e('The form selected does not have a credit card field. Please add a credit card field to the form and try again.', 'gfp-stripe'); ?> </div> </div> <div id="stripe_field_group" valign="top" <?php echo strlen(rgars($feed, "meta/type")) == 0 || empty($feed["form_id"]) ? "style='display:none;'" : ''; ?> > <?php do_action('gfp_stripe_feed_before_billing', $feed, $form); ?> <div class="margin_vertical_10" id="gfp_stripe_billing_info" <?php echo false == apply_filters('gfp_stripe_display_billing_info', true, $feed) ? "style='display:none;'" : ''; ?> > <label class="left_header"><?php _e('Billing Information', 'gfp-stripe'); ?> <?php gform_tooltip('stripe_customer'); ?> </label> <div id="stripe_customer_fields"> <?php if (!empty($form)) { echo $this->get_customer_information($form, $feed); } ?> </div> </div> <?php do_action('gfp_stripe_feed_after_billing', $feed, $form); ?> <div class="margin_vertical_10"> <label class="left_header"><?php _e('Options', 'gfp-stripe'); ?> <?php gform_tooltip('stripe_options'); ?> </label> <ul style="overflow:hidden;"> <?php $display_post_fields = !empty($form) ? GFCommon::has_post_field($form['fields']) : false; ?> <li id="stripe_post_update_action" <?php echo $display_post_fields && 'subscription' == $feed['meta']['type'] ? '' : "style='display:none;'"; ?> > <input type="checkbox" name="gfp_stripe_update_post" id="gfp_stripe_update_post" value="1" <?php echo rgar($feed['meta'], 'update_post_action') ? "checked='checked'" : ""; ?> onclick="var action = this.checked ? 'draft' : ''; jQuery('#gfp_stripe_update_action').val(action);"/> <label class="inline" for="gfp_stripe_update_post"><?php _e('Update Post when subscription is canceled.', 'gfp-stripe'); ?> <?php gform_tooltip('stripe_update_post'); ?> </label> <select id="gfp_stripe_update_action" name="gfp_stripe_update_action" onchange="var checked = jQuery(this).val() ? 'checked' : false; jQuery('#gfp_stripe_update_post').attr('checked', checked);"> <option value=""></option> <option value="draft" <?php echo 'draft' == rgar($feed["meta"], 'update_post_action') ? "selected='selected'" : ""; ?> ><?php _e('Mark Post as Draft', 'gfp-stripe'); ?> </option> <option value="delete" <?php echo 'delete' == rgar($feed["meta"], 'update_post_action') ? "selected='selected'" : ""; ?> ><?php _e('Delete Post', 'gfp-stripe'); ?> </option> </select> </li> <?php do_action('gfp_stripe_feed_options', $feed, $form); ?> </ul> </div> <?php do_action('gfp_stripe_feed_setting', $feed, $form); ?> <div id="gfp_stripe_conditional_section" valign="top" class="margin_vertical_10"> <label for="gfp_stripe_conditional_optin" class="left_header"><?php _e('Stripe Condition', 'gfp-stripe'); ?> <?php gform_tooltip('stripe_conditional'); ?> </label> <div id="gfp_stripe_conditional_option"> <table cellspacing="0" cellpadding="0"> <tr> <td> <input type="checkbox" id="gfp_stripe_conditional_enabled" name="gfp_stripe_conditional_enabled" value="1" onclick="if(this.checked){jQuery('#gfp_stripe_conditional_container').fadeIn('fast');} else{ jQuery('#gfp_stripe_conditional_container').fadeOut('fast'); }" <?php echo rgar($feed['meta'], 'stripe_conditional_enabled') ? "checked='checked'" : ''; ?> /> <label for="gfp_stripe_conditional_enable"><?php _e('Enable', 'gfp-stripe'); ?> </label> </td> </tr> <tr> <td> <div id="gfp_stripe_conditional_container" <?php echo !rgar($feed['meta'], 'stripe_conditional_enabled') ? "style='display:none'" : ''; ?> > <div id="gfp_stripe_conditional_fields" style="display:none"> <?php _e('Send to Stripe if ', 'gfp-stripe'); ?> <select id="gfp_stripe_conditional_field_id" name="gfp_stripe_conditional_field_id" class="optin_select" onchange='jQuery("#gfp_stripe_conditional_value_container").html(GetFieldValues(jQuery(this).val(), "", 20));'> </select> <select id="gfp_stripe_conditional_operator" name="gfp_stripe_conditional_operator"> <option value="is" <?php selected('is', rgar($feed['meta'], 'stripe_conditional_operator'), true); ?> > <?php _e('is', 'gfp-stripe'); ?> </option> <option value="isnot" <?php selected('isnot', rgar($feed['meta'], 'stripe_conditional_operator'), true); ?> > <?php _e('is not', 'gfp-stripe'); ?> </option> <option value=">" <?php selected('>', rgar($feed['meta'], 'stripe_conditional_operator'), true); ?> > <?php _e('greater than', 'gfp-stripe'); ?> </option> <option value="<" <?php selected('<', rgar($feed['meta'], 'stripe_conditional_operator'), true); ?> > <?php _e('less than', 'gfp-stripe'); ?> </option> <option value="contains" <?php selected('contains', rgar($feed['meta'], 'stripe_conditional_operator'), true); ?> > <?php _e('contains', 'gfp-stripe'); ?> </option> <option value="starts_with" <?php selected('starts_with', rgar($feed['meta'], 'stripe_conditional_operator'), true); ?> > <?php _e('starts with', 'gfp-stripe'); ?> </option> <option value="ends_with" <?php selected('ends_with', rgar($feed['meta'], 'stripe_conditional_operator'), true); ?> > <?php _e('ends with', 'gfp-stripe'); ?> </option> </select> <div id="gfp_stripe_conditional_value_container" name="gfp_stripe_conditional_value_container" style="display:inline"></div> </div> <div id="gfp_stripe_conditional_message" style="display:none"> <?php _e('To create a registration condition, your form must have a field supported by conditional logic', 'gfp-stripe'); ?> </div> </div> </td> </tr> </table> </div> </div> <!-- / stripe conditional --> <div id="stripe_submit_container" class="margin_vertical_30"> <input type="submit" name="gfp_stripe_submit" value="<?php echo empty($id) ? __(' Save ', 'gfp-stripe') : __('Update', 'gfp-stripe'); ?> " class="button-primary"/> <input type="button" value="<?php _e('Cancel', 'gfp-stripe'); ?> " class="button" onclick="javascript:document.location='admin.php?page=gfp_stripe'"/> </div> </div> </form> </div> <script type="text/javascript"> function SelectType( type ) { jQuery( "#stripe_field_group" ).slideUp(); jQuery( "#stripe_field_group input[type=\"text\"], #stripe_field_group select" ).val( "" ); jQuery( "#stripe_field_group input:checked" ).attr( "checked", false ); if ( type ) { jQuery( "#stripe_form_container" ).slideDown(); jQuery( "#gfp_stripe_form" ).val( "" ); } else { jQuery( "#stripe_form_container" ).slideUp(); } } function SelectForm( type, formId, settingId ) { if ( !formId ) { jQuery( "#stripe_field_group" ).slideUp(); return; } jQuery( "#stripe_wait" ).show(); jQuery( "#stripe_field_group" ).slideUp(); var mysack = new sack( ajaxurl ); mysack.execute = 1; mysack.method = 'POST'; mysack.setVar( "action", "gfp_select_stripe_form" ); mysack.setVar( "gfp_select_stripe_form", "<?php echo wp_create_nonce('gfp_select_stripe_form'); ?> " ); mysack.setVar( "type", type ); mysack.setVar( "form_id", formId ); mysack.setVar( "setting_id", settingId ); mysack.encVar( "cookie", document.cookie, false ); mysack.onError = function () { jQuery( "#stripe_wait" ).hide(); alert( '<?php _e('Ajax error while selecting a form', 'gfp-stripe'); ?> ' ) }; mysack.runAJAX(); return true; } function EndSelectForm( form_meta, customer_fields, additional_functions ) { //setting global form object form = form_meta; if ( !( typeof additional_functions === 'null' ) ) { var populate_field_options = additional_functions.populate_field_options; var post_update_action = additional_functions.post_update_action; var show_fields = additional_functions.show_fields; } else { var populate_field_options = ''; var post_update_action = ''; var show_fields = ''; } var type = jQuery( "#gfp_stripe_type" ).val(); jQuery( ".gfp_stripe_invalid_form" ).hide(); if ( ( 'product' == type || 'subscription' == type || 'update-subscription' == type ) && GetFieldsByType( ['product'] ).length == 0 ) { jQuery( "#gfp_stripe_invalid_product_form" ).show(); jQuery( "#stripe_wait" ).hide(); return; } else if ( ( 'product' == type || 'subscription' == type || 'update-billing' == type ) && GetFieldsByType( ['creditcard'] ).length == 0 ) { jQuery( "#gfp_stripe_invalid_creditcard_form" ).show(); jQuery( "#stripe_wait" ).hide(); return; } jQuery( ".stripe_field_container" ).hide(); jQuery( "#stripe_customer_fields" ).html( customer_fields ); if ( populate_field_options.length > 0 ) { var func; for ( var i = 0; i < populate_field_options.length; i++ ) { func = new Function( populate_field_options[ i ] ); func(); } } var post_fields = GetFieldsByType( ["post_title", "post_content", "post_excerpt", "post_category", "post_custom_field", "post_image", "post_tag"] ); if ( post_update_action.length > 0 ) { var func; for ( var i = 0; i < post_update_action.length; i++ ) { func = new Function( 'type', 'post_fields', post_update_action[ i ] ); func( type, post_fields ); } } else { jQuery( "#gfp_stripe_update_post" ).attr( "checked", false ); jQuery( "#stripe_post_update_action" ).hide(); } //Calling callback functions jQuery( document ).trigger( 'stripeFormSelected', [form] ); jQuery( "#gfp_stripe_conditional_enabled" ).attr( 'checked', false ); SetStripeCondition( "", "" ); jQuery( "#stripe_field_container_" + type ).show(); if ( show_fields.length > 0 ) { var func; for ( var i = 0; i < show_fields.length; i++ ) { func = new Function( 'type', show_fields[ i ] ); func( type ); } } jQuery( "#stripe_field_group" ).slideDown(); jQuery( "#stripe_wait" ).hide(); } function GetFieldsByType( types ) { var fields = new Array(); for ( var i = 0; i < form["fields"].length; i++ ) { if ( IndexOf( types, form["fields"][i]["type"] ) >= 0 ) fields.push( form["fields"][i] ); } return fields; } function IndexOf( ary, item ) { for ( var i = 0; i < ary.length; i++ ) if ( ary[i] == item ) return i; return -1; } </script> <script type="text/javascript"> // Stripe Conditional Functions <?php if (!empty($feed['form_id'])) { ?> // initialize form object form = <?php echo GFCommon::json_encode($form); ?> ; // initializing registration condition drop downs jQuery( document ).ready( function () { var selectedField = "<?php echo str_replace('"', '\\"', $feed['meta']['stripe_conditional_field_id']); ?> "; var selectedValue = "<?php echo str_replace('"', '\\"', $feed['meta']['stripe_conditional_value']); ?> "; SetStripeCondition( selectedField, selectedValue ); } ); <?php } ?> function SetStripeCondition( selectedField, selectedValue ) { // load form fields jQuery( "#gfp_stripe_conditional_field_id" ).html( GetSelectableFields( selectedField, 20 ) ); var optinConditionField = jQuery( "#gfp_stripe_conditional_field_id" ).val(); var checked = jQuery( "#gfp_stripe_conditional_enabled" ).attr( 'checked' ); if ( optinConditionField ) { jQuery( "#gfp_stripe_conditional_message" ).hide(); jQuery( "#gfp_stripe_conditional_fields" ).show(); jQuery( "#gfp_stripe_conditional_value_container" ).html( GetFieldValues( optinConditionField, selectedValue, 20 ) ); jQuery( "#gfp_stripe_conditional_value" ).val( selectedValue ); } else { jQuery( "#gfp_stripe_conditional_message" ).show(); jQuery( "#gfp_stripe_conditional_fields" ).hide(); } if ( !checked ) { jQuery( "#gfp_stripe_conditional_container" ).hide(); } } function GetFieldValues( fieldId, selectedValue, labelMaxCharacters ) { if ( !fieldId ) return ""; var str = ""; var field = GetFieldById( fieldId ); if ( !field ) return ""; var isAnySelected = false; if ( ( 'post_category' == field['type'] ) && field['displayAllCategories'] ) { str += '<?php $select = wp_dropdown_categories(array('orderby' => 'name', 'hide_empty' => 0, 'echo' => false, 'hierarchical' => true, 'name' => 'gfp_stripe_conditional_value', 'id' => 'gfp_stripe_conditional_value', 'class' => 'optin_select')); echo str_replace("\n", "", str_replace("'", "\\'", $select)); ?> '; } else if ( field.choices ) { str += '<select id="gfp_stripe_conditional_value" name="gfp_stripe_conditional_value" class="optin_select">' for ( var i = 0; i < field.choices.length; i++ ) { var fieldValue = field.choices[i].value ? field.choices[i].value : field.choices[i].text; var isSelected = fieldValue == selectedValue; var selected = isSelected ? "selected='selected'" : ""; if ( isSelected ) isAnySelected = true; str += "<option value='" + fieldValue.replace( /'/g, "'" ) + "' " + selected + ">" + TruncateMiddle( field.choices[i].text, labelMaxCharacters ) + "</option>"; } if ( !isAnySelected && selectedValue ) { str += "<option value='" + selectedValue.replace( /'/g, "'" ) + "' selected='selected'>" + TruncateMiddle( selectedValue, labelMaxCharacters ) + "</option>"; } str += "</select>"; } else { selectedValue = selectedValue ? selectedValue.replace( /'/g, "'" ) : ""; str += "<input type='text' placeholder='<?php _e('Enter value', 'gfp-stripe'); ?> ' id='gfp_stripe_conditional_value' name='gfp_stripe_conditional_value' value='" + selectedValue.replace( /'/g, "'" ) + "'>"; } return str; } function GetFieldById( fieldId ) { for ( var i = 0; i < form.fields.length; i++ ) { if ( form.fields[i].id == fieldId ) return form.fields[i]; } return null; } function TruncateMiddle( text, maxCharacters ) { if ( text.length <= maxCharacters ) return text; var middle = parseInt( maxCharacters / 2 ); return text.substr( 0, middle ) + "..." + text.substr( text.length - middle, middle ); } function GetSelectableFields( selectedFieldId, labelMaxCharacters ) { var str = ""; var inputType; for ( var i = 0; i < form.fields.length; i++ ) { fieldLabel = form.fields[i].adminLabel ? form.fields[i].adminLabel : form.fields[i].label; fieldLabel = typeof fieldLabel == 'undefined' ? '' : fieldLabel; inputType = form.fields[i].inputType ? form.fields[i].inputType : form.fields[i].type; if ( IsConditionalLogicField( form.fields[i] ) ) { var selected = form.fields[i].id == selectedFieldId ? "selected='selected'" : ""; str += "<option value='" + form.fields[i].id + "' " + selected + ">" + TruncateMiddle( fieldLabel, labelMaxCharacters ) + "</option>"; } } return str; } function IsConditionalLogicField( field ) { inputType = field.inputType ? field.inputType : field.type; var supported_fields = ["checkbox", "radio", "select", "text", "website", "textarea", "email", "hidden", "number", "phone", "multiselect", "post_title", "post_tags", "post_custom_field", "post_content", "post_excerpt", "total"]; var index = jQuery.inArray( inputType, supported_fields ); return index >= 0; } </script> <?php }
/** * Configures the settings which should be rendered on the feed edit page. * * @return array The feed settings. */ public function feed_settings_fields() { $default_settings = parent::feed_settings_fields(); //remove default options before adding custom $default_settings = parent::remove_field('options', $default_settings); $default_settings = parent::remove_field('billingCycle', $default_settings); $default_settings = parent::remove_field('trial', $default_settings); //add pay period if subscription if ($this->get_setting('transactionType') == 'subscription') { $pay_period_field = array('name' => 'payPeriod', 'label' => esc_html__('Pay Period', 'gravityformspaypalpaymentspro'), 'type' => 'select', 'choices' => array(array('label' => esc_html__('Weekly', 'gravityformspaypalpaymentspro'), 'value' => 'WEEK'), array('label' => esc_html__('Every Two Weeks', 'gravityformspaypalpaymentspro'), 'value' => 'BIWK'), array('label' => esc_html__('Twice Every Month', 'gravityformspaypalpaymentspro'), 'value' => 'SMMO'), array('label' => esc_html__('Every Four Weeks', 'gravityformspaypalpaymentspro'), 'value' => 'FRWK'), array('label' => esc_html__('Monthly', 'gravityformspaypalpaymentspro'), 'value' => 'MONT'), array('label' => esc_html__('Quarterly', 'gravityformspaypalpaymentspro'), 'value' => 'QTER'), array('label' => esc_html__('Twice Every Year', 'gravityformspaypalpaymentspro'), 'value' => 'SMYR'), array('label' => esc_html__('Yearly', 'gravityformspaypalpaymentspro'), 'value' => 'YEAR')), 'tooltip' => '<h6>' . esc_html__('Pay Period', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Select pay period. This determines how often the recurring payment should occur.', 'gravityformspaypalpaymentspro')); $default_settings = $this->add_field_after('recurringAmount', $pay_period_field, $default_settings); //Add post fields if form has a post $form = $this->get_current_form(); if (GFCommon::has_post_field($form['fields'])) { $post_settings = array('name' => 'post_checkboxes', 'label' => esc_html__('Posts', 'gravityformspaypalpaymentspro'), 'type' => 'checkbox', 'tooltip' => '<h6>' . esc_html__('Posts', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Enable this option if you would like to change the post status when a subscription is cancelled.', 'gravityformspaypalpaymentspro'), 'choices' => array(array('label' => esc_html__('Update Post when subscription is cancelled.', 'gravityformspaypalpaymentspro'), 'name' => 'change_post_status', 'onChange' => 'var action = this.checked ? "draft" : ""; jQuery("#update_post_action").val(action);'))); $default_settings = $this->add_field_after('billingInformation', $post_settings, $default_settings); } } $fields = array(array('name' => 'apiSettingsEnabled', 'label' => esc_html__('API Settings', 'gravityformspaypalpaymentspro'), 'type' => 'checkbox', 'tooltip' => '<h6>' . esc_html__('API Settings', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Override the settings provided on the PayPal Payments Pro Settings page and use these instead for this feed.', 'gravityformspaypalpaymentspro'), 'onchange' => "if(jQuery(this).prop('checked')){\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideMode').show();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideUsername').show();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overridePassword').show();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideVendor').show();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overridePartner').show();\r\n\t\t\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideMode').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideUsername').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overridePassword').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideVendor').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overridePartner').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#overrideUsername').val('');\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#overridePassword').val('');\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#overrideVendor').val('');\r\n\t\t\t\t\t\t\t\t\t\t//jQuery('#overridePartner').val('');\r\n\t\t\t\t\t\t\t\t\t\tjQuery('i').removeClass('icon-check fa-check gf_valid');\r\n\t\t\t\t\t\t\t\t\t}", 'choices' => array(array('label' => 'Override Default Settings', 'name' => 'apiSettingsEnabled'))), array('name' => 'overrideMode', 'label' => esc_html__('API', 'gravityformspaypalpaymentspro'), 'type' => 'radio', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('API', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Select either Production or Sandbox API to override the chosen mode on the PayPal Payments Pro Settings page.', 'gravityformspaypalpaymentspro'), 'choices' => array(array('label' => esc_html__('Production', 'gravityformspaypalpaymentspro'), 'value' => 'production'), array('label' => esc_html__('Sandbox', 'gravityformspaypalpaymentspro'), 'value' => 'test')), 'horizontal' => true), array('name' => 'overrideUsername', 'label' => esc_html__('Username', 'gravityformspaypalpaymentspro'), 'type' => 'text', 'class' => 'medium', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('Username', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Enter a new value to override the Username on the PayPal Payments Pro Settings page.', 'gravityformspaypalpaymentspro'), 'feedback_callback' => array($this, 'is_valid_override_credentials')), array('name' => 'overridePassword', 'label' => esc_html__('Password', 'gravityformspaypalpaymentspro'), 'type' => 'password', 'class' => 'medium', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('Password', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Enter a new value to override the Password on the PayPal Payments Pro Settings page.', 'gravityformspaypalpaymentspro'), 'feedback_callback' => array($this, 'check_valid_override_credential_setting')), array('name' => 'overrideVendor', 'label' => esc_html__('Vendor (optional)', 'gravityformspaypalpaymentspro'), 'type' => 'vendor', 'class' => 'medium', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('Vendor', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Enter a new value to override the Vendor on the PayPal Payments Pro Settings page.', 'gravityformspaypalpaymentspro'), 'feedback_callback' => array($this, 'check_valid_override_credential_setting')), array('name' => 'overridePartner', 'label' => esc_html__('Partner', 'gravityformspaypalpaymentspro'), 'type' => 'partner', 'class' => 'medium', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('Partner', 'gravityformspaypalpaymentspro') . '</h6>' . esc_html__('Enter a new value to override the Partner on the PayPal Payments Pro Settings page.', 'gravityformspaypalpaymentspro'), 'default_value' => 'PayPal', 'feedback_callback' => array($this, 'check_valid_override_credential_setting'))); $default_settings = $this->add_field_after('conditionalLogic', $fields, $default_settings); return $default_settings; }
public static function get_form_fields($form) { $str = "<option value=''>" . __("Insert merge code", "gravityforms") . "</option>"; $required_fields = array(); $optional_fields = array(); $pricing_fields = array(); foreach ($form["fields"] as $field) { if ($field["displayOnly"]) { continue; } $input_type = RGFormsModel::get_input_type($field); //skip field types that should be excluded if (is_array($exclude) && in_array($input_type, $exclude)) { continue; } if ($field["isRequired"]) { switch ($input_type) { case "name": if ($field["nameFormat"] == "extended") { $prefix = GFCommon::get_input($field, $field["id"] + 0.2); $suffix = GFCommon::get_input($field, $field["id"] + 0.8); $optional_field = $field; $optional_field["inputs"] = array($prefix, $suffix); //Add optional name fields to the optional list $optional_fields[] = $optional_field; //Remove optional name field from required list unset($field["inputs"][0]); unset($field["inputs"][3]); } $required_fields[] = $field; break; default: $required_fields[] = $field; } } else { $optional_fields[] = $field; } if (GFCommon::is_pricing_field($field["type"])) { $pricing_fields[] = $field; } } if (!empty($required_fields)) { $str .= "<optgroup label='" . __("Required form fields", "gravityforms") . "'>"; foreach ($required_fields as $field) { $str .= self::get_field_variable($field); } $str .= "</optgroup>"; } if (!empty($optional_fields)) { $str .= "<optgroup label='" . __("Optional form fields", "gravityforms") . "'>"; foreach ($optional_fields as $field) { $str .= self::get_field_variable($field); } $str .= "</optgroup>"; } if (!empty($pricing_fields)) { $str .= "<optgroup label='" . __("Pricing form fields", "gravityforms") . "'>"; foreach ($pricing_fields as $field) { $str .= self::get_field_variable($field); } $str .= "</optgroup>"; } $str .= "<optgroup label='" . __("Other", "gravityforms") . "'>\n <option value='{ip}'>" . __("Client IP Address", "gravityforms") . "</option>\n <option value='{date_mdy}'>" . __("Date", "gravityforms") . " (mm/dd/yyyy)</option>\n <option value='{date_dmy}'>" . __("Date", "gravityforms") . " (dd/mm/yyyy)</option>\n <option value='{embed_post:ID}'>" . __("Embed Post/Page Id", "gravityforms") . "</option>\n <option value='{embed_post:post_title}'>" . __("Embed Post/Page Title", "gravityforms") . "</option>\n <option value='{embed_url}'>" . __("Embed URL", "gravityforms") . "</option>\n <option value='{entry_id}'>" . __("Entry Id", "gravityforms") . "</option>\n <option value='{entry_url}'>" . __("Entry URL", "gravityforms") . "</option>\n <option value='{form_id}'>" . __("Form Id", "gravityforms") . "</option>\n <option value='{form_title}'>" . __("Form Title", "gravityforms") . "</option>\n <option value='{user_agent}'>" . __("HTTP User Agent", "gravityforms") . "</option>"; if (GFCommon::has_post_field($form["fields"])) { $str .= "<option value='{post_id}'>" . __("Post Id", "gravityforms") . "</option>\n <option value='{post_edit_url}'>" . __("Post Edit URL", "gravityforms") . "</option>"; } $str .= "<option value='{user:display_name}'>" . __("User Display Name", "gravityforms") . "</option>\n <option value='{user:user_email}'>" . __("User Email", "gravityforms") . "</option>\n <option value='{user:user_login}'>" . __("User Login", "gravityforms") . "</option>\n </optgroup>"; return $str; }
public function feed_settings_fields() { $default_settings = parent::feed_settings_fields(); //remove default options before adding custom $default_settings = parent::remove_field('options', $default_settings); $fields = array(array('name' => 'options', 'label' => esc_html__('Options', 'gravityformsauthorizenet'), 'type' => 'options', 'tooltip' => '<h6>' . esc_html__('Options', 'gravityformsauthorizenet') . '</h6>' . esc_html__('Turn on or off the available Authorize.Net checkout options.', 'gravityformsauthorizenet'))); //Add post fields if form has a post $form = $this->get_current_form(); if (GFCommon::has_post_field($form['fields'])) { if ($this->get_setting('transactionType') == 'subscription') { $post_settings = array('name' => 'post_checkboxes', 'label' => esc_html__('Posts', 'gravityformsauthorizenet'), 'type' => 'checkbox', 'tooltip' => '<h6>' . esc_html__('Posts', 'gravityformsauthorizenet') . '</h6>' . esc_html__('Enable this option if you would like to change the post status when a subscription is canceled.', 'gravityformsauthorizenet'), 'choices' => array(array('label' => esc_html__('Change post status when subscription is canceled.', 'gravityformsauthorizenet'), 'name' => 'change_post_status', 'onChange' => 'var action = this.checked ? "draft" : ""; jQuery("#update_post_action").val(action);'))); $fields[] = $post_settings; } } $default_settings = $this->add_field_after('billingInformation', $fields, $default_settings); $fields = array(array('name' => 'apiSettingsEnabled', 'label' => esc_html__('API Settings', 'gravityformsauthorizenet'), 'type' => 'checkbox', 'tooltip' => '<h6>' . esc_html__('API Settings', 'gravityformsauthorizenet') . '</h6>' . esc_html__('Override the settings provided on the Authorize.Net Settings page and use these instead for this feed.', 'gravityformsauthorizenet'), 'onchange' => "if(jQuery(this).prop('checked')){\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideMode').show();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideLogin').show();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideKey').show();\r\n\t\t\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideMode').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideLogin').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#gaddon-setting-row-overrideKey').hide();\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#overrideLogin').val('');\r\n\t\t\t\t\t\t\t\t\t\tjQuery('#overrideKey').val('');\r\n\t\t\t\t\t\t\t\t\t\tjQuery('i').removeClass('icon-check fa-check gf_valid');\r\n\t\t\t\t\t\t\t\t\t}", 'choices' => array(array('label' => 'Override Default Settings', 'name' => 'apiSettingsEnabled'))), array('name' => 'overrideMode', 'label' => esc_html__('Mode', 'gravityformsauthorizenet'), 'type' => 'radio', 'default_value' => 'test', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('Mode', 'gravityformsauthorizenet') . '</h6>' . esc_html__('Select either Production or Test mode to override the chosen mode on the Authorize.Net Settings page.', 'gravityformsauthorizenet'), 'choices' => array(array('label' => esc_html__('Production', 'gravityformsauthorizenet'), 'value' => 'production'), array('label' => esc_html__('Test', 'gravityformsauthorizenet'), 'value' => 'test')), 'horizontal' => true), array('name' => 'overrideLogin', 'label' => esc_html__('API Login ID', 'gravityformsauthorizenet'), 'type' => 'text', 'class' => 'medium', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('API Login ID', 'gravityformsauthorizenet') . '</h6>' . esc_html__('Enter a new value to override the API Login ID on the Authorize.Net Settings page.', 'gravityformsauthorizenet'), 'feedback_callback' => array($this, 'is_valid_custom_key')), array('name' => 'overrideKey', 'label' => esc_html__('Transaction Key', 'gravityformsauthorizenet'), 'type' => 'text', 'class' => 'medium', 'hidden' => !$this->get_setting('apiSettingsEnabled'), 'tooltip' => '<h6>' . esc_html__('Transaction Key', 'gravityformsauthorizenet') . '</h6>' . esc_html__('Enter a new value to override the Transaction Key on the Authorize.Net Settings page.', 'gravityformsauthorizenet'), 'feedback_callback' => array($this, 'is_valid_custom_key'))); $default_settings = $this->add_field_after('conditionalLogic', $fields, $default_settings); return $default_settings; }