function ninja_forms_replyto_change() { $plugin_settings = nf_get_settings(); if (!isset($plugin_settings['fix_field_reply_to']) or $plugin_settings['fix_field_reply_to'] != 1) { $fields = ninja_forms_get_all_fields(); foreach ($fields as $field) { if ($field['type'] = '_text') { $change_required = false; if (isset($field['data']['from_email']) and $field['data']['from_email'] == 1) { $field['data']['replyto_email'] = 1; unset($field['data']['from_email']); $change_required = true; } elseif (isset($field['data']['from_email']) and $field['data']['from_email'] == 0) { $field['data']['replyto_email'] = 0; unset($field['data']['from_email']); $change_required = true; } if ($change_required) { $data = serialize($field['data']); $args = array('update_array' => array('data' => $data), 'where' => array('id' => $field['id'])); ninja_forms_update_field($args); } } } $plugin_settings['fix_field_reply_to'] = 1; update_option('ninja_forms_settings', $plugin_settings); } }
function ninja_forms_conditionals_after_import_form($form) { global $wpdb; if (is_array($form['field']) and !empty($form['field'])) { $field_rows = ninja_forms_get_fields_by_form_id($form['id']); if (is_array($field_rows) and !empty($field_rows)) { for ($y = 0; $y < count($field_rows); $y++) { if (isset($field_rows[$y]['data']['conditional']) and is_array($field_rows[$y]['data']['conditional'])) { for ($i = 0; $i < count($field_rows[$y]['data']['conditional']); $i++) { if (isset($field_rows[$y]['data']['conditional'][$i]['cr']) and is_array($field_rows[$y]['data']['conditional'][$i]['cr'])) { for ($n = 0; $n < count($field_rows[$y]['data']['conditional'][$i]['cr']); $n++) { foreach ($form['field'] as $inserted_field) { if ($inserted_field['old_id'] == $field_rows[$y]['data']['conditional'][$i]['cr'][$n]['field']) { $field_rows[$y]['data']['conditional'][$i]['cr'][$n]['field'] = $inserted_field['id']; } } } } } } $field_rows[$y]['data'] = serialize($field_rows[$y]['data']); $args = array('update_array' => array('data' => $field_rows[$y]['data']), 'where' => array('id' => $field_rows[$y]['id'])); ninja_forms_update_field($args); } } } }
/** * Hook into our copy page multi-part form action. * Change any old ids to their new ones. * */ function nf_cl_mp_copy_page($new_fields) { foreach ($new_fields as $old_field => $new_field) { $field = ninja_forms_get_field_by_id($new_field); if (isset($field['data']['conditional'])) { for ($x = 0; $x < count($field['data']['conditional']); $x++) { if (isset($field['data']['conditional'][$x]['cr'])) { for ($y = 0; $y < count($field['data']['conditional'][$x]['cr']); $y++) { if (isset($field['data']['conditional'][$x]['cr'][$y]['field'])) { $current_id = $field['data']['conditional'][$x]['cr'][$y]['field']; if (isset($new_fields[$current_id])) { $field['data']['conditional'][$x]['cr'][$y]['field'] = $new_fields[$current_id]; } } } } } } $field['data'] = serialize($field['data']); $args = array('update_array' => array('data' => $field['data']), 'where' => array('id' => $new_field)); ninja_forms_update_field($args); } }
function nf_output_registered_field_settings($field_id, $data = array()) { global $ninja_forms_fields, $nf_rte_editors; $field_row = ninja_forms_get_field_by_id($field_id); $field_type = $field_row['type']; $field_data = empty($data) ? $field_row['data'] : $data; $current_tab = ninja_forms_get_current_tab(); if (isset($_REQUEST['page'])) { $current_page = esc_html($_REQUEST['page']); } else { $current_page = ''; } $reg_field = $ninja_forms_fields[$field_type]; $type_name = $reg_field['name']; $edit_function = $reg_field['edit_function']; $edit_options = $reg_field['edit_options']; $edit_settings = $reg_field['edit_settings']; if ($reg_field['nesting']) { $nesting_class = 'ninja-forms-nest'; } else { $nesting_class = 'ninja-forms-no-nest'; } $conditional = $reg_field['conditional']; if (isset($field_row['fav_id']) && $field_row['fav_id'] != 0) { $fav_id = $field_row['fav_id']; $fav_row = ninja_forms_get_fav_by_id($fav_id); if (empty($fav_row['name'])) { $args = array('update_array' => array('fav_id' => ''), 'where' => array('id' => $field_id)); ninja_forms_update_field($args); $fav_id = ''; } } else { $fav_id = ''; } if (isset($field_row['def_id']) && $field_row['def_id'] != 0) { $def_id = $field_row['def_id']; } else { $def_id = ''; } if ($fav_id != 0 && $fav_id != '') { $fav_row = ninja_forms_get_fav_by_id($fav_id); if (!empty($fav_row['name'])) { $fav_class = 'ninja-forms-field-remove-fav'; $type_name = $fav_row['name']; $icon_class = 'filled'; } } else { $fav_class = 'ninja-forms-field-add-fav'; $icon_class = 'empty'; } if ($reg_field['show_field_id'] || $reg_field['show_fav']) { ?> <table id="field-info"> <tr> <?php if ($reg_field['show_field_id']) { ?> <td width="65%"><?php _e('Field ID', 'ninja-forms'); ?> : <strong><?php echo $field_id; ?> </strong></td> <?php } ?> <!-- <td width="15%"><a href="#" class="ninja-forms-field-add-def" id="ninja_forms_field_<?php echo $field_id; ?> _def" class="ninja-forms-field-add-def">Add Defined</a></td><td width="15%"><a href="#" class="ninja-forms-field-remove-def" id="ninja_forms_field_<?php echo $field_id; ?> _def">Remove Defined</a></td> --> <?php if ($reg_field['show_fav']) { ?> <td width="5%"><a href="#" class="<?php echo $fav_class; ?> " id="ninja_forms_field_<?php echo $field_id; ?> _fav"><span class="dashicons dashicons-star-<?php echo $icon_class; ?> "></span></a></td> <?php } ?> </tr> </table> <?php } do_action('ninja_forms_edit_field_before_registered', $field_id, $field_data); $arguments = array('field_id' => $field_id, 'data' => $field_data); if ($edit_function != '') { call_user_func_array($edit_function, $arguments); } /** * We need to get a list of all of our RTEs. * If we're submitting via ajax, we'll need to use this list. */ if (!isset($nf_rte_editors)) { $nf_rte_editors = array(); } $editors = new NF_WP_Editor_Ajax(); if (is_array($edit_options) and !empty($edit_options)) { foreach ($edit_options as $opt) { $type = $opt['type']; $label_class = ''; if (isset($opt['label'])) { $label = $opt['label']; } else { $label = ''; } if (isset($opt['name'])) { $name = $opt['name']; } else { $name = ''; } if (isset($opt['width'])) { $width = $opt['width']; } else { $width = ''; } if (isset($opt['options'])) { $options = $opt['options']; } else { $options = ''; } if (isset($opt['class'])) { $class = $opt['class']; } else { $class = ''; } if (isset($opt['default'])) { $default = $opt['default']; } else { $default = ''; } if (isset($opt['desc'])) { $desc = $opt['desc']; } else { $desc = ''; } if (isset($field_data[$name])) { $value = $field_data[$name]; } else { $value = $default; } ninja_forms_edit_field_el_output($field_id, $type, $label, $name, $value, $width, $options, $class, $desc, $label_class); } } add_action('nf_edit_field_advanced', 'nf_test', 10, 2); $settings_sections = apply_filters('nf_edit_field_settings_sections', array('restrictions' => __('Restriction Settings', 'ninja-forms'), 'calculations' => __('Calculation Settings', 'ninja-forms'), 'advanced' => __('Advanced Settings', 'ninja-forms'))); foreach ($settings_sections as $key => $name) { ?> <div class="nf-field-settings description-wide description"> <div class="title"> <?php echo $name; ?> <span class="dashicons dashicons-arrow-down nf-field-sub-section-toggle"></span> </div> <div class="inside" style="display:none;"> <?php if (!empty($edit_settings[$key])) { foreach ($edit_settings[$key] as $opt) { $type = $opt['type']; $label_class = ''; if (isset($opt['label'])) { $label = $opt['label']; } else { $label = ''; } if (isset($opt['name'])) { $name = $opt['name']; } else { $name = ''; } if (isset($opt['width'])) { $width = $opt['width']; } else { $width = ''; } if (isset($opt['options'])) { $options = $opt['options']; } else { $options = ''; } if (isset($opt['class'])) { $class = $opt['class']; } else { $class = ''; } if (isset($opt['default'])) { $default = $opt['default']; } else { $default = ''; } if (isset($opt['desc'])) { $desc = $opt['desc']; } else { $desc = ''; } if (isset($field_data[$name])) { $value = $field_data[$name]; } else { $value = $default; } ninja_forms_edit_field_el_output($field_id, $type, $label, $name, $value, $width, $options, $class, $desc, $label_class); } } do_action('nf_edit_field_' . $key, $field_id, $field_data); ?> </div> </div> <?php } ?> <div class="menu-item-actions description-wide submitbox"> <a class="submitdelete deletion nf-remove-field" id="ninja_forms_field_<?php echo $field_id; ?> _remove" data-field="<?php echo $field_id; ?> " href="#"><?php _e('Remove', 'ninja-forms'); ?> </a> </div> <?php if (!empty($nf_rte_editors) && isset($editors) && is_object($editors)) { $editors->output_js($field_id, $nf_rte_editors); } }
public function step($step) { global $ninja_forms_fields; // Get our form ID $form_id = $this->args['forms'][$step]; // Bail if we've already converted the notifications for this form. if (in_array($form_id, $this->completed_forms)) { return false; } // Grab our form from the database $form_settings = Ninja_Forms()->form($form_id)->settings; $fields = Ninja_Forms()->form($form_id)->fields; $process_fields = array(); foreach ($fields as $field_id => $field) { $label = strip_tags(nf_get_field_admin_label($field_id)); if (strlen($label) > 30) { $tmp_label = substr($label, 0, 30); } else { $tmp_label = $label; } $tmp_array = array('value' => $field_id, 'label' => $tmp_label . ' - ID: ' . $field_id); $admin_label = $label; $label = isset($field['data']['label']) ? $field['data']['label'] : ''; // Check to see if this field is supposed to be "processed" $type = $field['type']; if (isset($ninja_forms_fields[$type]['process_field']) && $ninja_forms_fields[$type]['process_field']) { $process_fields[$field_id] = array('field_id' => $field_id, 'label' => $label, 'admin_label' => $admin_label); } } // Create a notification for our admin email if (isset($form_settings['admin_email_msg']) && !empty($form_settings['admin_email_msg']) || isset($form_settings['admin_email_fields']) && 1 == $form_settings['admin_email_fields']) { // Create a notification $n_id = nf_insert_notification($form_id); // Update our notification type nf_update_object_meta($n_id, 'type', 'email'); // Activate our notification Ninja_Forms()->notification($n_id)->activate(); // Update our notification name Ninja_Forms()->notification($n_id)->update_setting('name', __('Admin Email', 'ninja-forms')); $admin_mailto = isset($form_settings['admin_mailto']) ? $form_settings['admin_mailto'] : array(); // Implode our admin email addresses $to = implode('`', $admin_mailto); // Update our to setting Ninja_Forms()->notification($n_id)->update_setting('to', $to); // Update our Format Setting Ninja_Forms()->notification($n_id)->update_setting('email_format', $form_settings['email_type']); // Update our attach csv option Ninja_Forms()->notification($n_id)->update_setting('attach_csv', $form_settings['admin_attach_csv']); // Update our subject $subject = $this->replace_shortcodes($form_settings['admin_subject']); Ninja_Forms()->notification($n_id)->update_setting('email_subject', $subject); // Update our From Name if (isset($form_settings['email_from_name'])) { Ninja_Forms()->notification($n_id)->update_setting('from_name', $form_settings['email_from_name']); } foreach ($fields as $field) { if (isset($field['data']['from_name']) && $field['data']['from_name'] == 1) { // Update our From Name Ninja_Forms()->notification($n_id)->update_setting('from_name', 'field_' . $field['id']); break; } } // Update our From Address Ninja_Forms()->notification($n_id)->update_setting('from_address', $form_settings['email_from']); // Get our reply-to address foreach ($fields as $field) { if (isset($field['data']['replyto_email']) && $field['data']['replyto_email'] == 1) { Ninja_Forms()->notification($n_id)->update_setting('reply_to', 'field_' . $field['id']); break; } } $email_message = $form_settings['admin_email_msg']; // Check to see if the "include list of fields" checkbox was checked. if (isset($form_settings['admin_email_fields']) && $form_settings['admin_email_fields'] == 1) { $email_message .= '<br />[ninja_forms_all_fields]'; } // Update our email message Ninja_Forms()->notification($n_id)->update_setting('email_message', $email_message); Ninja_Forms()->notification($n_id)->update_setting('admin_email', true); } // Create a notification for our user email if (!empty($fields)) { $addresses = array(); foreach ($fields as $field_id => $field) { if (isset($field['data']['send_email']) && $field['data']['send_email'] == 1) { // Add this field to our $addresses variable. $addresses[] = 'field_' . $field_id; unset($field['data']['send_email']); unset($field['data']['replyto_email']); unset($field['data']['from_name']); $args = array('update_array' => array('data' => serialize($field['data'])), 'where' => array('id' => $field_id)); ninja_forms_update_field($args); } } if (!empty($addresses)) { // We have a user email, so create a notification $n_id = nf_insert_notification($form_id); // Update our notification type nf_update_object_meta($n_id, 'type', 'email'); // Activate our notification Ninja_Forms()->notification($n_id)->activate(); // Update our notification name Ninja_Forms()->notification($n_id)->update_setting('name', __('User Email', 'ninja-forms')); // Implode our admin email addresses $n_var = count($addresses) > 1 ? 'bcc' : 'to'; $addresses = implode('`', $addresses); Ninja_Forms()->notification($n_id)->update_setting($n_var, $addresses); // Update our Format Setting Ninja_Forms()->notification($n_id)->update_setting('email_format', $form_settings['email_type']); // Update our subject $subject = $this->replace_shortcodes($form_settings['user_subject']); Ninja_Forms()->notification($n_id)->update_setting('email_subject', $subject); // Update our From Name if (isset($form_settings['email_from_name'])) { Ninja_Forms()->notification($n_id)->update_setting('from_name', $form_settings['email_from_name']); } // Update our From Address Ninja_Forms()->notification($n_id)->update_setting('from_address', $form_settings['email_from']); $email_message = $form_settings['user_email_msg']; // Check to see if the "include list of fields" checkbox was checked. If so, add our table to the end of the email message. if (isset($form_settings['user_email_fields']) && $form_settings['user_email_fields'] == 1) { $email_message .= '<br />[ninja_forms_all_fields]'; } // Update our email message Ninja_Forms()->notification($n_id)->update_setting('email_message', $email_message); Ninja_Forms()->notification($n_id)->update_setting('user_email', true); } } if (isset($form_settings['success_msg']) && !empty($form_settings['success_msg'])) { // Create a notification for our success message $n_id = nf_insert_notification($form_id); nf_update_object_meta($n_id, 'name', __('Success Message', 'ninja-forms')); nf_update_object_meta($n_id, 'type', 'success_message'); nf_update_object_meta($n_id, 'active', 1); nf_update_object_meta($n_id, 'success_msg', $form_settings['success_msg']); } if (isset($form_settings['landing_page']) && !empty($form_settings['landing_page'])) { // Create a notification for our redirect $n_id = nf_insert_notification($form_id); nf_update_object_meta($n_id, 'name', __('Redirect', 'ninja-forms')); nf_update_object_meta($n_id, 'type', 'redirect'); nf_update_object_meta($n_id, 'active', 1); nf_update_object_meta($n_id, 'redirect_url', $form_settings['landing_page']); } $completed_forms = get_option('nf_convert_notifications_forms'); if (!is_array($completed_forms) || empty($completed_forms)) { $completed_forms = array($form_id); } else { $completed_forms[] = $form_id; } update_option('nf_convert_notifications_forms', $completed_forms); // Unset our admin email settings and save the form. if (isset($form_settings['admin_mailto'])) { unset($form_settings['admin_mailto']); unset($form_settings['admin_attach_csv']); unset($form_settings['admin_subject']); unset($form_settings['admin_email_msg']); unset($form_settings['admin_email_fields']); unset($form_settings['success_msg']); unset($form_settings['user_email_msg']); unset($form_settings['user_subject']); unset($form_settings['landing_page']); $args = array('update_array' => array('data' => serialize($form_settings)), 'where' => array('id' => $form_id)); ninja_forms_update_form($args); } }
/** * Removes old email settings form a single form. * * @since 2.8.4 * @return void */ function nf_remove_old_email_send_to( $form_id ) { if ( empty ( $form_id ) ) return false; // Remove any "Admin mailto" settings we might have. $form_row = ninja_forms_get_form_by_id( $form_id ); if ( isset ( $form_row['data']['admin_mailto'] ) ) { unset ( $form_row['data']['admin_mailto'] ); $args = array( 'update_array' => array( 'data' => serialize( $form_row['data'] ), ), 'where' => array( 'id' => $form_id, ), ); ninja_forms_update_form( $args ); } // Update any old email settings we have. $fields = Ninja_Forms()->form( $form_id )->fields; // Create a notification for our user email if ( ! empty ( $fields ) ) { foreach ( $fields as $field_id => $field ) { if ( isset ( $field['data']['send_email'] ) && $field['data']['send_email'] == 1 ) { // Add this field to our $addresses variable. unset( $field['data']['send_email'] ); unset( $field['data']['replyto_email'] ); unset( $field['data']['from_name'] ); $args = array( 'update_array' => array( 'data' => serialize( $field['data'] ), ), 'where' => array( 'id' => $field_id, ), ); ninja_forms_update_field( $args ); } } } }
function ninja_forms_edit_field_output_li($field_id) { global $wpdb, $ninja_forms_fields, $nf_rte_editors; $field_row = ninja_forms_get_field_by_id($field_id); $current_tab = ninja_forms_get_current_tab(); if (isset($_REQUEST['page'])) { $current_page = esc_html($_REQUEST['page']); } else { $current_page = ''; } $field_type = $field_row['type']; $field_data = $field_row['data']; $plugin_settings = nf_get_settings(); if (isset($ninja_forms_fields[$field_type]['use_li']) and $ninja_forms_fields[$field_type]['use_li']) { if (isset($field_row['fav_id']) and $field_row['fav_id'] != 0) { $fav_id = $field_row['fav_id']; $fav_row = ninja_forms_get_fav_by_id($fav_id); if (empty($fav_row['name'])) { $args = array('update_array' => array('fav_id' => ''), 'where' => array('id' => $field_id)); ninja_forms_update_field($args); $fav_id = ''; } } else { $fav_id = ''; } if (isset($field_row['def_id']) and $field_row['def_id'] != 0) { $def_id = $field_row['def_id']; } else { $def_id = ''; } $form_id = $field_row['form_id']; $field_results = ninja_forms_get_fields_by_form_id($form_id); if (isset($ninja_forms_fields[$field_type])) { $reg_field = $ninja_forms_fields[$field_type]; $type_name = $reg_field['name']; $edit_function = $reg_field['edit_function']; $edit_options = $reg_field['edit_options']; if ($reg_field['nesting']) { $nesting_class = 'ninja-forms-nest'; } else { $nesting_class = 'ninja-forms-no-nest'; } $conditional = $reg_field['conditional']; $type_class = $field_type . '-li'; if ($def_id != 0 and $def_id != '') { $def_row = ninja_forms_get_def_by_id($def_id); if (!empty($def_row['name'])) { $type_name = $def_row['name']; } } if ($fav_id != 0 and $fav_id != '') { $fav_row = ninja_forms_get_fav_by_id($fav_id); if (!empty($fav_row['name'])) { $fav_class = 'ninja-forms-field-remove-fav'; $type_name = $fav_row['name']; } } else { $fav_class = 'ninja-forms-field-add-fav'; } if (isset($field_data['label']) and $field_data['label'] != '') { $li_label = $field_data['label']; } else { $li_label = $type_name; } $li_label = apply_filters('ninja_forms_edit_field_li_label', $li_label, $field_id); $li_label = stripslashes($li_label); $li_label = ninja_forms_esc_html_deep($li_label); if (isset($reg_field) && isset($reg_field['conditional']) && isset($reg_field['conditional']['value']) && isset($reg_field['conditional']['value']['type'])) { $conditional_value_type = $reg_field['conditional']['value']['type']; } else { $conditional_value_type = ''; } ?> <li id="ninja_forms_field_<?php echo $field_id; ?> " class="<?php echo $nesting_class; ?> <?php echo $type_class; ?> "> <input type="hidden" id="ninja_forms_field_<?php echo $field_id; ?> _conditional_value_type" value="<?php echo $conditional_value_type; ?> "> <input type="hidden" id="ninja_forms_field_<?php echo $field_id; ?> _fav_id" name="" class="ninja-forms-field-fav-id" value="<?php echo $fav_id; ?> "> <dl class="menu-item-bar"> <dt class="menu-item-handle" id="ninja_forms_metabox_field_<?php echo $field_id; ?> " > <span class="item-title ninja-forms-field-title" id="ninja_forms_field_<?php echo $field_id; ?> _title"><?php echo $li_label; ?> </span> <span class="item-controls"> <span class="item-type"><?php echo $type_name; ?> </span> <a class="item-edit metabox-item-edit" id="ninja_forms_field_<?php echo $field_id; ?> _toggle" title="<?php _e('Edit Menu Item', 'ninja-forms'); ?> " href="#"><?php _e('Edit Menu Item', 'ninja-forms'); ?> </a> </span> </dt> </dl> <?php $slug = 'field_' . $field_id; if (isset($plugin_settings['metabox_state'][$current_page][$current_tab][$slug])) { $state = $plugin_settings['metabox_state'][$current_page][$current_tab][$slug]; } else { $state = 'display:none;'; } ?> <div class="menu-item-settings type-class inside" id="ninja_forms_field_<?php echo $field_id; ?> _inside" style="<?php echo $state; ?> "> <table id="field-info"><tr><td width="65%"><?php _e('Field ID', 'ninja-forms'); ?> : <strong><?php echo $field_id; ?> </strong></td><!-- <td width="15%"><a href="#" class="ninja-forms-field-add-def" id="ninja_forms_field_<?php echo $field_id; ?> _def" class="ninja-forms-field-add-def">Add Defined</a></td><td width="15%"><a href="#" class="ninja-forms-field-remove-def" id="ninja_forms_field_<?php echo $field_id; ?> _def">Remove Defined</a></td> --> <td width="5%"><a href="#" class="<?php echo $fav_class; ?> " id="ninja_forms_field_<?php echo $field_id; ?> _fav">Star</a></td></tr></table> <?php do_action('ninja_forms_edit_field_before_registered', $field_id); $arguments = func_get_args(); array_shift($arguments); // We need to remove the first arg ($function_name) $arguments['field_id'] = $field_id; $arguments['data'] = $field_data; if ($edit_function != '') { call_user_func_array($edit_function, $arguments); } /** * We need to get a list of all of our RTEs. * If we're submitting via ajax, we'll need to use this list. */ if (!isset($nf_rte_editors)) { $nf_rte_editors = array(); } $editors = new NF_WP_Editor_Ajax(); if (is_array($edit_options) and !empty($edit_options)) { foreach ($edit_options as $opt) { $type = $opt['type']; $label_class = ''; if (isset($opt['label'])) { $label = $opt['label']; } else { $label = ''; } if (isset($opt['name'])) { $name = $opt['name']; } else { $name = ''; } if (isset($opt['width'])) { $width = $opt['width']; } else { $width = ''; } if (isset($opt['options'])) { $options = $opt['options']; } else { $options = ''; } if (isset($opt['class'])) { $class = $opt['class']; } else { $class = ''; } if (isset($opt['default'])) { $default = $opt['default']; } else { $default = ''; } if (isset($opt['desc'])) { $desc = $opt['desc']; } else { $desc = ''; } if (isset($field_data[$name])) { $value = $field_data[$name]; } else { $value = $default; } ninja_forms_edit_field_el_output($field_id, $type, $label, $name, $value, $width, $options, $class, $desc, $label_class); } } do_action('ninja_forms_edit_field_after_registered', $field_id); } } else { if (isset($ninja_forms_fields[$field_type])) { $reg_field = $ninja_forms_fields[$field_type]; $edit_function = $reg_field['edit_function']; $arguments = func_get_args(); array_shift($arguments); // We need to remove the first arg ($function_name) $arguments['field_id'] = $field_id; $arguments['data'] = $field_data; if ($edit_function != '') { call_user_func_array($edit_function, $arguments); } } } /** * We need to get a list of all of our RTEs. * If we're submitting via ajax, we'll need to use this list. */ if (isset($_POST['action']) && $_POST['action'] == 'ninja_forms_new_field') { if (!empty($nf_rte_editors) && isset($editors) && is_object($editors)) { $editors->output_js($field_id, $nf_rte_editors); } } }
function ninja_forms_calc_after_import_form($form) { global $wpdb; if (is_array($form['field']) and !empty($form['field'])) { $field_rows = ninja_forms_get_fields_by_form_id($form['id']); if (is_array($field_rows) and !empty($field_rows)) { for ($y = 0; $y < count($field_rows); $y++) { if (isset($field_rows[$y]['data']['calc']) and is_array($field_rows[$y]['data']['calc'])) { for ($i = 0; $i < count($field_rows[$y]['data']['calc']); $i++) { foreach ($form['field'] as $inserted_field) { if (isset($field_rows[$y]['data']['calc'][$i]['field']) and $inserted_field['old_id'] == $field_rows[$y]['data']['calc'][$i]['field']) { $field_rows[$y]['data']['calc'][$i]['field'] = $inserted_field['id']; } } } } if (isset($field_rows[$y]['data']['calc_eq']) and $field_rows[$y]['data']['calc_eq'] != '') { $calc_eq = $field_rows[$y]['data']['calc_eq']; foreach ($form['field'] as $inserted_field) { $calc_eq = str_replace('field_' . $inserted_field['old_id'], 'field_' . $inserted_field['id'], $calc_eq); } $field_rows[$y]['data']['calc_eq'] = $calc_eq; } $field_rows[$y]['data'] = serialize($field_rows[$y]['data']); $args = array('update_array' => array('data' => $field_rows[$y]['data']), 'where' => array('id' => $field_rows[$y]['id'])); ninja_forms_update_field($args); } if (isset($form['data']['success_msg']) and $form['data']['success_msg'] != '') { $success_msg = $form['data']['success_msg']; foreach ($form['field'] as $inserted_field) { $success_msg = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $success_msg); } $form['data']['success_msg'] = $success_msg; } if (isset($form['data']['user_subject']) and $form['data']['user_subject'] != '') { $user_subject = $form['data']['user_subject']; foreach ($form['field'] as $inserted_field) { $user_subject = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $user_subject); } $form['data']['user_subject'] = $user_subject; } if (isset($form['data']['user_email_msg']) and $form['data']['user_email_msg'] != '') { $user_email_msg = $form['data']['user_email_msg']; foreach ($form['field'] as $inserted_field) { $user_email_msg = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $user_email_msg); } $form['data']['user_email_msg'] = $user_email_msg; } if (isset($form['data']['admin_subject']) and $form['data']['admin_subject'] != '') { $admin_subject = $form['data']['admin_subject']; foreach ($form['field'] as $inserted_field) { $admin_subject = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $admin_subject); } $form['data']['admin_subject'] = $admin_subject; } if (isset($form['data']['admin_email_msg']) and $form['data']['admin_email_msg'] != '') { $admin_email_msg = $form['data']['admin_email_msg']; foreach ($form['field'] as $inserted_field) { $admin_email_msg = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $admin_email_msg); } $form['data']['admin_email_msg'] = $admin_email_msg; } if (isset($form['data']['mp_confirm_msg']) and $form['data']['mp_confirm_msg'] != '') { $mp_confirm_msg = $form['data']['mp_confirm_msg']; foreach ($form['field'] as $inserted_field) { $mp_confirm_msg = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $mp_confirm_msg); } $form['data']['mp_confirm_msg'] = $mp_confirm_msg; } if (isset($form['data']['save_msg']) and $form['data']['save_msg'] != '') { $save_msg = $form['data']['save_msg']; foreach ($form['field'] as $inserted_field) { $save_msg = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $save_msg); } $form['data']['save_msg'] = $save_msg; } if (isset($form['data']['save_email_msg']) and $form['data']['save_email_msg'] != '') { $save_email_msg = $form['data']['save_email_msg']; foreach ($form['field'] as $inserted_field) { $save_email_msg = str_replace('[ninja_forms_field id=' . $inserted_field['old_id'] . ']', '[ninja_forms_field id=' . $inserted_field['id'] . ']', $save_email_msg); } $form['data']['save_email_msg'] = $save_email_msg; } $args = array('update_array' => array('data' => serialize($form['data'])), 'where' => array('id' => $form['id'])); ninja_forms_update_form($args); } } }