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
This diff is collapsed.
......@@ -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
......
......@@ -3,53 +3,70 @@
*
* 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 ){
global $post;
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return $data;
// 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;
$field_row = ninja_forms_get_field_by_id( $field_id );
$field_type = $field_row['type'];
$field_data = $field_row['data'];
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return $data;
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 ) ){
$selected_terms = get_the_terms( $post->ID, $field_data['populate_term'] );
}else{
$selected_term = '';
}
$field_row = ninja_forms_get_field_by_id( $field_id );
$field_type = $field_row['type'];
$field_data = $field_row['data'];
if( is_array( $selected_terms ) ){
foreach( $selected_terms as $term ){
$selected_term = $term->term_id;
break;
}
if ( isset ( $field_data['exclude_terms'] ) ) {
$exclude_terms = $field_data['exclude_terms'];
} else {
$selected_term = '';
$exclude_terms = array();
}
$tmp_array = array( array( 'label' => '- Select One', 'value' => '' ) );
$populate_term = $field_data['populate_term'];
$taxonomies = array( $populate_term );
$args = array(
'hide_empty' => false,
);
foreach( get_terms( $taxonomies, $args ) as $term ){
if( $selected_term == $term->term_id ){
$data['default_value'] = $term->term_id;
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 ) ){
$selected_terms = get_the_terms( $post->ID, $field_data['populate_term'] );
}else{
$selected_term = '';
}
$tmp_array[] = array( 'label' => $term->name, 'value' => $term->term_id );
if( is_array( $selected_terms ) ){
foreach( $selected_terms as $term ){
$selected_term = $term->term_id;
break;
}
} else {
$selected_term = '';
}
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(
'hide_empty' => false,
);
foreach( get_terms( $taxonomies, $args ) as $term ){
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;
}
$data['list']['options'] = apply_filters( 'ninja_forms_list_terms', $tmp_array, $field_id );
$data['list_show_value'] = 1;
return $data;
}
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,72 +3,76 @@
*
* 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 ){
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return $val;
// 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 ){
$field_row = ninja_forms_get_field_by_id( $field_id );
if ( $field_row['type'] == '_list' ) {
if ( isset( $field_row['data']['populate_term'] ) ) {
$tax = $field_row['data']['populate_term'];
if ( !is_array( $val ) ) {
if ( strpos( $val, "," ) !== false ) {
$val = explode( ",", $val );
}
}
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return $val;
if ( is_array( $val ) ) {
$tmp = '';
$x = 0;
foreach ( $val as $v ) {
$term_obj = get_term( $v, $tax );
if ( $term_obj AND !is_wp_error( $term_obj ) ) {
if ( $x == 0 ) {
$tmp .= $term_obj->name;
} else {
$tmp .= ', '.$term_obj->name;
$field_row = ninja_forms_get_field_by_id( $field_id );
if ( $field_row['type'] == '_list' ) {
if ( isset( $field_row['data']['populate_term'] ) ) {
$tax = $field_row['data']['populate_term'];
if ( !is_array( $val ) ) {
if ( strpos( $val, "," ) !== false ) {
$val = explode( ",", $val );
}
}
if ( is_array( $val ) ) {
$tmp = '';
$x = 0;
foreach ( $val as $v ) {
$term_obj = get_term( $v, $tax );
if ( $term_obj AND !is_wp_error( $term_obj ) ) {
if ( $x == 0 ) {
$tmp .= $term_obj->name;
} else {
$tmp .= ', '.$term_obj->name;
}
$x++;
}
$x++;
}
$val = $tmp;
} else {
$term_obj = get_term( $val, $tax );
if ( $term_obj AND !is_wp_error( $term_obj ) ) {
$val = $term_obj->name;
}
}
$val = $tmp;
} else {
$term_obj = get_term( $val, $tax );
if ( $term_obj AND !is_wp_error( $term_obj ) ) {
$val = $term_obj->name;
}
}
}
}
}
return $val;
}
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 ){
$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 );
}
// 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;
add_filter( 'ninja_forms_view_sub_td', 'ninja_forms_filter_term_ids_for_name_sub_td', 10, 3 );
*/
\ No newline at end of file
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
......@@ -3,31 +3,35 @@
*
* 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 ){
global $ninja_forms_processing;
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return false;
// 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 );
if ( !$add_field )
return false;
// Loop through our fields and see if we have a list field. If we do, check for the 'populate_term' setting.
$field_values = $ninja_forms_processing->get_all_fields();
if( is_array( $field_values ) ){
foreach( $field_values as $field_id => $user_value ){
$field_row = $ninja_forms_processing->get_field_settings( $field_id );
$field_type = $field_row['type'];
$field_data = $field_row['data'];
if( $field_type == '_list' AND isset( $field_data['populate_term'] ) AND $field_data['populate_term'] != '' ){
if( !is_array( $user_value ) ){
$user_value = array( $user_value );
// Loop through our fields and see if we have a list field. If we do, check for the 'populate_term' setting.
$field_values = $ninja_forms_processing->get_all_fields();
if( is_array( $field_values ) ){
foreach( $field_values as $field_id => $user_value ){
$field_row = $ninja_forms_processing->get_field_settings( $field_id );
$field_type = $field_row['type'];
$field_data = $field_row['data'];
if( $field_type == '_list' AND isset( $field_data['populate_term'] ) AND $field_data['populate_term'] != '' ){
if( !is_array( $user_value ) ){
$user_value = array( $user_value );
}
$ninja_forms_processing->update_form_setting( $field_data['populate_term'].'_terms', $user_value );
}
$ninja_forms_processing->update_form_setting( $field_data['populate_term'].'_terms', $user_value );
}
}
}
}
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;
}
$calc_eq = 'field_'.$sub_total.' + ( field_'.$sub_total.' * '.$tax_rate.' )';
}
// Figure out how many calculation fields we have and run
......
......@@ -25,7 +25,7 @@ function ninja_forms_register_field_desc(){
array('name' => 'h3', 'value' => 'h3'),
array('name' => 'h4', 'value' => 'h4'),
array('name' => 'h5', 'value' => 'h5'),
array('name' => 'h6', 'value' => 'h6'),
array('name' => 'h6', 'value' => 'h6'),
array('name' => 'p', 'value' => 'p'),
array('name' => 'span', 'value' => 'span'),
),
......
<?php
function ninja_forms_register_field_post_content(){
$add_field = apply_filters( 'ninja_forms_use_post_fields', false );
if ( !$add_field )
return false;
$args = array(
'name' => 'Content',
'edit_options' => array(
array(
'type' => 'checkbox', //What type of input should this be?
'name' => 'content_rte', //What should it be named. This should always be a programmatic name, not a label.
'label' => __('Show Rich Text Editor?', 'ninja-forms'),
'width' => 'wide',
//'class' => 'widefat', //Additional classes to be added to the input element.
),
array(
'type' => 'rte', //What type of input should this be?
'name' => 'default_value', //What should it be named. This should always be a programmatic name, not a label.