Ejemplo n.º 1
0
function ninja_forms_user_info_fields_groups($field_id, $field_data)
{
    global $ninja_forms_fields;
    $field = ninja_forms_get_field_by_id($field_id);
    $field_type = $field['type'];
    $default_user_info = 0;
    if (isset($ninja_forms_fields[$field_type]['edit_options']) and is_array($ninja_forms_fields[$field_type]['edit_options'])) {
        foreach ($ninja_forms_fields[$field_type]['edit_options'] as $option) {
            if (isset($option['name']) and $option['name'] == 'user_info_field_group' and isset($option['default'])) {
                $default_user_info = $option['default'];
                break;
            }
        }
    }
    if (isset($field_data['user_info_field_group']) and $field_data['user_info_field_group'] == 1 or (!isset($field_data['user_info_field_group']) or $field_data['user_info_field_group'] !== 0) and $default_user_info == 1) {
        $options = array(array('name' => '- ' . __('None', 'ninja-forms'), 'value' => ''), array('name' => __('Billing', 'ninja-forms'), 'value' => 'billing'), array('name' => __('Shipping', 'ninja-forms'), 'value' => 'shipping'), array('name' => __('Custom', 'ninja-forms') . ' ->', 'value' => 'custom'));
        if (isset($field_data['user_info_field_group_name'])) {
            $group_name = $field_data['user_info_field_group_name'];
        } else {
            $group_name = '';
        }
        if (isset($field_data['user_info_field_group_custom'])) {
            $group_custom = $field_data['user_info_field_group_custom'];
        } else {
            $group_custom = '';
        }
        if ($group_name == 'custom') {
            $custom_class = '';
        } else {
            $custom_class = 'hidden';
        }
        ninja_forms_edit_field_el_output($field_id, 'select', __('User Info Field Group', 'ninja-forms'), 'user_info_field_group_name', $group_name, 'thin', $options, 'user-info-group-name widefat');
        ninja_forms_edit_field_el_output($field_id, 'text', __('Custom Field Group', 'ninja-forms'), 'user_info_field_group_custom', $group_custom, 'thin', '', 'user-info-custom-group widefat ' . $custom_class, '', $custom_class);
    }
}
Ejemplo n.º 2
0
function nf_edit_field_sub_settings($field_id)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    if ($ninja_forms_fields[$field_type]['process_field']) {
        if (isset($field_row['data']['admin_label'])) {
            $admin_label = $field_row['data']['admin_label'];
        } else {
            $admin_label = '';
        }
        if (isset($field_row['data']['num_sort'])) {
            $num_sort = $field_row['data']['num_sort'];
        } else {
            $num_sort = '';
        }
        ?>
		<div class="description description-wide">
		<hr>
		<h5><?php 
        _e('Submission Settings', 'ninja-forms');
        ?>
</h5>
		<?php 
        ninja_forms_edit_field_el_output($field_id, 'text', __('Admin Label', 'ninja-forms'), 'admin_label', $admin_label, 'wide', '', 'widefat code', __('This is the label used when viewing/editing/exporting submissions.', 'ninja-forms'));
        ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Sort as numeric', 'ninja-forms'), 'num_sort', $num_sort, 'wide', '', '', __('If this box is checked, this column in the submissions table will sort by number.', 'ninja-forms'));
    }
}
Ejemplo n.º 3
0
/**
 * Function that adds a character and word limit option to textboxes and textareas.
 *
 * @since 2.4.3
 * @return void
 */
function ninja_forms_edit_field_input_limit($field_id, $field_data)
{
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $allowed_types = apply_filters('nf_input_limit_types', array('_text', '_textarea'));
    if (!in_array($field_type, $allowed_types)) {
        return false;
    }
    if (isset($field_data['input_limit'])) {
        $input_limit = $field_data['input_limit'];
    } else {
        $input_limit = '';
    }
    if (isset($field_data['input_limit_type'])) {
        $input_limit_type = $field_data['input_limit_type'];
    } else {
        $input_limit_type = '';
    }
    if (isset($field_data['input_limit_msg'])) {
        $input_limit_msg = $field_data['input_limit_msg'];
    } else {
        $input_limit_msg = '';
    }
    $desc = '<em>' . __('If you leave the box empty, no limit will be used', 'ninja-forms') . '</em>';
    ninja_forms_edit_field_el_output($field_id, 'text', __('Limit input to this number', 'ninja-forms'), 'input_limit', $input_limit, 'thin', '', 'widefat', $desc);
    ninja_forms_edit_field_el_output($field_id, 'select', __('of', 'ninja-forms'), 'input_limit_type', $input_limit_type, 'thin', array(array('name' => __('Characters', 'ninja-forms'), 'value' => 'char'), array('name' => __('Words', 'ninja-forms'), 'value' => 'word')), 'widefat');
    echo '<p class="description description-wide">&nbsp;</p>';
    ninja_forms_edit_field_el_output($field_id, 'text', __('Text to appear after character/word counter', 'ninja-forms'), 'input_limit_msg', $input_limit_msg, 'wide', '', 'widefat');
}
Ejemplo n.º 4
0
function nf_edit_field_admin_label($field_id, $field_data)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    if ($ninja_forms_fields[$field_type]['process_field']) {
        if (isset($field_data['admin_label'])) {
            $admin_label = $field_data['admin_label'];
        } else {
            $admin_label = '';
        }
        if (isset($field_data['num_sort'])) {
            $num_sort = $field_data['num_sort'];
        } else {
            $num_sort = '';
        }
        ?>
		<div class="description description-wide">
		<?php 
        ninja_forms_edit_field_el_output($field_id, 'text', __('Admin Label', 'ninja-forms'), 'admin_label', $admin_label, 'wide', '', 'widefat code', __('This is the label used when viewing/editing/exporting submissions.', 'ninja-forms'));
        ?>
		</div>
		<?php 
    }
}
Ejemplo n.º 5
0
/**
 * Function that adds a character and word limit option to textboxes and textareas.
 *
 * @since 2.4.3
 * @return void
 */
function ninja_forms_edit_field_input_limit($field_id)
{
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $allowed_types = apply_filters('nf_input_limit_types', array('_text', '_textarea'));
    if (!in_array($field_type, $allowed_types)) {
        return false;
    }
    $field_data = $field_row['data'];
    if (isset($field_data['input_limit'])) {
        $input_limit = $field_data['input_limit'];
    } else {
        $input_limit = '';
    }
    if (isset($field_data['input_limit_type'])) {
        $input_limit_type = $field_data['input_limit_type'];
    } else {
        $input_limit_type = '';
    }
    if (isset($field_data['input_limit_msg'])) {
        $input_limit_msg = $field_data['input_limit_msg'];
    } else {
        $input_limit_msg = '';
    }
    $desc = __('If you want to limit the number of characters or words that your user can input, set the number and type of limit you want to enforce below.', 'ninja-forms');
    ninja_forms_edit_field_el_output($field_id, 'desc', $desc);
    $desc = '<em>' . __('If you leave the box empty, no limit will be used', 'ninja-forms') . '</em>';
    ninja_forms_edit_field_el_output($field_id, 'desc', $desc);
    ninja_forms_edit_field_el_output($field_id, 'text', __('Limit input to this number', 'ninja-forms'), 'input_limit', $input_limit, 'thin', '', 'widefat', '');
    ninja_forms_edit_field_el_output($field_id, 'select', __('of', 'ninja-forms'), 'input_limit_type', $input_limit_type, 'thin', array(array('name' => __('Characters', 'ninja-forms'), 'value' => 'char'), array('name' => __('Words', 'ninja-forms'), 'value' => 'word')), 'widefat');
    ninja_forms_edit_field_el_output($field_id, 'text', __('Text to appear after character/word counter', 'ninja-forms'), 'input_limit_msg', $input_limit_msg, 'wide', '', 'widefat');
}
Ejemplo n.º 6
0
function nf_edit_field_req($field_id, $field_data)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $reg_field = $ninja_forms_fields[$field_type];
    $field_req = $reg_field['req'];
    if ($field_req) {
        ninja_forms_edit_field_el_output($field_id, 'hidden', '', 'req', 1);
    }
}
Ejemplo n.º 7
0
function nf_field_autocomplete_off($field_id, $field_data)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $reg_field = $ninja_forms_fields[$field_type];
    $edit_autocomplete_off = $reg_field['edit_autocomplete_off'];
    if ($edit_autocomplete_off) {
        $autocomplete_off = isset($field_data['autocomplete_off']) ? $field_data['autocomplete_off'] : 0;
        ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Disable Browser Autocomplete', 'ninja-forms'), 'autocomplete_off', $autocomplete_off, 'wide');
    }
}
Ejemplo n.º 8
0
function ninja_forms_edit_field_custom_class($field_id, $field_data)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $reg_field = $ninja_forms_fields[$field_type];
    $edit_custom_class = $reg_field['edit_custom_class'];
    if ($edit_custom_class) {
        if (isset($field_data['class'])) {
            $class = $field_data['class'];
        } else {
            $class = '';
        }
        ninja_forms_edit_field_el_output($field_id, 'text', __('Custom CSS Classes', 'ninja-forms'), 'class', $class, 'wide', '', 'widefat');
    }
}
Ejemplo n.º 9
0
function ninja_forms_edit_field_calc($field_id)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    if ($ninja_forms_fields[$field_type]['process_field']) {
        if (isset($field_row['data']['calc_option'])) {
            $calc_option = $field_row['data']['calc_option'];
        } else {
            $calc_option = 0;
        }
        if (isset($field_row['data']['calc_auto_include'])) {
            $calc_auto_include = $field_row['data']['calc_auto_include'];
        } else {
            $calc_auto_include = 0;
        }
        if (isset($field_row['data']['calc_value'])) {
            $calc_value = $field_row['data']['calc_value'];
        } else {
            $calc_value = 0;
        }
        ?>
		<div class="description description-wide">
		<hr>
		<h5><?php 
        _e('Calculation Settings', 'ninja-forms');
        ?>
</h5>
		<?php 
        if ($field_type == '_checkbox') {
            if (!isset($calc_value['unchecked'])) {
                $calc_value = array();
                $calc_value['unchecked'] = 0;
                $calc_value['checked'] = 0;
            }
            ninja_forms_edit_field_el_output($field_id, 'text', __('<strong>Checked</strong> Calculation Value', 'ninja-forms'), 'calc_value[checked]', $calc_value['checked'], 'wide', '', '', __('This is the value that will be used if <strong>Checked</strong>.', 'ninja-forms'));
            ninja_forms_edit_field_el_output($field_id, 'text', __('<strong>Unchecked</strong> Calculation Value', 'ninja-forms'), 'calc_value[unchecked]', $calc_value['unchecked'], 'wide', '', '', __('This is the value that will be used if <strong>Unchecked</strong>.', 'ninja-forms'));
        }
        //if ( $field_type != '_calc' ) {
        ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Include in the auto-total? (If enabled)', 'ninja-forms'), 'calc_auto_include', $calc_auto_include, 'wide', '', 'ninja-forms-field-auto-total-include');
        //}
        //ninja_forms_edit_field_el_output($field_id, 'checkbox', __( 'Include in payment details list?', 'ninja-forms' ), 'calc_option', $calc_option, 'wide', '', '', __( ' - Should this field be considered as pertinant to a payment/product? i.e. an item option, a product size or color, etc.', 'ninja-forms' ) );
    }
    ?>
		
	<?php 
}
Ejemplo n.º 10
0
function ninja_forms_edit_field_placeholder($field_id)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $field_data = $field_row['data'];
    $reg_field = $ninja_forms_fields[$field_type];
    $edit_placeholder = $reg_field['edit_placeholder'];
    if ($edit_placeholder) {
        if (isset($field_data['placeholder'])) {
            $placeholder = stripslashes($field_data['placeholder']);
        } else {
            $placeholder = '';
        }
        ninja_forms_edit_field_el_output($field_id, 'text', __('Placeholder', 'ninja-forms'), 'placeholder', $placeholder, 'wide', '', 'widefat ninja-forms-field-label');
    }
}
Ejemplo n.º 11
0
function ninja_forms_edit_field_calc($field_id)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    if ($ninja_forms_fields[$field_type]['process_field']) {
        if (isset($field_row['data']['calc_option'])) {
            $calc_option = $field_row['data']['calc_option'];
        } else {
            $calc_option = 0;
        }
        if (isset($field_row['data']['calc_auto_include'])) {
            $calc_auto_include = $field_row['data']['calc_auto_include'];
        } else {
            $calc_auto_include = 0;
        }
        if (isset($field_row['data']['calc_value'])) {
            $calc_value = $field_row['data']['calc_value'];
        } else {
            $calc_value = 0;
        }
        ?>
		<div class="description description-wide">
		<hr>
		<h5><?php 
        _e('Calculation Settings', 'ninja-forms');
        ?>
</h5>
		<?php 
        if ($field_type == '_checkbox') {
            if (!isset($calc_value['unchecked'])) {
                $calc_value = array();
                $calc_value['unchecked'] = 0;
                $calc_value['checked'] = 0;
            }
            ninja_forms_edit_field_el_output($field_id, 'text', __('<strong>Checked</strong> Calculation Value', 'ninja-forms'), 'calc_value[checked]', $calc_value['checked'], 'wide', '', '', __('This is the value that will be used if <strong>Checked</strong>.', 'ninja-forms'));
            ninja_forms_edit_field_el_output($field_id, 'text', __('<strong>Unchecked</strong> Calculation Value', 'ninja-forms'), 'calc_value[unchecked]', $calc_value['unchecked'], 'wide', '', '', __('This is the value that will be used if <strong>Unchecked</strong>.', 'ninja-forms'));
        }
        ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Include in the auto-total? (If enabled)', 'ninja-forms'), 'calc_auto_include', $calc_auto_include, 'wide', '', 'ninja-forms-field-auto-total-include');
    }
    ?>
		
	<?php 
}
Ejemplo n.º 12
0
function ninja_forms_edit_field_help($field_id)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $field_data = $field_row['data'];
    $reg_field = $ninja_forms_fields[$field_type];
    $edit_help = $reg_field['edit_help'];
    if ($edit_help) {
        if (isset($field_data['help_text'])) {
            $help_text = $field_data['help_text'];
        } else {
            $help_text = '';
        }
        if (isset($field_data['show_help'])) {
            $show_help = $field_data['show_help'];
        } else {
            $show_help = '';
        }
        if ($show_help == 1) {
            $display_span = '';
        } else {
            $display_span = 'display:none;';
        }
        $help_desc = sprintf(__('If "help text" is enabled, there will be a question mark %s placed next to the input field. Hovering over this question mark will show the help text.', 'ninja-forms'), '<img src="' . NINJA_FORMS_URL . 'images/question-ico.gif">');
        ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Show Help Text', 'ninja-forms'), 'show_help', $show_help, 'wide', '', 'ninja-forms-show-help');
        ?>
		<span id="ninja_forms_field_<?php 
        echo $field_id;
        ?>
_help_span" style="<?php 
        echo $display_span;
        ?>
">
			<?php 
        ninja_forms_edit_field_el_output($field_id, 'textarea', __('Help Text', 'ninja-forms'), 'help_text', $help_text, 'wide', '', 'widefat');
        ninja_forms_edit_field_el_output($field_id, 'desc', $help_desc, 'help_desc');
        ?>
		</span>
		<?php 
    }
}
Ejemplo n.º 13
0
function ninja_forms_field_required($field_id)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $field_data = $field_row['data'];
    $reg_field = $ninja_forms_fields[$field_type];
    $edit_req = $reg_field['edit_req'];
    $field_req = $reg_field['req'];
    if ($edit_req) {
        if (isset($field_data['req'])) {
            $req = $field_data['req'];
        } else {
            $req = '';
        }
        $options = array(array('name' => __('No', 'ninja-forms'), 'value' => '0'), array('name' => __('Yes', 'ninja-forms'), 'value' => '1'));
        ninja_forms_edit_field_el_output($field_id, 'select', __('Required', 'ninja-forms'), 'req', $req, 'thin', $options);
    }
    if ($field_req) {
        ninja_forms_edit_field_el_output($field_id, 'hidden', '', 'req', 1);
    }
}
Ejemplo n.º 14
0
function ninja_forms_edit_field_label_pos($field_id, $field_data)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $reg_field = $ninja_forms_fields[$field_type];
    $edit_label_pos = $reg_field['edit_label_pos'];
    $label_pos_options = $reg_field['label_pos_options'];
    if (!$label_pos_options or $label_pos_options == '') {
        $options = array(array('name' => __('Left of Element', 'ninja-forms'), 'value' => 'left'), array('name' => __('Above Element', 'ninja-forms'), 'value' => 'above'), array('name' => __('Below Element', 'ninja-forms'), 'value' => 'below'), array('name' => __('Right of Element', 'ninja-forms'), 'value' => 'right'), array('name' => __('Inside Element', 'ninja-forms'), 'value' => 'inside'));
    } else {
        $options = $label_pos_options;
    }
    if ($edit_label_pos) {
        if (isset($field_data['label_pos'])) {
            $label_pos = $field_data['label_pos'];
        } else {
            $label_pos = 'above';
        }
        ninja_forms_edit_field_el_output($field_id, 'select', __('Label Position', 'ninja-forms'), 'label_pos', $label_pos, 'wide', $options, 'widefat');
    }
}
Ejemplo n.º 15
0
function ninja_forms_user_info_fields_groups($field_id)
{
    $field = ninja_forms_get_field_by_id($field_id);
    if (isset($field['data']['user_info_field_group']) and $field['data']['user_info_field_group'] == 1) {
        $options = array(array('name' => '- ' . __('None', 'ninja-forms'), 'value' => ''), array('name' => __('Billing', 'ninja-forms'), 'value' => 'billing'), array('name' => __('Shipping', 'ninja-forms'), 'value' => 'shipping'), array('name' => __('Custom', 'ninja-forms') . ' ->', 'value' => 'custom'));
        if (isset($field['data']['user_info_field_group_name'])) {
            $group_name = $field['data']['user_info_field_group_name'];
        } else {
            $group_name = '';
        }
        if (isset($field['data']['user_info_field_group_custom'])) {
            $group_custom = $field['data']['user_info_field_group_custom'];
        } else {
            $group_custom = '';
        }
        if ($group_name == 'custom') {
            $custom_class = '';
        } else {
            $custom_class = 'hidden';
        }
        ninja_forms_edit_field_el_output($field_id, 'select', __('User Info Field Group', 'ninja-forms'), 'user_info_field_group_name', $group_name, 'thin', $options, 'user-info-group-name widefat');
        ninja_forms_edit_field_el_output($field_id, 'text', __('Custom Field Group', 'ninja-forms'), 'user_info_field_group_custom', $group_custom, 'thin', '', 'user-info-custom-group widefat ' . $custom_class, '', $custom_class);
    }
}
Ejemplo n.º 16
0
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);
    }
}
Ejemplo n.º 17
0
function nf_field_calc_advanced_settings($field_id, $data)
{
    $field = ninja_forms_get_field_by_id($field_id);
    if ('_calc' != $field['type']) {
        return false;
    }
    $calc_name = isset($data['calc_name']) ? $data['calc_name'] : 'calc_name';
    $default_value = isset($data['default_value']) ? $data['default_value'] : '';
    $calc_payment = isset($data['calc_payment']) ? $data['calc_payment'] : '';
    $calc_autho = isset($data['calc_auto']) ? $data['calc_auto'] : 0;
    $calc_display_type = isset($data['calc_display_type']) ? $data['calc_display_type'] : 'text';
    ninja_forms_edit_field_el_output($field_id, 'text', __('Calculation name', 'ninja-forms'), 'calc_name', $calc_name, 'wide', '', 'widefat ninja-forms-calc-name', __('This is the programmatic name of your field. Examples are: my_calc, price_total, user-total.', 'ninja-forms'));
    ninja_forms_edit_field_el_output($field_id, 'text', __('Default Value', 'ninja-forms'), 'default_value', $default_value, 'wide', '', 'widefat');
    // If any option besides "none" is selected, then show our custom class and help options.
    if ($calc_display_type == 'hidden') {
        $class = 'hidden';
    } else {
        $class = '';
    }
    if (isset($data['class'])) {
        $custom_class = $data['class'];
    } else {
        $custom_class = '';
    }
    if (isset($data['show_help'])) {
        $show_help = $data['show_help'];
    } else {
        $show_help = 0;
    }
    if (isset($data['help_text'])) {
        $help_text = $data['help_text'];
    } else {
        $help_text = '';
    }
    if ($show_help == 1) {
        $display_span = '';
    } else {
        $display_span = 'display:none;';
    }
    echo '<div id="ninja_forms_field_' . $field_id . '_calc_extra_display" class="' . $class . '">';
    // Output our custom class textbox.
    ninja_forms_edit_field_el_output($field_id, 'text', __('Custom CSS Class', 'ninja-forms'), 'class', $custom_class, 'wide', '', 'widefat');
    // Output our help text options.
    $help_desc = sprintf(__('If "help text" is enabled, there will be a question mark %s placed next to the input field. Hovering over this question mark will show the help text.', 'ninja-forms'), '<img src="' . NINJA_FORMS_URL . 'images/question-ico.gif">');
    ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Show Help Text', 'ninja-forms'), 'show_help', $show_help, 'wide', '', 'ninja-forms-show-help');
    ?>
	<span id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_help_span" style="<?php 
    echo $display_span;
    ?>
">
		<?php 
    ninja_forms_edit_field_el_output($field_id, 'textarea', __('Help Text', 'ninja-forms'), 'help_text', $help_text, 'wide', '', 'widefat', $help_desc);
    ?>
	</span>
	<?php 
    echo '</div>';
}
Ejemplo n.º 18
0
function ninja_forms_field_calc_edit($field_id, $data)
{
    if (isset($data['calc_name'])) {
        $calc_name = $data['calc_name'];
    } else {
        $calc_name = 'calc_name';
    }
    if (isset($data['default_value'])) {
        $default_value = $data['default_value'];
    } else {
        $default_value = '';
    }
    if (isset($data['calc_payment'])) {
        $calc_payment = $data['calc_payment'];
    } else {
        $calc_payment = '';
    }
    if (isset($data['calc_auto'])) {
        $calc_auto = $data['calc_auto'];
    } else {
        $calc_auto = 0;
    }
    ninja_forms_edit_field_el_output($field_id, 'text', __('Calculation name', 'ninja-forms'), 'calc_name', $calc_name, 'wide', '', 'widefat ninja-forms-calc-name', __('This is the programmatic name of your field. Examples are: my_calc, price_total, user-total.', 'ninja-forms'));
    ninja_forms_edit_field_el_output($field_id, 'text', __('Default Value', 'ninja-forms'), 'default_value', $default_value, 'wide', '', 'widefat');
    echo '<hr>';
    echo '<h5>' . __('Display Options', 'ninja-forms') . '</h5>';
    // Output calculation display type
    $options = array(array('name' => __('- None', 'ninja-forms'), 'value' => 'hidden'), array('name' => __('Textbox', 'ninja-forms'), 'value' => 'text'), array('name' => __('HTML', 'ninja-forms'), 'value' => 'html'));
    if (isset($data['calc_display_type'])) {
        $calc_display_type = $data['calc_display_type'];
    } else {
        $calc_display_type = 'text';
    }
    ninja_forms_edit_field_el_output($field_id, 'select', __('Output calculation as', 'ninja-forms'), 'calc_display_type', $calc_display_type, 'wide', $options, 'widefat ninja-forms-calc-display');
    // If the calc_display_type is set to text, then we have several options to output.
    // Set the output to hidden for these options if the calc_display_type is not set to text.
    if ($calc_display_type != 'text') {
        $class = 'hidden';
    } else {
        $class = '';
    }
    echo '<div id="ninja_forms_field_' . $field_id . '_clac_text_display" class="' . $class . '">';
    // Output a label input textbox.
    if (isset($data['label'])) {
        $label = stripslashes($data['label']);
    } else {
        $label = '';
    }
    ninja_forms_edit_field_el_output($field_id, 'text', __('Label', 'ninja-forms'), 'label', $label, 'wide', '', 'widefat');
    // Output a label position select box.
    if (isset($data['label_pos'])) {
        $label_pos = $data['label_pos'];
    } else {
        $label_pos = '';
    }
    $options = array(array('name' => __('Left of Element', 'ninja-forms'), 'value' => 'left'), array('name' => __('Above Element', 'ninja-forms'), 'value' => 'above'), array('name' => __('Below Element', 'ninja-forms'), 'value' => 'below'), array('name' => __('Right of Element', 'ninja-forms'), 'value' => 'right'));
    ninja_forms_edit_field_el_output($field_id, 'select', __('Label Position', 'ninja-forms'), 'label_pos', $label_pos, 'wide', $options, 'widefat');
    // Output a disabled option checkbox.
    if (isset($data['calc_display_text_disabled'])) {
        $calc_display_text_disabled = $data['calc_display_text_disabled'];
    } else {
        $calc_display_text_disabled = 1;
    }
    ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Disable input?', 'ninja-forms'), 'calc_display_text_disabled', $calc_display_text_disabled, 'thin', '', '');
    echo '</div>';
    // Set the output to hidden for the HTML RTE if the calc_display_type is not set to HTML.
    if ($calc_display_type != 'html') {
        $class = 'hidden';
    } else {
        $class = '';
    }
    // Output our RTE. This is the only extra setting needed if the calc_display_type is set to HTML.
    if (isset($data['calc_display_html'])) {
        $calc_display_html = $data['calc_display_html'];
    } else {
        $calc_display_html = '[ninja_forms_calc]';
    }
    echo '<div id="ninja_forms_field_' . $field_id . '_clac_html_display" class="' . $class . '">';
    ninja_forms_edit_field_el_output($field_id, 'rte', '', 'calc_display_html', $calc_display_html, '', '', '', __('Use the following shortcode to insert the final calculation: [ninja_forms_calc]', 'ninja-forms'));
    echo '</div>';
    // If any option besides "none" is selected, then show our custom class and help options.
    if ($calc_display_type == 'hidden') {
        $class = 'hidden';
    } else {
        $class = '';
    }
    if (isset($data['class'])) {
        $custom_class = $data['class'];
    } else {
        $custom_class = '';
    }
    if (isset($data['show_help'])) {
        $show_help = $data['show_help'];
    } else {
        $show_help = 0;
    }
    if (isset($data['help_text'])) {
        $help_text = $data['help_text'];
    } else {
        $help_text = '';
    }
    if ($show_help == 1) {
        $display_span = '';
    } else {
        $display_span = 'display:none;';
    }
    echo '<div id="ninja_forms_field_' . $field_id . '_clac_extra_display" class="' . $class . '">';
    // Output our custom class textbox.
    ninja_forms_edit_field_el_output($field_id, 'text', __('Custom CSS Class', 'ninja-forms'), 'class', $custom_class, 'thin', '', '');
    // Output our help text options.
    $help_desc = sprintf(__('If "help text" is enabled, there will be a question mark %s placed next to the input field. Hovering over this question mark will show the help text.', 'ninja-forms'), '<img src="' . NINJA_FORMS_URL . '/images/question-ico.gif">');
    ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Show Help Text', 'ninja-forms'), 'show_help', $show_help, 'wide', '', 'ninja-forms-show-help');
    ?>
	<span id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_help_span" style="<?php 
    echo $display_span;
    ?>
">
		<?php 
    ninja_forms_edit_field_el_output($field_id, 'textarea', __('Help Text', 'ninja-forms'), 'help_text', $help_text, 'wide', '', 'widefat', $help_desc);
    ?>
	</span>
	<?php 
    echo '</div>';
    echo '<div class="description description-wide"><hr></div>';
    //echo '<h5>'.__( 'Calculation Options', 'ninja-forms' ).'</h5>';
    if (isset($data['calc_method'])) {
        $calc_method = $data['calc_method'];
    } else {
        $calc_method = 'auto';
    }
    switch ($calc_method) {
        case 'auto':
            $eq_class = 'hidden';
            $field_class = 'hidden';
            break;
        case 'fields':
            $eq_class = 'hidden';
            $field_class = '';
            break;
        case 'eq':
            $eq_class = '';
            $field_class = 'hidden';
            break;
    }
    if (isset($data['calc_eq'])) {
        $calc_eq = $data['calc_eq'];
    } else {
        $calc_eq = '';
    }
    if (isset($data['calc']) and $data['calc'] != '') {
        $calc = $data['calc'];
    } else {
        $calc = array();
    }
    $desc = '<p>' . __('You can enter calculation equations here using field_x where x is the ID of the field you want to use. For example, <strong>field_53 + field_28 + field_65</strong>.', 'ninja-forms') . '</p>';
    $desc .= '<p>' . __('Complex equations can be created by adding parentheses: <strong>( field_45 * field_2 ) / 2</strong>.', 'ninja-forms') . '</p>';
    $desc .= '<p>' . __('Please use these operators: + - * /. This is an advanced feature. Watch out for things like division by 0.', 'ninja-forms') . '</p>';
    $options = array(array('name' => __('Automatically Total Calculation Values', 'ninja-forms'), 'value' => 'auto'), array('name' => __('Specify Operations And Fields (Advanced)', 'ninja-forms'), 'value' => 'fields'), array('name' => __('Use An Equation (Advanced)', 'ninja-forms'), 'value' => 'eq'));
    ninja_forms_edit_field_el_output($field_id, 'select', __('Calculation Method', 'ninja-forms'), 'calc_method', $calc_method, 'wide', $options, 'widefat ninja-forms-calc-method');
    ?>
	
	<div class="ninja-forms-calculations <?php 
    echo $field_class;
    ?>
">
		<div class="label">
			<?php 
    _e('Field Operations', 'ninja-forms');
    ?>
 - <a href="#" name="" id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_add_calc" class="ninja-forms-field-add-calc" rel="<?php 
    echo $field_id;
    ?>
"><?php 
    _e('Add Operation', 'ninja-forms');
    ?>
</a>
			
			<span class="spinner" style="float:left;"></span>
		</div>

		<input type="hidden" name="ninja_forms_field_<?php 
    echo $field_id;
    ?>
[calc]" value="">
		<div id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_calc" class="" name="">
			<?php 
    $x = 0;
    foreach ($calc as $c) {
        ninja_forms_output_field_calc_row($field_id, $c, $x);
        $x++;
    }
    ?>
		</div>
	</div>
	<div class="ninja-forms-eq <?php 
    echo $eq_class;
    ?>
">
		<?php 
    ninja_forms_edit_field_el_output($field_id, 'textarea', __('Advanced Equation', 'ninja-forms'), 'calc_eq', $calc_eq, 'wide', '', 'widefat', $desc);
    ?>
	</div>
	<hr>
	<?php 
}
Ejemplo n.º 19
0
Archivo: li.php Proyecto: serker72/T3S
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);
        }
    }
}
Ejemplo n.º 20
0
function ninja_forms_edit_field_desc($field_id)
{
    global $ninja_forms_fields;
    $field_row = ninja_forms_get_field_by_id($field_id);
    $field_type = $field_row['type'];
    $field_data = $field_row['data'];
    $reg_field = $ninja_forms_fields[$field_type];
    if (isset($reg_field['edit_desc'])) {
        $edit_desc = $reg_field['edit_desc'];
    } else {
        $edit_desc = true;
    }
    if ($edit_desc) {
        if (isset($field_data['desc_text'])) {
            $desc_text = $field_data['desc_text'];
        } else {
            $desc_text = '';
        }
        if (isset($field_data['show_desc'])) {
            $show_desc = $field_data['show_desc'];
        } else {
            $show_desc = '';
        }
        if ($show_desc == 1) {
            $display_span = '';
        } else {
            $display_span = ' style="display:none;"';
        }
        if (!isset($desc_pos_options) or $desc_pos_options == '') {
            $options = array();
            $options[] = array('name' => __('None', 'ninja-forms'), 'value' => 'none');
            $options[] = array('name' => __('Before Everything', 'ninja-forms'), 'value' => 'before_everything');
            if ('_submit' != $field_type) {
                $options[] = array('name' => __('Before Label', 'ninja-forms'), 'value' => 'before_label');
                $options[] = array('name' => __('After Label', 'ninja-forms'), 'value' => 'after_label');
            }
            $options[] = array('name' => __('After Everything', 'ninja-forms'), 'value' => 'after_everything');
        } else {
            $options = $desc_pos_options;
        }
        $desc_desc = sprintf(__('If "desc text" is enabled, there will be a question mark %s placed next to the input field. Hovering over this question mark will show the desc text.', 'ninja-forms'), '<img src="' . NINJA_FORMS_URL . 'images/question-ico.gif">');
        ninja_forms_edit_field_el_output($field_id, 'checkbox', __('Add Description', 'ninja-forms'), 'show_desc', $show_desc, 'wide', '', 'ninja-forms-show-desc');
        ?>
		<span id="ninja_forms_field_<?php 
        echo $field_id;
        ?>
_desc_span" <?php 
        echo $display_span;
        ?>
>
			<?php 
        if (isset($field_data['desc_pos'])) {
            $desc_pos = $field_data['desc_pos'];
        } else {
            $desc_pos = '';
        }
        ninja_forms_edit_field_el_output($field_id, 'select', __('Description Position', 'ninja-forms'), 'desc_pos', $desc_pos, 'wide', $options, 'wide');
        ninja_forms_edit_field_el_output($field_id, 'rte', __('Description Content', 'ninja-forms'), 'desc_text', $desc_text, 'wide', '', 'widefat');
        ?>
		</span>
		<?php 
    }
}
Ejemplo n.º 21
0
function ninja_forms_field_list_edit($field_id, $data)
{
    global $wpdb;
    $list_type = isset($data['list_type']) ? $data['list_type'] : '';
    $hidden = isset($data['list_show_value']) ? $data['list_show_value'] : 0;
    $multi_size = isset($data['multi_size']) ? $data['multi_size'] : 5;
    $default_options = array(array('label' => 'Option 1', 'value' => '', 'calc' => '', 'selected' => 0), array('label' => 'Option 2', 'value' => '', 'calc' => '', 'selected' => 0), array('label' => 'Option 3', 'value' => '', 'calc' => '', 'selected' => 0));
    $list_options = isset($data['list']['options']) ? $data['list']['options'] : $default_options;
    $list_type_options = array(array('name' => __('Dropdown', 'ninja-forms'), 'value' => 'dropdown'), array('name' => __('Radio', 'ninja-forms'), 'value' => 'radio'), array('name' => __('Checkboxes', 'ninja-forms'), 'value' => 'checkbox'), array('name' => __('Multi-Select', 'ninja-forms'), 'value' => 'multi'));
    ninja_forms_edit_field_el_output($field_id, 'select', __('List Type', 'ninja-forms'), 'list_type', $list_type, 'wide', $list_type_options, 'widefat');
    ?>
	
	<p id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_multi_size_p" class="description description-wide" style="<?php 
    if ($list_type != 'multi') {
        echo 'display:none;';
    }
    ?>
">
		<?php 
    _e('Multi-Select Box Size', 'ninja-forms');
    ?>
: <input type="text" id="" name="ninja_forms_field_<?php 
    echo $field_id;
    ?>
[multi_size]" value="<?php 
    echo $multi_size;
    ?>
">
	</p>
	<span id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_list_span" class="ninja-forms-list-span">
		<!-- <p class="description description-wide"> -->
			<a href="#" id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_list_add_option" class="ninja-forms-field-add-list-option button-secondary"><?php 
    _e('Add New', 'ninja-forms');
    ?>
</a>
			<a href="#TB_inline?width=640&height=530&inlineId=ninja_forms_field_<?php 
    echo $field_id;
    ?>
_import_options_div" class="thickbox button-secondary" title="<?php 
    _e('Import List Items', 'ninja-forms');
    ?>
" id=""><?php 
    _e('Import List Items', 'ninja-forms');
    ?>
</a>
		<!-- </p> -->

		<p class="description description-wide">
			<input type="hidden" id="" name="ninja_forms_field_<?php 
    echo $field_id;
    ?>
[list_show_value]" value="0">
			<label for="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_list_show_value"><input type="checkbox" value="1" id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_list_show_value" name="ninja_forms_field_<?php 
    echo $field_id;
    ?>
[list_show_value]" class="ninja-forms-field-list-show-value" <?php 
    if (isset($data['list_show_value']) and $data['list_show_value'] == 1) {
        echo "checked='checked'";
    }
    ?>
>
			<?php 
    _e('Show list item values', 'ninja-forms');
    ?>
 </label>
		</p>
		<div id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_list_options" class="ninja-forms-field-list-options description description-wide">
			<input type="hidden" name="ninja_forms_field_<?php 
    echo $field_id;
    ?>
[list][options]" value="">
			<?php 
    if (isset($list_options) and is_array($list_options) and $list_options != '') {
        $x = 0;
        foreach ($list_options as $option) {
            ninja_forms_field_list_option_output($field_id, $x, $option, $hidden);
            $x++;
        }
    }
    ?>

		</div>
	</span>
	<?php 
    add_thickbox();
    ?>
		<div id="ninja_forms_field_<?php 
    echo $field_id;
    ?>
_import_options_div" style="display:none;">
			<textarea id="test" class="list-import-textarea"></textarea>
			<input type="button" class="save-list-import button-secondary" value="<?php 
    _e('Import', 'ninja-forms');
    ?>
" rel="<?php 
    echo $field_id;
    ?>
">
			<input type="button" class="cancel-list-import button-secondary" value="<?php 
    _e('Cancel', 'ninja-forms');
    ?>
">
			<p><?php 
    _e('To use this feature, you can paste your CSV into the textarea above.', 'ninja-forms');
    ?>
</p>
			<p><?php 
    _e('The format should look like the following:', 'ninja-forms');
    ?>
</p>
<pre>
<?php 
    $example1 = _x('Label,Value,Calc', 'Example for list importing. Leave puncation in place.', 'ninja-forms');
    echo $example1;
    echo '<br />';
    echo $example1;
    echo '<br />';
    echo $example1;
    ?>
</pre>

			<p><?php 
    _e("If you want to send an empty value or calc, you should use '' for those.", 'ninja-forms');
    ?>
</p>
<pre>
<?php 
    $example2 = __('Label', 'ninja-forms') . ",'',''";
    echo $example2;
    echo '<br />';
    echo $example2;
    echo '<br />';
    echo $example2;
    ?>
</pre>


		</div>
	<?php 
}