Skip to content

Commit

Permalink
Move ?? operator from get_source_values back to `get_unprefixed_f…
Browse files Browse the repository at this point in the history
…ields`

 because `$_POST` may not include all these values.

Co-authored-by: Justin Palmer <228780+layoutd@users.noreply.github.com>
  • Loading branch information
tomalec and layoutd committed Nov 27, 2023
1 parent 55b3ab1 commit c28b0a9
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private function get_unprefixed_fields( array $raw_values = array() ): array {

// Look through each field in POST data.
foreach ( $this->fields as $field ) {
$values[ $field ] = $raw_values[ $this->get_prefixed_field( $field ) ];
$values[ $field ] = $raw_values[ $this->get_prefixed_field( $field ) ] ?? '(none)';
}

return $values;
Expand All @@ -262,7 +262,7 @@ private function get_source_values( array $raw_values = array() ): array {

// Look through each field in given data.
foreach ( $this->fields as $field ) {
$value = sanitize_text_field( wp_unslash( $raw_values[ $field ] ?? '(none)' ) );
$value = sanitize_text_field( wp_unslash( $raw_values[ $field ] ) );
if ( '(none)' === $value ) {
continue;
}
Expand Down

0 comments on commit c28b0a9

Please sign in to comment.