CMB2_Type_Text_Datetime_Timestamp_Timezone

CMB text_datetime_timestamp_timezone 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_Text_Datetime_Timestamp_Timezone.php  
  1. class CMB2_Type_Text_Datetime_Timestamp_Timezone extends CMB2_Type_Base { 
  2.  
  3. public function render() { 
  4. $field = $this->field; 
  5.  
  6. $args = wp_parse_args( $this->args, array( 
  7. 'value' => $field->escaped_value(),  
  8. 'desc' => $this->_desc( true ),  
  9. 'text_datetime_timestamp' => array(),  
  10. 'select_timezone' => array(),  
  11. ) ); 
  12.  
  13. $args['value'] = $field->escaped_value(); 
  14. if ( is_array( $args['value'] ) ) { 
  15. $args['value'] = ''; 
  16.  
  17. $datetime = maybe_unserialize( $args['value'] ); 
  18. $value = $tzstring = ''; 
  19.  
  20. if ( $datetime && $datetime instanceof DateTime ) { 
  21. $tz = $datetime->getTimezone(); 
  22. $tzstring = $tz->getName(); 
  23. $value = $datetime->getTimestamp(); 
  24.  
  25. $timestamp_args = wp_parse_args( $args['text_datetime_timestamp'], array( 
  26. 'desc' => '',  
  27. 'value' => $value,  
  28. 'rendered' => true,  
  29. ) ); 
  30. $datetime_timestamp = $this->types->text_datetime_timestamp( $timestamp_args ); 
  31.  
  32. $timezone_select_args = wp_parse_args( $args['select_timezone'], array( 
  33. 'class' => 'cmb2_select cmb2-select-timezone',  
  34. 'name' => $this->_name( '[timezone]' ),  
  35. 'id' => $this->_id( '_timezone' ),  
  36. 'options' => wp_timezone_choice( $tzstring ),  
  37. 'desc' => $args['desc'],  
  38. 'rendered' => true,  
  39. ) ); 
  40. $select = $this->types->select( $timezone_select_args ); 
  41.  
  42. return $this->rendered( 
  43. $datetime_timestamp . "\n" . $select 
  44. ); 
  45.