ninja_forms_field_credit_card_display

Function to display our credit_card field on the front-end.

Description

ninja_forms_field_credit_card_display( $field_id, $data, (string) $form_id = '' ); 

Parameters (3)

0. $field_id
The field id.
1. $data
The data.
2. $form_id — Optional. (string) => ''
The form id.

Usage

  1. if ( !function_exists( 'ninja_forms_field_credit_card_display' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/credit-card.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The data. 
  8. $data = null; 
  9.  
  10. // The form id. 
  11. $form_id = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = ninja_forms_field_credit_card_display($field_id, $data, $form_id); 
  15.  

Defined (1)

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

/deprecated/includes/fields/credit-card.php  
  1. function ninja_forms_field_credit_card_display( $field_id, $data, $form_id = '' ) { 
  2. global $ninja_forms_processing; 
  3.  
  4. if( isset( $data['default_value'] ) ) { 
  5. $default_value = $data['default_value']; 
  6. }else{ 
  7. $default_value = ''; 
  8.  
  9. if ( isset ( $data['label_pos'] ) ) { 
  10. $label_pos = $data['label_pos']; 
  11. } else { 
  12. $label_pos = 'above'; 
  13.  
  14. $cc_number_label = isset ( $data['cc_number_label'] ) ? $data['cc_number_label'] : __( 'Card Number', 'ninja-forms' ); 
  15. $cc_number_desc = isset ( $data['cc_number_desc'] ) ? $data['cc_number_desc'] : __( 'The (typically) 16 digits on the front of your credit card.', 'ninja-forms' ); 
  16.  
  17. $cc_cvc_label = isset ( $data['cc_cvc_label'] ) ? $data['cc_cvc_label'] : __( 'CVC', 'ninja-forms' ); 
  18. $cc_cvc_desc = isset ( $data['cc_cvc_desc'] ) ? $data['cc_cvc_desc'] : __( 'The 3 digit (back) or 4 digit (front) value on your card.', 'ninja-forms' ); 
  19.  
  20. $cc_name_label = isset ( $data['cc_name_label'] ) ? $data['cc_name_label'] : __( 'Name on the card', 'ninja-forms' ); 
  21. $cc_name_desc = isset ( $data['cc_name_desc'] ) ? $data['cc_name_desc'] : __( 'The name printed on the front of your credit card.', 'ninja-forms' ); 
  22.  
  23. $cc_exp_month_label = isset ( $data['cc_exp_month_label'] ) ? $data['cc_exp_month_label'] : __( 'Expiration month (MM)', 'ninja-forms' ); 
  24. $cc_exp_month_desc = isset ( $data['cc_exp_month_desc'] ) ? $data['cc_exp_month_desc'] : __( 'The month your credit card expires, typically on the front of the card.', 'ninja-forms' ); 
  25.  
  26. $cc_exp_year_label = isset ( $data['cc_exp_year_label'] ) ? $data['cc_exp_year_label'] : __( 'Expiration year (YYYY)', 'ninja-forms' ); 
  27. $cc_exp_year_desc = isset ( $data['cc_exp_year_desc'] ) ? $data['cc_exp_year_desc'] : __( 'The year your credit card expires, typically on the front of the card.', 'ninja-forms' ); 
  28.  
  29. if ( isset ( $ninja_forms_processing ) ) { 
  30. $name = $ninja_forms_processing->get_extra_value( '_credit_card_name' ); 
  31. $expiry_month = $ninja_forms_processing->get_extra_value( '_credit_card_expiry_month' ); 
  32. $expiry_year = $ninja_forms_processing->get_extra_value( '_credit_card_expiry_year' ); 
  33. $card_number_errors = $ninja_forms_processing->get_errors_by_location( 'credit_card_number' ); 
  34. $card_cvc_errors = $ninja_forms_processing->get_errors_by_location( 'credit_card_cvc' ); 
  35. $card_name_errors = $ninja_forms_processing->get_errors_by_location( 'credit_card_name' ); 
  36. $card_month_errors = $ninja_forms_processing->get_errors_by_location( 'credit_card_month' ); 
  37. $card_year_errors = $ninja_forms_processing->get_errors_by_location( 'credit_card_year' ); 
  38. } else { 
  39. $name = ''; 
  40. $expiry_month = ''; 
  41. $expiry_year = ''; 
  42. $card_number_errors = ''; 
  43. $card_cvc_errors = ''; 
  44. $card_name_errors = ''; 
  45. $card_month_errors = ''; 
  46. $card_year_errors = ''; 
  47.  
  48. $field_class = ninja_forms_get_field_class( $field_id, $form_id ); 
  49. $post_field = apply_filters( 'ninja_forms_post_credit_card_field', false ); 
  50. $desc_pos = apply_filters( 'ninja_forms_credit_card_field_desc_pos', 'after_label' ); 
  51. $hide_cc_fields = apply_filters( 'ninja_forms_hide_cc_field', array() ); 
  52.  
  53. if( !in_array( 'number' , $hide_cc_fields ) ) { 
  54. ?> 
  55. <div class="ninja-forms-credit-card-number label-<?php echo $label_pos; ?> field-wrap"> <!-- Open Credit Card Wrap --> 
  56. <?php 
  57. if ( $desc_pos == 'before_label' or $desc_pos == 'before_everything' ) { 
  58. ?> 
  59. <span><?php echo apply_filters( 'ninja_forms_credit_card_number_desc', $cc_number_desc ); ?></span> 
  60. <?php 
  61.  
  62. if ( $label_pos == 'above' or $label_pos == 'left' ) { 
  63. ?> 
  64. <label><?php echo apply_filters( 'ninja_forms_credit_card_cvc_label', $cc_number_label ); ?></label> 
  65. <?php 
  66.  
  67. if ( $desc_pos == 'after_label' ) { 
  68. ?> 
  69. <span><?php echo apply_filters( 'ninja_forms_credit_card_number_desc', $cc_number_desc ); ?></span> 
  70. <?php 
  71. ?> 
  72.  
  73. <input type="text" <?php if ( $post_field ) { echo 'name="_credit_card_number"'; } ?> class="ninja-forms-field card-number"> 
  74.  
  75. <?php 
  76. if ( $label_pos == 'below' or $label_pos == 'right' ) { 
  77. ?> 
  78. <label><?php echo apply_filters( 'ninja_forms_credit_card_cvc_label', $cc_number_label ); ?></label> 
  79. <?php 
  80.  
  81. if ( $desc_pos == 'after_everything' ) { 
  82. ?> 
  83. <span><?php echo apply_filters( 'ninja_forms_credit_card_number_desc', $cc_number_desc ); ?></span> 
  84. <?php 
  85. ?> 
  86. </div> 
  87. <div> 
  88. <div id="ninja_forms_field_credit_card_number_error" class="ninja-forms-credit-card-number-error ninja-forms-field-error"> 
  89. <?php 
  90. if ( $card_number_errors ) { 
  91. if( is_array( $card_number_errors ) ) { 
  92. foreach ( $card_number_errors as $error ) { 
  93. echo '<p>'.$error['msg'].'</p>'; 
  94. ?> 
  95. </div> 
  96. </div> 
  97. <?php 
  98.  
  99. if( !in_array( 'cvc' , $hide_cc_fields ) ) { 
  100.  
  101. ?> 
  102. <div class="ninja-forms-credit-card-cvc label-<?php echo $label_pos; ?> field-wrap"> <!-- [open_cvc_wrap] --> 
  103. <?php 
  104. if ( $desc_pos == 'before_label' or $desc_pos == 'before_everything' ) { 
  105. ?> 
  106. <span><?php echo apply_filters( 'ninja_forms_credit_card_cvc_desc', $cc_cvc_desc ); ?></span> 
  107. <?php 
  108.  
  109. if ( $label_pos == 'above' or $label_pos == 'left' ) { 
  110. ?> 
  111. <label><?php echo apply_filters( 'ninja_forms_credit_card_cvc_label', $cc_cvc_label ); ?></label> 
  112. <?php 
  113.  
  114. if ( $desc_pos == 'after_label' ) { 
  115. ?> 
  116. <span><?php echo apply_filters( 'ninja_forms_credit_card_cvc_desc', $cc_cvc_desc ); ?></span> 
  117. <?php 
  118. ?> 
  119.  
  120. <input type="text" <?php if ( $post_field ) { echo 'name="_credit_card_cvc"'; } ?> class="ninja-forms-field card-cvc"> 
  121.  
  122. <?php 
  123. if ( $label_pos == 'below' or $label_pos == 'right' ) { 
  124. ?> 
  125. <label><?php echo apply_filters( 'ninja_forms_credit_card_cvc_label', $cc_cvc_label ); ?></label> 
  126. <?php 
  127.  
  128. if ( $desc_pos == 'after_everything' ) { 
  129. ?> 
  130. <span><?php echo apply_filters( 'ninja_forms_credit_card_cvc_desc', $cc_cvc_desc ); ?></span> 
  131. <?php 
  132. ?> 
  133.  
  134. </div> 
  135. <div> 
  136. <div class="ninja-forms-credit-card-cvc-error ninja-forms-field-error"> 
  137. <?php 
  138. if ( $card_cvc_errors ) { 
  139. if( is_array( $card_cvc_errors ) ) { 
  140. foreach ( $card_cvc_errors as $error ) { 
  141. echo '<p>'.$error['msg'].'</p>'; 
  142. ?> 
  143. </div> 
  144. </div> 
  145. <?php 
  146.  
  147. if( !in_array( 'name' , $hide_cc_fields ) ) { 
  148.  
  149. ?>  
  150.  
  151. <div class="ninja-forms-credit-card-name label-<?php echo $label_pos; ?> field-wrap"> <!-- [open_nameoncard_wrap] --> 
  152. <?php 
  153. if ( $desc_pos == 'before_label' or $desc_pos == 'before_everything' ) { 
  154. ?> 
  155. <span><?php echo apply_filters( 'ninja_forms_credit_card_name_desc', $cc_name_desc ); ?></span> 
  156. <?php 
  157.  
  158. if ( $label_pos == 'above' or $label_pos == 'left' ) { 
  159. ?> 
  160. <label><?php echo apply_filters( 'ninja_forms_credit_card_name_label', $cc_name_label ); ?></label> 
  161. <?php 
  162.  
  163. if ( $desc_pos == 'after_label' ) { 
  164. ?> 
  165. <span><?php echo apply_filters( 'ninja_forms_credit_card_name_desc', $cc_name_desc ); ?></span> 
  166. <?php 
  167. ?> 
  168.  
  169. <input type="text" <?php if ( $post_field ) { echo 'name="_credit_card_name"'; } ?> class="ninja-forms-field card-name" value="<?php echo $name;?>"> 
  170.  
  171. <?php 
  172. if ( $label_pos == 'below' or $label_pos == 'right' ) { 
  173. ?> 
  174. <label><?php echo apply_filters( 'ninja_forms_credit_card_name_label', $cc_name_label ); ?></label> 
  175. <?php 
  176.  
  177. if ( $desc_pos == 'after_everything' ) { 
  178. ?> 
  179. <span><?php echo apply_filters( 'ninja_forms_credit_card_name_desc', $cc_name_desc ); ?></span> 
  180. <?php 
  181. ?> 
  182.  
  183. </div> 
  184. <div> 
  185. <div class="ninja-forms-credit-card-name-error ninja-forms-field-error"> 
  186. <?php 
  187. if ( $card_name_errors ) { 
  188. if( is_array( $card_name_errors ) ) { 
  189. foreach ( $card_name_errors as $error ) { 
  190. echo '<p>'.$error['msg'].'</p>'; 
  191. ?> 
  192. </div> 
  193. </div> 
  194. <?php 
  195.  
  196. if( !in_array( 'expires' , $hide_cc_fields ) ) { 
  197.  
  198. ?> 
  199. <div class="ninja-forms-credit-card-exp-month label-<?php echo $label_pos; ?> field-wrap"> <!-- [open_expires_wrap] --> 
  200. <?php 
  201. if ( $desc_pos == 'before_label' or $desc_pos == 'before_everything' ) { 
  202. ?> 
  203. <span><?php echo apply_filters( 'ninja_forms_credit_card_exp_month_desc', $cc_exp_month_desc ); ?></span> 
  204. <?php 
  205.  
  206. if ( $label_pos == 'above' or $label_pos == 'left' ) { 
  207. ?> 
  208. <label><?php echo apply_filters( 'ninja_forms_credit_card_exp_month_label', $cc_exp_month_label ); ?></label> 
  209. <?php 
  210.  
  211. if ( $desc_pos == 'after_label' ) { 
  212. ?> 
  213. <span><?php echo apply_filters( 'ninja_forms_credit_card_exp_month_desc', $cc_exp_month_desc ); ?></span> 
  214. <?php 
  215. ?> 
  216.  
  217. <input type="text" <?php if ( $post_field ) { echo 'name="_credit_card_expires_month"'; } ?> class="ninja-forms-field ninja-forms-mask card-expiry-month" data-mask="99" value="<?php echo $expiry_month;?>"> 
  218.  
  219. <?php 
  220. if ( $label_pos == 'below' or $label_pos == 'right' ) { 
  221. ?> 
  222. <label><?php echo apply_filters( 'ninja_forms_credit_card_exp_month_label', $cc_exp_month_label ); ?></label> 
  223. <?php 
  224.  
  225. if ( $desc_pos == 'after_everything' ) { 
  226. ?> 
  227. <span><?php echo apply_filters( 'ninja_forms_credit_card_exp_month_desc', $cc_exp_month_desc ); ?></span> 
  228. <?php 
  229. ?> 
  230.  
  231. </div> 
  232. <div> 
  233. <div class="ninja-forms-credit-card-exp-month-error ninja-forms-field-error"> 
  234. <?php 
  235. if ( $card_month_errors ) { 
  236. if( is_array( $card_month_errors ) ) { 
  237. foreach ( $card_month_errors as $error ) { 
  238. echo '<p>'.$error['msg'].'</p>'; 
  239. ?> 
  240. </div> <!-- [close_exp_month_wrap] --> 
  241. </div> 
  242. <div class="ninja-forms-credit-card-exp-year label-<?php echo $label_pos; ?> field-wrap"> <!-- [open_exp_year_wrap] --> 
  243. <?php 
  244. if ( $desc_pos == 'before_label' or $desc_pos == 'before_everything' ) { 
  245. ?> 
  246. <span><?php echo apply_filters( 'ninja_forms_credit_card_exp_year_desc', $cc_exp_year_desc ); ?></span> 
  247. <?php 
  248.  
  249. if ( $label_pos == 'above' or $label_pos == 'left' ) { 
  250. ?> 
  251. <label><?php echo apply_filters( 'ninja_forms_credit_card_exp_year_label', $cc_exp_year_label ); ?></label> 
  252. <?php 
  253.  
  254. if ( $desc_pos == 'after_label' ) { 
  255. ?> 
  256. <span><?php echo apply_filters( 'ninja_forms_credit_card_exp_year_desc', $cc_exp_year_desc ); ?></span> 
  257. <?php 
  258. ?> 
  259.  
  260. <input type="text" <?php if ( $post_field ) { echo 'name="_credit_card_expires_year"'; } ?> class="ninja-forms-field ninja-forms-mask card-expiry-year" data-mask="9999" value="<?php echo $expiry_year;?>"> 
  261.  
  262. <?php 
  263. if ( $label_pos == 'below' or $label_pos == 'right' ) { 
  264. ?> 
  265. <label><?php echo apply_filters( 'ninja_forms_credit_card_exp_year_label', $cc_exp_year_label ); ?></label> 
  266. <?php 
  267.  
  268. if ( $desc_pos == 'after_everything' ) { 
  269. ?> 
  270. <span><?php echo apply_filters( 'ninja_forms_credit_card_exp_year_desc', $cc_exp_year_desc ); ?></span> 
  271. <?php 
  272. ?> 
  273.  
  274. </div> 
  275. <div> 
  276. <div class="ninja-forms-credit-card-exp-year-error ninja-forms-field-error"> 
  277. <?php 
  278. if ( $card_year_errors ) { 
  279. if( is_array( $card_year_errors ) ) { 
  280. foreach ( $card_year_errors as $error ) { 
  281. echo '<p>'.$error['msg'].'</p>'; 
  282. ?> 
  283. </div> <!-- [close_exp_month_wrap] --> 
  284. </div> 
  285. <?php