| @@ -22,8 +22,11 @@ | ||
| 22 | 22 | return $this->transformer->toApi( $raw ); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function update( int $tour_id, array $api_data ): bool { |
| 26 | + $api_data['tourId'] = $tour_id; | |
| 27 | + $api_data['id'] = $tour_id; | |
| 28 | + | |
| 26 | 29 | // Read existing panodata first so we can preserve pro-managed fields |
| 27 | 30 | // that the free transformer does not handle. |
| 28 | 31 | $existing_raw = $this->repository->find( $tour_id ); |
| 29 | 32 | |
| @@ -37,8 +40,13 @@ | ||
| 37 | 40 | // Merge: existing supplies fields unknown to the new editor; transformed |
| 38 | 41 | // values overwrite fields the current plan is allowed to manage. |
| 39 | 42 | if ( is_array( $existing_raw ) && ! empty( $existing_raw ) ) { |
| 40 | 43 | $raw = array_merge( $existing_raw, $raw ); |
| 44 | + } | |
| 45 | + | |
| 46 | + // If not a video tour, remove any stale video ID from existing data | |
| 47 | + if ( ( $raw['tour-type'] ?? '' ) !== 'video' ) { | |
| 48 | + unset( $raw['vidid'] ); | |
| 41 | 49 | } |
| 42 | 50 | |
| 43 | 51 | // If the request carries proData (future React pro panels will send this), |
| 44 | 52 | // run the same filter the legacy AJAX stack uses so pro plugin saves its fields. |