| @@ 55-66 (lines=12) @@ | ||
| 52 | * @param array $input Array of field names and values. |
|
| 53 | * @return Field $this |
|
| 54 | */ |
|
| 55 | public function set_value_from_input( $input ) { |
|
| 56 | if ( ! isset( $input[ $this->name ] ) ) { |
|
| 57 | $this->set_value( array() ); |
|
| 58 | } else { |
|
| 59 | $value = stripslashes_deep( $input[ $this->name ] ); |
|
| 60 | if ( is_array( $value ) ) { |
|
| 61 | $value = array_values( $value ); |
|
| 62 | } |
|
| 63 | $this->set_value( $value ); |
|
| 64 | } |
|
| 65 | return $this; |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Returns an array that holds the field data, suitable for JSON representation. |
|
| @@ 121-132 (lines=12) @@ | ||
| 118 | * @param array $input Array of field names and values. |
|
| 119 | * @return Field $this |
|
| 120 | */ |
|
| 121 | public function set_value_from_input( $input ) { |
|
| 122 | if ( ! isset( $input[ $this->name ] ) ) { |
|
| 123 | $this->set_value( array() ); |
|
| 124 | } else { |
|
| 125 | $value = stripslashes_deep( $input[ $this->name ] ); |
|
| 126 | if ( is_array( $value ) ) { |
|
| 127 | $value = array_values( $value ); |
|
| 128 | } |
|
| 129 | $this->set_value( $value ); |
|
| 130 | } |
|
| 131 | return $this; |
|
| 132 | } |
|
| 133 | ||
| 134 | /** |
|
| 135 | * Converts the field values into a usable associative array. |
|