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,11 +3,13 @@
*
* 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 ){
// 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;
......@@ -22,6 +24,12 @@ function ninja_forms_edit_field_list_term( $field_id ){
$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'] ) ){
......@@ -33,14 +41,16 @@ function ninja_forms_edit_field_list_term( $field_id ){
if( $field_type == '_list' AND $post_type != '' ){
?>
<div>
<hr>
<label>
<?php _e( 'Populate this with the term: ', 'ninja-forms-post-creation' );?>
<select name="ninja_forms_field_<?php echo $field_id;?>[populate_term]">
<?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' ){
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>
......@@ -49,10 +59,15 @@ function ninja_forms_edit_field_list_term( $field_id ){
}
?>
</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,16 +153,23 @@ 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">
......@@ -172,18 +179,10 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
<?php echo $help_text;?>
</span>
</a>
<?php } ?>
</td>
</tr>
<?php
<?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;?>">
<?php
if( is_array( $s['options']) AND !empty( $s['options'] ) ){
......@@ -202,21 +201,14 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
<?php echo $help_text;?>
</span>
</a>
<?php } ?>
</td>
</tr>
<?php
<?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;?>">
<?php
......@@ -236,18 +228,10 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
<?php echo $help_text;?>
</span>
</a>
<?php } ?>
</td>
</tr>
<?php
<?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 != ''){ ?>
......@@ -258,10 +242,7 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
<?php echo $help_text;?>
</span>
</a>
<?php } ?>
</td>
</tr>
<?php
<?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,11 +301,6 @@ 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 != ''){ ?>
......@@ -350,64 +316,27 @@ function ninja_forms_output_tab_metabox($form_id = '', $slug, $metabox){
<?php
$x++;
} ?>
</td>
</tr>
<?php
}
}
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>
<?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
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>
<?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>
<?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 )
......@@ -43,4 +43,3 @@ function ninja_forms_register_sidebar_post_fields(){
}
add_action( 'admin_init', 'ninja_forms_register_sidebar_post_fields' );
\ No newline at end of file
*/
\ No newline at end of file
......@@ -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>
......
......@@ -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
......
......@@ -3,9 +3,13 @@
*
* Function to hook into our field filter and add the selected terms if the field is set to populate_term.
*
* @since 2.2.51
* @return void
*/
/*
function ninja_forms_field_filter_populate_term( $data, $field_id ){
// Make sure that this function isn't already defined.
if ( !function_exists ( 'ninja_forms_field_filter_populate_term' ) ) {
function ninja_forms_field_filter_populate_term( $data, $field_id ){
global $post;
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
......@@ -16,6 +20,12 @@ function ninja_forms_field_filter_populate_term( $data, $field_id ){
$field_type = $field_row['type'];
$field_data = $field_row['data'];
if ( isset ( $field_data['exclude_terms'] ) ) {
$exclude_terms = $field_data['exclude_terms'];
} else {
$exclude_terms = array();
}
if( $field_type == '_list' AND isset( $field_data['populate_term'] ) AND $field_data['populate_term'] != '' ){
// Set the selected option if we are editing a post.
if( is_object( $post ) ){
......@@ -32,7 +42,12 @@ function ninja_forms_field_filter_populate_term( $data, $field_id ){
} else {
$selected_term = '';
}
$tmp_array = array( array( 'label' => '- Select One', 'value' => '' ) );
if ( $field_data['list_type'] == 'dropdown' ) {
$tmp_array = array( array( 'label' => __( '- Select One', 'ninja-forms' ), 'value' => '' ) );
} else {
$tmp_array = array();
}
$populate_term = $field_data['populate_term'];
$taxonomies = array( $populate_term );
$args = array(
......@@ -43,13 +58,15 @@ function ninja_forms_field_filter_populate_term( $data, $field_id ){
if( $selected_term == $term->term_id ){
$data['default_value'] = $term->term_id;
}
if ( !in_array( $term->term_id, $exclude_terms ) ) {
$tmp_array[] = array( 'label' => $term->name, 'value' => $term->term_id );
}
}
$data['list']['options'] = apply_filters( 'ninja_forms_list_terms', $tmp_array, $field_id );
$data['list_show_value'] = 1;
}
return $data;
}
}
add_filter( 'ninja_forms_field', 'ninja_forms_field_filter_populate_term', 11, 2 );
*/
\ No newline at end of file
add_filter( 'ninja_forms_field', 'ninja_forms_field_filter_populate_term', 11, 2 );
}
\ No newline at end of file
<?php
/*
*
* Function used to store the attachment IDs being uploaded into a $_SESSION variable.
*
* This should affect files being uploaded by the media manager popup on the front-end.
* Becuase the post hasn't technically been created yet, when you insert an image or media, it doesn't automatically attach it to the post id.
*
* @since 0.8
* @returns $data
*/
function ninja_forms_set_attachment_to_change( $data, $attachment_id ){
if ( !isset ( $data['ninja_forms_upload_field'] ) OR !$data['ninja_forms_upload_field'] ) {
if ( !isset( $_SESSION['ninja_forms_change_attachment'] ) OR !is_array( $_SESSION['ninja_forms_change_attachment'] ) ) {
$_SESSION['ninja_forms_change_attachment'] = array();
}
$_SESSION['ninja_forms_change_attachment'][] = $attachment_id;
}
return $data;
}
add_filter( 'wp_update_attachment_metadata', 'ninja_forms_set_attachment_to_change', 10, 2 );
/*
*
* Function used to attach media uploads to the newly created post when a post is updated or created.
*
* @since 0.8
* @returns void
*/
function ninja_forms_attach_media_uploads( $post_id ){
if ( isset( $_SESSION['ninja_forms_change_attachment'] ) AND is_array( $_SESSION['ninja_forms_change_attachment'] ) ) {
foreach ( $_SESSION['ninja_forms_change_attachment'] as $attachment_id ) {
$post = get_post( $attachment_id, ARRAY_A );
if ( is_array( $post ) ) {
wp_update_post( array( 'ID' => $attachment_id, 'post_type' => 'attachment', 'post_parent' => $post_id ) );
}
}
$_SESSION['ninja_forms_change_attachment'] = '';
}
}
add_action( 'ninja_forms_create_post', 'ninja_forms_attach_media_uploads' );
add_action( 'ninja_forms_update_post', 'ninja_forms_attach_media_uploads' );
\ No newline at end of file
......@@ -3,11 +3,13 @@
*
* Function to filter the term IDS and return the term names.
*
* @since 2.2.45
* @since 2.2.51
* @returns void
*/
/*
function ninja_forms_filter_term_ids_for_name( $val, $field_id ){
// Make sure that this function isn't already defined.
if ( !function_exists ( 'ninja_forms_filter_term_ids_for_name' ) ) {
function ninja_forms_filter_term_ids_for_name( $val, $field_id ){
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
......@@ -48,27 +50,29 @@ function ninja_forms_filter_term_ids_for_name( $val, $field_id ){
}
return $val;
}
}
add_filter( 'ninja_forms_email_user_value', 'ninja_forms_filter_term_ids_for_name', 10, 2 );
add_filter( 'ninja_forms_export_sub_value', 'ninja_forms_filter_term_ids_for_name', 10, 2 );
add_filter( 'ninja_forms_email_user_value', 'ninja_forms_filter_term_ids_for_name', 10, 2 );
add_filter( 'ninja_forms_export_sub_value', 'ninja_forms_filter_term_ids_for_name', 10, 2 );
}
/*
*
* Function to filter the term IDS and return the term names for the backend submission editor.
*
* @since 2.2.45
* @since 2.2.51
* @returns void
*/
/*
function ninja_forms_filter_term_ids_for_name_sub_td( $val, $field_id, $sub_id ){
// Make sure that this function isn't already defined.
if ( !function_exists ( 'ninja_forms_filter_term_ids_for_name_sub_td' ) ) {
function ninja_forms_filter_term_ids_for_name_sub_td( $val, $field_id, $sub_id ){
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return $val;
return ninja_forms_filter_term_ids_for_name( $val, $field_id );
}
}
add_filter( 'ninja_forms_view_sub_td', 'ninja_forms_filter_term_ids_for_name_sub_td', 10, 3 );
*/
\ No newline at end of file
add_filter( 'ninja_forms_view_sub_td', 'ninja_forms_filter_term_ids_for_name_sub_td', 10, 3 );
}
\ No newline at end of file
......@@ -3,9 +3,13 @@
*
* Function to hook into the post creation/update that will change the term based upon the selected term(s)
*
* @since 2.2.51
* @return void
*/
/*
function ninja_forms_pre_process_populate_term( $form_id ){
// Make sure that this function isn't already defined.
if ( !function_exists ( 'ninja_forms_pre_process_populate_term' ) ) {
function ninja_forms_pre_process_populate_term( $form_id ){
global $ninja_forms_processing;
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
......@@ -27,7 +31,7 @@ function ninja_forms_pre_process_populate_term( $form_id ){
}
}
}
}
}
add_action( 'ninja_forms_pre_process', 'ninja_forms_pre_process_populate_term' );
*/
\ No newline at end of file
add_action( 'ninja_forms_pre_process', 'ninja_forms_pre_process_populate_term' );
}
\ No newline at end of file
......@@ -201,7 +201,6 @@ function ninja_forms_display_js($form_id, $local_vars = ''){
$password_mismatch = esc_html(stripslashes($plugin_settings['password_mismatch']));
$msg_format = $plugin_settings['msg_format'];
$msg_format = 'inline';
wp_enqueue_script( 'ninja-forms-display',
NINJA_FORMS_URL .'/js/min/ninja-forms-display.min.js',
array( 'jquery', 'jquery-form' ) );
......
......@@ -518,7 +518,12 @@ function ninja_forms_field_calc_pre_process(){
// 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 ( $field_data['payment_total'] ) AND $field_data['payment_total'] == 1 AND $calc_method == 'auto' ) {
$calc_method = 'eq';
$calc_eq = 'field_'.$sub_total.' + ( field_'.$sub_total.' * field_'.$tax.' )';
$tax_rate = $ninja_forms_processing->get_field_value( $tax );
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.' )';
$field_settings = $ninja_forms_processing->get_field_settings( $field_id );
$field_settings['data']['calc_method'] = $calc_method;
......@@ -645,8 +650,12 @@ function ninja_forms_calc_field_loop2( $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.' )';
$calc_method = 'eq';$tax_rate = $ninja_forms_processing->get_field_value( $tax );
if ( strpos( $tax_rate, "%" ) !== false ) {
$tax_rate = str_replace( "%", "", $tax_rate );
$tax_rate = $tax_rate / 100;
}