public static function import_options() { check_ajax_referer('frm_ajax', 'nonce'); if (!is_admin() || !current_user_can('frm_edit_forms')) { return; } $field_id = absint($_POST['field_id']); $field = FrmField::getOne($field_id); if (!in_array($field->type, array('radio', 'checkbox', 'select'))) { return; } $field = FrmFieldsHelper::setup_edit_vars($field); $opts = stripslashes_deep($_POST['opts']); $opts = explode("\n", rtrim($opts, "\n")); if ($field['separate_value']) { foreach ($opts as $opt_key => $opt) { if (strpos($opt, '|') !== false) { $vals = explode('|', $opt); if ($vals[0] != $vals[1]) { $opts[$opt_key] = array('label' => trim($vals[0]), 'value' => trim($vals[1])); } unset($vals); } unset($opt_key, $opt); } } //Keep other options after bulk update if (isset($field['field_options']['other']) && $field['field_options']['other'] == true) { $other_array = array(); foreach ($field['options'] as $opt_key => $opt) { if ($opt_key && strpos($opt_key, 'other') !== false) { $other_array[$opt_key] = $opt; } unset($opt_key, $opt); } if (!empty($other_array)) { $opts = array_merge($opts, $other_array); } } FrmField::update($field_id, array('options' => maybe_serialize($opts))); $field['options'] = $opts; $field_name = $field['name']; // Get html_id which will be used in single-option.php $html_id = FrmFieldsHelper::get_html_id($field); if ($field['type'] == 'radio' || $field['type'] == 'checkbox') { require FrmAppHelper::plugin_path() . '/classes/views/frm-fields/radio.php'; } else { FrmFieldsHelper::show_single_option($field); } wp_die(); }
public static function show($field, $name = '') { $field_name = empty($name) ? 'item_meta' : $name; if (is_object($field)) { $field = FrmFieldsHelper::setup_edit_vars($field); if (in_array($field['type'], array('text', 'textarea', 'radio', 'checkbox', 'select', 'captcha'))) { $frm_settings = FrmAppHelper::get_settings(); $field_name .= '[' . $field['id'] . ']'; $html_id = FrmFieldsHelper::get_html_id($field); $display = array('type' => $field['type'], 'default_blank' => true); include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/show-build.php'; return; } } $field_name .= '[' . $field['id'] . ']'; $html_id = FrmFieldsHelper::get_html_id($field); require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/show.php'; }
public static function replace_html_shortcodes($html, $field, $atts) { if ('divider' == $field['type']) { global $frm_vars; $html = str_replace(array('frm_none_container', 'frm_hidden_container', 'frm_top_container', 'frm_left_container', 'frm_right_container'), '', $html); if (isset($frm_vars['collapse_div']) && $frm_vars['collapse_div']) { $html = "</div>\n" . $html; $frm_vars['collapse_div'] = false; } if (isset($frm_vars['div']) && $frm_vars['div'] && $frm_vars['div'] != $field['id']) { // close the div if it's from a different section $html = "</div>\n" . $html; $frm_vars['div'] = false; } if (FrmField::is_option_true($field, 'slide')) { $trigger = ' frm_trigger'; $collapse_div = '<div class="frm_toggle_container" style="display:none;">'; } else { $trigger = $collapse_div = ''; } if (FrmField::is_option_true($field, 'repeat')) { $errors = isset($atts['errors']) ? $atts['errors'] : array(); $field_name = 'item_meta[' . $field['id'] . ']'; $html_id = FrmFieldsHelper::get_html_id($field); $frm_settings = FrmAppHelper::get_settings(); ob_start(); include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php'; $input = ob_get_contents(); ob_end_clean(); if (FrmField::is_option_true($field, 'slide')) { $input = $collapse_div . $input . '</div>'; } $html = str_replace('[collapse_this]', $input, $html); } else { self::remove_close_div($field, $html); if (strpos($html, '[collapse_this]') !== false) { $html = str_replace('[collapse_this]', $collapse_div, $html); // indicate that a second div is open if (!empty($collapse_div)) { $frm_vars['collapse_div'] = $field['id']; } } } self::maybe_add_collapse_icon($trigger, $field, $html); $html = str_replace('[collapse_class]', $trigger, $html); } else { if ($field['type'] == 'html') { if (apply_filters('frm_use_wpautop', true)) { $html = wpautop($html); } $html = apply_filters('frm_get_default_value', $html, (object) $field, false); $html = do_shortcode($html); } else { if (FrmField::is_option_true($field, 'conf_field')) { //Add confirmation field //Get confirmation field ready for replace_shortcodes function $conf_html = $field['custom_html']; $conf_field = $field; $conf_field['id'] = 'conf_' . $field['id']; $conf_field['name'] = __('Confirm', 'formidable') . ' ' . $field['name']; $conf_field['description'] = $field['conf_desc']; $conf_field['field_key'] = 'conf_' . $field['field_key']; if ($conf_field['classes']) { $conf_field['classes'] = str_replace('first_', '', $conf_field['classes']); } else { if ($conf_field['conf_field'] == 'inline') { $conf_field['classes'] = ' frm_half'; } } //Prevent loop $conf_field['conf_field'] = 'stop'; //If inside of repeating section $args = array(); if (isset($atts['section_id'])) { $args['field_name'] = preg_replace('/\\[' . $field['id'] . '\\]$/', '', $atts['field_name']); $args['field_name'] = $args['field_name'] . '[conf_' . $field['id'] . ']'; $args['field_id'] = 'conf_' . $atts['field_id']; $args['field_plus_id'] = $atts['field_plus_id']; $args['section_id'] = $atts['section_id']; } // Filter default value/placeholder text $field['conf_input'] = apply_filters('frm_get_default_value', $field['conf_input'], (object) $field, false); //If clear on focus, set default value. Otherwise, set value. if ($conf_field['clear_on_focus'] == 1) { $conf_field['default_value'] = $field['conf_input']; $conf_field['value'] = ''; } else { $conf_field['value'] = $field['conf_input']; } //If going back and forth between pages, keep value in confirmation field if (isset($_POST['item_meta'])) { $temp_args = array(); if (isset($atts['section_id'])) { $temp_args = array('parent_field_id' => $atts['section_id'], 'key_pointer' => str_replace('-', '', $atts['field_plus_id'])); } FrmEntriesHelper::get_posted_value($conf_field['id'], $conf_field['value'], $temp_args); } //Replace shortcodes $conf_html = FrmFieldsHelper::replace_shortcodes($conf_html, $conf_field, '', '', $args); //Add a couple of classes $conf_html = str_replace('frm_primary_label', 'frm_primary_label frm_conf_label', $conf_html); $conf_html = str_replace('frm_form_field', 'frm_form_field frm_conf_field', $conf_html); //Remove label if stacked. Hide if inline. if ($field['conf_field'] == 'inline') { $conf_html = str_replace('frm_form_field', 'frm_form_field frm_hidden_container', $conf_html); } else { $conf_html = str_replace('frm_form_field', 'frm_form_field frm_none_container', $conf_html); } $html .= $conf_html; } } } if (strpos($html, '[collapse_this]')) { $html = str_replace('[collapse_this]', '', $html); } return $html; }
<div class="alignleft sketch3"> <div class="alignright"><?php _e('3. Save your form', 'formidable'); ?> </div> <img src="<?php echo esc_url(FrmAppHelper::plugin_url() . '/images/sketch_arrow3.png'); ?> " alt="" /> </div> <div class="clear"></div> </div> <ul id="new_fields" class="frm_sorting inside"> <?php if (isset($values['fields']) && !empty($values['fields'])) { $count = 0; foreach ($values['fields'] as $field) { $count++; $field_name = 'item_meta[' . $field['id'] . ']'; $html_id = FrmFieldsHelper::get_html_id($field); require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php'; unset($field, $field_name); } unset($count); } ?> </ul> </div> </div>