| @@ -398,9 +398,9 @@ | ||
| 398 | 398 | $this->value = $utc_stamp = ''; |
| 399 | 399 | } else { |
| 400 | 400 | $datetime->setTimezone( new DateTimeZone( $tzstring ) ); |
| 401 | 401 | $utc_stamp = date_timestamp_get( $datetime ) - $offset; |
| 402 | - $this->value = serialize( $datetime ); | |
| 402 | + $this->value = json_encode( $datetime ); | |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | if ( $this->field->group ) { |
| 406 | 406 | $this->value = array( |
| @@ -430,12 +430,9 @@ | ||
| 430 | 430 | * @since 1.0.1 |
| 431 | 431 | * @return string Sanitized data |
| 432 | 432 | */ |
| 433 | 433 | public function textarea() { |
| 434 | - if ( $this->value === null ) | |
| 435 | - $this->value = ''; | |
| 436 | - | |
| 437 | - return is_array( $this->value ) ? array_map( 'wp_kses_post', $this->value ) : wp_kses_post( $this->value ); | |
| 434 | + return is_array( $this->value ) ? array_map( 'wp_kses_post', $this->value ) : ( $this->value !== null ? wp_kses_post( $this->value ) : '' ); | |
| 438 | 435 | } |
| 439 | 436 | |
| 440 | 437 | /** |
| 441 | 438 | * Sanitize code textareas |
| @@ -450,9 +447,9 @@ | ||
| 450 | 447 | if ( false !== $repeat_value ) { |
| 451 | 448 | return $repeat_value; |
| 452 | 449 | } |
| 453 | 450 | |
| 454 | - return htmlspecialchars_decode( stripslashes( $this->value ) ); | |
| 451 | + return htmlspecialchars_decode( stripslashes( $this->value ), ENT_COMPAT ); | |
| 455 | 452 | } |
| 456 | 453 | |
| 457 | 454 | /** |
| 458 | 455 | * Handles saving of attachment post ID and sanitizing file url |
| @@ -487,9 +484,9 @@ | ||
| 487 | 484 | $base_id = $this->field->group->_id( '', false ); |
| 488 | 485 | $i = $this->field->group->index; |
| 489 | 486 | |
| 490 | 487 | // Check group $alldata data. |
| 491 | - $id_val = isset( $alldata[ $base_id ][ $i ][ $id_key ] ) | |
| 488 | + $id_val = isset( $alldata[ $base_id ][ $i ][ $id_key ] ) | |
| 492 | 489 | ? absint( $alldata[ $base_id ][ $i ][ $id_key ] ) |
| 493 | 490 | : ''; |
| 494 | 491 | |
| 495 | 492 | // We don't want to save 0 to the DB for file fields. |
| @@ -523,9 +520,9 @@ | ||
| 523 | 520 | // If there is no ID saved yet, try to get it from the url. |
| 524 | 521 | if ( $this->value && ! $id_val ) { |
| 525 | 522 | $id_val = CMB2_Utils::image_id_from_url( $this->value ); |
| 526 | 523 | |
| 527 | - // If there is an ID but user emptied the input value, remove the ID. | |
| 524 | + // If there is an ID but user emptied the input value, remove the ID. | |
| 528 | 525 | } elseif ( ! $this->value && $id_val ) { |
| 529 | 526 | $id_val = null; |
| 530 | 527 | } |
| 531 | 528 | |
| @@ -575,9 +572,9 @@ | ||
| 575 | 572 | |
| 576 | 573 | $values_array = $this->value; |
| 577 | 574 | |
| 578 | 575 | $new_value = array(); |
| 579 | - foreach ( $values_array as $iterator => $this->value ) { | |
| 576 | + foreach ( $values_array as $this->value ) { | |
| 580 | 577 | if ( $this->value ) { |
| 581 | 578 | $val = $this->$method( true ); |
| 582 | 579 | if ( ! empty( $val ) ) { |
| 583 | 580 | $new_value[] = $val; |