/** * Removes all settings and deactivates the Add-On. * * Not intended to be overridden or called directly by Add-Ons. * * @ignore */ public function uninstall_addon() { if (!$this->current_user_can_any($this->_capabilities_uninstall)) { die(__("You don't have adequate permission to uninstall this addon: " . $this->_title, "gravityforms")); } $continue = $this->uninstall(); if (false === $continue) { return false; } global $wpdb; $lead_meta_table = GFFormsModel::get_lead_meta_table_name(); $forms = GFFormsModel::get_forms(); $all_form_ids = array(); // remove entry meta foreach ($forms as $form) { $all_form_ids[] = $form->id; $entry_meta = $this->get_entry_meta(array(), $form->id); if (is_array($entry_meta)) { foreach (array_keys($entry_meta) as $meta_key) { $sql = $wpdb->prepare("DELETE from {$lead_meta_table} WHERE meta_key=%s", $meta_key); $wpdb->query($sql); } } } //remove form settings $form_metas = GFFormsModel::get_form_meta_by_id($all_form_ids); require_once GFCommon::get_base_path() . '/form_detail.php'; foreach ($form_metas as $form_meta) { if (isset($form_meta[$this->_slug])) { unset($form_meta[$this->_slug]); $form_json = json_encode($form_meta); GFFormDetail::save_form_info($form_meta["id"], addslashes($form_json)); } } //removing options delete_option("gravityformsaddon_" . $this->_slug . "_settings"); delete_option("gravityformsaddon_" . $this->_slug . "_version"); //Deactivating plugin deactivate_plugins($this->_path); update_option('recently_activated', array($this->_path => time()) + (array) get_option('recently_activated')); return true; }
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(); }
public static function save_new_form() { if (!check_admin_referer('gf_save_new_form', 'gf_save_new_form')) { die(json_encode(array('error' => __('There was an issue creating your form.', 'gravityforms')))); } GFFormsModel::ensure_tables_exist(); require_once GFCommon::get_base_path() . '/form_detail.php'; $form_json = rgpost('form'); $form = json_decode($form_json, true); if (empty($form['title'])) { $result = array('error' => __('Please enter a form title.', 'gravityforms')); die(json_encode($result)); } /* * This is now added in JavaScript using jQuery.toJSON(). See the DocBlock GFFormDetail::save_form_info() for details. * $form['labelPlacement'] = 'top_label'; $form['descriptionPlacement'] = 'below'; $form['button'] = array( 'type' => 'text', 'text' => __("Submit", "gravityforms"), 'imageUrl' => '' ); $form['fields'] = array(); */ $result = GFFormDetail::save_form_info(0, $form_json); switch (rgar($result, 'status')) { case 'invalid_json': $result['error'] = __('There was an issue creating your form.', 'gravityforms'); die(json_encode($result)); case 'duplicate_title': $result['error'] = __('Please enter a unique form title.', 'gravityforms'); die(json_encode($result)); default: $form_id = abs($result['status']); die(json_encode(array('redirect' => admin_url("admin.php?page=gf_edit_forms&id={$form_id}")))); } }
public static function save_new_form() { if (!check_admin_referer('gf_save_new_form', 'gf_save_new_form')) { die(json_encode(array('error' => __('There was an issue creating your form.', 'gravityforms')))); } GFFormsModel::ensure_tables_exist(); require_once GFCommon::get_base_path() . '/form_detail.php'; $form_json = rgpost('form'); $form = json_decode($form_json, true); if (empty($form['title'])) { $result = array('error' => __('Please enter a form title.', 'gravityforms')); die(json_encode($result)); } $result = GFFormDetail::save_form_info(0, $form_json); switch (rgar($result, 'status')) { case 'invalid_json': $result['error'] = __('There was an issue creating your form.', 'gravityforms'); die(json_encode($result)); case 'duplicate_title': $result['error'] = __('Please enter a unique form title.', 'gravityforms'); die(json_encode($result)); default: $form_id = absint($result['status']); die(json_encode(array('redirect' => admin_url("admin.php?page=gf_edit_forms&id={$form_id}")))); } }