Caldera_Forms_Field_Credit

A class for adding non-removable hooks to prevent saving of credit card details.

Defined (1)

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

/classes/field/credit.php  
  1. class Caldera_Forms_Field_Credit { 
  2.  
  3. /** 
  4. * Caldera_Forms_Field_Credit constructor. 
  5. * Adds hooks 
  6. * @since 1.5.0 
  7. */ 
  8. public function __construct() { 
  9. add_filter( 'caldera_forms_save_field_credit_card_number', array( $this, 'credit_card_number' ) ); 
  10. add_filter( 'caldera_forms_save_field_credit_card_cvc', array( $this, 'credit_card_cvc' ) ); 
  11.  
  12. /** 
  13. * Replace all but last 4 of credit card with Xs 
  14. * @uses "caldera_forms_save_field_credit_card_number" filter. 
  15. * @since 1.5.0 
  16. * @param string $number Credit card number 
  17. * @return string 
  18. */ 
  19. public function credit_card_number( $number ) { 
  20. return substr_replace($number, str_repeat('X', strlen( $number ) - 4), 0, strlen( $number ) - 4); 
  21.  
  22. /** 
  23. * Replace credit card secret code with Xs 
  24. * @uses "caldera_forms_save_field_credit_card_cvc" 
  25. * @since 1.5.0 
  26. * @param string $number Secret code 
  27. * @return string 
  28. */ 
  29. public function credit_card_cvc( $number ) { 
  30. return str_repeat('X', strlen( $number ) ); 
  31.