date-field-parser.php
4 years ago
datetime-field-parser.php
4 years ago
datetime-trait.php
4 years ago
media-field-parser.php
4 years ago
repeater-field-parser.php
4 years ago
text-field-parser.php
4 years ago
wysiwyg-field-parser.php
4 years ago
media-field-parser.php
28 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Request\Fields; |
| 5 | |
| 6 | use Jet_Form_Builder\Request\Field_Data_Parser; |
| 7 | |
| 8 | class Media_Field_Parser extends Field_Data_Parser { |
| 9 | |
| 10 | public function type() { |
| 11 | return 'media-field'; |
| 12 | } |
| 13 | |
| 14 | public function get_response() { |
| 15 | $value = json_decode( wp_unslash( $this->value ), true ); |
| 16 | |
| 17 | if ( ! empty( $this->settings['insert_attachment'] ) && ! empty( $this->settings['value_format'] ) ) { |
| 18 | |
| 19 | if ( 'id' === $this->settings['value_format'] ) { |
| 20 | $value = absint( $value ); |
| 21 | } elseif ( is_array( $value ) ) { |
| 22 | $value = implode( ',', $value ); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | return $value; |
| 27 | } |
| 28 | } |