CMB2_Type_Picker_Base

CMB Picker base field type.

Defined (1)

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

/vendor/wordimpress/maps-builder-core/includes/libraries/metabox/includes/types/CMB2_Type_Picker_Base.php  
  1. abstract class CMB2_Type_Picker_Base extends CMB2_Type_Text { 
  2.  
  3. /** 
  4. * Parse the picker attributes. 
  5. * @since 2.2.0 
  6. * @param string $arg 'date' or 'time' 
  7. * @param array $args Optional arguments to modify (else use $this->field->args['attributes']) 
  8. * @return array Array of field attributes 
  9. */ 
  10. public function parse_picker_options( $arg = 'date', $args = array() ) { 
  11. $att = 'data-' . $arg . 'picker'; 
  12. $update = empty( $args ); 
  13. $atts = array(); 
  14. $format = $this->field->args( $arg . '_format' ); 
  15.  
  16. if ( $js_format = cmb2_utils()->php_to_js_dateformat( $format ) ) { 
  17.  
  18. if ( $update ) { 
  19. $atts = $this->field->args( 'attributes' ); 
  20. } else { 
  21. $atts = isset( $args['attributes'] ) 
  22. ? $args['attributes'] 
  23. : $atts; 
  24.  
  25. // Don't override user-provided datepicker values 
  26. $data = isset( $atts[ $att ] ) 
  27. ? json_decode( $atts[ $att ], true ) 
  28. : array(); 
  29.  
  30. $data[ $arg . 'Format' ] = $js_format; 
  31. $atts[ $att ] = function_exists( 'wp_json_encode' ) 
  32. ? wp_json_encode( $data ) 
  33. : json_encode( $data ); 
  34.  
  35. if ( $update ) { 
  36. $this->field->args['attributes'] = $atts; 
  37.  
  38. return array_merge( $args, $atts );