ninja_forms_edit_field_list_term

The Ninja Forms ninja forms edit field list term function.

Description

ninja_forms_edit_field_list_term( $field_id, $field_data ); 

Parameters (2)

0. $field_id
The field id.
1. $field_data
The field data.

Usage

  1. if ( !function_exists( 'ninja_forms_edit_field_list_term' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/edit-field/list-terms.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The field data. 
  8. $field_data = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ninja_forms_edit_field_list_term($field_id, $field_data); 
  12.  

Defined (1)

The function is defined in the following location(s).

/deprecated/includes/admin/edit-field/list-terms.php  
  1. function ninja_forms_edit_field_list_term( $field_id, $field_data ) { 
  2. $add_field = apply_filters( 'ninja_forms_use_post_fields', false ); 
  3. if ( !$add_field ) 
  4. return false; 
  5.  
  6. $field_row = ninja_forms_get_field_by_id( $field_id ); 
  7. $field_type = $field_row['type']; 
  8.  
  9. if( isset( $field_data['populate_term'] ) ) { 
  10. $populate_term = $field_data['populate_term']; 
  11. }else{ 
  12. $populate_term = ''; 
  13.  
  14. if ( $populate_term != '' ) { 
  15. $display = ''; 
  16. } else { 
  17. $display = 'style="display:none;"'; 
  18.  
  19. $form_row = ninja_forms_get_form_by_field_id( $field_id ); 
  20.  
  21. if( isset( $form_row['data']['post_type'] ) ) { 
  22. $post_type = $form_row['data']['post_type']; 
  23. }else{ 
  24. $post_type = ''; 
  25.  
  26. if( $field_type == '_list' AND $post_type != '' ) { 
  27. ?> 
  28. <div> 
  29. <hr> 
  30. <label> 
  31. <?php _e( 'Populate this with the taxonomy', 'ninja-forms' );?>:  
  32. </label> 
  33. <select name="ninja_forms_field_<?php echo $field_id;?>[populate_term]" class="ninja-forms-list-populate-term" rel="<?php echo $field_id;?>"> 
  34. <option value=""><?php _e( '- None', 'ninja-forms' );?></option> 
  35. <?php 
  36. // Get a list of terms registered to the post type set above and loop through them. 
  37. foreach ( get_object_taxonomies( $post_type ) as $tax_name ) { 
  38. if( $tax_name != 'post_tag' AND $tax_name != 'post_status' AND $tax_name != 'post_format' ) { 
  39. $tax = get_taxonomy( $tax_name ); 
  40. ?> 
  41. <option value="<?php echo $tax_name;?>" <?php selected( $populate_term, $tax_name );?>><?php echo $tax->labels->name;?></option> 
  42. <?php 
  43. ?> 
  44. </select> 
  45. <div id="ninja_forms_field_<?php echo $field_id;?>_exclude_terms" <?php echo $display;?>> 
  46. <?php ninja_forms_list_terms_checkboxes( $field_id, $populate_term ); ?> 
  47. </div> 
  48. <br /> 
  49. <hr> 
  50. </div> 
  51. <?php