ninja_forms_edit_field_el_output

The Ninja Forms ninja forms edit field el output function.

Description

ninja_forms_edit_field_el_output( $field_id, $type, (string) $label = '', (string) $name = '', (string) $value = '', (string) $width = 'wide', (string) $options = '', (string) $class = '', (string) $desc = '', (string) $label_class = '' ); 

Parameters (10)

0. $field_id
The field id.
1. $type
The type.
2. $label — Optional. (string) => ''
The label.
3. $name — Optional. (string) => ''
The name.
4. $value — Optional. (string) => ''
The value.
5. $width — Optional. (string) => 'wide'
The width.
6. $options — Optional. (string) => ''
The options.
7. $class — Optional. (string) => ''
The class.
8. $desc — Optional. (string) => ''
The desc.
9. $label_class — Optional. (string) => ''
The label class.

Usage

  1. if ( !function_exists( 'ninja_forms_edit_field_el_output' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/admin/edit-field/edit-field.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The type. 
  8. $type = null; 
  9.  
  10. // The label. 
  11. $label = ''; 
  12.  
  13. // The name. 
  14. $name = ''; 
  15.  
  16. // The value. 
  17. $value = ''; 
  18.  
  19. // The width. 
  20. $width = 'wide'; 
  21.  
  22. // The options. 
  23. $options = ''; 
  24.  
  25. // The class. 
  26. $class = ''; 
  27.  
  28. // The desc. 
  29. $desc = ''; 
  30.  
  31. // The label class. 
  32. $label_class = ''; 
  33.  
  34. // NOTICE! Understand what this does before running. 
  35. $result = ninja_forms_edit_field_el_output($field_id, $type, $label, $name, $value, $width, $options, $class, $desc, $label_class); 
  36.  

Defined (1)

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

/deprecated/includes/admin/edit-field/edit-field.php  
  1. function ninja_forms_edit_field_el_output($field_id, $type, $label = '', $name = '', $value = '', $width = 'wide', $options = '', $class = '', $desc = '', $label_class = '' ) { 
  2. global $ninja_forms_fields, $nf_rte_editors; 
  3.  
  4. $field_row = ninja_forms_get_field_by_id($field_id); 
  5. $field_type = $field_row['type']; 
  6. $reg_field = $ninja_forms_fields[$field_type]; 
  7.  
  8. $class = 'code ninja-forms-'.$field_type.'-'.$name.' '.$class; 
  9. $id = 'ninja_forms_field_'.$field_id.'_'.$name; 
  10. if ( strpos( $name, '[' ) !== false ) { 
  11. str_replace( ']', '', $name ); 
  12. $name = explode( '[', $name ); 
  13. if ( is_array ( $name ) ) { 
  14. $tmp_name = 'ninja_forms_field_'.$field_id; 
  15. foreach ( $name as $n ) { 
  16. $tmp_name .= '['.$n.']'; 
  17. $name = $tmp_name; 
  18. } else { 
  19. $name = 'ninja_forms_field_'.$field_id.'['.$name.']'; 
  20. } else { 
  21. $name = 'ninja_forms_field_'.$field_id.'['.$name.']'; 
  22.  
  23. ?> 
  24. <div class="description description-<?php echo $width;?> <?php echo $type;?>" id="<?php echo $name;?>_p"> 
  25. <?php 
  26. if($type != 'rte') { 
  27. $value = ninja_forms_esc_html_deep( $value ); 
  28. ?> 
  29. <span class="field-option"> 
  30. <?php 
  31. if($type != 'checkbox' AND $type != 'desc') { 
  32. ?> 
  33. <label for="<?php echo $id;?>" id="<?php echo $id;?>_label" class="<?php echo $label_class;?>"> 
  34. <?php _e( $label , 'ninja-forms'); ?></label><br/> 
  35. <?php 
  36. switch($type) { 
  37. case 'text': 
  38. ?> 
  39. <input type="text" class="<?php echo $class;?>" name="<?php echo $name;?>" id="<?php echo $id;?>" value="<?php echo $value;?>" /> 
  40. <?php 
  41. break; 
  42. case 'number': 
  43. ?> 
  44. <input type="number" class="<?php echo $class;?>" name="<?php echo $name;?>" id="<?php echo $id;?>" value="<?php echo $value;?>" /> 
  45. <?php 
  46. break; 
  47. case 'checkbox': 
  48. ?> 
  49. <label for="<?php echo $id;?>" id="<?php echo $id;?>_label"> 
  50. <input type="hidden" value="0" name="<?php echo $name;?>"> 
  51. <input type="checkbox" value="1" name="<?php echo $name;?>" id="<?php echo $id;?>" class="<?php echo $class;?>" <?php checked($value, 1);?>> 
  52. <?php _e( $label , 'ninja-forms'); ?> 
  53. </label> 
  54. <?php 
  55. break; 
  56. case 'select': 
  57. ?> 
  58. <select id="<?php echo $id;?>" name="<?php echo $name;?>" class="<?php echo $class;?>"> 
  59. <?php 
  60. if(is_array($options) AND !empty($options)) { 
  61. foreach($options as $opt) { 
  62. ?> 
  63. <option value="<?php echo $opt['value'];?>" <?php selected($opt['value'], $value); ?> ><?php _e( $opt['name'], 'ninja-forms'); ?></option> 
  64. <?php 
  65. ?> 
  66. </select> 
  67. <?php 
  68. break; 
  69. case 'multi': 
  70. ?> 
  71. <select multiple="multiple" id="<?php echo $id;?>" name="<?php echo $name;?>" class="<?php echo $class;?>"> 
  72. <?php 
  73. if(is_array($options) AND !empty($options)) { 
  74. foreach($options as $opt) { 
  75. ?> 
  76. <option value="<?php echo $opt['value'];?>" <?php selected($opt['value'], $value); ?> ><?php _e( $opt['name'], 'ninja-forms'); ?></option> 
  77. <?php 
  78. ?> 
  79. </select> 
  80. <?php 
  81. break; 
  82. case 'textarea': 
  83. ?> 
  84. <textarea id="<?php echo $id;?>" name="<?php echo $name;?>" class="<?php echo $class;?>" rows="3" cols="20" ><?php echo $value;?></textarea> 
  85. <?php 
  86. break; 
  87. case 'hidden': 
  88. ?> 
  89. <input type="hidden" name="<?php echo $name;?>" value="<?php echo $value;?>"> 
  90. <?php 
  91. break; 
  92. case 'desc': 
  93. ?> 
  94. <span class="desc"><label for="<?php echo $id;?>" id="<?php echo $id;?>_label"><?php _e($label, 'ninja-forms'); ?></label></span> 
  95. <?php 
  96. break; 
  97. case 'rte': 
  98. // Check if our current user has the RTE disabled. 
  99. $user_id = get_current_user_id(); 
  100. $rich_editing = get_user_meta( $user_id, 'rich_editing', true ); 
  101. if ( 'true' == $rich_editing ) { 
  102. $editor_id = str_replace( '[', '_', $name ); 
  103. $editor_id = str_replace( ']', '', $editor_id ); 
  104.  
  105. $plugin_settings = nf_get_settings(); 
  106. if ( !isset( $plugin_settings['version_2_2_25_rte_fix'] ) OR $plugin_settings['version_2_2_25_rte_fix'] == '' ) { 
  107. $value = html_entity_decode( $value ); 
  108. $plugin_settings['version_2_2_25_rte_fix'] = 1; 
  109. update_option( 'ninja_forms_settings', $plugin_settings ); 
  110.  
  111. $args = apply_filters( 'ninja_forms_edit_field_rte', array( 'textarea_name' => $name ) ); 
  112. wp_editor( $value, $editor_id, $args );  
  113.  
  114. // If we're using ajax, add this editor ID to our global var so that we can instantiate it on the front-end. 
  115. if ( isset ( $_POST['action'] ) && ( $_POST['action'] == 'ninja_forms_new_field' || $_POST['action'] == 'nf_output_field_settings_html' ) ) 
  116. $nf_rte_editors[] = $editor_id; 
  117. } else { 
  118. ?> 
  119. <textarea id="<?php echo $id;?>" name="<?php echo $name;?>" class="<?php echo $class;?>" rows="3" cols="20" ><?php echo $value;?></textarea> 
  120. <?php 
  121.  
  122. break; 
  123.  
  124. if($desc != '') { 
  125. ?> 
  126. <span class="description"> 
  127. <?php _e($desc, 'ninja-forms'); ?> 
  128. </span> 
  129. <?php 
  130. if($type != 'rte') { 
  131. ?> 
  132. </span> 
  133. <?php 
  134. ?> 
  135. </div> 
  136. <?php