/includes/Fields/Date.php

  1. <?php if ( ! defined( 'ABSPATH' ) ) exit; 
  2.  
  3. /** 
  4. * Class NF_Fields_Date 
  5. */ 
  6. class NF_Fields_Date extends NF_Fields_Textbox 
  7. protected $_name = 'date'; 
  8.  
  9. protected $_nicename = 'Date'; 
  10.  
  11. protected $_section = 'common'; 
  12.  
  13. protected $_icon = 'calendar'; 
  14.  
  15. protected $_type = 'date'; 
  16.  
  17. protected $_templates = 'date'; 
  18.  
  19. protected $_test_value = '12/12/2022'; 
  20.  
  21. protected $_settings = array( 'date_default', 'date_format', 'year_range' ); 
  22.  
  23. protected $_settings_exclude = array( 'default', 'placeholder', 'input_limit_set', 'disable_input' ); 
  24.  
  25. public function __construct() 
  26. parent::__construct(); 
  27.  
  28. $this->_nicename = __( 'Date', 'ninja-forms' ); 
  29.  
  30. public function process( $field, $data ) 
  31. return $data; 
  32.  
  33. private function get_format( $format ) 
  34. $lookup = array( 
  35. 'MM/DD/YYYY' => __( 'm/d/Y', 'ninja-forms' ),  
  36. 'MM-DD-YYYY' => __( 'm-d-Y', 'ninja-forms' ),  
  37. 'MM.DD.YYYY' => __( 'm.d.Y', 'ninja-forms' ),  
  38. 'DD/MM/YYYY' => __( 'm/d/Y', 'ninja-forms' ),  
  39. 'DD-MM-YYYY' => __( 'd-m-Y', 'ninja-forms' ),  
  40. 'DD.MM.YYYY' => __( 'd.m.Y', 'ninja-forms' ),  
  41. 'YYYY-MM-DD' => __( 'Y-m-d', 'ninja-forms' ),  
  42. 'YYYY/MM/DD' => __( 'Y/m/d', 'ninja-forms' ),  
  43. 'YYYY.MM.DD' => __( 'Y.m.d', 'ninja-forms' ),  
  44. 'dddd, MMMM D YYYY' => __( 'l, F d Y', 'ninja-forms' ),  
  45.  
  46.  
  47.  
  48.  
  49. ); 
  50.  
  51. return ( isset( $lookup[ $format ] ) ) ? $lookup[ $format ] : $format; 
  52.  
.