function ninja_forms_filter_restore_progress($data, $field_id)
{
    global $ninja_forms_processing, $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    if (isset($ninja_forms_fields[$field_type]['esc_html'])) {
        $esc_html = $ninja_forms_fields[$field_type]['esc_html'];
    } else {
        $esc_html = true;
    }
    if (is_object($ninja_forms_processing)) {
        $clear_form = $ninja_forms_processing->get_form_setting('clear_complete');
        $process_complete = $ninja_forms_processing->get_form_setting('processing_complete');
        if ($process_complete != 1 or $process_complete == 1 and $clear_form != 1) {
            if ($ninja_forms_processing->get_field_value($field_id) !== false) {
                if ($esc_html) {
                    if (is_array($ninja_forms_processing->get_field_value($field_id))) {
                        $default_value = ninja_forms_esc_html_deep($ninja_forms_processing->get_field_value($field_id));
                    } else {
                        $default_value = esc_html($ninja_forms_processing->get_field_value($field_id));
                    }
                } else {
                    $default_value = $ninja_forms_processing->get_field_value($field_id);
                }
                $data['default_value'] = $default_value;
            }
        }
    }
    return $data;
}
Exemple #2
0
function nf_save_sub()
{
    global $ninja_forms_processing, $ninja_forms_fields;
    // save forms by default
    $save = true;
    // check if there's some legacy save settings saved in the database
    if (0 === $ninja_forms_processing->get_form_setting('save_subs')) {
        $save = false;
    }
    $save = apply_filters('ninja_forms_save_submission', $save, $ninja_forms_processing->get_form_ID());
    if ($save) {
        $action = $ninja_forms_processing->get_action();
        $user_id = $ninja_forms_processing->get_user_ID();
        $sub_id = $ninja_forms_processing->get_form_setting('sub_id');
        $form_id = $ninja_forms_processing->get_form_ID();
        $field_data = $ninja_forms_processing->get_all_fields();
        // If we don't have a submission ID already, create a submission post.
        if (empty($sub_id)) {
            $sub_id = Ninja_Forms()->subs()->create($form_id);
            Ninja_Forms()->sub($sub_id)->update_user_id($user_id);
            do_action('nf_create_sub', $sub_id);
            // Update our legacy $ninja_forms_processing with the new sub_id
            $ninja_forms_processing->update_form_setting('sub_id', $sub_id);
        }
        do_action('nf_before_save_sub', $sub_id);
        Ninja_Forms()->sub($sub_id)->update_action($action);
        if (is_array($field_data) && !empty($field_data)) {
            // Loop through our submitted data and add the values found there.
            // Maintain backwards compatibility with older extensions that use the ninja_forms_save_sub_args filter.
            $data = array();
            //
            foreach ($field_data as $field_id => $user_value) {
                $field_row = $ninja_forms_processing->get_field_settings($field_id);
                $field_type = $field_row['type'];
                if (isset($ninja_forms_fields[$field_type]['save_sub'])) {
                    $save_sub = $ninja_forms_fields[$field_type]['save_sub'];
                    if ($save_sub) {
                        $user_value = apply_filters('nf_save_sub_user_value', $user_value, $field_id);
                        if (is_array($user_value)) {
                            $user_value = ninja_forms_esc_html_deep($user_value);
                        } else {
                            $user_value = esc_html($user_value);
                        }
                        // Add our submitted field value.
                        Ninja_Forms()->sub($sub_id)->add_field($field_id, $user_value);
                        // Maintain backwards compatibility with older extensions that use the ninja_forms_save_sub_args filter.
                        $data[] = array('field_id' => $field_id, 'user_value' => $user_value);
                        //
                    }
                }
            }
        }
        // Maintain backwards compatibility with older extensions that still use the ninja_forms_save_sub_args filter.
        $args = apply_filters('ninja_forms_save_sub_args', array('sub_id' => $sub_id, 'form_id' => $form_id, 'data' => serialize($data)));
        ninja_forms_update_sub($args);
        //
        do_action('nf_save_sub', $sub_id);
    }
}
function ninja_forms_save_impexp_fields($data)
{
    global $wpdb, $ninja_forms_admin_update_message;
    $plugin_settings = nf_get_settings();
    $update_message = '';
    if ($_POST['submit'] == __('Export Fields', 'ninja-forms')) {
        if (isset($_POST['ninja_forms_fav']) and !empty($_POST['ninja_forms_fav'])) {
            $fav_ids = ninja_forms_esc_html_deep($_POST['ninja_forms_fav']);
            if (isset($plugin_settings['date_format'])) {
                $date_format = $plugin_settings['date_format'];
            } else {
                $date_format = 'm/d/Y';
            }
            //$today = date($date_format);
            $current_time = current_time('timestamp');
            $today = date($date_format, $current_time);
            $favorites = array();
            if (is_array($fav_ids) and !empty($fav_ids)) {
                $x = 0;
                foreach ($fav_ids as $fav_id) {
                    $fav_row = ninja_forms_get_fav_by_id($fav_id);
                    $fav_row['id'] = NULL;
                    $favorites[$x] = $fav_row;
                    $x++;
                }
            }
            $favorites = serialize($favorites);
            header("Content-type: application/csv");
            header("Content-Disposition: attachment; filename=favorites-" . $today . ".nff");
            header("Pragma: no-cache");
            header("Expires: 0");
            echo $favorites;
            die;
        } else {
            $update_message = __('Please select favorite fields to export.', 'ninja-forms');
        }
    } elseif ($_POST['submit'] == __('Import Favorites', 'ninja-forms')) {
        if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK and is_uploaded_file($_FILES['userfile']['tmp_name'])) {
            $file = file_get_contents($_FILES['userfile']['tmp_name']);
            $favorites = unserialize($file);
            if (is_array($favorites)) {
                foreach ($favorites as $fav) {
                    $fav['data'] = serialize($fav['data']);
                    $wpdb->insert(NINJA_FORMS_FAV_FIELDS_TABLE_NAME, $fav);
                }
            }
            $update_message = __('Favorites imported successfully.', 'ninja-forms');
        } else {
            $update_message = __('Please select a valid favorite fields file.', 'ninja-forms');
        }
    }
    return $update_message;
}
function ninja_forms_save_sub()
{
    global $ninja_forms_processing, $ninja_forms_fields;
    // save forms by default
    $save = true;
    // check if there's some legacy save settings saved in the database
    if (0 === $ninja_forms_processing->get_form_setting('save_subs')) {
        $save = false;
    }
    $save = apply_filters('ninja_forms_save_submission', $save, $ninja_forms_processing->get_form_ID());
    if ($save) {
        $action = $ninja_forms_processing->get_action();
        $user_id = $ninja_forms_processing->get_user_ID();
        $sub_id = $ninja_forms_processing->get_form_setting('sub_id');
        $form_id = $ninja_forms_processing->get_form_ID();
        $field_data = $ninja_forms_processing->get_all_fields();
        $sub_data = array();
        if (is_array($field_data) and !empty($field_data)) {
            foreach ($field_data as $field_id => $user_value) {
                $field_row = $ninja_forms_processing->get_field_settings($field_id);
                $field_type = $field_row['type'];
                if (isset($ninja_forms_fields[$field_type]['save_sub'])) {
                    $save_sub = $ninja_forms_fields[$field_type]['save_sub'];
                    if ($save_sub) {
                        ninja_forms_remove_from_array($sub_data, "field_id", $field_id, TRUE);
                        $user_value = apply_filters('ninja_forms_save_sub', $user_value, $field_id);
                        if (is_array($user_value)) {
                            $user_value = ninja_forms_esc_html_deep($user_value);
                        } else {
                            $user_value = esc_html($user_value);
                        }
                        array_push($sub_data, array('field_id' => $field_id, 'user_value' => $user_value));
                    }
                }
            }
        }
        $args = array('form_id' => $form_id, 'user_id' => $user_id, 'action' => $action, 'data' => serialize($sub_data), 'status' => 1);
        $args = apply_filters('ninja_forms_save_sub_args', $args);
        if ($sub_id != '') {
            $args['sub_id'] = $sub_id;
            ninja_forms_update_sub($args);
            do_action('ninja_forms_update_sub', $sub_id);
        } else {
            $sub_id = ninja_forms_insert_sub($args);
            $ninja_forms_processing->update_form_setting('sub_id', $sub_id);
            do_action('ninja_forms_insert_sub', $sub_id);
        }
    }
}
Exemple #5
0
    /**
     * Add our custom column data
     * 
     * @access public
     * @since 2.7
     * @return void
     */
    public function custom_columns($column, $sub_id)
    {
        if (isset($_GET['form_id'])) {
            $form_id = $_GET['form_id'];
            if ($column == 'id') {
                echo apply_filters('nf_sub_table_seq_num', Ninja_Forms()->sub($sub_id)->get_seq_num(), $sub_id, $column);
                echo '<div class="locked-info"><span class="locked-avatar"></span> <span class="locked-text"></span></div>';
                if (!isset($_GET['post_status']) || $_GET['post_status'] == 'all') {
                    echo '<div class="row-actions">';
                    do_action('nf_sub_table_before_row_actions', $sub_id, $column);
                    echo '<span class="edit"><a href="post.php?post=' . $sub_id . '&action=edit&ref=' . urlencode(add_query_arg(array())) . '" title="' . __('Edit this item', 'ninja-forms') . '">' . __('Edit', 'ninja-forms') . '</a> | </span> 
						<span class="edit"><a href="' . add_query_arg(array('export_single' => $sub_id)) . '" title="' . __('Export this item', 'ninja-forms') . '">' . __('Export', 'ninja-forms') . '</a> | </span>';
                    $row_actions = apply_filters('nf_sub_table_row_actions', array(), $sub_id, $form_id);
                    if (!empty($row_actions)) {
                        echo implode(" | ", $row_actions);
                        echo '| ';
                    }
                    echo '<span class="trash"><a class="submitdelete" title="' . __('Move this item to the Trash', 'ninja-forms') . '" href="' . get_delete_post_link($sub_id) . '">' . __('Trash', 'ninja-forms') . '</a> </span>';
                    do_action('nf_sub_table_after_row_actions', $sub_id, $column);
                    echo '</div>';
                } else {
                    echo '<div class="row-actions">';
                    do_action('nf_sub_table_before_row_actions_trash', $sub_id, $column);
                    echo '<span class="untrash"><a title="' . esc_attr(__('Restore this item from the Trash')) . '" href="' . wp_nonce_url(sprintf(get_edit_post_link($sub_id) . '&amp;action=untrash', $sub_id), 'untrash-post_' . $sub_id) . '">' . __('Restore') . '</a> | </span> 
					<span class="delete"><a class="submitdelete" title="' . esc_attr(__('Delete this item permanently')) . '" href="' . get_delete_post_link($sub_id, '', true) . '">' . __('Delete Permanently') . '</a></span>';
                    do_action('nf_sub_table_after_row_actions_trash', $sub_id, $column);
                    echo '</div>';
                }
            } else {
                if ($column == 'sub_date') {
                    $post = get_post($sub_id);
                    if ('0000-00-00 00:00:00' == $post->post_date) {
                        $t_time = $h_time = __('Unpublished');
                        $time_diff = 0;
                    } else {
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $post->post_date;
                        $time = get_post_time('G', true, $post);
                        $time_diff = time() - $time;
                        if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
                            $h_time = sprintf(__('%s ago'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                    }
                    $t_time = apply_filters('nf_sub_title_time', $t_time);
                    $h_time = apply_filters('nf_sub_human_time', $h_time);
                    /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
                    echo '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
                    echo '<br />';
                    echo apply_filters('nf_sub_table_status', __('Submitted', 'ninja-forms'), $sub_id);
                } else {
                    if (strpos($column, '_field_') !== false) {
                        global $ninja_forms_fields;
                        $field_id = str_replace('form_' . $form_id . '_field_', '', $column);
                        //if ( apply_filters( 'nf_add_sub_value', Ninja_Forms()->field( $field_id )->type->add_to_sub, $field_id ) ) {
                        $field = Ninja_Forms()->form($form_id)->fields[$field_id];
                        $field_type = $field['type'];
                        if (isset($ninja_forms_fields[$field_type])) {
                            $reg_field = $ninja_forms_fields[$field_type];
                        } else {
                            $reg_field = array();
                        }
                        if (isset($reg_field['sub_table_value'])) {
                            $edit_value_function = $reg_field['sub_table_value'];
                        } else {
                            $edit_value_function = 'nf_field_text_sub_table_value';
                        }
                        $user_value = Ninja_Forms()->sub($sub_id)->get_field($field_id);
                        $args['field_id'] = $field_id;
                        $args['user_value'] = ninja_forms_esc_html_deep($user_value);
                        $args['field'] = $field;
                        call_user_func_array($edit_value_function, $args);
                        //}
                    }
                }
            }
        }
    }
function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox)
{
    $plugin_settings = nf_get_settings();
    if ($form_id != '') {
        $form_row = ninja_forms_get_form_by_id($form_id);
        $current_settings = $form_row['data'];
    } else {
        $form_id = '';
        $current_settings = nf_get_settings();
    }
    $page = $metabox['page'];
    $tab = $metabox['tab'];
    $title = $metabox['title'];
    if (isset($metabox['settings'])) {
        $settings = $metabox['settings'];
    } else {
        $settings = '';
    }
    if (isset($metabox['display_function'])) {
        $display_function = $metabox['display_function'];
    } else {
        $display_function = '';
    }
    if ($metabox['state'] == 'closed') {
        $state = 'display:none;';
    } else {
        $state = '';
    }
    if (isset($plugin_settings['metabox_state'][$page][$tab][$slug])) {
        $state = $plugin_settings['metabox_state'][$page][$tab][$slug];
    }
    if (isset($metabox['display_container'])) {
        $display_container = $metabox['display_container'];
    } else {
        $display_container = true;
    }
    if ($display_container) {
        ?>
		<div id="ninja_forms_metabox_<?php 
        echo $slug;
        ?>
" class="postbox ">
			<span class="item-controls">
				<a class="item-edit metabox-item-edit" id="edit_id" title="<?php 
        _e('Edit Menu Item', 'ninja-forms');
        ?>
" href="#"><?php 
        _e('Edit Menu Item', 'ninja-forms');
        ?>
</a>
			</span>
			<h3 class="hndle"><span><?php 
        _e($title, 'ninja-forms');
        ?>
</span></h3>
			<div class="inside" style="<?php 
        echo $state;
        ?>
">
			<table class="form-table">
				<tbody>
		<?php 
    }
    if (is_array($settings) and !empty($settings)) {
        foreach ($settings as $s) {
            $value = '';
            if (isset($s['name'])) {
                $name = $s['name'];
            } else {
                $name = '';
            }
            $name_array = '';
            if (strpos($name, '[') !== false) {
                $name_array = str_replace(']', '', $name);
                $name_array = explode('[', $name_array);
            }
            if (isset($s['type'])) {
                $type = $s['type'];
            } else {
                $type = '';
            }
            if (isset($s['desc'])) {
                $desc = $s['desc'];
            } else {
                $desc = '';
            }
            if (isset($s['help_text'])) {
                $help_text = $s['help_text'];
            } else {
                $help_text = '';
            }
            if (isset($s['label'])) {
                $label = $s['label'];
            } else {
                $label = '';
            }
            if (isset($s['class'])) {
                $class = $s['class'];
            } else {
                $class = '';
            }
            if (isset($s['tr_class'])) {
                $tr_class = $s['tr_class'];
            } else {
                $tr_class = '';
            }
            if (isset($s['max_file_size'])) {
                $max_file_size = $s['max_file_size'];
            } else {
                $max_file_size = '';
            }
            if (isset($s['select_all'])) {
                $select_all = $s['select_all'];
            } else {
                $select_all = false;
            }
            if (isset($s['default_value'])) {
                $default_value = $s['default_value'];
            } else {
                $default_value = '';
            }
            if (isset($s['style'])) {
                $style = $s['style'];
            } else {
                $style = '';
            }
            if (isset($s['size'])) {
                $size = $s['size'];
            } else {
                $size = '';
            }
            if (isset($s['min'])) {
                $min = $s['min'];
            } else {
                $min = 0;
            }
            if (isset($s['max'])) {
                $max = $s['max'];
            } else {
                $max = '';
            }
            if (is_array($name_array)) {
                $tmp = '';
                foreach ($name_array as $n) {
                    if ($tmp == '') {
                        if (isset($current_settings[$n])) {
                            $tmp = $current_settings[$n];
                        }
                    } else {
                        if (isset($tmp[$n])) {
                            $tmp = $tmp[$n];
                        }
                    }
                }
                $value = !is_array($tmp) && !is_object($tmp) ? $tmp : '';
            } else {
                if (isset($current_settings[$name])) {
                    if (is_array($current_settings[$name])) {
                        $value = ninja_forms_stripslashes_deep($current_settings[$name]);
                    } else {
                        $value = stripslashes($current_settings[$name]);
                    }
                } else {
                    $value = '';
                }
            }
            if ($value == '') {
                $value = $default_value;
            }
            ?>

			<tr id="row_<?php 
            echo $name;
            ?>
" <?php 
            if ($tr_class != '') {
                ?>
class="<?php 
                echo $tr_class;
                ?>
"<?php 
            }
            ?>
 <?php 
            if ($style != '') {
                ?>
 style="<?php 
                echo $style;
                ?>
"<?php 
            }
            ?>
>
				<?php 
            if ($s['type'] == 'desc' and !$label) {
                ?>
					 <td colspan="2">
				<?php 
            } else {
                ?>
					<th scope="row">
						<label for="<?php 
                echo $name;
                ?>
"><?php 
                echo $label;
                ?>
</label>
					</th>
					<td>
				<?php 
            }
            ?>
			<?php 
            switch ($s['type']) {
                case 'text':
                    $value = ninja_forms_esc_html_deep($value);
                    ?>

					<input type="text" class="code widefat <?php 
                    echo $class;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" value="<?php 
                    echo $value;
                    ?>
" />
					<?php 
                    if ($help_text != '') {
                        ?>
					<a href="#" class="tooltip">
					    <img id="" class='ninja-forms-help-text' src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
images/question-ico.gif" title="">
					    <span>
					        <img class="callout" src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
/images/callout.gif" />
					        <?php 
                        echo $help_text;
                        ?>
					    </span>
					</a>
					<?php 
                    }
                    break;
                case 'number':
                    $value = ninja_forms_esc_html_deep($value);
                    ?>

					<input type="number" class="code <?php 
                    echo $class;
                    ?>
" name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" value="<?php 
                    echo $value;
                    ?>
" min="<?php 
                    echo $min;
                    ?>
" max="<?php 
                    echo $max;
                    ?>
" />
					<?php 
                    if ($help_text != '') {
                        ?>
					<a href="#" class="tooltip">
					    <img id="" class='ninja-forms-help-text' src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
images/question-ico.gif" title="">
					    <span>
					        <img class="callout" src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
/images/callout.gif" />
					        <?php 
                        echo $help_text;
                        ?>
					    </span>
					</a>
					<?php 
                    }
                    break;
                case 'select':
                    ?>
					<select name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" class="<?php 
                    echo $class;
                    ?>
">
						<?php 
                    if (is_array($s['options']) and !empty($s['options'])) {
                        foreach ($s['options'] as $option) {
                            ?>
								<option value="<?php 
                            echo $option['value'];
                            ?>
" <?php 
                            selected($value, $option['value']);
                            ?>
><?php 
                            echo $option['name'];
                            ?>
</option>
								<?php 
                        }
                    }
                    ?>
					</select>
					<?php 
                    if ($help_text != '') {
                        ?>
						<a href="#" class="tooltip">
						    <img id="" class='ninja-forms-help-text' src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
images/question-ico.gif" title="">
						    <span>
						        <img class="callout" src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
images/callout.gif" />
						        <?php 
                        echo $help_text;
                        ?>
						    </span>
						</a>
					<?php 
                    }
                    break;
                case 'multi_select':
                    if ($value == '') {
                        $value = array();
                    }
                    ?>

					<input type="hidden" name="<?php 
                    echo $name;
                    ?>
" value="">
					<select name="<?php 
                    echo $name;
                    ?>
[]" id="<?php 
                    echo $name;
                    ?>
" class="<?php 
                    echo $class;
                    ?>
" multiple="multiple" size="<?php 
                    echo $size;
                    ?>
">
						<?php 
                    if (is_array($s['options']) and !empty($s['options'])) {
                        foreach ($s['options'] as $option) {
                            ?>
								<option value="<?php 
                            echo $option['value'];
                            ?>
" <?php 
                            selected(in_array($option['value'], $value));
                            ?>
><?php 
                            echo $option['name'];
                            ?>
</option>
								<?php 
                        }
                    }
                    ?>
					</select>
					<?php 
                    if ($help_text != '') {
                        ?>
						<a href="#" class="tooltip">
						    <img id="" class='ninja-forms-help-text' src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
images/question-ico.gif" title="">
						    <span>
						        <img class="callout" src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
/images/callout.gif" />
						        <?php 
                        echo $help_text;
                        ?>
						    </span>
						</a>
					<?php 
                    }
                    break;
                case 'checkbox':
                    ?>
					<input type="hidden" name="<?php 
                    echo $name;
                    ?>
" value="0">
					<input type="checkbox" name="<?php 
                    echo $name;
                    ?>
" value="1" <?php 
                    checked($value, 1);
                    ?>
 id="<?php 
                    echo $name;
                    ?>
" class="<?php 
                    echo $class;
                    ?>
">
					<?php 
                    if ($help_text != '') {
                        ?>
						<a href="#" class="tooltip">
						    <img id="" class='ninja-forms-help-text' src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
images/question-ico.gif" title="">
						    <span>
						        <img class="callout" src="<?php 
                        echo NINJA_FORMS_URL;
                        ?>
images/callout.gif" />
						        <?php 
                        echo $help_text;
                        ?>
						    </span>
						</a>
					<?php 
                    }
                    break;
                case 'checkbox_list':
                    if ($value == '') {
                        $value = array();
                    }
                    ?>
					<input type="hidden" name="<?php 
                    echo $name;
                    ?>
" value="">

						<?php 
                    if ($select_all) {
                        ?>

								<label>
									<input type="checkbox" name="" value="" id="<?php 
                        echo $name;
                        ?>
_select_all" class="ninja-forms-select-all" title="ninja-forms-<?php 
                        echo $name;
                        ?>
">
								- <?php 
                        _e('Select All', 'ninja-forms');
                        ?>
								</label>

						<?php 
                    } else {
                        if (is_array($s['options']) and isset($s['options'][0])) {
                            $option_name = $s['options'][0]['name'];
                            $option_value = $s['options'][0]['value'];
                            ?>

									<label>
										<input type="checkbox" class="ninja-forms-<?php 
                            echo $name;
                            ?>
 <?php 
                            echo $class;
                            ?>
" name="<?php 
                            echo $name;
                            ?>
[]" value="<?php 
                            echo $option_value;
                            ?>
" <?php 
                            checked(in_array($option_value, $value));
                            ?>
 id="<?php 
                            echo $option_name;
                            ?>
">
										<?php 
                            echo $option_name;
                            ?>
									</label>

								<?php 
                        }
                    }
                    ?>

					<?php 
                    if (is_array($s['options']) and !empty($s['options'])) {
                        $x = 0;
                        foreach ($s['options'] as $option) {
                            if (!$select_all and $x > 0 or $select_all) {
                                $option_name = $option['name'];
                                $option_value = $option['value'];
                                ?>
										<label>
											<input type="checkbox" class="ninja-forms-<?php 
                                echo $name;
                                ?>
 <?php 
                                echo $class;
                                ?>
" name="<?php 
                                echo $name;
                                ?>
[]" value="<?php 
                                echo $option_value;
                                ?>
" <?php 
                                checked(in_array($option_value, $value));
                                ?>
 id="<?php 
                                echo $option_name;
                                ?>
">
											<?php 
                                echo $option_name;
                                ?>
										</label>
								<?php 
                            }
                            $x++;
                        }
                    }
                    break;
                case 'radio':
                    if (is_array($s['options']) and !empty($s['options'])) {
                        $x = 0;
                        ?>
						<?php 
                        foreach ($s['options'] as $option) {
                            ?>
							<input type="radio" name="<?php 
                            echo $name;
                            ?>
" value="<?php 
                            echo $option['value'];
                            ?>
" id="<?php 
                            echo $name . "_" . $x;
                            ?>
" <?php 
                            checked($value, $option['value']);
                            ?>
 class="<?php 
                            echo $class;
                            ?>
"> <label for="<?php 
                            echo $name . "_" . $x;
                            ?>
"><?php 
                            echo $option['name'];
                            ?>
</label>
								<?php 
                            if ($help_text != '') {
                                ?>
									<a href="#" class="tooltip">
									    <img id="" class='ninja-forms-help-text' src="<?php 
                                echo NINJA_FORMS_URL;
                                ?>
images/question-ico.gif" title="">
									    <span>
									        <img class="callout" src="<?php 
                                echo NINJA_FORMS_URL;
                                ?>
images/callout.gif" />
									        <?php 
                                echo $help_text;
                                ?>
									    </span>
									</a>
								<?php 
                            }
                            ?>
							<br />

						<?php 
                            $x++;
                        }
                    }
                    break;
                case 'textarea':
                    $value = ninja_forms_esc_html_deep($value);
                    ?>
					<textarea name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" class="<?php 
                    echo $class;
                    ?>
"><?php 
                    echo $value;
                    ?>
</textarea>
					<?php 
                    break;
                case 'rte':
                    $args = apply_filters('ninja_forms_admin_metabox_rte', array());
                    wp_editor($value, $name, $args);
                    break;
                case 'file':
                    ?>
					<input type="hidden" name="MAX_FILE_SIZE" value="<?php 
                    echo $max_file_size;
                    ?>
" />
					<input type="file" name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" class="<?php 
                    echo $class;
                    ?>
">
					<?php 
                    break;
                case 'desc':
                    echo $desc;
                    break;
                case 'hidden':
                    ?>
					<input type="hidden" name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" value="<?php 
                    echo $value;
                    ?>
">
					<?php 
                    break;
                case 'submit':
                    ?>
					<input type="submit" name="<?php 
                    echo $name;
                    ?>
" class="<?php 
                    echo $class;
                    ?>
" value="<?php 
                    echo $label;
                    ?>
">
					<?php 
                    break;
                case 'button':
                    // set a default value for $class to maintain the standard WordPress UI
                    if (isset($class) && empty($class)) {
                        $class = "button-secondary";
                    }
                    ?>
					<input type="button" name="<?php 
                    echo $name;
                    ?>
" id="<?php 
                    echo $name;
                    ?>
" class="<?php 
                    echo $class;
                    ?>
" value="<?php 
                    echo $label;
                    ?>
">
					<?php 
                    break;
                default:
                    if (isset($s['display_function'])) {
                        $s_display_function = $s['display_function'];
                        if ($s_display_function != '') {
                            $arguments['form_id'] = $form_id;
                            $arguments['data'] = $current_settings;
                            $arguments['field'] = $s;
                            call_user_func_array($s_display_function, $arguments);
                        }
                    }
                    break;
            }
            if ($desc != '' and $s['type'] != 'desc') {
                ?>
					<p class="description">
						<?php 
                echo $desc;
                ?>
					</p>
				<?php 
            }
            echo '</td></tr>';
        }
    }
    if ($display_function != '') {
        if ($form_id != '') {
            $arguments['form_id'] = $form_id;
        }
        $arguments['metabox'] = $metabox;
        call_user_func_array($display_function, $arguments);
    }
    if ($display_container) {
        ?>
					</tbody>
				</table>
			</div>
		</div>
		<?php 
    }
}
Exemple #7
0
function ninja_forms_edit_field_output_li($field_id, $new = false)
{
    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']) && $ninja_forms_fields[$field_type]['use_li']) {
        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 = '';
        }
        $form_id = $field_row['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'];
            $li_class = $reg_field['li_class'];
            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 && $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 && $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']) && $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 $li_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"><span class="spinner" style="margin-top:-2px;float:left;"></span><span class="item-type-name"><?php 
            echo $type_name;
            ?>
</span></span>
							<a class="item-edit nf-edit-field" id="ninja_forms_field_<?php 
            echo $field_id;
            ?>
_toggle" title="<?php 
            _e('Edit Menu Item', 'ninja-forms');
            ?>
" href="#" data-field="<?php 
            echo $field_id;
            ?>
"><?php 
            _e('Edit Menu Item', 'ninja-forms');
            ?>
</a>
						</span>
					</dt>
				</dl>
				<?php 
            if ($new) {
                $padding = '';
            } else {
                $padding = 'no-padding';
            }
            ?>
				<div class="menu-item-settings type-class inside <?php 
            echo $padding;
            ?>
" id="ninja_forms_field_<?php 
            echo $field_id;
            ?>
_inside" >
					<?php 
            if ($new) {
                nf_output_registered_field_settings($field_id);
            }
        }
    } else {
        if (isset($ninja_forms_fields[$field_type])) {
            $reg_field = $ninja_forms_fields[$field_type];
            $edit_function = $reg_field['edit_function'];
            $arguments = array();
            $arguments['field_id'] = $field_id;
            $arguments['data'] = $field_data;
            if ($edit_function != '') {
                call_user_func_array($edit_function, $arguments);
            }
        }
    }
}
Exemple #8
0
 /**
  * Listen for exporting subs
  * 
  * @access public
  * @since 2.7.3
  * @return void
  */
 public function export_listen()
 {
     // Bail if we aren't in the admin
     if (!is_admin()) {
         return false;
     }
     if (!isset($_REQUEST['form_id']) || empty($_REQUEST['form_id'])) {
         return false;
     }
     if (isset($_REQUEST['export_single']) && !empty($_REQUEST['export_single'])) {
         Ninja_Forms()->sub(esc_html($_REQUEST['export_single']))->export();
     }
     if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'export' || isset($_REQUEST['action2']) && $_REQUEST['action2'] == 'export') {
         Ninja_Forms()->subs()->export(ninja_forms_esc_html_deep($_REQUEST['post']));
     }
     if (isset($_REQUEST['download_file']) && !empty($_REQUEST['download_file'])) {
         // Open our download all file
         $filename = esc_html($_REQUEST['download_file']);
         $upload_dir = wp_upload_dir();
         $file_path = trailingslashit($upload_dir['path']) . $filename . '.csv';
         if (file_exists($file_path)) {
             $myfile = file_get_contents($file_path);
         } else {
             $redirect = esc_url_raw(remove_query_arg(array('download_file', 'download_all')));
             wp_redirect($redirect);
             die;
         }
         unlink($file_path);
         $form_name = Ninja_Forms()->form(absint($_REQUEST['form_id']))->get_setting('form_title');
         $form_name = sanitize_title($form_name);
         $today = date('Y-m-d', current_time('timestamp'));
         $filename = apply_filters('nf_download_all_filename', $form_name . '-all-subs-' . $today);
         header('Content-type: application/csv');
         header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
         header('Pragma: no-cache');
         header('Expires: 0');
         echo $myfile;
         die;
     }
 }
Exemple #9
0
function ninja_forms_edit_field_el_output($field_id, $type, $label = '', $name = '', $value = '', $width = 'wide', $options = '', $class = '', $desc = '', $label_class = '')
{
    global $ninja_forms_fields, $nf_rte_editors;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $reg_field = $ninja_forms_fields[$field_type];
    $class = 'code ninja-forms-' . $field_type . '-' . $name . ' ' . $class;
    $id = 'ninja_forms_field_' . $field_id . '_' . $name;
    if (strpos($name, '[') !== false) {
        str_replace(']', '', $name);
        $name = explode('[', $name);
        if (is_array($name)) {
            $tmp_name = 'ninja_forms_field_' . $field_id;
            foreach ($name as $n) {
                $tmp_name .= '[' . $n . ']';
            }
            $name = $tmp_name;
        } else {
            $name = 'ninja_forms_field_' . $field_id . '[' . $name . ']';
        }
    } else {
        $name = 'ninja_forms_field_' . $field_id . '[' . $name . ']';
    }
    ?>
	<div class="description description-<?php 
    echo $width;
    ?>
 <?php 
    echo $type;
    ?>
" id="<?php 
    echo $name;
    ?>
_p">
	<?php 
    if ($type != 'rte') {
        $value = ninja_forms_esc_html_deep($value);
        ?>
		<span class="field-option">
			<?php 
    }
    if ($type != 'checkbox' and $type != 'desc') {
        ?>
		<label for="<?php 
        echo $id;
        ?>
" id="<?php 
        echo $id;
        ?>
_label" class="<?php 
        echo $label_class;
        ?>
">
			<?php 
        _e($label, 'ninja-forms');
        ?>
</label><br/>
		<?php 
    }
    switch ($type) {
        case 'text':
            ?>
			<input type="text" class="<?php 
            echo $class;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $id;
            ?>
" value="<?php 
            echo $value;
            ?>
" />
		<?php 
            break;
        case 'number':
            ?>
			<input type="number" class="<?php 
            echo $class;
            ?>
" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $id;
            ?>
" value="<?php 
            echo $value;
            ?>
" />
		<?php 
            break;
        case 'checkbox':
            ?>
			<label for="<?php 
            echo $id;
            ?>
" id="<?php 
            echo $id;
            ?>
_label">
				<input type="hidden" value="0" name="<?php 
            echo $name;
            ?>
">
				<input type="checkbox" value="1" name="<?php 
            echo $name;
            ?>
" id="<?php 
            echo $id;
            ?>
" class="<?php 
            echo $class;
            ?>
" <?php 
            checked($value, 1);
            ?>
>
				<?php 
            _e($label, 'ninja-forms');
            ?>
			</label>
		<?php 
            break;
        case 'select':
            ?>
			<select id="<?php 
            echo $id;
            ?>
" name="<?php 
            echo $name;
            ?>
" class="<?php 
            echo $class;
            ?>
">
				<?php 
            if (is_array($options) and !empty($options)) {
                foreach ($options as $opt) {
                    ?>
						<option value="<?php 
                    echo $opt['value'];
                    ?>
" <?php 
                    selected($opt['value'], $value);
                    ?>
 ><?php 
                    _e($opt['name'], 'ninja-forms');
                    ?>
</option>
						<?php 
                }
            }
            ?>
			</select>
		<?php 
            break;
        case 'multi':
            ?>
			<select multiple="multiple" id="<?php 
            echo $id;
            ?>
" name="<?php 
            echo $name;
            ?>
" class="<?php 
            echo $class;
            ?>
">
				<?php 
            if (is_array($options) and !empty($options)) {
                foreach ($options as $opt) {
                    ?>
						<option value="<?php 
                    echo $opt['value'];
                    ?>
" <?php 
                    selected($opt['value'], $value);
                    ?>
 ><?php 
                    _e($opt['name'], 'ninja-forms');
                    ?>
</option>
						<?php 
                }
            }
            ?>
			</select>
		<?php 
            break;
        case 'textarea':
            ?>
			<textarea id="<?php 
            echo $id;
            ?>
" name="<?php 
            echo $name;
            ?>
" class="<?php 
            echo $class;
            ?>
" rows="3" cols="20" ><?php 
            echo $value;
            ?>
</textarea>
		<?php 
            break;
        case 'hidden':
            ?>
			<input type="hidden" name="<?php 
            echo $name;
            ?>
" value="<?php 
            echo $value;
            ?>
">
		<?php 
            break;
        case 'desc':
            ?>
			<span class="desc"><label for="<?php 
            echo $id;
            ?>
" id="<?php 
            echo $id;
            ?>
_label"><?php 
            _e($label, 'ninja-forms');
            ?>
</label></span>
		<?php 
            break;
        case 'rte':
            $editor_id = str_replace('[', '_', $name);
            $editor_id = str_replace(']', '', $editor_id);
            $plugin_settings = nf_get_settings();
            if (!isset($plugin_settings['version_2_2_25_rte_fix']) or $plugin_settings['version_2_2_25_rte_fix'] == '') {
                $value = html_entity_decode($value);
                $plugin_settings['version_2_2_25_rte_fix'] = 1;
                update_option('ninja_forms_settings', $plugin_settings);
            }
            $args = apply_filters('ninja_forms_edit_field_rte', array('textarea_name' => $name));
            wp_editor($value, $editor_id, $args);
            // If we're using ajax, add this editor ID to our global var so that we can instantiate it on the front-end.
            if (isset($_POST['action']) && $_POST['action'] == 'ninja_forms_new_field') {
                $nf_rte_editors[] = $editor_id;
            }
            break;
    }
    if ($desc != '') {
        ?>
		<span class="description">
			<?php 
        _e($desc, 'ninja-forms');
        ?>
		</span>
	<?php 
    }
    if ($type != 'rte') {
        ?>
		</span>
		<?php 
    }
    ?>
	</div>
	<?php 
}
Exemple #10
0
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);
        }
    }
}
Exemple #11
0
function ninja_forms_side_sortable()
{
    // Bail if we aren't in the admin
    if (!is_admin()) {
        return false;
    }
    check_ajax_referer('nf_ajax', 'nf_ajax_nonce');
    $plugin_settings = nf_get_settings();
    $page = esc_html($_REQUEST['page']);
    $tab = esc_html($_REQUEST['tab']);
    $order = ninja_forms_esc_html_deep($_REQUEST['order']);
    $plugin_settings['sidebars'][$page][$tab] = $order;
    update_option('ninja_forms_settings', $plugin_settings);
    die;
}
function ninja_forms_save_view_subs($form_id, $data = array())
{
    global $ninja_forms_admin_update_message;
    $plugin_settings = get_option("ninja_forms_settings");
    if (isset($_POST['submit']) and $_REQUEST['page'] == 'ninja-forms-subs') {
        switch ($_POST['submit']) {
            case __('Apply', 'ninja-forms'):
                if (isset($_POST['bulk_action'])) {
                    if ($_POST['bulk_action'] == 'delete') {
                        if (isset($_POST['ninja_forms_sub']) and is_array($_POST['ninja_forms_sub']) and !empty($_POST['ninja_forms_sub'])) {
                            $subs = ninja_forms_esc_html_deep($_POST['ninja_forms_sub']);
                            foreach ($subs as $sub_id) {
                                ninja_forms_delete_sub($sub_id);
                            }
                            $ninja_forms_admin_update_message = count($_POST['ninja_forms_sub']) . ' ';
                            if (count($_POST['ninja_forms_sub']) > 1) {
                                $ninja_forms_admin_update_message .= __('Submissions Deleted', 'ninja-forms');
                            } else {
                                $ninja_forms_admin_update_message .= __('Submission Deleted', 'ninja-forms');
                            }
                        }
                    } elseif ($_POST['bulk_action'] == 'export') {
                        if (isset($_POST['ninja_forms_sub']) and is_array($_POST['ninja_forms_sub']) and !empty($_POST['ninja_forms_sub'])) {
                            $subs = ninja_forms_esc_html_deep($_POST['ninja_forms_sub']);
                            ninja_forms_export_subs_to_csv($subs);
                        }
                    }
                }
                break;
            case __('Download All Submissions', 'ninja-forms'):
                if (isset($plugin_settings['date_format']) and $plugin_settings['date_format'] != '') {
                    $date_format = $plugin_settings['date_format'];
                } else {
                    $date_format = 'm/d/Y';
                }
                if (isset($_REQUEST['form_id']) and !empty($_REQUEST['form_id'])) {
                    $form_id = absint($_REQUEST['form_id']);
                } else {
                    $form_id = '';
                }
                if (isset($_REQUEST['ninja_forms_begin_date']) and !empty($_REQUEST['ninja_forms_begin_date'])) {
                    $begin_date = esc_html($_REQUEST['ninja_forms_begin_date']);
                } else {
                    $begin_date = '';
                }
                if (isset($_REQUEST['ninja_forms_end_date']) and !empty($_REQUEST['ninja_forms_end_date'])) {
                    $end_date = esc_html($_REQUEST['ninja_forms_end_date']);
                } else {
                    $end_date = '';
                }
                $args = array('form_id' => $form_id, 'begin_date' => $begin_date, 'end_date' => $end_date);
                $sub_results = ninja_forms_get_subs($args);
                $sub_results = apply_filters('ninja_forms_download_all_subs_results', $sub_results);
                if (is_array($sub_results) and !empty($sub_results)) {
                    $sub_ids = array();
                    foreach ($sub_results as $sub) {
                        $sub_ids[] = $sub['id'];
                    }
                    ninja_forms_export_subs_to_csv($sub_ids);
                }
                break;
            case __('Save Sub', 'ninja-forms'):
                break;
            case __('View Submissions', 'ninja-forms'):
                break;
        }
    }
}
function ninja_forms_side_sortable()
{
    $plugin_settings = get_option('ninja_forms_settings');
    $page = esc_html($_REQUEST['page']);
    $tab = esc_html($_REQUEST['tab']);
    $order = ninja_forms_esc_html_deep($_REQUEST['order']);
    $plugin_settings['sidebars'][$page][$tab] = $order;
    update_option('ninja_forms_settings', $plugin_settings);
    die;
}