Exemplo n.º 1
0
 public function select_timezone()
 {
     $this->field->args['default'] = $this->field->args('default') ? $this->field->args('default') : cmb_Meta_Box::timezone_string();
     $meta_value = $this->field->escaped_value();
     return '<select name="' . $this->_name() . '" id="' . $this->_id() . '">' . wp_timezone_choice($meta_value) . '</select>';
 }
Exemplo n.º 2
0
 /**
  * Datetime to imestamp with timezone
  * @since  1.0.1
  * @param  string $value Meta value
  * @return string       Timestring
  */
 public function text_datetime_timestamp_timezone($value, $repeat = false)
 {
     $test = is_array($value) ? array_filter($value) : '';
     if (empty($test)) {
         return '';
     }
     if ($repeat_value = $this->_check_repeat($value, __FUNCTION__, $repeat)) {
         return $repeat_value;
     }
     $tzstring = null;
     if (is_array($value) && array_key_exists('timezone', $value)) {
         $tzstring = $value['timezone'];
     }
     if (empty($tzstring)) {
         $tzstring = cmb_Meta_Box::timezone_string();
     }
     $offset = cmb_Meta_Box::timezone_offset($tzstring, true);
     if (substr($tzstring, 0, 3) === 'UTC') {
         $tzstring = timezone_name_from_abbr('', $offset, 0);
     }
     $value = new DateTime($value['date'] . ' ' . $value['time'], new DateTimeZone($tzstring));
     $value = serialize($value);
     return $value;
 }
Exemplo n.º 3
0
 public static function select_timezone($field, $meta)
 {
     $meta = '' !== $meta ? $meta : $field['std'];
     if ('' === $meta) {
         $meta = cmb_Meta_Box::timezone_string();
     }
     echo '<select name="', $field['id'], '" id="', $field['id'], '">';
     echo wp_timezone_choice($meta);
     echo '</select>';
 }
 /**
  * Datetime to imestamp with timezone
  * @since  1.0.1
  * @param  string $meta Meta value
  * @return string       Timestring
  */
 public static function text_datetime_timestamp_timezone($meta)
 {
     $test = is_array($meta) ? array_filter($meta) : '';
     if (empty($test)) {
         return '';
     }
     $tzstring = null;
     if (is_array($meta) && array_key_exists('timezone', $meta)) {
         $tzstring = $meta['timezone'];
     }
     if (empty($tzstring)) {
         $tzstring = cmb_Meta_Box::timezone_string();
     }
     $offset = cmb_Meta_Box::timezone_offset($tzstring, true);
     if (substr($tzstring, 0, 3) === 'UTC') {
         $tzstring = timezone_name_from_abbr('', $offset, 0);
     }
     $meta = new DateTime($meta['date'] . ' ' . $meta['time'], new DateTimeZone($tzstring));
     $meta = serialize($meta);
     return $meta;
 }