Commit d21092d3 authored by Kevin Stover's avatar Kevin Stover

Merge branch 'release/v2.2.51'

parents eb81946e 81f86d96
......@@ -459,6 +459,57 @@ function ninja_forms_import_list_options(){
add_action( 'wp_ajax_ninja_forms_import_list_options', 'ninja_forms_import_list_options' );
/*
*
* Function that outputs a list of terms so that the user can exclude terms from a list selector.
*
* @since 2.2.51
* @return void
*/
function ninja_forms_list_terms_checkboxes( $field_id = '', $tax_name = '' ){
if ( $field_id == '' AND isset ( $_POST['field_id'] ) ) {
$field_id = $_POST['field_id'];
}
if ( $tax_name == '' AND isset ( $_POST['tax_name'] ) ) {
$tax_name = $_POST['tax_name'];
}
if ( $field_id != '' AND $tax_name != '' ) {
$field = ninja_forms_get_field_by_id( $field_id );
if ( isset ( $field['data']['exclude_terms'] ) ) {
$exclude_terms = $field['data']['exclude_terms'];
} else {
$exclude_terms = '';
}
$terms = get_terms( $tax_name, array( 'hide_empty' => false ) );
if ( is_array ( $terms ) AND !empty ( $terms ) ) {
?>
<h4><?php _e( 'Do not show these terms', 'ninja-forms' );?>:</h4>
<input type="hidden" name="ninja_forms_field_<?php echo $field_id;?>[exclude_terms]" value="">
<?php
foreach ( $terms as $term ) {
?>
<div>
<label>
<input type="checkbox" <?php checked( in_array ( $term->term_id, $exclude_terms ), true );?> name="ninja_forms_field_<?php echo $field_id;?>[exclude_terms][]" value="<?php echo $term->term_id;?>">
<?php echo $term->name;?>
</label>
</div>
<?php
}
}
}
if ( isset ( $_POST['from_ajax'] ) AND $_POST['from_ajax'] == 1 ) {
die();
}
}
add_action( 'wp_ajax_ninja_forms_list_terms_checkboxes', 'ninja_forms_list_terms_checkboxes' );
/*
*
* Function that outputs a calculation row
......
......@@ -3,56 +3,71 @@
*
* Function to add a dropdown of terms to the list field.
*
* @since 0.7
* @since 2.2.51
* @returns void
*/
/*
function ninja_forms_edit_field_list_term( $field_id ){
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return false;
$field_row = ninja_forms_get_field_by_id( $field_id );
$field_type = $field_row['type'];
$field_data = $field_row['data'];
if( isset( $field_data['populate_term'] ) ){
$populate_term = $field_data['populate_term'];
}else{
$populate_term = '';
}
$form_row = ninja_forms_get_form_by_field_id( $field_id );
// Make sure that this function isn't already defined.
if ( !function_exists ( 'ninja_forms_edit_field_list_term' ) ) {
function ninja_forms_edit_field_list_term( $field_id ){
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return false;
if( isset( $form_row['data']['post_type'] ) ){
$post_type = $form_row['data']['post_type'];
}else{
$post_type = '';
}
$field_row = ninja_forms_get_field_by_id( $field_id );
$field_type = $field_row['type'];
$field_data = $field_row['data'];
if( isset( $field_data['populate_term'] ) ){
$populate_term = $field_data['populate_term'];
}else{
$populate_term = '';
}
if ( $populate_term != '' ) {
$display = '';
} else {
$display = 'style="display:none;"';
}
$form_row = ninja_forms_get_form_by_field_id( $field_id );
if( isset( $form_row['data']['post_type'] ) ){
$post_type = $form_row['data']['post_type'];
}else{
$post_type = '';
}
if( $field_type == '_list' AND $post_type != '' ){
?>
<div>
<label>
<?php _e( 'Populate this with the term: ', 'ninja-forms-post-creation' );?>
<select name="ninja_forms_field_<?php echo $field_id;?>[populate_term]">
<option value=""><?php _e( '- None', 'ninja-forms-post-creation' );?></option>
<?php
// Get a list of terms registered to the post type set above and loop through them.
foreach ( get_object_taxonomies( $post_type ) as $tax_name ) {
if( $tax_name != 'post_tag' AND $tax_name != 'post_status' ){
$tax = get_taxonomy( $tax_name );
?>
<option value="<?php echo $tax_name;?>" <?php selected( $populate_term, $tax_name );?>><?php echo $tax->labels->name;?></option>
<?php
if( $field_type == '_list' AND $post_type != '' ){
?>
<div>
<hr>
<label>
<?php _e( 'Populate this with the taxonomy', 'ninja-forms' );?>:
</label>
<select name="ninja_forms_field_<?php echo $field_id;?>[populate_term]" class="ninja-forms-list-populate-term" rel="<?php echo $field_id;?>">
<option value=""><?php _e( '- None', 'ninja-forms-post-creation' );?></option>
<?php
// Get a list of terms registered to the post type set above and loop through them.
foreach ( get_object_taxonomies( $post_type ) as $tax_name ) {
if( $tax_name != 'post_tag' AND $tax_name != 'post_status' AND $tax_name != 'post_format' ){
$tax = get_taxonomy( $tax_name );
?>
<option value="<?php echo $tax_name;?>" <?php selected( $populate_term, $tax_name );?>><?php echo $tax->labels->name;?></option>
<?php
}
}
}
?>
</select>
</div>
<?php
?>
</select>
<div id="ninja_forms_field_<?php echo $field_id;?>_exclude_terms" <?php echo $display;?>>
<?php ninja_forms_list_terms_checkboxes( $field_id, $populate_term ); ?>
</div>
<br />
<hr>
</div>
<?php
}
}
}
add_action('ninja_forms_edit_field_after_registered', 'ninja_forms_edit_field_list_term', 9);
*/
\ No newline at end of file
add_action('ninja_forms_edit_field_after_registered', 'ninja_forms_edit_field_list_term', 9);
}
\ No newline at end of file
......@@ -153,115 +153,96 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
if( $value == '' ){
$value = $default_value;
}
?>
<tr <?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 );
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label; ?>
</th>
<td>
<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 } ?>
</td>
</tr>
<?php
<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 'select':
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label; ?>
</th>
<td>
<select name="<?php echo $name;?>" id="<?php echo $name;?>" class="<?php echo $class;?>">
<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
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 } ?>
</td>
</tr>
<?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();
}
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label; ?>
</th>
<td>
<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;?>">
<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
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 } ?>
</td>
</tr>
<?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':
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<label for="<?php echo $name;?>"><?php echo $label;?></label>
</th>
<td>
<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 } ?>
</td>
</tr>
<?php
<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 == '' ){
......@@ -270,19 +251,16 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
?>
<input type="hidden" name="<?php echo $name;?>" value="">
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label;?>
</th>
<?php
if( $select_all ){
?>
<td>
<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>
</td>
<?php
}else{
if( is_array( $s['options'] ) AND isset( $s['options'][0] ) ){
......@@ -291,17 +269,17 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
$option_value = $s['options'][0]['value'];
?>
<td>
<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>
</td>
<?php
}
}
?>
</tr>
<?php
if( is_array( $s['options'] ) AND !empty( $s['options'] ) ){
$x = 0;
......@@ -310,17 +288,10 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
$option_name = $option['name'];
$option_value = $option['value'];
?>
<tr <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
</th>
<td>
<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>
</td>
</tr>
<?php
}
$x++;
......@@ -330,84 +301,42 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
case 'radio':
if( is_array( $s['options'] ) AND !empty( $s['options'] ) ){
$x = 0; ?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label;?>
</th>
<td>
<?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 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++;
} ?>
</td>
</tr>
<?php
<?php
$x++;
}
}
break;
case 'textarea':
$value = ninja_forms_esc_html_deep( $value );
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label; ?>
</th>
<td>
<textarea name="<?php echo $name;?>" id="<?php echo $name;?>" class="<?php echo $class;?>"><?php echo $value;?></textarea>
</td>
</tr>
<textarea name="<?php echo $name;?>" id="<?php echo $name;?>" class="<?php echo $class;?>"><?php echo $value;?></textarea>
<?php
break;
case 'rte':
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label; ?>
</th>
<td>
<?php
$args = apply_filters( 'ninja_forms_admin_metabox_rte', array() );
wp_editor( $value, $name, $args );
?>
</td>
</tr>
<?php
$args = apply_filters( 'ninja_forms_admin_metabox_rte', array() );
wp_editor( $value, $name, $args );
break;
case 'file':
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label; ?>
</th>
<td colspan="2">
<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;?>">
</td>
</tr>
<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':
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
<?php echo $label; ?>
</th>
<td>
<?php echo $desc;?>
</td>
</tr>
<?php
echo $desc;
break;
case 'hidden':
?>
......@@ -416,11 +345,7 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
break;
case 'submit':
?>
<tr <?php if( $tr_class != '' ){ ?>class="<?php echo $tr_class;?>"<?php } ?> <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<td colspan="2">
<input type="submit" name="<?php echo $name;?>" class="<?php echo $class; ?>" value="<?php echo $label;?>">
</td>
</tr>
<input type="submit" name="<?php echo $name;?>" class="<?php echo $class; ?>" value="<?php echo $label;?>">
<?php
break;
default:
......@@ -437,18 +362,14 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
if( $desc != '' AND $s['type'] != 'desc' ){
?>
<tr class="<?php echo $tr_class;?>" <?php if( $style != '' ){ ?> style="<?php echo $style;?>"<?php }?>>
<th>
</th>
<td class="howto">
<p class="description">
<?php echo $desc;?>
</td>
</tr>
</p>
<?php
}
echo '</td></tr>';
}
}
if( $display_function != '' ){
......
......@@ -22,12 +22,11 @@ function ninja_forms_register_license_settings_metabox(){
'slug' => 'license_settings',
'title' => __( 'Licenses', 'ninja-forms' ),
'settings' => array(
//array(
//'name' => 'license_key',
//'type' => 'text',
//'label' => __('Ninja Forms License Key', 'ninja-forms'),
//'desc' => __('You will find this included with your purchase email.', 'ninja-forms'),
//),
array(
'name' => 'license_key',
'type' => 'desc',
'desc' => __('To activate licenses for Ninja Forms extensions you must first <a target="_blank" href="http://ninjaforms.com/documentation/extension-docs/installing-extensions/">install and activate</a> the chosen extension. License settings will then appear below.', 'ninja-forms'),
),
),
);
ninja_forms_register_tab_metabox($args);
......
<?php
/*
function ninja_forms_register_sidebar_post_fields(){
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
......@@ -42,5 +42,4 @@ function ninja_forms_register_sidebar_post_fields(){
}
}
add_action( 'admin_init', 'ninja_forms_register_sidebar_post_fields' );
*/
\ No newline at end of file
add_action( 'admin_init', 'ninja_forms_register_sidebar_post_fields' );
\ No newline at end of file
......@@ -74,7 +74,7 @@ function ninja_forms_register_form_settings_basic_metabox(){
$hide_complete_style = 'hidden';
$success_msg_style = 'hidden';
$ajax_style = 'hidden';
$landing_page_style = '';
$landing_page_style = '';
}else{
$clear_complete_style = '';
$hide_complete_style = '';
......@@ -129,7 +129,7 @@ function ninja_forms_register_form_settings_basic_metabox(){
'display_function' => '',
'help' => __('', 'ninja-forms'),
'options' => $append_array,
),
),
array(
'name' => 'ajax',
'type' => 'checkbox',
......@@ -138,7 +138,7 @@ function ninja_forms_register_form_settings_basic_metabox(){
'display_function' => '',
'help' => __( '', 'ninja-forms' ),
'tr_class' => 'landing-page-hide '.$ajax_style,
),
),
array(
'name' => 'landing_page',
'type' => 'select',
......@@ -311,7 +311,7 @@ function ninja_forms_admin_email($form_id, $data){
?>
<label for="">
<p>
<?php _e( 'Administrator Email Addresses', 'ninja-forms' ); ?> &nbsp;&nbsp;<a href="#" id="ninja_forms_add_mailto_<?php echo $form_id;?>" name="" class="ninja-forms-add-mailto"><?php _e( 'Add New', 'ninja-forms' ); ?></a>
<a href="#" id="ninja_forms_add_mailto_<?php echo $form_id;?>" name="" class="ninja-forms-add-mailto"><?php _e( 'Add New', 'ninja-forms' ); ?></a>
<a href="#" class="tooltip">
<img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>/images/question-ico.gif" title="">
<span>
......@@ -349,7 +349,7 @@ function ninja_forms_save_form_settings($form_id, $data){
foreach( $data as $key => $val ){
$form_data[$key] = $val;
}
if($form_id != 'new'){
$data_array = array('data' => serialize($form_data));
$wpdb->update( NINJA_FORMS_TABLE_NAME, $data_array, array( 'id' => $form_id ));
......@@ -361,7 +361,7 @@ function ninja_forms_save_form_settings($form_id, $data){
$form_data['email_from'] = get_option( 'admin_email' );
}
$data_array = array('data' => serialize($form_data));
$wpdb->insert( NINJA_FORMS_TABLE_NAME, $data_array );
$redirect = add_query_arg( array('form_id' => $wpdb->insert_id, 'update_message' => __( 'Form Settings Saved', 'ninja-forms' ) ) );
do_action( 'ninja_forms_save_new_form_settings', $wpdb->insert_id, $data );
......
......@@ -60,7 +60,13 @@ function ninja_forms_field_calc_filter( $calc_data, $field_id ){
// If the tax and sub_total have been found, and this is a total field set to auto, change the calc_method and calc_eq.
if ( $tax AND $sub_total AND isset ( $calc_data['payment_total'] ) AND $calc_data['payment_total'] == 1 AND $calc_method == 'auto' ) {
$calc_method = 'eq';
$calc_eq = 'field_'.$sub_total.' + ( field_'.$sub_total.' * field_'.$tax.' )';
$tax_field = ninja_forms_get_field_by_id( $tax );
$tax_rate = $tax_field['data']['default_value'];
if ( strpos( $tax_rate, "%" ) !== false ) {
$tax_rate = str_replace( "%", "", $tax_rate );
$tax_rate = $tax_rate / 100;
}
$calc_eq = 'field_'.$sub_total.' + ( field_'.$sub_total.' * '.$tax_rate.' )';
}
// Figure out how many calculation fields we have and run
......@@ -200,7 +206,13 @@ function ninja_forms_calc_field_loop( $field_id, $calc_eq = '', $result = '' ){
// If the tax and sub_total have been found, and this is a total field set to auto, change the calc_method and calc_eq.
if ( $tax AND $sub_total AND isset ( $calc_data['payment_total'] ) AND $calc_data['payment_total'] == 1 AND $calc_method == 'auto' ) {
$calc_method = 'eq';
$calc_eq = 'field_'.$sub_total.' + ( field_'.$sub_total.' * field_'.$tax.' )';
$tax_field = ninja_forms_get_field_by_id( $tax );
$tax_rate = $tax_field['data']['default_value'];
if ( strpos( $tax_rate, "%" ) !== false ) {
$tax_rate = str_replace( "%", "", $tax_rate );
$tax_rate = $tax_rate / 100;
}
$calc_eq = 'field_'.$sub_total.' + ( field_'.$sub_total.' * '.$tax_rate.' )';
}
// Figure out how many calculation fields we have and run
......