function gforms_autologin($user_id, $config, $entry, $password) { $form = RGFormsModel::get_form_meta($entry['form_id']); $user_login = apply_filters("gform_username_{$form['id']}", apply_filters('gform_username', GFUser::get_meta_value('username', $config, $form, $entry), $config, $form, $entry), $config, $form, $entry); $redirect_url = rgars($form, 'confirmation/url') ? rgars($form, 'confirmation/url') : get_bloginfo('home'); //pass the above to the wp_signon function $result = wp_signon(array('user_login' => $user_login, 'user_password' => $password, 'remember' => false)); if (!is_wp_error($result)) { wp_redirect($redirect_url); } }
public function filter_menu_items($menu_items, $form_id, $compact) { $form_meta = GFFormsModel::get_form_meta($form_id); $results_fields = $this->get_fields($form_meta); if (false === empty($results_fields)) { $form_id = $form_meta["id"]; $link_class = ""; if (rgget("page") == "gf_new_form") { $link_class = "gf_toolbar_disabled"; } else { if (rgget("page") == "gf_entries" && rgget("view") == "gf_results_" . $this->_slug) { $link_class = "gf_toolbar_active"; } } $sub_menu_items = array(); $sub_menu_items[] = array('label' => $this->_title, 'title' => __("View results generated by this form", "gravityforms"), 'link_class' => $link_class, 'url' => admin_url("admin.php?page=gf_entries&view=gf_results_{$this->_slug}&id={$form_id}"), 'capabilities' => $this->_capabilities); $duplicate_submenus = wp_filter_object_list(rgars($menu_items, "results/sub_menu_items"), array("label" => $sub_menu_items[0]["label"])); if (count($duplicate_submenus) > 0) { return $menu_items; } // If there's already a menu item with the key "results" then merge the two. if (isset($menu_items["results"])) { $existing_link_class = $menu_items["results"]["link_class"]; $link_class == empty($existing_link_class) ? $link_class : $existing_link_class; $existing_capabilities = $menu_items["results"]["capabilities"]; $merged_capabilities = array_merge($existing_capabilities, $this->_capabilities); $existing_sub_menu_items = $menu_items["results"]["sub_menu_items"]; $merged_sub_menu_items = array_merge($existing_sub_menu_items, $sub_menu_items); $menu_items["results"]["link_class"] = $link_class; $menu_items["results"]["capabilities"] = $merged_capabilities; $menu_items["results"]["sub_menu_items"] = $merged_sub_menu_items; $menu_items["results"]["label"] = __("Results", "gravityforms"); } else { // so far during the page cycle this is the only menu item for this key $menu_items["results"] = array('label' => $compact ? __("Results", "gravityforms") : $this->_title, 'title' => __("View results generated by this form", "gravityforms"), 'url' => "", 'onclick' => "return false;", 'menu_class' => 'gf_form_toolbar_results', 'link_class' => $link_class, 'capabilities' => $this->_capabilities, 'sub_menu_items' => $sub_menu_items, 'priority' => 750); } } return $menu_items; }
/** * Make API request. * * @access public * @param string $action * @param array $options (default: array()) * @param string $method (default: 'GET') * @param int $expected_code (default: 200) * @return array or int */ function make_request($action, $options = array(), $method = 'GET', $expected_code = 200) { $request_options = $method == 'GET' ? '?' . http_build_query($options) : null; /* Build request URL. */ $request_url = 'https://' . $this->account_url . '.capsulecrm.com/api/' . $action . $request_options; /* Setup request arguments. */ $args = array('headers' => array('Accept' => 'application/json', 'Authorization' => 'Basic ' . base64_encode($this->api_token . ':x'), 'Content-Type' => 'application/json'), 'method' => $method, 'sslverify' => $this->verify_ssl); /* Add request options to body of POST and PUT requests. */ if ($method == 'POST' || $method == 'PUT') { $args['body'] = $options; } /* Execute request. */ $result = wp_remote_request($request_url, $args); $decoded_result = json_decode($result['body'], true); /* If WP_Error, throw exception */ if (is_wp_error($result)) { throw new Exception('Request failed. ' . $result->get_error_messages()); } /* If API credentials failed, throw exception. */ if (strpos(rgars($result, 'response/content-type'), 'application/json') == FALSE && $result['response']['code'] !== $expected_code) { throw new Exception('API credentials invalid.'); } /* If return HTTP code does not match expected code, throw exception. */ if ($result['response']['code'] !== $expected_code) { throw new CapsuleCRM_Exception($decoded_result['message'], $result['response']['code'], null, rgar($decoded_result, 'errors')); } /* If the decoded result isn't empty, return it. */ if (!empty($decoded_result)) { return $decoded_result; } /* If the body is empty, retrieve the ID from the location header. */ if (rgars($result, 'headers/location')) { $new_id = explode('/', $result['headers']['location']); return end($new_id); } return; }
public static function get_form_confirmations($form_id) { global $wpdb; if (isset($_confirmations[$form_id])) { return $_confirmations[$form_id]; } $tablename = GFFormsModel::get_meta_table_name(); $sql = $wpdb->prepare("SELECT confirmations FROM {$tablename} WHERE form_id = %d", $form_id); $results = $wpdb->get_results($sql, ARRAY_A); $confirmations = rgars($results, '0/confirmations'); self::$_confirmations[$form_id] = $confirmations ? self::unserialize($confirmations) : array(); return self::$_confirmations[$form_id]; }
/** * Updates feeds to use Zoho CRM module field label instead of field name. * * @access public * @return void */ public function run_foreign_language_fix() { /* Get the Zoho CRM feeds. */ $feeds = $this->get_feeds(); foreach ($feeds as &$feed) { if (rgars($feed, 'meta/action') === 'contact') { $contact_fields = $this->get_module_fields('Contacts'); foreach ($contact_fields as $contact_field) { $search_for = 'contactStandardFields_' . str_replace(' ', '_', $contact_field['name']); $replace_with = 'contactStandardFields_' . str_replace(' ', '_', $contact_field['label']); if (rgars($feed, 'meta/' . $search_for)) { $value = rgars($feed, 'meta/' . $search_for); unset($feed['meta'][$search_for]); $feed['meta'][$replace_with] = $value; } } if (rgars($feed, 'meta/contactCustomFields')) { foreach ($contact_fields as $contact_field) { foreach ($feed['meta']['contactCustomFields'] as &$feed_custom_field) { if ($feed_custom_field['key'] === $contact_field['name']) { $feed_custom_field['key'] = $contact_field['label']; } } } } } if (rgars($feed, 'meta/action') === 'lead') { $lead_fields = $this->get_module_fields('Leads'); foreach ($lead_fields as $lead_field) { $search_for = 'leadStandardFields_' . str_replace(' ', '_', $lead_field['name']); $replace_with = 'leadStandardFields_' . str_replace(' ', '_', $lead_field['label']); if (rgars($feed, 'meta/' . $search_for)) { $value = rgars($feed, 'meta/' . $search_for); unset($feed['meta'][$search_for]); $feed['meta'][$replace_with] = $value; } } if (rgars($feed, 'meta/leadCustomFields')) { foreach ($lead_fields as $lead_field) { foreach ($feed['meta']['leadCustomFields'] as &$feed_custom_field) { if ($feed_custom_field['key'] === $lead_field['name']) { $feed_custom_field['key'] = $lead_field['label']; } } } } } $this->update_feed_meta($feed['id'], $feed['meta']); } }
public static function get_field_map_choices($form_id) { $form = RGFormsModel::get_form_meta($form_id); $fields = array(); // Adding default fields $fields[] = array("value" => "", "label" => ""); $fields[] = array("value" => "date_created", "label" => __("Entry Date", "gravityforms")); $fields[] = array("value" => "ip", "label" => __("User IP", "gravityforms")); $fields[] = array("value" => "source_url", "label" => __("Source Url", "gravityforms")); $fields[] = array("value" => "form_title", "label" => __("Form Title", "gravityforms")); // Populate entry meta $entry_meta = GFFormsModel::get_entry_meta($form["id"]); foreach ($entry_meta as $meta_key => $meta) { $fields[] = array('value' => $meta_key, 'label' => rgars($entry_meta, "{$meta_key}/label")); } // Populate form fields if (is_array($form["fields"])) { foreach ($form["fields"] as $field) { if (is_array(rgar($field, "inputs"))) { //If this is an address field, add full name to the list if (RGFormsModel::get_input_type($field) == "address") { $fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field) . " (" . __("Full", "gravityforms") . ")"); } //If this is a name field, add full name to the list if (RGFormsModel::get_input_type($field) == "name") { $fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field) . " (" . __("Full", "gravityforms") . ")"); } //If this is a checkbox field, add to the list if (RGFormsModel::get_input_type($field) == "checkbox") { $fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field) . " (" . __("Selected", "gravityforms") . ")"); } foreach ($field['inputs'] as $input) { if (RGFormsModel::get_input_type($field) == 'creditcard') { //only include the credit card type (field_id.4) and number (field_id.1) if ($input['id'] == $field['id'] . '.1' || $input['id'] == $field['id'] . '.4') { $fields[] = array('value' => $input["id"], 'label' => GFCommon::get_label($field, $input['id'])); } } else { $fields[] = array('value' => $input["id"], 'label' => GFCommon::get_label($field, $input["id"])); } } } else { if (!rgar($field, "displayOnly")) { $fields[] = array('value' => $field["id"], 'label' => GFCommon::get_label($field)); } } } } return $fields; }
<?php /** * Display Gravity Forms Quiz output * * @package GravityView * @subpackage GravityView/templates/fields */ $gravityview_view = GravityView_View::getInstance(); $field = $gravityview_view->getCurrentField(); // If there's no grade, don't continue if (gv_empty($field['value'])) { return; } if (!class_exists('GFQuiz')) { do_action('gravityview_log_error', __FILE__ . ': GFQuiz class does not exist.'); return; } // Get the setting for show/hide explanation $show_answer = rgars($field, 'field_settings/quiz_show_explanation'); // Update the quiz field so GF generates the output properly $field['field']->gquizShowAnswerExplanation = !empty($show_answer); // Generate the output echo GFQuiz::get_instance()->display_quiz_on_entry_detail($field['value'], $field['field'], $field['entry'], $field['form']);
public function has_paypal_payment($feed, $form, $entry) { $products = GFCommon::get_product_fields($form, $entry); $payment_field = $feed['meta']['transactionType'] == 'product' ? $feed['meta']['paymentAmount'] : $feed['meta']['recurringAmount']; $setup_fee_field = rgar($feed['meta'], 'setupFee_enabled') ? $feed['meta']['setupFee_product'] : false; $trial_field = rgar($feed['meta'], 'trial_enabled') ? rgars($feed, 'meta/trial_product') : false; $amount = 0; $line_items = array(); $discounts = array(); $fee_amount = 0; $trial_amount = 0; foreach ($products['products'] as $field_id => $product) { $quantity = $product['quantity'] ? $product['quantity'] : 1; $product_price = GFCommon::to_number($product['price']); $options = array(); if (is_array(rgar($product, 'options'))) { foreach ($product['options'] as $option) { $options[] = $option['option_name']; $product_price += $option['price']; } } $is_trial_or_setup_fee = false; if (!empty($trial_field) && $trial_field == $field_id) { $trial_amount = $product_price * $quantity; $is_trial_or_setup_fee = true; } else { if (!empty($setup_fee_field) && $setup_fee_field == $field_id) { $fee_amount = $product_price * $quantity; $is_trial_or_setup_fee = true; } } //Do not add to line items if the payment field selected in the feed is not the current field. if (is_numeric($payment_field) && $payment_field != $field_id) { continue; } //Do not add to line items if the payment field is set to "Form Total" and the current field was used for trial or setup fee. if ($is_trial_or_setup_fee && !is_numeric($payment_field)) { continue; } $amount += $product_price * $quantity; } if (!empty($products['shipping']['name']) && !is_numeric($payment_field)) { $line_items[] = array('id' => '', 'name' => $products['shipping']['name'], 'description' => '', 'quantity' => 1, 'unit_price' => GFCommon::to_number($products['shipping']['price']), 'is_shipping' => 1); $amount += $products['shipping']['price']; } return $amount > 0; }
public function prepare_settings_checkbox_and_select($field) { // prepare checkbox $checkbox_input = rgars($field, 'checkbox'); $checkbox_field = array('type' => 'checkbox', 'name' => $field['name'] . 'Enable', 'label' => esc_html__('Enable', 'gravityforms'), 'horizontal' => true, 'value' => '1', 'choices' => false, 'tooltip' => false); $checkbox_field = wp_parse_args($checkbox_input, $checkbox_field); // prepare select $select_input = rgars($field, 'select'); $select_field = array('name' => $field['name'] . 'Value', 'type' => 'select', 'class' => '', 'tooltip' => false); $select_field['class'] .= ' ' . $select_field['name']; $select_field = wp_parse_args($select_input, $select_field); // a little more with the checkbox if (empty($checkbox_field['choices'])) { $checkbox_field['choices'] = array(array('name' => $checkbox_field['name'], 'label' => $checkbox_field['label'], 'onchange' => sprintf("( function( \$, elem ) {\r\n\t\t\t\t\t\t\$( elem ).parents( 'td' ).css( 'position', 'relative' );\r\n\t\t\t\t\t\tif( \$( elem ).prop( 'checked' ) ) {\r\n\t\t\t\t\t\t\t\$( '%1\$s' ).fadeIn();\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\$( '%1\$s' ).fadeOut();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} )( jQuery, this );", "#{$select_field['name']}Span"))); } $field['select'] = $select_field; $field['checkbox'] = $checkbox_field; return $field; }
public function get_column_value_amount($feed) { $form = $this->get_current_form(); $field_id = $feed["meta"]["transactionType"] == "subscription" ? rgars($feed, "meta/recurringAmount") : rgars($feed, "meta/paymentAmount"); if ($field_id == "form_total") { $label = __("Form Total", "gravityforms"); } else { $field = GFFormsModel::get_field($form, $field_id); $label = GFCommon::get_label($field); } return $label; }
public function fulfill_order(&$entry, $transaction_id, $amount, $feed = null) { if (!$feed) { $feed = $this->get_payment_feed($entry); } $form = GFFormsModel::get_form_meta($entry['form_id']); if (rgars($feed, 'meta/delayPost')) { $this->log_debug(__METHOD__ . '(): Creating post.'); $entry['post_id'] = GFFormsModel::create_post($form, $entry); $this->log_debug(__METHOD__ . '(): Post created.'); } if (rgars($feed, 'meta/delayNotification')) { //sending delayed notifications $notifications = rgars($feed, 'meta/selectedNotifications'); GFCommon::send_notifications($notifications, $form, $entry, true, 'form_submission'); } do_action('gform_paypal_fulfillment', $entry, $feed, $transaction_id, $amount); if (has_filter('gform_paypal_fulfillment')) { $this->log_debug(__METHOD__ . '(): Executing functions hooked to gform_paypal_fulfillment.'); } }
/** * Returns the value of the specified List field. * * @param array $entry * @param string $field_id * @param object $field * * @return string */ protected function get_list_field_value($entry, $field_id, $field) { if (!ctype_digit($field_id)) { $field_id_array = explode('.', $field_id); $field_id = rgar($field_id_array, 0); $column_num = rgar($field_id_array, 1); } $value = rgar($entry, $field_id); if (empty($value)) { return ''; } $list_values = $column_values = unserialize($value); if (!empty($column_num) && $field->enableColumns) { $column = rgars($field->choices, "{$column_num}/text"); $column_values = array(); foreach ($list_values as $value) { $column_values[] = rgar($value, $column); } } elseif ($field->enableColumns) { return $value; } return GFCommon::implode_non_blank(', ', $column_values); }
public static function select_mailchimp_form() { check_ajax_referer("gf_select_mailchimp_form", "gf_select_mailchimp_form"); $form_id = intval(rgpost("form_id")); list($list_id, $list_name) = explode("|:|", rgpost("list_id")); $setting_id = intval(rgpost("setting_id")); $api = self::get_api(); if (!$api) { die("EndSelectForm();"); } //getting list of all MailChimp merge variables for the selected contact list self::log("Retrieving Merge_Vars for list {$list_id}", "debug"); $merge_vars = $api->listMergeVars($list_id); self::log("Merge_Vars retrieved: " . print_r($merge_vars, true), "debug"); //getting configuration $config = GFMailChimpData::get_feed($setting_id); //getting field map UI $str = self::get_field_mapping($config, $form_id, $merge_vars); //getting list of selection fields to be used by the optin $form_meta = RGFormsModel::get_form_meta($form_id); $selection_fields = GFCommon::get_selection_fields($form_meta, rgars($config, "meta/optin_field_id")); $group_condition = array(); $group_names = array(); $grouping = self::get_groupings($config, $list_id, $selection_fields, $group_condition, $group_names); //fields meta $form = RGFormsModel::get_form_meta($form_id); die("EndSelectForm('" . str_replace("'", "\\'", $str) . "', " . GFCommon::json_encode($form) . ", '" . str_replace("'", "\\'", $grouping) . "', " . json_encode($group_names) . " );"); }
public function get_subscription_line_item($response) { $lines = rgars($response, 'data/object/lines/data'); foreach ($lines as $line) { if ($line['type'] == 'subscription') { return $line; } } return false; }
public static function get_version_info($cache = true) { $raw_response = get_transient('gform_update_info'); if (!$cache) { $raw_response = null; } if (!$raw_response) { //Getting version number $options = array('method' => 'POST', 'timeout' => 20); $options['headers'] = array('Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'User-Agent' => 'WordPress/' . get_bloginfo('version'), 'Referer' => get_bloginfo('url')); $options['body'] = self::get_remote_post_params(); $options['timeout'] = 15; $nocache = $cache ? '' : 'nocache=1'; //disabling server side caching $raw_response = self::post_to_manager('version.php', $nocache, $options); //caching responses. set_transient('gform_update_info', $raw_response, 86400); //caching for 24 hours } if (is_wp_error($raw_response) || rgars($raw_response, 'response/code') != 200) { return array('is_valid_key' => '1', 'version' => '', 'url' => '', 'is_error' => '1'); } $version_info = json_decode($raw_response['body'], true); if (empty($version_info)) { return array('is_valid_key' => '1', 'version' => '', 'url' => '', 'is_error' => '1'); } return $version_info; }
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(); </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; //updating meta information if (rgpost("gf_paypal_submit")) { $config["form_id"] = absint(rgpost("gf_paypal_form")); $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_autoresponder"] = rgpost('gf_paypal_delay_autoresponder'); $config["meta"]["delay_notification"] = rgpost('gf_paypal_delay_notification'); $config["meta"]["delay_post"] = rgpost('gf_paypal_delay_post'); $config["meta"]["update_post_action"] = rgpost('gf_paypal_update_action'); // 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 = isset($config["form_id"]) && $config["form_id"] ? $form = RGFormsModel::get_form_meta($config["form_id"]) : array(); ?> <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 Donation fields. Please add a Donation 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, $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 $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 == $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"> <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"> <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 $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 $config["meta"]["update_post_action"] == "draft" ? "selected='selected'" : ""; ?> ><?php _e("Mark Post as Draft", "gravityformspaypal"); ?> </option> <option value="delete" <?php echo $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> <?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" <?php echo empty($selection_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").html(GetFieldValues(jQuery(this).val(), "", 20));'> <?php echo empty($selection_fields) ? "" : $selection_fields; ?> </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> </select> <select id="gf_paypal_conditional_value" name="gf_paypal_conditional_value" class='optin_select'></select> </div> <div id="gf_paypal_conditional_message" <?php echo !empty($selection_fields) ? "style='display:none'" : ""; ?> > <?php _e("To create a registration condition, your form must have a drop down, checkbox or multiple choice field", "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("<?php bloginfo('wpurl'); ?> /wp-admin/admin-ajax.php" ); 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.encVar( "cookie", document.cookie, false ); 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("",""); 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").html(GetFieldValues(optinConditionField, selectedValue, 20)); } 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 || !field.choices) return ""; var isAnySelected = false; 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>"; } 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(inputType == "checkbox" || inputType == "radio" || inputType == "select"){ var selected = form.fields[i].id == selectedFieldId ? "selected='selected'" : ""; str += "<option value='" + form.fields[i].id + "' " + selected + ">" + TruncateMiddle(fieldLabel, labelMaxCharacters) + "</option>"; } } return str; } </script> <?php }
public function get_column_value_amount($feed) { $form = $this->get_current_form(); $field_id = $feed['meta']['transactionType'] == 'subscription' ? rgars($feed, 'meta/recurringAmount') : rgars($feed, 'meta/paymentAmount'); if ($field_id == 'form_total') { $label = esc_html__('Form Total', 'gravityforms'); } else { $field = GFFormsModel::get_field($form, $field_id); $label = GFCommon::get_label($field); } return $label; }
public function cancel_subscription($entry, $feed, $note = null) { if (!$note) { $note = sprintf(__('Subscription has been cancelled. Subscription Id: %s.', 'gravityforms'), $entry['transaction_id']); } if (strtolower($entry['payment_status']) == 'cancelled') { $this->log('Subscription is already canceled.'); return false; } GFAPI::update_entry_property($entry['id'], 'payment_status', "Cancelled"); $this->modify_post(rgar($entry, 'post_id'), rgars($feed, 'meta/update_post_action')); $this->add_note($entry['id'], $note); // include $subscriber_id as 3rd parameter for backwards compatability do_action('gform_subscription_canceled', $entry, $feed, $entry['transaction_id']); return true; }
public static function is_update_feed($feed) { return rgars($feed, 'meta/feed_type') == 'update'; }
public static function insert_calculation_variables($fields, $element_id, $onchange = '', $callback = '', $max_label_size = 40) { if ($fields == null) { $fields = array(); } $onchange = empty($onchange) ? "InsertVariable('{$element_id}', '{$callback}');" : $onchange; $class = 'gform_merge_tags'; ?> <select id="<?php echo $element_id; ?> _variable_select" onchange="<?php echo $onchange; ?> " class="<?php echo esc_attr($class); ?> "> <option value=''><?php _e("Insert Merge Tag", "gravityforms"); ?> </option> <optgroup label="<?php _e("Allowable form fields", "gravityforms"); ?> "> <?php foreach ($fields as $field) { if (!self::is_valid_for_calcuation($field)) { continue; } if (RGFormsModel::get_input_type($field) == 'checkbox') { foreach ($field["inputs"] as $input) { ?> <option value='<?php echo "{" . esc_html(GFCommon::get_label($field, $input["id"])) . ":" . $input["id"] . "}"; ?> '><?php echo esc_html(GFCommon::get_label($field, $input["id"])); ?> </option> <?php } } else { self::insert_field_variable($field, $max_label_size); } } ?> </optgroup> <?php $custom_merge_tags = apply_filters('gform_custom_merge_tags', array(), rgars($fields, '0/formId'), $fields, $element_id); if (is_array($custom_merge_tags) && !empty($custom_merge_tags)) { ?> <optgroup label="<?php _e("Custom", "gravityforms"); ?> "> <?php foreach ($custom_merge_tags as $custom_merge_tag) { ?> <option value='<?php echo rgar($custom_merge_tag, 'tag'); ?> '><?php echo rgar($custom_merge_tag, 'label'); ?> </option> <?php } ?> </optgroup> <?php } ?> </select> <?php }
public static function admin_edit_payment_status($payment_status, $form_id, $lead) { //allow the payment status to be edited when for paypal, not set to Approved, and not a subscription $payment_gateway = gform_get_meta($lead["id"], "payment_gateway"); require_once self::get_base_path() . "/data.php"; //get the transaction type out of the feed configuration, do not allow status to be changed when subscription $paypal_feed_id = gform_get_meta($lead["id"], "paypal_feed_id"); $feed_config = GFPayPalData::get_feed($paypal_feed_id); $transaction_type = rgars($feed_config, "meta/type"); if ($payment_gateway != "paypal" || strtolower(rgpost("save")) != "edit" || $payment_status == "Approved" || $transaction_type == "subscription") { return $payment_status; } //create drop down for payment status $payment_string = gform_tooltip("paypal_edit_payment_status", "", true); $payment_string .= '<select id="payment_status" name="payment_status">'; $payment_string .= '<option value="' . $payment_status . '" selected>' . $payment_status . '</option>'; $payment_string .= '<option value="Approved">Approved</option>'; $payment_string .= '</select>'; return $payment_string; }
private static function get_notification_ui_settings($notification) { /** * These variables are used to convenient "wrap" child form settings in the appropriate HTML. */ $subsetting_open = ' <td colspan="2" class="gf_sub_settings_cell"> <div class="gf_animate_sub_settings"> <table> <tr>'; $subsetting_close = ' </tr> </table> </div> </td>'; $ui_settings = array(); $form_id = rgget('id'); $form = RGFormsModel::get_form_meta($form_id); $form = apply_filters('gform_admin_pre_render_' . $form_id, apply_filters('gform_admin_pre_render', $form)); $is_valid = empty(GFCommon::$errors); ob_start(); ?> <tr valign="top" <?php echo rgar($notification, 'isDefault') ? "style='display:none'" : ''; ?> > <th scope="row"> <label for="gform_notification_name"> <?php esc_html_e('Name', 'gravityforms'); ?> <?php gform_tooltip('notification_name'); ?> </label> </th> <td> <input type="text" class="fieldwidth-2" name="gform_notification_name" id="gform_notification_name" value="<?php echo esc_attr(rgget('name', $notification)); ?> " /> </td> </tr> <!-- / name --> <?php $ui_settings['notification_name'] = ob_get_contents(); ob_clean(); ?> <?php $notification_events = array('form_submission' => esc_html__('Form is submitted', 'gravityforms')); if (rgars($form, 'save/enabled')) { $notification_events['form_saved'] = esc_html__('Form is saved', 'gravityforms'); $notification_events['form_save_email_requested'] = esc_html__('Save and continue email is requested', 'gravityforms'); } $notification_events = apply_filters('gform_notification_events', $notification_events, $form); $event_style = count($notification_events) == 1 || rgar($notification, 'isDefault') ? "style='display:none'" : ''; ?> <tr valign="top" <?php echo $event_style; ?> > <th scope="row"> <label for="gform_notification_event"> <?php esc_html_e('Event', 'gravityforms'); ?> <?php gform_tooltip('notification_event'); ?> </label> </th> <td> <select name="gform_notification_event" id="gform_notification_event"> <?php foreach ($notification_events as $code => $label) { ?> <option value="<?php echo esc_attr($code); ?> " <?php selected(rgar($notification, 'event'), $code); ?> ><?php echo esc_html($label); ?> </option> <?php } ?> </select> </td> </tr> <!-- / event --> <?php $ui_settings['notification_event'] = ob_get_contents(); ob_clean(); ?> <?php $notification_to_type = !rgempty('gform_notification_to_type') ? rgpost('gform_notification_to_type') : rgar($notification, 'toType'); if (empty($notification_to_type)) { $notification_to_type = 'email'; } $is_invalid_email_to = !$is_valid && !self::is_valid_notification_to(); $send_to_class = $is_invalid_email_to ? 'gfield_error' : ''; ?> <tr valign="top" class='<?php echo esc_attr($send_to_class); ?> ' <?php echo $notification_to_type == 'hidden' ? 'style="display:none;"' : ''; ?> > <th scope="row"> <label for="gform_notification_to_email"> <?php esc_html_e('Send To', 'gravityforms'); ?> <span class="gfield_required">*</span> <?php gform_tooltip('notification_send_to_email'); ?> </label> </th> <td> <input type="radio" id="gform_notification_to_type_email" name="gform_notification_to_type" <?php checked('email', $notification_to_type); ?> value="email" onclick="jQuery('.notification_to_container').hide(); jQuery('#gform_notification_to_email_container').show('slow');" /> <label for="gform_notification_to_type_email" class="inline"> <?php esc_html_e('Enter Email', 'gravityforms'); ?> </label> <input type="radio" id="gform_notification_to_type_field" name="gform_notification_to_type" <?php checked('field', $notification_to_type); ?> value="field" onclick="jQuery('.notification_to_container').hide(); jQuery('#gform_notification_to_field_container').show('slow');" /> <label for="gform_notification_to_type_field" class="inline"> <?php esc_html_e('Select a Field', 'gravityforms'); ?> </label> <input type="radio" id="gform_notification_to_type_routing" name="gform_notification_to_type" <?php checked('routing', $notification_to_type); ?> value="routing" onclick="jQuery('.notification_to_container').hide(); jQuery('#gform_notification_to_routing_container').show('slow');" /> <label for="gform_notification_to_type_routing" class="inline"> <?php esc_html_e('Configure Routing', 'gravityforms'); ?> <?php gform_tooltip('notification_send_to_routing'); ?> </label> </td> </tr> <!-- / to email type --> <?php $ui_settings['notification_to_email_type'] = ob_get_contents(); ob_clean(); if ($notification_to_type == 'hidden') { $ui_settings['notification_to_email_type'] = '<input type="hidden" name="gform_notification_to_type" value="hidden" />'; } ?> <tr id="gform_notification_to_email_container" class="notification_to_container <?php echo esc_attr($send_to_class); ?> " <?php echo $notification_to_type != 'email' ? "style='display:none';" : ''; ?> > <?php echo $subsetting_open; ?> <th scope="row"><?php esc_html_e('Send to Email', 'gravityforms'); ?> </th> <td> <?php $to_email = rgget('toType', $notification) == 'email' ? rgget('to', $notification) : ''; ?> <input type="text" name="gform_notification_to_email" id="gform_notification_to_email" value="<?php echo esc_attr($to_email); ?> " class="fieldwidth-1" /> <?php if (rgpost('gform_notification_to_type') == 'email' && $is_invalid_email_to) { ?> <span class="validation_message"><?php esc_html_e('Please enter a valid email address', 'gravityforms'); ?> .</span> <?php } ?> </td> <?php echo $subsetting_close; ?> </tr> <!-- / to email --> <?php $ui_settings['notification_to_email'] = ob_get_contents(); ob_clean(); ?> <?php $email_fields = apply_filters("gform_email_fields_notification_admin_{$form['id']}", apply_filters('gform_email_fields_notification_admin', GFCommon::get_email_fields($form), $form), $form); ?> <tr id="gform_notification_to_field_container" class="notification_to_container <?php echo esc_attr($send_to_class); ?> " <?php echo $notification_to_type != 'field' ? "style='display:none';" : ''; ?> > <?php echo $subsetting_open; ?> <th scope="row"><?php esc_html_e('Send to Field', 'gravityforms'); ?> </th> <td> <?php if (!empty($email_fields)) { ?> <select name="gform_notification_to_field" id="gform_notification_to_field"> <option value=""><?php esc_html_e('Select an email field', 'gravityforms'); ?> </option> <?php $to_field = rgget('toType', $notification) == 'field' ? rgget('to', $notification) : ''; foreach ($email_fields as $field) { ?> <option value="<?php echo esc_attr($field->id); ?> " <?php echo selected($field->id, $to_field); ?> ><?php echo GFCommon::get_label($field); ?> </option> <?php } ?> </select> <?php } else { ?> <div class="error_base"> <p><?php esc_html_e('Your form does not have an email field. Add an email field to your form and try again.', 'gravityforms'); ?> </p> </div> <?php } ?> </td> <?php echo $subsetting_close; ?> </tr> <!-- / to email field --> <?php $ui_settings['notification_to_email_field'] = ob_get_contents(); ob_clean(); ?> <tr id="gform_notification_to_routing_container" class="notification_to_container <?php echo esc_attr($send_to_class); ?> " <?php echo $notification_to_type != 'routing' ? "style='display:none';" : ''; ?> > <?php echo $subsetting_open; ?> <td colspan="2"> <div id="gform_notification_to_routing_rules"> <?php $routing_fields = self::get_routing_fields($form, '0'); if (empty($routing_fields)) { ?> <div class="gold_notice"> <p><?php esc_html_e('To use notification routing, your form must have a field supported by conditional logic.', 'gravityforms'); ?> </p> </div> <?php } else { if (empty($notification['routing'])) { $notification['routing'] = array(array()); } $count = sizeof($notification['routing']); $routing_list = ','; for ($i = 0; $i < $count; $i++) { $routing_list .= $i . ','; $routing = $notification['routing'][$i]; $is_invalid_rule = !$is_valid && $_POST['gform_notification_to_type'] == 'routing' && !self::is_valid_notification_email(rgar($routing, 'email')); $class = $is_invalid_rule ? "class='grouting_rule_error'" : ''; ?> <div style='width:99%' <?php echo $class; ?> > <?php esc_html_e('Send to', 'gravityforms'); ?> <input type="text" id="routing_email_<?php echo $i; ?> " value="<?php echo esc_attr(rgar($routing, 'email')); ?> " onkeyup="SetRouting(<?php echo $i; ?> );" /> <?php esc_html_e('if', 'gravityforms'); ?> <select id="routing_field_id_<?php echo $i; ?> " class='gfield_routing_select' onchange='jQuery("#routing_value_<?php echo $i; ?> ").replaceWith(GetRoutingValues(<?php echo $i; ?> , jQuery(this).val())); SetRouting(<?php echo $i; ?> ); '><?php echo self::get_routing_fields($form, rgar($routing, 'fieldId')); ?> </select> <select id="routing_operator_<?php echo $i; ?> " onchange="SetRouting(<?php echo $i; ?> )" class="gform_routing_operator"> <option value="is" <?php echo rgar($routing, 'operator') == 'is' ? "selected='selected'" : ''; ?> ><?php esc_html_e('is', 'gravityforms'); ?> </option> <option value="isnot" <?php echo rgar($routing, 'operator') == 'isnot' ? "selected='selected'" : ''; ?> ><?php esc_html_e('is not', 'gravityforms'); ?> </option> <option value=">" <?php echo rgar($routing, 'operator') == '>' ? "selected='selected'" : ''; ?> ><?php esc_html_e('greater than', 'gravityforms'); ?> </option> <option value="<" <?php echo rgar($routing, 'operator') == '<' ? "selected='selected'" : ''; ?> ><?php esc_html_e('less than', 'gravityforms'); ?> </option> <option value="contains" <?php echo rgar($routing, 'operator') == 'contains' ? "selected='selected'" : ''; ?> ><?php esc_html_e('contains', 'gravityforms'); ?> </option> <option value="starts_with" <?php echo rgar($routing, 'operator') == 'starts_with' ? "selected='selected'" : ''; ?> ><?php esc_html_e('starts with', 'gravityforms'); ?> </option> <option value="ends_with" <?php echo rgar($routing, 'operator') == 'ends_with' ? "selected='selected'" : ''; ?> ><?php esc_html_e('ends with', 'gravityforms'); ?> </option> </select> <?php echo self::get_field_values($i, $form, rgar($routing, 'fieldId'), rgar($routing, 'value')); ?> <a class='gf_insert_field_choice' title='add another rule' onclick='SetRouting(<?php echo $i; ?> ); InsertRouting(<?php echo $i + 1; ?> );'><i class='gficon-add'></i></a> <?php if ($count > 1) { ?> <img src='<?php echo GFCommon::get_base_url(); ?> /images/remove.png' id='routing_delete_<?php echo $i; ?> ' title='remove this email routing' alt='remove this email routing' class='delete_field_choice' style='cursor:pointer;' onclick='DeleteRouting(<?php echo $i; ?> );' /> <?php } ?> </div> <?php } if ($is_invalid_rule) { ?> <span class="validation_message"><?php esc_html_e('Please enter a valid email address for all highlighted routing rules above.', 'gravityforms'); ?> </span> <?php } ?> <input type="hidden" name="routing_count" id="routing_count" value="<?php echo $routing_list; ?> " /> <?php } ?> </div> </td> <?php echo $subsetting_close; ?> </tr> <!-- / to routing --> <?php $ui_settings['notification_to_routing'] = ob_get_contents(); ob_clean(); ?> <tr valign="top"> <th scope="row"> <label for="gform_notification_from_name"> <?php esc_html_e('From Name', 'gravityforms'); ?> <?php gform_tooltip('notification_from_name'); ?> </label> </th> <td> <input type="text" class="fieldwidth-2 merge-tag-support mt-position-right mt-hide_all_fields" name="gform_notification_from_name" id="gform_notification_from_name" value="<?php echo esc_attr(rgget('fromName', $notification)); ?> " /> </td> </tr> <!-- / from name --> <?php $ui_settings['notification_from_name'] = ob_get_contents(); ob_clean(); ?> <tr valign="top"> <th scope="row"> <label for="gform_notification_from"> <?php esc_html_e('From Email', 'gravityforms'); ?> <?php gform_tooltip('notification_from_email'); ?> </label> </th> <td> <input type="text" class="fieldwidth-2 merge-tag-support mt-position-right mt-hide_all_fields" name="gform_notification_from" id="gform_notification_from" value="<?php echo rgempty('from', $notification) ? '{admin_email}' : esc_attr(rgget('from', $notification)); ?> " /> </td> </tr> <!-- / to from email --> <?php $ui_settings['notification_from'] = ob_get_contents(); ob_clean(); ?> <tr valign="top"> <th scope="row"> <label for="gform_notification_reply_to"> <?php $is_invalid_reply_to = !$is_valid && !self::is_valid_notification_email(rgar($notification, 'replyTo')); $class = $is_invalid_reply_to ? ' gfield_error' : ''; ?> <?php esc_html_e('Reply To', 'gravityforms'); ?> <?php gform_tooltip('notification_reply_to'); ?> </label> </th> <td> <input type="text" name="gform_notification_reply_to" id="gform_notification_reply_to" class="merge-tag-support mt-hide_all_fields fieldwidth-2<?php echo $class; ?> " value="<?php echo esc_attr(rgget('replyTo', $notification)); ?> " /> </td> </tr> <!-- / reply to --> <?php $ui_settings['notification_reply_to'] = ob_get_contents(); ob_clean(); ?> <tr valign="top"> <th scope="row"> <label for="gform_notification_bcc"> <?php esc_html_e('BCC', 'gravityforms'); ?> <?php gform_tooltip('notification_bcc'); ?> </label> </th> <td> <?php $is_invalid_bcc = !$is_valid && !self::is_valid_notification_email(rgar($notification, 'bcc')); $class = $is_invalid_bcc ? ' gfield_error' : ''; ?> <input type="text" name="gform_notification_bcc" id="gform_notification_bcc" value="<?php echo esc_attr(rgget('bcc', $notification)); ?> " class="merge-tag-support mt-hide_all_fields fieldwidth-2<?php echo $class; ?> " /> </td> </tr> <!-- / bcc --> <?php $ui_settings['notification_bcc'] = ob_get_contents(); ob_clean(); ?> <?php $is_invalid_subject = !$is_valid && empty($_POST['gform_notification_subject']); $subject_class = $is_invalid_subject ? "class='gfield_error'" : ''; ?> <tr valign="top" <?php echo $subject_class; ?> > <th scope="row"> <label for="gform_notification_subject"> <?php esc_html_e('Subject', 'gravityforms'); ?> <span class="gfield_required">*</span> </label> </th> <td> <input type="text" name="gform_notification_subject" id="gform_notification_subject" class="fieldwidth-1 merge-tag-support mt-hide_all_fields mt-position-right" value="<?php echo esc_attr(rgar($notification, 'subject')); ?> " /> <?php if ($is_invalid_subject) { ?> <span class="validation_message"><?php esc_html_e('Please enter a subject for the notification email', 'gravityforms'); ?> </span><?php } ?> </td> </tr> <!-- / subject --> <?php $ui_settings['notification_subject'] = ob_get_contents(); ob_clean(); ?> <?php $is_invalid_message = !$is_valid && empty($_POST['gform_notification_message']); $message_class = $is_invalid_message ? "class='gfield_error'" : ''; ?> <tr valign="top" <?php echo $message_class; ?> > <th scope="row"> <label for="gform_notification_message"> <?php esc_html_e('Message', 'gravityforms'); ?> <span class="gfield_required">*</span> </label> </th> <td> <span class="mt-gform_notification_message"></span> <?php if (GFCommon::is_wp_version('3.3')) { wp_editor(rgar($notification, 'message'), 'gform_notification_message', array('autop' => false, 'editor_class' => 'merge-tag-support mt-wp_editor mt-manual_position mt-position-right')); } else { ?> <textarea name="gform_notification_message" id="gform_notification_message" class="fieldwidth-1 fieldheight-1"><?php echo esc_html($notification['message']); ?> </textarea><?php } if ($is_invalid_message) { ?> <span class="validation_message"><?php esc_html_e('Please enter a message for the notification email', 'gravityforms'); ?> </span><?php } ?> </td> </tr> <!-- / message --> <?php $ui_settings['notification_message'] = ob_get_contents(); ob_clean(); ?> <tr valign="top"> <th scope="row"> <label for="gform_notification_disable_autoformat"> <?php esc_html_e('Auto-formatting', 'gravityforms'); ?> <?php gform_tooltip('notification_autoformat'); ?> </label> </th> <td> <input type="checkbox" name="gform_notification_disable_autoformat" id="gform_notification_disable_autoformat" value="1" <?php echo empty($notification['disableAutoformat']) ? '' : "checked='checked'"; ?> /> <label for="form_notification_disable_autoformat" class="inline"> <?php esc_html_e('Disable auto-formatting', 'gravityforms'); ?> <?php gform_tooltip('notification_autoformat'); ?> </label> </td> </tr> <!-- / disable autoformat --> <?php $ui_settings['notification_disable_autoformat'] = ob_get_contents(); ob_clean(); ?> <tr valign="top" <?php echo rgar($notification, 'isDefault') ? 'style=display:none;' : ''; ?> > <th scope="row"> <label for="gform_notification_conditional_logic"> <?php esc_html_e('Conditional Logic', 'gravityforms'); gform_tooltip('notification_conditional_logic'); ?> </label> </th> <td> <input type="checkbox" id="notification_conditional_logic" onclick="SetConditionalLogic(this.checked); ToggleConditionalLogic(false, 'notification');" <?php checked(is_array(rgar($notification, 'conditionalLogic')), true); ?> /> <label for="notification_conditional_logic" class="inline"><?php esc_html_e('Enable conditional logic', 'gravityforms'); gform_tooltip('notification_conditional_logic'); ?> </label> <br /> </td> </tr> <!-- / conditional logic --> <tr> <td colspan="2"> <div id="notification_conditional_logic_container" class="gf_animate_sub_settings" style="padding-left:10px;"> <!-- content dynamically created from form_admin.js --> </div> </td> </tr> <?php $ui_settings['notification_conditional_logic'] = ob_get_contents(); ob_clean(); ?> <?php ob_end_clean(); $ui_settings = apply_filters("gform_notification_ui_settings_{$form_id}", apply_filters('gform_notification_ui_settings', $ui_settings, $notification, $form), $notification, $form); return $ui_settings; }
public static function get_progress_bar($form, $page, $confirmation_message = '') { $form_id = $form['id']; $progress_complete = false; $progress_bar = ''; $page_count = self::get_max_page_number($form); $current_page = $page; $page_name = rgars($form['pagination'], sprintf('pages/%d', $current_page - 1)); $page_name = !empty($page_name) ? ' - ' . $page_name : ''; $style = $form['pagination']['style']; $color = $style == 'custom' ? " color:{$form['pagination']['color']};" : ''; $bgcolor = $style == 'custom' ? " background-color:{$form['pagination']['backgroundColor']};" : ''; if (!empty($confirmation_message)) { $progress_complete = true; } //check admin setting for whether the progress bar should start at zero $start_at_zero = rgars($form, 'pagination/display_progressbar_on_confirmation'); //check for filter $start_at_zero = apply_filters('gform_progressbar_start_at_zero', $start_at_zero, $form); $progressbar_page_count = $start_at_zero ? $current_page - 1 : $current_page; $percent = !$progress_complete ? floor($progressbar_page_count / $page_count * 100) . '%' : '100%'; $percent_number = !$progress_complete ? floor($progressbar_page_count / $page_count * 100) . '' : '100'; if ($progress_complete) { $wrapper_css_class = GFCommon::get_browser_class() . ' gform_wrapper'; //add on surrounding wrapper class when confirmation page $progress_bar = "<div class='{$wrapper_css_class}' id='gform_wrapper_{$form_id}' >"; $page_name = !empty($form['pagination']['progressbar_completion_text']) ? $form['pagination']['progressbar_completion_text'] : ''; } $progress_bar .= "\n <div id='gf_progressbar_wrapper_{$form_id}' class='gf_progressbar_wrapper'>\n <h3 class='gf_progressbar_title'>"; $progress_bar .= !$progress_complete ? esc_html__('Step', 'gravityforms') . " {$current_page} " . esc_html__('of', 'gravityforms') . " {$page_count}{$page_name}" : "{$page_name}"; $progress_bar .= "\n </h3>\n <div class='gf_progressbar'>\n <div class='gf_progressbar_percentage percentbar_{$style} percentbar_{$percent_number}' style='width:{$percent};{$color}{$bgcolor}'><span>{$percent}</span></div>\n </div></div>"; //close div for surrounding wrapper class when confirmation page $progress_bar .= $progress_complete ? $confirmation_message . '</div>' : ''; /** * Filter the mulit-page progress bar markup. * * @since 2.0 * * @param string $progress_bar Progress bar markup as an HTML string. * @param array $form Current form object. * @param string $confirmation_message The confirmation message to be displayed on the confirmation page. * * @see https://www.gravityhelp.com/documentation/article/gform_progress_bar/ */ $progress_bar = apply_filters('gform_progress_bar', $progress_bar, $form, $confirmation_message); $progress_bar = apply_filters("gform_progress_bar_{$form_id}", $progress_bar, $form, $confirmation_message); return $progress_bar; }
/** * Restore the Display Name and roles of a user after being updated by Gravity Forms User Registration Addon * * @see GFUser::update_user() * @param int $user_id WP User ID that was updated by Gravity Forms User Registration Addon * @param array $config Gravity Forms User Registration Addon form feed configuration * @param array $entry The Gravity Forms entry that was just updated * @param string $password User password * @return void */ public function restore_display_name($user_id = 0, $config = array(), $entry = array(), $password = '') { /** * @filter `gravityview/edit_entry/restore_display_name` Whether display names should be restored to before updating an entry. * Otherwise, display names will be reset to the format specified in Gravity Forms User Registration "Update" feed * @since 1.14.4 * @param boolean $restore_display_name Restore Display Name? Default: true */ $restore_display_name = apply_filters('gravityview/edit_entry/restore_display_name', true); $is_update_feed = $config && rgars($config, 'meta/feed_type') === 'update'; /** * Don't restore display name: * - either disabled, * - or it is an Update feed (we only care about Create feed) * - or we don't need as we found the correct format before updating user. * @since 1.14.4 */ if (!$restore_display_name || $is_update_feed || is_null($this->_user_before_update)) { return; } $user_after_update = get_userdata($user_id); $restored_user = $user_after_update; // Restore previous display_name $restored_user->display_name = $this->_user_before_update->display_name; // Don't have WP update the password. unset($restored_user->data->user_pass, $restored_user->user_pass); /** * Modify the user data after updated by Gravity Forms User Registration but before restored by GravityView * @since 1.14 * @param WP_User $restored_user The user with restored details about to be updated by wp_update_user() * @param WP_User $user_before_update The user before being updated by Gravity Forms User Registration * @param WP_User $user_after_update The user after being updated by Gravity Forms User Registration * @param array $entry The Gravity Forms entry that was just updated */ $restored_user = apply_filters('gravityview/edit_entry/user_registration/restored_user', $restored_user, $this->_user_before_update, $user_after_update, $entry); $updated = wp_update_user($restored_user); if (is_wp_error($updated)) { do_action('gravityview_log_error', __METHOD__ . sprintf(' - There was an error updating user #%d details', $user_id), $updated); } else { do_action('gravityview_log_debug', __METHOD__ . sprintf(' - User #%d details restored', $user_id)); } $this->_user_before_update = null; unset($updated, $restored_user, $user_after_update); }
private static function get_progress_bar($form, $form_id, $confirmation_message) { $progress_complete = false; $progress_bar = ''; $page_count = self::get_max_page_number($form); $current_page = self::get_current_page($form_id); $page_name = rgar(rgar($form['pagination'], 'pages'), $current_page - 1); $page_name = !empty($page_name) ? ' - ' . $page_name : ''; $style = $form['pagination']['style']; $color = $style == 'custom' ? " color:{$form['pagination']['color']};" : ''; $bgcolor = $style == 'custom' ? " background-color:{$form['pagination']['backgroundColor']};" : ''; if (!empty($confirmation_message)) { $progress_complete = true; } //check admin setting for whether the progress bar should start at zero $start_at_zero = rgars($form, 'pagination/display_progressbar_on_confirmation'); //check for filter $start_at_zero = apply_filters('gform_progressbar_start_at_zero', $start_at_zero, $form); $progressbar_page_count = $start_at_zero ? $current_page - 1 : $current_page; $percent = !$progress_complete ? floor($progressbar_page_count / $page_count * 100) . '%' : '100%'; $percent_number = !$progress_complete ? floor($progressbar_page_count / $page_count * 100) . '' : '100'; if ($progress_complete) { $wrapper_css_class = GFCommon::get_browser_class() . ' gform_wrapper'; //add on surrounding wrapper class when confirmation page $progress_bar = "<div class='{$wrapper_css_class}' id='gform_wrapper_{$form_id}' >"; $page_name = !empty($form['pagination']['progressbar_completion_text']) ? $form['pagination']['progressbar_completion_text'] : ''; } $progress_bar .= "\n <div id='gf_progressbar_wrapper_{$form_id}' class='gf_progressbar_wrapper'>\n <h3 class='gf_progressbar_title'>"; $progress_bar .= !$progress_complete ? esc_html__('Step', 'gravityforms') . " {$current_page} " . esc_html__('of', 'gravityforms') . " {$page_count}{$page_name}" : "{$page_name}"; $progress_bar .= "\n </h3>\n <div class='gf_progressbar'>\n <div class='gf_progressbar_percentage percentbar_{$style} percentbar_{$percent_number}' style='width:{$percent};{$color}{$bgcolor}'><span>{$percent}</span></div>\n </div></div>"; //close div for surrounding wrapper class when confirmation page $progress_bar .= $progress_complete ? $confirmation_message . '</div>' : ''; return $progress_bar; }
public function get_value_export($entry, $input_id = '', $use_text = false, $is_csv = false) { if (empty($input_id)) { $input_id = $this->id; } elseif (!ctype_digit($input_id)) { $field_id_array = explode('.', $input_id); $input_id = rgar($field_id_array, 0); $column_num = rgar($field_id_array, 1); } $value = rgar($entry, $input_id); if (empty($value) || $is_csv) { return $value; } $list_values = $column_values = unserialize($value); if (isset($column_num) && is_numeric($column_num) && $this->enableColumns) { $column = rgars($this->choices, "{$column_num}/text"); $column_values = array(); foreach ($list_values as $value) { $column_values[] = rgar($value, $column); } } elseif ($this->enableColumns) { return json_encode($list_values); } return GFCommon::implode_non_blank(', ', $column_values); }
private static function get_progress_bar($form, $form_id, $confirmation_message) { $progress_complete = false; $progress_bar = ""; $page_count = self::get_max_page_number($form); $current_page = self::get_current_page($form_id); $page_name = rgar(rgar($form["pagination"], "pages"), $current_page - 1); $page_name = !empty($page_name) ? " - " . $page_name : ""; $style = $form["pagination"]["style"]; $color = $style == "custom" ? " color:{$form["pagination"]["color"]};" : ""; $bgcolor = $style == "custom" ? " background-color:{$form["pagination"]["backgroundColor"]};" : ""; if (!empty($confirmation_message)) { $progress_complete = true; } //check admin setting for whether the progress bar should start at zero $start_at_zero = rgars($form, "pagination/display_progressbar_on_confirmation"); //check for filter $start_at_zero = apply_filters("gform_progressbar_start_at_zero", $start_at_zero, $form); $progressbar_page_count = $start_at_zero ? $current_page - 1 : $current_page; $percent = !$progress_complete ? floor($progressbar_page_count / $page_count * 100) . "%" : "100%"; $percent_number = !$progress_complete ? floor($progressbar_page_count / $page_count * 100) . "" : "100"; if ($progress_complete) { $wrapper_css_class = GFCommon::get_browser_class() . " gform_wrapper"; //add on surrounding wrapper class when confirmation page $progress_bar = "<div class='{$wrapper_css_class}' id='gform_wrapper_{$form_id}' >"; $page_name = !empty($form["pagination"]["progressbar_completion_text"]) ? $form["pagination"]["progressbar_completion_text"] : ""; } $progress_bar .= "\n <div id='gf_progressbar_wrapper_{$form_id}' class='gf_progressbar_wrapper'>\n <h3 class='gf_progressbar_title'>"; $progress_bar .= !$progress_complete ? __("Step", "gravityforms") . " {$current_page} " . __("of", "gravityforms") . " {$page_count}{$page_name}" : "{$page_name}"; $progress_bar .= "\n </h3>\n <div class='gf_progressbar'>\n <div class='gf_progressbar_percentage percentbar_{$style} percentbar_{$percent_number}' style='width:{$percent};{$color}{$bgcolor}'><span>{$percent}</span></div>\n </div></div>"; //close div for surrounding wrapper class when confirmation page $progress_bar .= $progress_complete ? "</div>" : ""; return $progress_bar; }
/** * Renders and initializes a checkbox field that displays a select field when checked based on the $field array. * * @access public * @param array $field - Field array containing the configuration options of this field * @param bool $echo = true - true to echo the output to the screen, false to simply return the contents as a string * * @return string The HTML for the field */ public function settings_checkbox_and_select($field, $echo = true) { // prepare checkbox $checkbox_input = rgars($field, 'checkbox'); $checkbox_field = array('type' => 'checkbox', 'name' => $field['name'] . 'Enable', 'label' => esc_html__('Enable', 'gravityforms'), 'horizontal' => true, 'value' => '1', 'choices' => false, 'tooltip' => false); $checkbox_field = wp_parse_args($checkbox_input, $checkbox_field); // prepare select $select_input = rgars($field, 'select'); $is_enabled = $this->get_setting($checkbox_field['name']); $select_field = array('name' => $field['name'] . 'Value', 'type' => 'select', 'class' => '', 'tooltip' => false); $select_field['class'] .= ' ' . $select_field['name']; $select_field = wp_parse_args($select_input, $select_field); // a little more with the checkbox if (empty($checkbox_field['choices'])) { $checkbox_field['choices'] = array(array('name' => $checkbox_field['name'], 'label' => $checkbox_field['label'], 'onchange' => sprintf("( function( \$, elem ) {\r\n\t\t\t\t\t\t\$( elem ).parents( 'td' ).css( 'position', 'relative' );\r\n\t\t\t\t\t\tif( \$( elem ).prop( 'checked' ) ) {\r\n\t\t\t\t\t\t\t\$( '%1\$s' ).fadeIn();\r\n\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\$( '%1\$s' ).fadeOut();\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} )( jQuery, this );", "#{$select_field['name']}Span"))); } // get markup $html = sprintf('%s <span id="%s" class="%s">%s %s</span>', $this->settings_checkbox($checkbox_field, false), $select_field['name'] . 'Span', $is_enabled ? '' : 'hidden', $this->settings_select($select_field, false), $this->maybe_get_tooltip($select_field)); if ($echo) { echo $html; } return $html; }
public function filter_menu_items($menu_items, $form_id, $compact) { $form_meta = GFFormsModel::get_form_meta($form_id); $results_fields = $this->get_fields($form_meta); if (false === empty($results_fields)) { $form_id = $form_meta['id']; $link_class = ''; if (rgget('page') == 'gf_new_form') { $link_class = 'gf_toolbar_disabled'; } elseif (rgget('page') == 'gf_entries' && rgget('view') == 'gf_results_' . $this->_slug) { $link_class = 'gf_toolbar_active'; } $id = rgget('id'); if (empty($id)) { //on the form list page, do not use icons $icon = ''; } else { $icon = $this->_icon; if (empty($icon)) { $icon = '<i class="fa fa-bar-chart-o fa-lg"></i>'; } } $sub_menu_items = array(); $sub_menu_items[] = array('label' => $this->_title, 'icon' => $icon, 'title' => esc_html__('View results generated by this form', 'gravityforms'), 'link_class' => $link_class, 'url' => admin_url("admin.php?page=gf_entries&view=gf_results_{$this->_slug}&id={$form_id}"), 'capabilities' => $this->_capabilities); $duplicate_submenus = wp_filter_object_list(rgars($menu_items, 'results/sub_menu_items'), array('label' => $sub_menu_items[0]['label'])); if (count($duplicate_submenus) > 0) { return $menu_items; } // If there's already a menu item with the key "results" then merge the two. if (isset($menu_items['results'])) { $existing_link_class = $menu_items['results']['link_class']; $link_class == empty($existing_link_class) ? $link_class : $existing_link_class; $existing_capabilities = $menu_items['results']['capabilities']; $merged_capabilities = array_merge($existing_capabilities, $this->_capabilities); $existing_sub_menu_items = $menu_items['results']['sub_menu_items']; $merged_sub_menu_items = array_merge($existing_sub_menu_items, $sub_menu_items); $menu_items['results']['link_class'] = $link_class; $menu_items['results']['capabilities'] = $merged_capabilities; $menu_items['results']['sub_menu_items'] = $merged_sub_menu_items; $menu_items['results']['label'] = esc_html__('Results', 'gravityforms'); $menu_items['results']['icon'] = '<i class="fa fa-bar-chart-o fa-lg"></i>'; } else { // so far during the page cycle this is the only menu item for this key $menu_items['results'] = array('label' => $compact ? esc_html__('Results', 'gravityforms') : $this->_title, 'icon' => $icon, 'title' => esc_attr__('View results generated by this form', 'gravityforms'), 'url' => '', 'onclick' => 'return false;', 'menu_class' => 'gf_form_toolbar_results', 'link_class' => $link_class, 'capabilities' => $this->_capabilities, 'sub_menu_items' => $sub_menu_items, 'priority' => 750); } } return $menu_items; }
public static function form_settings_ui() { require_once GFCommon::get_base_path() . '/form_detail.php'; require_once GFCommon::get_base_path() . '/currency.php'; $form_id = rgget('id'); $form = RGFormsModel::get_form_meta($form_id); $update_result = array(); if (rgpost('gform_meta')) { // die if not posted from correct page check_admin_referer("gform_save_form_settings_{$form_id}", 'gform_save_form_settings'); $updated_form = json_decode(rgpost('gform_meta'), true); $updated_form['fields'] = $form['fields']; // -- standard form settings -- $updated_form['title'] = rgpost('form_title_input'); $updated_form['description'] = rgpost('form_description_input'); $updated_form['labelPlacement'] = rgpost('form_label_placement'); $updated_form['descriptionPlacement'] = rgpost('form_description_placement'); $updated_form['subLabelPlacement'] = rgpost('form_sub_label_placement'); // -- advanced form settings -- $updated_form['cssClass'] = rgpost('form_css_class'); $updated_form['enableHoneypot'] = rgpost('form_enable_honeypot'); $updated_form['enableAnimation'] = rgpost('form_enable_animation'); // form button settings $updated_form['button']['type'] = rgpost('form_button'); $updated_form['button']['text'] = rgpost('form_button') == 'text' ? rgpost('form_button_text_input') : ''; $updated_form['button']['imageUrl'] = rgpost('form_button') == 'image' ? rgpost('form_button_image_url') : ''; // Save and Continue settings $updated_form['save']['enabled'] = rgpost('form_save_enabled'); $updated_form['save']['button']['type'] = 'link'; $updated_form['save']['button']['text'] = rgpost('form_save_button_text'); // limit entries settings $updated_form['limitEntries'] = rgpost('form_limit_entries'); $updated_form['limitEntriesCount'] = $updated_form['limitEntries'] ? rgpost('form_limit_entries_count') : ''; $updated_form['limitEntriesPeriod'] = $updated_form['limitEntries'] ? rgpost('form_limit_entries_period') : ''; $updated_form['limitEntriesMessage'] = $updated_form['limitEntries'] ? rgpost('form_limit_entries_message') : ''; // form scheduling settings $updated_form['scheduleForm'] = rgpost('form_schedule_form'); $updated_form['scheduleStart'] = $updated_form['scheduleForm'] ? rgpost('gform_schedule_start') : ''; $updated_form['scheduleStartHour'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_start_hour') : ''; $updated_form['scheduleStartMinute'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_start_minute') : ''; $updated_form['scheduleStartAmpm'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_start_ampm') : ''; $updated_form['scheduleEnd'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end') : ''; $updated_form['scheduleEndHour'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end_hour') : ''; $updated_form['scheduleEndMinute'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end_minute') : ''; $updated_form['scheduleEndAmpm'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_end_ampm') : ''; $updated_form['schedulePendingMessage'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_pending_message') : ''; $updated_form['scheduleMessage'] = $updated_form['scheduleForm'] ? rgpost('form_schedule_message') : ''; // require login settings $updated_form['requireLogin'] = rgpost('form_require_login'); $updated_form['requireLoginMessage'] = $updated_form['requireLogin'] ? rgpost('form_require_login_message') : ''; $updated_form = GFFormsModel::maybe_sanitize_form_settings($updated_form); if ($updated_form['save']['enabled']) { $updated_form = self::activate_save($updated_form); } else { $updated_form = self::deactivate_save($updated_form); } $updated_form = apply_filters('gform_pre_form_settings_save', $updated_form); $update_result = GFFormDetail::save_form_info($form_id, addslashes(json_encode($updated_form))); // update working form object with updated form object $form = $updated_form; } $form = gf_apply_filters('gform_admin_pre_render', $form_id, $form); self::page_header(__('Form Settings', 'gravityforms')); ?> <script type="text/javascript"> <?php GFCommon::gf_global(); ?> var form = <?php echo json_encode($form); ?> ; var fieldSettings = []; jQuery(document).ready(function ($) { HandleUnsavedChanges('#gform_form_settings'); jQuery('.datepicker').datepicker({showOn: 'both', changeMonth: true, changeYear: true, buttonImage: "<?php echo GFCommon::get_base_url(); ?> /images/calendar.png", buttonImageOnly: true}); ToggleConditionalLogic(true, 'form_button'); jQuery('tr:hidden .gf_animate_sub_settings').hide(); jQuery(document).trigger('gform_load_form_settings', [form]); }); /** * New Form Settings Functions */ function SaveFormSettings() { hasUnsavedChanges = false; // allow users to update form with custom function before save if (window['gform_before_update']) { form = window['gform_before_update'](form); if (window.console) console.log('"gform_before_update" is deprecated since version 1.7! Use "gform_pre_form_settings_save" php hook instead.'); } // set fields to empty array to avoid issues with post data being too long form.fields = []; jQuery("#gform_meta").val(jQuery.toJSON(form)); jQuery("form#gform_form_settings").submit(); } function UpdateLabelPlacement() { var placement = jQuery("#form_label_placement").val(); if (placement == 'top_label') { jQuery('#description_placement_setting').show('slow'); } else { jQuery('#description_placement_setting').hide('slow'); jQuery('#form_description_placement').val('below'); UpdateDescriptionPlacement(); } } function UpdateDescriptionPlacement() { var placement = jQuery("#form_description_placement").val(); //jQuery("#gform_fields").removeClass("description_below").removeClass("description_above").addClass("description_" + placement); jQuery(".gfield_description").each(function () { var prevElement = placement == 'above' ? '.gfield_label' : '.ginput_container:visible'; jQuery(this).siblings(prevElement).after(jQuery(this).remove()); }); } function ToggleButton() { var isText = jQuery("#form_button_text").is(":checked"); var show_element = isText ? '#form_button_text_setting' : '#form_button_image_path_setting'; var hide_element = isText ? '#form_button_image_path_setting' : '#form_button_text_setting'; jQuery(hide_element).hide(); jQuery(show_element).fadeIn(); } function ToggleEnableSave() { if (jQuery("#form_save_enabled").is(":checked")) { ShowSettingRow('#form_save_button_text_setting'); ShowSettingRow('#form_save_warning'); } else { HideSettingRow('#form_save_warning'); HideSettingRow('#form_save_button_text_setting'); } } function ToggleLimitEntry() { if (jQuery("#gform_limit_entries").is(":checked")) { ShowSettingRow('#limit_entries_count_setting'); ShowSettingRow('#limit_entries_message_setting'); } else { HideSettingRow('#limit_entries_count_setting'); HideSettingRow('#limit_entries_message_setting'); } } function ShowSettingRow(elemId) { jQuery(elemId).show().find('.gf_animate_sub_settings').slideDown(); } function HideSettingRow(elemId) { var elem = jQuery(elemId); elem.find('.gf_animate_sub_settings').slideUp(function () { elem.hide(); }); } function ToggleSchedule() { if (jQuery("#gform_schedule_form").is(":checked")) { ShowSettingRow('#schedule_start_setting'); ShowSettingRow('#schedule_end_setting'); ShowSettingRow('#schedule_pending_message_setting'); ShowSettingRow('#schedule_message_setting'); } else { HideSettingRow('#schedule_start_setting'); HideSettingRow('#schedule_end_setting'); HideSettingRow('#schedule_pending_message_setting'); HideSettingRow('#schedule_message_setting'); } } function ToggleRequireLogin() { if (jQuery("#gform_require_login").is(":checked")) { ShowSettingRow('#require_login_message_setting'); } else { HideSettingRow('#require_login_message_setting'); } } function SetButtonConditionalLogic(isChecked) { form.button.conditionalLogic = isChecked ? new ConditionalLogic() : null; } function HandleUnsavedChanges(elemId) { hasUnsavedChanges = false; jQuery(elemId).find('input, select, textarea').change(function () { hasUnsavedChanges = true; }); window.onbeforeunload = function () { if (hasUnsavedChanges){ return '<?php echo esc_js('You have unsaved changes.', 'gravityforms'); ?> '; } } } function ShowAdvancedFormSettings() { jQuery('#form_setting_advanced').slideDown(); jQuery('.show_advanced_settings_container').slideUp(); } <?php self::output_field_scripts(); ?> </script> <?php switch (rgar($update_result, 'status')) { case 'invalid_json': ?> <div class="error below-h2" id="after_update_error_dialog"> <p> <?php _e('There was an error while saving your form.', 'gravityforms'); ?> <?php printf(__('Please %scontact our support team%s.', 'gravityforms'), '<a href="http://www.gravityhelp.com">', '</a>'); ?> </p> </div> <?php break; case 'duplicate_title': ?> <div class="error below-h2" id="after_update_error_dialog"> <p> <?php _e('The form title you have entered has already been used. Please enter a unique form title.', 'gravityforms'); ?> </p> </div> <?php break; default: if (!empty($update_result)) { ?> <div class="updated below-h2" id="after_update_dialog"> <p> <strong><?php _e('Form settings updated successfully.', 'gravityforms'); ?> </strong> </p> </div> <?php } break; } /** * These variables are used to convenient "wrap" child form settings in the appropriate HTML. */ $subsetting_open = ' <td colspan="2" class="gf_sub_settings_cell"> <div class="gf_animate_sub_settings"> <table> <tr>'; $subsetting_close = ' </tr> </table> </div> </td>'; //create form settings table rows and put them into an array //form title $tr_form_title = ' <tr> <th> ' . __('Form title', 'gravityforms') . ' ' . gform_tooltip('form_title', '', true) . ' </th> <td> <input type="text" id="form_title_input" name="form_title_input" class="fieldwidth-3" value="' . esc_attr($form['title']) . '" /> </td> </tr>'; //form description $tr_form_description = ' <tr> <th> ' . __('Form description', 'gravityforms') . ' ' . gform_tooltip('form_description', '', true) . ' </th> <td> <textarea id="form_description_input" name="form_description_input" class="fieldwidth-3 fieldheight-2">' . esc_html(rgar($form, 'description')) . '</textarea> </td> </tr>'; //form label placement $alignment_options = array('top_label' => __('Top aligned', 'gravityforms'), 'left_label' => __('Left aligned', 'gravityforms'), 'right_label' => __('Right aligned', 'gravityforms')); $label_dd = ''; foreach ($alignment_options as $value => $label) { $selected = $form['labelPlacement'] == $value ? 'selected="selected"' : ''; $label_dd .= '<option value="' . $value . '" ' . $selected . '>' . $label . '</option>'; } $tr_form_label_placement = ' <tr> <th> ' . __('Label placement', 'gravityforms') . ' ' . gform_tooltip('form_label_placement', '', true) . ' </th> <td> <select id="form_label_placement" name="form_label_placement" onchange="UpdateLabelPlacement();">' . $label_dd . '</select> </td> </tr>'; //form description placement $style = $form['labelPlacement'] != 'top_label' ? 'display:none;' : ''; $description_dd = ''; $description_options = array('below' => __('Below inputs', 'gravityforms'), 'above' => __('Above inputs', 'gravityforms')); foreach ($description_options as $value => $label) { $selected = rgar($form, 'descriptionPlacement') == $value ? 'selected="selected"' : ''; $description_dd .= '<option value="' . $value . '" ' . $selected . '>' . $label . '</option>'; } $tr_form_description_placement = ' <tr id="description_placement_setting" style="' . $style . '"> <th> ' . __('Description placement', 'gravityforms') . ' ' . gform_tooltip('form_description_placement', '', true) . ' </th> <td> <select id="form_description_placement" name="form_description_placement">' . $description_dd . '</select> </td> </tr>'; //Sub Label placement $sub_label_placement_dd = ''; $sub_label_placement_options = array('below' => __('Below inputs', 'gravityforms'), 'above' => __('Above inputs', 'gravityforms')); foreach ($sub_label_placement_options as $value => $label) { $selected = rgar($form, 'subLabelPlacement') == $value ? 'selected="selected"' : ''; $sub_label_placement_dd .= '<option value="' . $value . '" ' . $selected . '>' . $label . '</option>'; } $tr_sub_label_placement = ' <tr id="sub_label_placement_setting"> <th> ' . __('Sub-Label Placement', 'gravityforms') . ' ' . gform_tooltip('form_sub_label_placement', '', true) . ' </th> <td> <select id="form_sub_label_placement" name="form_sub_label_placement">' . $sub_label_placement_dd . '</select> </td> </tr>'; //css class name $tr_css_class_name = ' <tr> <th> <label for="form_css_class" style="display:block;">' . __('CSS Class Name', 'gravityforms') . ' ' . gform_tooltip('form_css_class', '', true) . '</label> </th> <td> <input type="text" id="form_css_class" name="form_css_class" class="fieldwidth-3" value="' . esc_attr(rgar($form, 'cssClass')) . '" /> </td> </tr>'; //create form advanced settings table rows //create form button rows $form_button_type = rgars($form, 'button/type'); $text_button_checked = ''; $image_button_checked = ''; $text_style_display = ''; $image_style_display = ''; if ($form_button_type == 'text') { $text_button_checked = 'checked="checked"'; $image_style_display = 'display:none;'; } else { if ($form_button_type == 'image') { $image_button_checked = 'checked="checked"'; $text_style_display = 'display:none;'; } } //form button $tr_form_button = ' <tr> <th> ' . __('Input type', 'gravityforms') . ' </th> <td> <input type="radio" id="form_button_text" name="form_button" value="text" onclick="ToggleButton();" ' . $text_button_checked . ' /> <label for="form_button_text" class="inline">' . __('Text', 'gravityforms') . '</label> <input type="radio" id="form_button_image" name="form_button" value="image" onclick="ToggleButton();" ' . $image_button_checked . ' /> <label for="form_button_image" class="inline">' . __('Image', 'gravityforms') . '</label> </td> </tr>'; //form button text $tr_form_button_text = $subsetting_open . ' <tr id="form_button_text_setting" class="child_setting_row" style="' . $text_style_display . '"> <th> ' . __('Button text', 'gravityforms') . ' ' . gform_tooltip('form_button_text', '', true) . ' </th> <td> <input type="text" id="form_button_text_input" name="form_button_text_input" class="fieldwidth-3" value="' . esc_attr(rgars($form, 'button/text')) . '" /> </td> </tr>'; //form button image path $tr_form_button_image_path = ' <tr id="form_button_image_path_setting" class="child_setting_row" style="' . $image_style_display . '"> <th> ' . __('Button image path', 'gravityforms') . ' ' . gform_tooltip('form_button_image', '', true) . ' </th> <td> <input type="text" id="form_button_image_url" name="form_button_image_url" class="fieldwidth-3" value="' . esc_attr(rgars($form, 'button/imageUrl')) . '" /> </td> </tr>' . $subsetting_close; //form button conditional logic $button_conditional_checked = ''; if (rgars($form, 'button/conditionalLogic')) { $button_conditional_checked = 'checked="checked"'; } $tr_form_button_conditional = ' <tr> <th> ' . __('Button conditional logic', 'gravityforms') . ' ' . gform_tooltip('form_button_conditional_logic', '', true) . ' </th> <td> <input type="checkbox" id="form_button_conditional_logic" onclick="SetButtonConditionalLogic(this.checked); ToggleConditionalLogic(false, \'form_button\');"' . $button_conditional_checked . ' /> <label for="form_button_conditional_logic" class="inline">' . ' ' . __('Enable Conditional Logic', 'gravityforms') . '</label> </td> </tr> <tr> <td colspan="2"> <div id="form_button_conditional_logic_container" class="gf_animate_sub_settings" style="display:none;"> <!-- content dynamically created from js.php --> </div> </td> </tr>'; //create save and continue rows $save_enabled_checked = ''; $save_enabled_style = ''; if (rgars($form, 'save/enabled')) { $save_enabled_checked = 'checked="checked"'; } else { $save_enabled_style = 'style="display:none;"'; } $save_button_text = isset($form['save']['button']['text']) ? esc_attr(rgars($form, 'save/button/text')) : __('Save and Continue Later', 'gravityforms'); $tr_enable_save = ' <tr> <th> ' . __('Save and Continue', 'gravityforms') . ' ' . gform_tooltip('form_enable_save', '', true) . ' </th> <td> <input type="checkbox" id="form_save_enabled" name="form_save_enabled" onclick="ToggleEnableSave();" value="1" ' . $save_enabled_checked . ' /> <label for="form_save_enabled">' . __('Enable Save and Continue', 'gravityforms') . '</label> </td> </tr>'; // Warning $tr_save_warning = ' <tr id="form_save_warning" class="child_setting_row" ' . $save_enabled_style . '> ' . $subsetting_open . ' <th> </th> <td> <div class="gforms_help_alert fieldwidth-3"> <div> <i class="fa fa-warning"></i> ' . __('This feature stores potentially private and sensitive data on this server and protects it with a unique link which is displayed to the user on the page in plain, unencrypted text. The link is similar to a password so it\'s strongly advisable to ensure that the page enforces a secure connection (HTTPS) before activating this setting.', 'gravityforms') . '</div> <br /> <div> <i class="fa fa-warning"></i> ' . __('When this setting is activated two confirmations and one notification are automatically generated and can be modified in their respective editors. When this setting is deactivated the confirmations and the notification will be deleted automatically and any modifications will be lost.', 'gravityforms') . '</div> </div> </td> </tr>'; //save button text $tr_save_button_text = ' <tr id="form_save_button_text_setting" class="child_setting_row" ' . $save_enabled_style . '> <th> ' . __('Link text', 'gravityforms') . ' ' . gform_tooltip('form_save_button_text', '', true) . ' </th> <td> <input type="text" id="form_save_button_text" name="form_save_button_text" class="fieldwidth-3" value="' . $save_button_text . '" /> </td> ' . $subsetting_close . ' </tr>'; //limit entries $limit_entry_checked = ''; $limit_entry_style = ''; $limit_entries_dd = ''; if (rgar($form, 'limitEntries')) { $limit_entry_checked = 'checked="checked"'; } else { $limit_entry_style = 'display:none'; } $limit_periods = array('' => __('total entries', 'gravityforms'), 'day' => __('per day', 'gravityforms'), 'week' => __('per week', 'gravityforms'), 'month' => __('per month', 'gravityforms'), 'year' => __('per year', 'gravityforms')); foreach ($limit_periods as $value => $label) { $selected = rgar($form, 'limitEntriesPeriod') == $value ? 'selected="selected"' : ''; $limit_entries_dd .= '<option value="' . $value . '" ' . $selected . '>' . $label . '</option>'; } $tr_limit_entries = ' <tr> <th> ' . __('Limit number of entries', 'gravityforms') . ' ' . gform_tooltip('form_limit_entries', '', true) . ' </th> <td> <input type="checkbox" id="gform_limit_entries" name="form_limit_entries" onclick="ToggleLimitEntry();" value="1" ' . $limit_entry_checked . ' /> <label for="gform_limit_entries">' . __('Enable entry limit', 'gravityforms') . '</label> </td> </tr>'; //limit entries count $tr_limit_entries_count = ' <tr id="limit_entries_count_setting" class="child_setting_row" style="' . esc_attr($limit_entry_style) . '"> ' . $subsetting_open . ' <th> ' . __('Number of Entries', 'gravityforms') . ' </th> <td> <input type="text" id="gform_limit_entries_count" name="form_limit_entries_count" style="width:70px;" value="' . esc_attr(rgar($form, 'limitEntriesCount')) . '" /> <select id="gform_limit_entries_period" name="form_limit_entries_period" style="height:22px;">' . $limit_entries_dd . '</select> </td> ' . $subsetting_close . ' </tr>'; //limit entries message $tr_limit_entries_message = ' <tr id="limit_entries_message_setting" class="child_setting_row" style="' . $limit_entry_style . '"> ' . $subsetting_open . ' <th> <label for="form_limit_entries_message">' . __('Entry Limit Reached Message', 'gravityforms') . '</label> </th> <td> <textarea id="form_limit_entries_message" name="form_limit_entries_message" class="fieldwidth-3">' . esc_html(rgar($form, 'limitEntriesMessage')) . '</textarea> </td> ' . $subsetting_close . ' </tr> '; //schedule form $schedule_form_checked = ''; $schedule_form_style = ''; $start_hour_dd = ''; $start_minute_dd = ''; $start_am_selected = ''; $start_pm_selected = ''; $end_hour_dd = ''; $end_minute_dd = ''; $end_am_selected = ''; $end_pm_selected = ''; if (rgar($form, 'scheduleForm')) { $schedule_form_checked = 'checked="checked"'; } else { $schedule_form_style = 'display:none'; } //create start hour dd options for ($i = 1; $i <= 12; $i++) { $selected = rgar($form, 'scheduleStartHour') == $i ? 'selected="selected"' : ''; $start_hour_dd .= '<option value="' . $i . '" ' . $selected . '>' . $i . '</option>'; } //create start minute dd options foreach (array('00', '15', '30', '45') as $value) { $selected = rgar($form, 'scheduleStartMinute') == $value ? 'selected="selected"' : ''; $start_minute_dd .= '<option value="' . $value . '" ' . $selected . '>' . $value . '</option>'; } //set start am/pm if (rgar($form, 'scheduleStartAmpm') == 'am') { $start_am_selected = 'selected="selected"'; } elseif (rgar($form, 'scheduleStartAmpm') == 'pm') { $start_pm_selected = 'selected="selected"'; } //create end hour dd options for ($i = 1; $i <= 12; $i++) { $selected = rgar($form, 'scheduleEndHour') == $i ? 'selected="selected"' : ''; $end_hour_dd .= '<option value="' . $i . ' "' . $selected . '>' . $i . '</option>'; } //create end minute dd options foreach (array('00', '15', '30', '45') as $value) { $selected = rgar($form, 'scheduleEndMinute') == $value ? 'selected="selected"' : ''; $end_minute_dd .= '<option value="' . $value . '" ' . $selected . '>' . $value . '</option>'; } //set end am/pm if (rgar($form, 'scheduleEndAmpm') == 'am') { $end_am_selected = 'selected="selected"'; } elseif (rgar($form, 'scheduleEndAmpm') == 'pm') { $end_pm_selected = 'selected="selected"'; } //schedule form $tr_schedule_form = ' <tr> <th> ' . __('Schedule form', 'gravityforms') . ' ' . gform_tooltip('form_schedule_form', '', true) . ' </th> <td> <input type="checkbox" id="gform_schedule_form" name="form_schedule_form" value="1" onclick="ToggleSchedule();"' . $schedule_form_checked . '/> <label for="gform_schedule_form">' . __('Schedule form', 'gravityforms') . '</label> </td> </tr>'; //schedule start $tr_schedule_start = ' <tr id="schedule_start_setting" class="child_setting_row" style="' . $schedule_form_style . '"> ' . $subsetting_open . ' <th> <label for="gform_schedule_start">' . __('Schedule Start Date/Time', 'gravityforms') . '</label> </th> <td> <input type="text" id="gform_schedule_start" name="gform_schedule_start" class="datepicker" value="' . esc_attr(rgar($form, 'scheduleStart')) . '" /> <select id="gform_schedule_start_hour" name="form_schedule_start_hour">' . $start_hour_dd . '</select> : <select id="gform_schedule_start_minute" name="form_schedule_start_minute">' . $start_minute_dd . '</select> <select id="gform_schedule_start_ampm" name="form_schedule_start_ampm"> <option value="am" ' . $start_am_selected . '>AM</option> <option value="pm" ' . $start_pm_selected . '>PM</option> </select> </td> ' . $subsetting_close . ' </tr>'; //schedule end $tr_schedule_end = ' <tr id="schedule_end_setting" class="child_setting_row" style="' . esc_attr($schedule_form_style) . '"> ' . $subsetting_open . ' <th> ' . __('Schedule Form End Date/Time', 'gravityforms') . ' </th> <td> <input type="text" id="gform_schedule_end" name="form_schedule_end" class="datepicker" value="' . esc_attr(rgar($form, 'scheduleEnd')) . '" /> <select id="gform_schedule_end_hour" name="form_schedule_end_hour">' . $end_hour_dd . '</select> : <select id="gform_schedule_end_minute" name="form_schedule_end_minute">' . $end_minute_dd . '</select> <select id="gform_schedule_end_ampm" name="form_schedule_end_ampm"> <option value="am" ' . $end_am_selected . '>AM</option> <option value="pm" ' . $end_pm_selected . '>PM</option> </select> </td> ' . $subsetting_close . ' </tr>'; //schedule message $tr_schedule_pending_message = ' <tr id="schedule_pending_message_setting" class="child_setting_row" style="' . esc_attr($schedule_form_style) . '"> ' . $subsetting_open . ' <th> ' . __('Form Pending Message', 'gravityforms') . ' </th> <td> <textarea id="gform_schedule_pending_message" name="form_schedule_pending_message" class="fieldwidth-3">' . esc_html(rgar($form, 'schedulePendingMessage')) . '</textarea> </td> ' . $subsetting_close . ' </td>'; //schedule message $tr_schedule_message = ' <tr id="schedule_message_setting" class="child_setting_row" style="' . esc_attr($schedule_form_style) . '"> ' . $subsetting_open . ' <th> ' . __('Form Expired Message', 'gravityforms') . ' </th> <td> <textarea id="gform_schedule_message" name="form_schedule_message" class="fieldwidth-3">' . esc_html(rgar($form, 'scheduleMessage')) . '</textarea> </td> ' . $subsetting_close . ' </td>'; //honey pot $honey_pot_checked = ''; if (rgar($form, 'enableHoneypot')) { $honey_pot_checked = 'checked="checked"'; } $tr_honey_pot = ' <tr> <th> ' . __('Anti-spam honeypot', 'gravityforms') . ' ' . gform_tooltip('form_honeypot', '', true) . ' </th> <td> <input type="checkbox" id="gform_enable_honeypot" name="form_enable_honeypot" value="1" ' . $honey_pot_checked . '/> <label for="gform_enable_honeypot">' . __('Enable anti-spam honeypot', 'gravityforms') . '</label> </td> </tr>'; //enable animation $enable_animation_checked = ''; if (rgar($form, 'enableAnimation')) { $enable_animation_checked = 'checked="checked"'; } $tr_enable_animation = ' <tr> <th> ' . __('Animated transitions', 'gravityforms') . ' ' . gform_tooltip('form_animation', '', true) . ' </th> <td> <input type="checkbox" id="gform_enable_animation" name="form_enable_animation" value="1" ' . $enable_animation_checked . ' /> <label for="gform_enable_animation">' . __('Enable animations', 'gravityforms') . '</label> </td> </tr>'; //require login $require_login_checked = ''; $require_login_style = ''; if (rgar($form, 'requireLogin')) { $require_login_checked = 'checked="checked"'; } else { $require_login_style = 'display:none'; } $tr_requires_login = '******' . __('Require user to be logged in', 'gravityforms') . ' ' . gform_tooltip('form_require_login', '', true) . ' </th> <td> <input type="checkbox" id="gform_require_login" name="form_require_login" value="1" onclick="ToggleRequireLogin();"' . $require_login_checked . ' /> <label for="gform_require_login">' . __('Require user to be logged in', 'gravityforms') . '</label> </td> </tr>'; //require login message $tr_requires_login_message = ' <tr id="require_login_message_setting" class="child_setting_row" style="' . esc_attr($require_login_style) . '"> ' . $subsetting_open . ' <th> ' . __('Require Login Message', 'gravityforms') . ' ' . gform_tooltip('form_require_login_message', '', true) . ' </th> <td> <textarea id="gform_require_login_message" name="form_require_login_message" class="fieldwidth-3">' . esc_html(rgar($form, 'requireLoginMessage')) . '</textarea> </td> ' . $subsetting_close . ' </td>'; //populate arrays with table rows $form_basics = array('form_title' => $tr_form_title, 'form_description' => $tr_form_description); $form_layout = array('form_label_placement' => $tr_form_label_placement, 'form_description_placement' => $tr_form_description_placement, 'form_sub_label_placement' => $tr_sub_label_placement, 'css_class_name' => $tr_css_class_name); $form_button = array('form_button_type' => $tr_form_button, 'form_button_text' => $tr_form_button_text, 'form_button_image_path' => $tr_form_button_image_path, 'form_button_conditional' => $tr_form_button_conditional); $save_button = array('save_enabled' => $tr_enable_save, 'save_warning' => $tr_save_warning, 'save_button_text' => $tr_save_button_text); $form_restrictions = array('limit_entries' => $tr_limit_entries, 'number_of_entries' => $tr_limit_entries_count, 'entry_limit_message' => $tr_limit_entries_message, 'schedule_form' => $tr_schedule_form, 'schedule_start' => $tr_schedule_start, 'schedule_end' => $tr_schedule_end, 'schedule_pending_message' => $tr_schedule_pending_message, 'schedule_message' => $tr_schedule_message, 'requires_login' => $tr_requires_login, 'requires_login_message' => $tr_requires_login_message); $form_options = array('honey_pot' => $tr_honey_pot, 'enable_animation' => $tr_enable_animation); $form_settings = array(__('Form Basics', 'gravityforms') => $form_basics, __('Form Layout', 'gravityforms') => $form_layout, __('Form Button', 'gravityforms') => $form_button, __('Save and Continue', 'gravityforms') => $save_button, __('Restrictions', 'gravityforms') => $form_restrictions, __('Form Options', 'gravityforms') => $form_options); $form_settings = apply_filters('gform_form_settings', $form_settings, $form); ?> <div class="gform_panel gform_panel_form_settings" id="form_settings"> <h3><span><i class="fa fa-cogs"></i> <?php _e('Form Settings', 'gravityforms'); ?> </span></h3> <form action="" method="post" id="gform_form_settings"> <table class="gforms_form_settings" cellspacing="0" cellpadding="0"> <?php //write out array of table rows if (is_array($form_settings)) { //foreach($form_settings as $row) { foreach ($form_settings as $key => $value) { ?> <tr> <td colspan="2"> <h4 class="gf_settings_subgroup_title"><?php _e($key, 'gravityforms'); ?> </h4> </td> </tr> <?php if (is_array($value)) { foreach ($value as $tr) { echo $tr; } } } } ?> </table> <div id="gform_custom_settings"> <!--form settings--> <?php do_action('gform_properties_settings', 100, $form_id); ?> <?php do_action('gform_properties_settings', 200, $form_id); ?> <?php do_action('gform_properties_settings', 300, $form_id); ?> <?php do_action('gform_properties_settings', 400, $form_id); ?> <?php do_action('gform_properties_settings', 500, $form_id); ?> <!--advanced settings--> <?php do_action('gform_advanced_settings', 100, $form_id); ?> <?php do_action('gform_advanced_settings', 200, $form_id); ?> <?php do_action('gform_advanced_settings', 300, $form_id); ?> <?php do_action('gform_advanced_settings', 400, $form_id); ?> <?php do_action('gform_advanced_settings', 500, $form_id); ?> <?php do_action('gform_advanced_settings', 600, $form_id); ?> <?php do_action('gform_advanced_settings', 700, $form_id); ?> <?php do_action('gform_advanced_settings', 800, $form_id); ?> </div> <?php wp_nonce_field("gform_save_form_settings_{$form_id}", 'gform_save_form_settings'); ?> <input type="hidden" id="gform_meta" name="gform_meta" /> <input type="button" id="gform_save_settings" name="gform_save_settings" value="<?php _e('Update Form Settings', 'gravityforms'); ?> " class="button-primary gfbutton" onclick="SaveFormSettings();" /> </form> </div> <!-- / gform_panel_form_settings --> <?php self::page_footer(); }