PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.3.0
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.3.0
9.3.0 9.2.0 9.1.4 9.1.3 9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 All 225 releases
← All changes | src/Api/Transformers/TourTransformer.php +470 -18 9.1.1 → 9.3.0 View file →
@@ -2,8 +2,10 @@
2 2
3 3 namespace RexTheme\WPVR\Api\Transformers;
4 4
5 5 use RexTheme\WPVR\Api\Contracts\TransformerInterface;
6 +use RexTheme\WPVR\Content\VideoSource;
7 +use RexTheme\WPVR\Content\TextOverlayContent;
6 8
7 9 class TourTransformer implements TransformerInterface {
8 10
9 11 protected bool $is_pro;
@@ -39,10 +41,12 @@
39 41 ? (int) $raw['autorotationstopdelay']
40 42 : ( isset( $raw['autoRotateStopDelay'] ) && $raw['autoRotateStopDelay'] !== '' ? (int) $raw['autoRotateStopDelay'] : null ),
41 43 ];
42 44
43 - $default_scene_id = ! empty( $raw['defaultscene'] ) ? $raw['defaultscene'] : null;
44 - $has_explicit_default_scene = ( $raw['defaultscene-auto'] ?? 'off' ) !== 'on';
45 + $default_scene_id = ! empty( $raw['defaultscene'] ) ? (string) $raw['defaultscene'] : null;
46 + $scene_ids = array_filter( array_column( $scenes, 'id' ) );
47 + $default_scene_exists = $default_scene_id !== null && in_array( $default_scene_id, $scene_ids, true );
48 + $has_explicit_default_scene = ( ( $raw['defaultscene-auto'] ?? 'off' ) !== 'on' ) && $default_scene_exists;
45 49
46 50 return [
47 51 'defaultSceneId' => $has_explicit_default_scene ? $default_scene_id : null,
48 52 'tourType' => $this->detect_tour_type( $raw ),
@@ -53,8 +57,9 @@
53 57 'previewImage' => $raw['preview'] ?? '',
54 58 'sceneFadeDuration' => isset( $raw['scenefadeduration'] ) ? (int) $raw['scenefadeduration'] : 0,
55 59 'showSceneInfo' => ( $raw['scene-info-enabled'] ?? 'on' ) !== 'off',
56 60 'autoRotate' => $auto_rotate,
61 + 'socialShare' => ( $raw['wpvr_social_share'] ?? 'off' ) === 'on',
57 62 ],
58 63 'floorPlan' => $this->floor_plan_to_api( $raw ),
59 64 'backgroundTour' => [
60 65 'enabled' => ( $raw['bg_tour_enabler'] ?? 'off' ) === 'on',
@@ -62,8 +67,9 @@
62 67 'subtitle' => $raw['bg_tour_subtitle'] ?? '',
63 68 ],
64 69 'videoData' => [
65 70 'url' => $raw['vidurl'] ?? '',
71 + 'sourceType' => VideoSource::normalize( $raw['video-source-type'] ?? '', (string) ( $raw['vidurl'] ?? '' ) ),
66 72 'autoplay' => ( $raw['video-autoplay'] ?? $raw['autoplay'] ?? 'off' ) === 'on',
67 73 'loop' => ( $raw['video-loop'] ?? $raw['loop'] ?? 'off' ) === 'on',
68 74 ],
69 75 'streetViewData' => [
@@ -96,8 +102,9 @@
96 102 $street_view_data = [];
97 103 }
98 104
99 105 $scenes = is_array( $data['scenes'] ?? null ) ? $data['scenes'] : [];
106 + $first_scene_id = $scenes[0]['id'] ?? '';
100 107 $requested_default_scene_id = (string) ( $data['defaultSceneId'] ?? '' );
101 108 $has_explicit_default_scene = $requested_default_scene_id !== ''
102 109 && ! empty( array_filter(
103 110 $scenes,
@@ -106,9 +113,9 @@
106 113 }
107 114 ) );
108 115 $default_scene_id = $has_explicit_default_scene
109 116 ? $requested_default_scene_id
110 - : ( $scenes[0]['id'] ?? '' );
117 + : $first_scene_id;
111 118
112 119 $raw = [
113 120 'autoLoad' => ! empty( $settings['autoLoad'] ) && $settings['autoLoad'] !== 'off' && $settings['autoLoad'] !== 'false',
114 121 'showControls' => ! empty( $settings['showControls'] ),
@@ -159,8 +166,9 @@
159 166 : []
160 167 ),
161 168 'tour-type' => $tour_type,
162 169 'vidurl' => esc_url_raw( $video_data['url'] ?? '' ),
170 + 'video-source-type' => VideoSource::normalize( $video_data['sourceType'] ?? '', (string) ( $video_data['url'] ?? '' ) ),
163 171 'video-autoplay' => ! empty( $video_data['autoplay'] ) ? 'on' : 'off',
164 172 'video-loop' => ! empty( $video_data['loop'] ) ? 'on' : 'off',
165 173 'autoplay' => ! empty( $video_data['autoplay'] ) ? 'on' : 'off',
166 174 'loop' => ! empty( $video_data['loop'] ) ? 'on' : 'off',
@@ -172,12 +180,15 @@
172 180 $default_scene_id,
173 181 ( $settings['showSceneInfo'] ?? true ) !== false
174 182 ),
175 183 ],
184 + 'wpvr_social_share' => ! empty( $settings['socialShare'] ) ? 'on' : 'off',
176 185 ];
177 186
178 187 if ( $tour_type === 'video' && ! empty( $video_data['url'] ) ) {
179 188 $raw['vidid'] = 'vid' . ( $data['tourId'] ?? $data['id'] ?? wp_rand( 1000, 99999 ) );
189 + $raw['vidtype'] = VideoSource::player_type( $raw['vidurl'], $raw['video-source-type'] );
190 + $raw['panoviddata'] = ''; // Rebuild preview markup from the current URL.
180 191 }
181 192
182 193 return $raw;
183 194 }
@@ -478,8 +489,10 @@
478 489 $scene['scene-attachment-url-face3'] ?? null,
479 490 $scene['scene-attachment-url-face4'] ?? null,
480 491 $scene['scene-attachment-url-face5'] ?? null,
481 492 ],
493 + 'textOverlays' => $this->text_overlays_to_api( $scene['text-overlays'] ?? [] ),
494 + 'showLayerToggle' => ( $scene['scene-show-layer-toggle'] ?? 'on' ) === 'on',
482 495 ];
483 496 }
484 497 // Older tours did not store whether a hotspot entry point inherited
485 498 // the target scene face or was edited manually. Keep those links in
@@ -509,12 +522,15 @@
509 522 // Free fields
510 523 'scene-id' => $scene_id,
511 524 'scene-ititle' => $scene['name'] ?? '',
512 525 'scene-type' => $this->is_pro && ( $scene['type'] ?? '' ) === 'cubemap' ? 'cubemap' : 'equirectangular',
513 - 'scene-attachment-url' => $scene['imageUrl'] ?? '',
526 + 'scene-attachment-url' => ! empty( $scene['imageUrl'] ) ? esc_url_raw( trim( (string) $scene['imageUrl'] ), [ 'http', 'https' ] ) : '',
514 527 'scene-show-info' => $show_scene_info ? 'on' : 'off',
515 528 'hotspot-list' => $this->hotspots_from_api( $scene['hotspots'] ?? [] ),
516 - 'dscene' => ( $default_scene_id !== '' && $scene_id === $default_scene_id ) ? 'on' : 'off',
529 + 'dscene' => ( $default_scene_id !== '' && $scene_id === $default_scene_id ) ? 'on' : 'off',
530 + 'text-overlays' => $this->text_overlays_from_api( $scene['textOverlays'] ?? [] ),
531 + 'scene-show-layer-toggle' => ( ! isset( $scene['showLayerToggle'] ) || ! empty( $scene['showLayerToggle'] ) ) ? 'on' : 'off',
532 + 'showLayerToggle' => ( ! isset( $scene['showLayerToggle'] ) || ! empty( $scene['showLayerToggle'] ) ),
517 533 ];
518 534
519 535 if ( $this->is_pro ) {
520 536 $scene_data = array_merge( $scene_data, [
@@ -519,9 +535,9 @@
519 535 if ( $this->is_pro ) {
520 536 $scene_data = array_merge( $scene_data, [
521 537 // Pro: metadata
522 538 'scene-author' => $scene['author'] ?? '',
523 - 'scene-author-url' => $scene['authorUrl'] ?? '',
539 + 'scene-author-url' => ! empty( $scene['authorUrl'] ) ? esc_url_raw( $scene['authorUrl'] ) : '',
524 540 'scene-vaov' => $scene['vaov'] ?? '',
525 541 'scene-haov' => $scene['haov'] ?? '',
526 542 'scene-vertical-offset' => $scene['verticalOffset'] ?? '',
527 543 // Pro: default face orientation
@@ -541,14 +557,15 @@
541 557 'scene-zoom' => $scene['zoom'] ?? '',
542 558 'scene-maxzoom' => $scene['maxZoom'] ?? '',
543 559 'scene-minzoom' => $scene['minZoom'] ?? '',
544 560 // Pro: cubemap faces
545 - 'scene-attachment-url-face0' => $faces[0] ?? '',
546 - 'scene-attachment-url-face1' => $faces[1] ?? '',
547 - 'scene-attachment-url-face2' => $faces[2] ?? '',
548 - 'scene-attachment-url-face3' => $faces[3] ?? '',
549 - 'scene-attachment-url-face4' => $faces[4] ?? '',
550 - 'scene-attachment-url-face5' => $faces[5] ?? '',
561 + 'scene-attachment-url-face0' => ! empty( $faces[0] ) ? esc_url_raw( trim( (string) $faces[0] ), [ 'http', 'https' ] ) : '',
562 + 'scene-attachment-url-face1' => ! empty( $faces[1] ) ? esc_url_raw( trim( (string) $faces[1] ), [ 'http', 'https' ] ) : '',
563 + 'scene-attachment-url-face2' => ! empty( $faces[2] ) ? esc_url_raw( trim( (string) $faces[2] ), [ 'http', 'https' ] ) : '',
564 + 'scene-attachment-url-face3' => ! empty( $faces[3] ) ? esc_url_raw( trim( (string) $faces[3] ), [ 'http', 'https' ] ) : '',
565 + 'scene-attachment-url-face4' => ! empty( $faces[4] ) ? esc_url_raw( trim( (string) $faces[4] ), [ 'http', 'https' ] ) : '',
566 + 'scene-attachment-url-face5' => ! empty( $faces[5] ) ? esc_url_raw( trim( (string) $faces[5] ), [ 'http', 'https' ] ) : '',
567 + 'text-overlays' => $this->text_overlays_from_api( $scene['textOverlays'] ?? [] ),
551 568 ] );
552 569 }
553 570
554 571 $scene_list[ $index ] = $scene_data;
@@ -568,8 +585,23 @@
568 585 : null;
569 586 $scene_yaw = isset( $hotspot['hotspot-scene-yaw'] ) && $hotspot['hotspot-scene-yaw'] !== ''
570 587 ? (float) $hotspot['hotspot-scene-yaw']
571 588 : null;
589 + $product_id = isset( $hotspot['hotspot-product-id'] ) ? (string) $hotspot['hotspot-product-id'] : '';
590 + $product_name = '';
591 + if ( ! empty( $product_id ) && function_exists( 'wc_get_product' ) ) {
592 + $product_obj = wc_get_product( $product_id );
593 + if ( is_object( $product_obj ) ) {
594 + $product_name = $product_obj->get_formatted_name();
595 + }
596 + }
597 +
598 + $template_val = $hotspot['hotspot-sticker-template'] ?? '';
599 + $is_separate_icon = $template_val === 'button_with_separate_icon';
600 + $is_add_to_cart = $template_val === 'add_to_cart';
601 + $is_social_share = $template_val === 'social_share';
602 + $default_card_radius = $is_separate_icon ? 135 : ( ( $is_add_to_cart || $is_social_share ) ? 15 : 20 );
603 +
572 604 $hotspots[] = [
573 605 'id' => $hotspot['hotspot-id'] ?? wp_generate_uuid4(),
574 606 'type' => $hotspot['hotspot-type'] ?? 'info',
575 607 'pitch' => isset( $hotspot['hotspot-pitch'] ) ? (float) $hotspot['hotspot-pitch'] : 0,
@@ -580,8 +612,95 @@
580 612 'urlOpen' => $hotspot['hotspot-url-open'] ?? 'off',
581 613 'hover' => $hotspot['hotspot-hover'] ?? '',
582 614 'targetSceneId' => $hotspot['hotspot-scene'] ?? '',
583 615 'customClass' => $hotspot['hotspot-customclass'] ?? '',
616 + 'fluentFormId' => isset( $hotspot['fluent-form-id'] ) ? (string) $hotspot['fluent-form-id'] : '',
617 + 'productId' => $product_id,
618 + 'productName' => $product_name,
619 + // Sticker fields
620 + 'stickerTemplate' => $template_val ?: 'social_proof',
621 + 'stickerReviewText' => $hotspot['hotspot-sticker-review-text'] ?? 'The support is super responsive and responds without worries to our requests and needs! Big up to the entire RexTheme team!',
622 + 'stickerClientName' => $hotspot['hotspot-sticker-client-name'] ?? 'Elena R.',
623 + 'stickerClientAvatar' => $hotspot['hotspot-sticker-client-avatar'] ?? '',
624 + 'stickerRating' => isset( $hotspot['hotspot-sticker-rating'] ) ? (int) $hotspot['hotspot-sticker-rating'] : 5,
625 + 'stickerBgColor' => $hotspot['hotspot-sticker-bg-color'] ?? '#201b2c',
626 + 'stickerBgOpacity' => isset( $hotspot['hotspot-sticker-bg-opacity'] ) ? (float) $hotspot['hotspot-sticker-bg-opacity'] : ( ( $is_separate_icon || $is_add_to_cart || $is_social_share ) ? 75 : 95 ),
627 + 'stickerBlur' => isset( $hotspot['hotspot-sticker-blur'] ) ? (float) $hotspot['hotspot-sticker-blur'] : 12,
628 + 'stickerBrightness' => isset( $hotspot['hotspot-sticker-brightness'] ) ? (float) $hotspot['hotspot-sticker-brightness'] : 100,
629 + 'stickerTextColor' => $hotspot['hotspot-sticker-text-color'] ?? '#ffffff',
630 + 'stickerBorderColor' => $hotspot['hotspot-sticker-border-color'] ?? ( ( $is_separate_icon || $is_add_to_cart || $is_social_share ) ? '#40355a' : '#3a3051' ),
631 + 'stickerBorderRadius' => isset( $hotspot['hotspot-sticker-border-radius'] ) && is_array( $hotspot['hotspot-sticker-border-radius'] ) ? [
632 + 'topLeft' => isset( $hotspot['hotspot-sticker-border-radius']['topLeft'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['topLeft'] : $default_card_radius,
633 + 'topRight' => isset( $hotspot['hotspot-sticker-border-radius']['topRight'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['topRight'] : $default_card_radius,
634 + 'bottomRight' => isset( $hotspot['hotspot-sticker-border-radius']['bottomRight'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['bottomRight'] : $default_card_radius,
635 + 'bottomLeft' => isset( $hotspot['hotspot-sticker-border-radius']['bottomLeft'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['bottomLeft'] : $default_card_radius,
636 + ] : ( isset( $hotspot['hotspot-sticker-border-radius'] ) && is_numeric( $hotspot['hotspot-sticker-border-radius'] ) ? [
637 + 'topLeft' => (float) $hotspot['hotspot-sticker-border-radius'],
638 + 'topRight' => (float) $hotspot['hotspot-sticker-border-radius'],
639 + 'bottomRight' => (float) $hotspot['hotspot-sticker-border-radius'],
640 + 'bottomLeft' => (float) $hotspot['hotspot-sticker-border-radius'],
641 + ] : [
642 + 'topLeft' => $default_card_radius,
643 + 'topRight' => $default_card_radius,
644 + 'bottomRight' => $default_card_radius,
645 + 'bottomLeft' => $default_card_radius,
646 + ] ),
647 + 'stickerPadding' => isset( $hotspot['hotspot-sticker-padding'] ) && is_array( $hotspot['hotspot-sticker-padding'] ) ? [
648 + 'top' => isset( $hotspot['hotspot-sticker-padding']['top'] ) ? (float) $hotspot['hotspot-sticker-padding']['top'] : 21,
649 + 'right' => isset( $hotspot['hotspot-sticker-padding']['right'] ) ? (float) $hotspot['hotspot-sticker-padding']['right'] : 21,
650 + 'bottom' => isset( $hotspot['hotspot-sticker-padding']['bottom'] ) ? (float) $hotspot['hotspot-sticker-padding']['bottom'] : 21,
651 + 'left' => isset( $hotspot['hotspot-sticker-padding']['left'] ) ? (float) $hotspot['hotspot-sticker-padding']['left'] : 21,
652 + ] : ( isset( $hotspot['hotspot-sticker-padding'] ) && is_numeric( $hotspot['hotspot-sticker-padding'] ) ? [
653 + 'top' => (float) $hotspot['hotspot-sticker-padding'],
654 + 'right' => (float) $hotspot['hotspot-sticker-padding'],
655 + 'bottom' => (float) $hotspot['hotspot-sticker-padding'],
656 + 'left' => (float) $hotspot['hotspot-sticker-padding'],
657 + ] : [
658 + 'top' => 21,
659 + 'right' => 21,
660 + 'bottom' => 21,
661 + 'left' => 21,
662 + ] ),
663 + 'stickerStarColor' => $hotspot['hotspot-sticker-star-color'] ?? '#EF991F',
664 + // Text before button (for add_to_cart)
665 + 'stickerPrefixText' => $hotspot['hotspot-sticker-prefix-text'] ?? '$1,090 -',
666 + 'stickerSubText' => $hotspot['hotspot-sticker-sub-text'] ?? 'Ready to ship',
667 + // Discount button, add to cart & social share sticker fields
668 + 'stickerBtnText' => $hotspot['hotspot-sticker-btn-text'] ?? ( $is_social_share ? 'SHARE EXPERIENCE' : ( $is_add_to_cart ? 'ADD TO CART' : ( $is_separate_icon ? 'Limited “Midnight Horizon” Edition' : 'GET 20% OFF NOW' ) ) ),
669 + 'stickerBtnColor' => $hotspot['hotspot-sticker-btn-color'] ?? ( $is_social_share ? '#201a2b' : ( $is_add_to_cart ? '#3f04fe' : ( $is_separate_icon ? '#ffffff' : '#EF991F' ) ) ),
670 + 'stickerBtnTextColor' => $hotspot['hotspot-sticker-btn-text-color'] ?? ( ( $is_add_to_cart || $is_social_share ) ? '#ffffff' : '#000000' ),
671 + 'stickerBtnIconColor' => $hotspot['hotspot-sticker-btn-icon-color'] ?? '#000000',
672 + 'stickerBtnUrl' => $hotspot['hotspot-sticker-btn-url'] ?? '',
673 + 'stickerBtnNewTab' => $hotspot['hotspot-sticker-btn-new-tab'] ?? 'off',
674 + 'stickerMainBg' => $hotspot['hotspot-sticker-main-bg'] ?? ( $hotspot['hotspot-sticker-card-bg'] ?? 'on' ),
675 + 'stickerCardBg' => $hotspot['hotspot-sticker-card-bg'] ?? ( $hotspot['hotspot-sticker-main-bg'] ?? 'on' ),
676 + 'stickerBtnBg' => $hotspot['hotspot-sticker-btn-bg'] ?? 'on',
677 + 'stickerBtnWidth' => isset( $hotspot['hotspot-sticker-btn-width'] ) && $hotspot['hotspot-sticker-btn-width'] !== '' ? (float) $hotspot['hotspot-sticker-btn-width'] : ( $is_social_share ? 222 : ( $is_add_to_cart ? 163 : ( $is_separate_icon ? 356 : '' ) ) ),
678 + 'stickerBtnHeight' => isset( $hotspot['hotspot-sticker-btn-height'] ) && $hotspot['hotspot-sticker-btn-height'] !== '' ? (float) $hotspot['hotspot-sticker-btn-height'] : ( ( $is_social_share || $is_add_to_cart || $is_separate_icon ) ? 60 : '' ),
679 + 'stickerBtnRadius' => isset( $hotspot['hotspot-sticker-btn-radius'] ) && $hotspot['hotspot-sticker-btn-radius'] !== '' ? (float) $hotspot['hotspot-sticker-btn-radius'] : ( $is_separate_icon ? 30 : 10 ),
680 + 'stickerBtnBorder' => isset( $hotspot['hotspot-sticker-btn-border'] ) && $hotspot['hotspot-sticker-btn-border'] !== '' ? (float) $hotspot['hotspot-sticker-btn-border'] : ( $is_social_share ? 1 : 0 ),
681 + 'stickerBtnBorderColor' => $hotspot['hotspot-sticker-btn-border-color'] ?? ( $is_social_share ? '#3a3051' : ( ( $is_add_to_cart || $is_separate_icon ) ? '#ffffff' : '#EF991F' ) ),
682 + 'stickerBtnTextSize' => isset( $hotspot['hotspot-sticker-btn-text-size'] ) && $hotspot['hotspot-sticker-btn-text-size'] !== '' ? (float) $hotspot['hotspot-sticker-btn-text-size'] : 18,
683 + 'stickerBtnTextWeight' => $hotspot['hotspot-sticker-btn-text-weight'] ?? ( ( $is_social_share || $is_add_to_cart || $is_separate_icon ) ? '600' : '700' ),
684 + 'stickerBtnIcon' => ( $is_add_to_cart || $is_social_share ) ? 'none' : ( $hotspot['hotspot-sticker-btn-icon'] ?? 'fas fa-tag' ),
685 + // Button with separate icon fields
686 + 'stickerIconBoxBgColor' => $hotspot['hotspot-sticker-icon-box-bg-color'] ?? '#ffffff',
687 + 'stickerIconBoxRadius' => isset( $hotspot['hotspot-sticker-icon-box-radius'] ) && $hotspot['hotspot-sticker-icon-box-radius'] !== '' ? (float) $hotspot['hotspot-sticker-icon-box-radius'] : 30,
688 + 'stickerIconBoxBorder' => isset( $hotspot['hotspot-sticker-icon-box-border'] ) && $hotspot['hotspot-sticker-icon-box-border'] !== '' ? (float) $hotspot['hotspot-sticker-icon-box-border'] : 0,
689 + 'stickerIconBoxBorderColor' => $hotspot['hotspot-sticker-icon-box-border-color'] ?? '#ffffff',
690 + 'stickerIconBoxSize' => isset( $hotspot['hotspot-sticker-icon-box-size'] ) && $hotspot['hotspot-sticker-icon-box-size'] !== '' ? (float) $hotspot['hotspot-sticker-icon-box-size'] : 60,
691 + // Social share sticker fields
692 + 'stickerSocialColor' => $hotspot['hotspot-sticker-social-color'] ?? '#ffffff',
693 + 'stickerSocialSize' => isset( $hotspot['hotspot-sticker-social-size'] ) && $hotspot['hotspot-sticker-social-size'] !== '' ? (float) $hotspot['hotspot-sticker-social-size'] : 20,
694 + 'stickerSocialGap' => isset( $hotspot['hotspot-sticker-social-gap'] ) && $hotspot['hotspot-sticker-social-gap'] !== '' ? (float) $hotspot['hotspot-sticker-social-gap'] : 16,
695 + 'stickerSocialLinks' => isset( $hotspot['hotspot-sticker-social-links'] ) ? ( is_array( $hotspot['hotspot-sticker-social-links'] ) ? $hotspot['hotspot-sticker-social-links'] : json_decode( (string) $hotspot['hotspot-sticker-social-links'], true ) ) : [
696 + [ 'id' => '1', 'icon' => 'fab fa-linkedin-in', 'customSvg' => '', 'url' => 'https://linkedin.com', 'openNewTab' => 'on' ],
697 + [ 'id' => '2', 'icon' => 'fab fa-facebook-f', 'customSvg' => '', 'url' => 'https://facebook.com', 'openNewTab' => 'on' ],
698 + [ 'id' => '3', 'icon' => 'fab fa-instagram', 'customSvg' => '', 'url' => 'https://instagram.com', 'openNewTab' => 'on' ],
699 + [ 'id' => '4', 'icon' => 'fab fa-dribbble', 'customSvg' => '', 'url' => 'https://dribbble.com', 'openNewTab' => 'on' ],
700 + ],
701 + 'stickerShowPlaceholderText' => $hotspot['hotspot-sticker-show-placeholder-text'] ?? 'on',
702 + 'scale' => isset( $hotspot['hotspot-scale'] ) ? ( $hotspot['hotspot-scale'] === 'on' || $hotspot['hotspot-scale'] === true ) : ( ( $hotspot['hotspot-type'] ?? '' ) === 'sticker' ),
584 703 // Pro styling fields
585 704 'iconClass' => ( ( $hotspot['hotspot-customclass-pro'] ?? '' ) === 'none' || ( $hotspot['hotspot-customclass-pro'] ?? '' ) === '' ) ? '' : $hotspot['hotspot-customclass-pro'],
586 705 'iconBgColor' => $hotspot['hotspot-customclass-color-icon-value'] ?? '#00b4ff',
587 706 'iconColor' => $hotspot['hotspot-custom-icon-color-value'] ?? '#ffffff',
@@ -607,11 +726,17 @@
607 726 $is_fluent_form = $hotspot_type === 'fluent_form';
608 727 $raw_content = (string) ( $hotspot['content'] ?? '' );
609 728 $raw_hover = (string) ( $hotspot['hover'] ?? '' );
610 729
611 - $content = function_exists( 'sanitize_content_preserve_styles' )
612 - ? sanitize_content_preserve_styles( $raw_content, $is_fluent_form )
613 - : wp_kses_post( $raw_content );
730 + // For fluent_form hotspots, content is dynamically rendered server-side from fluent-form-id.
731 + // User-supplied content is never used and must not be saved, completely eliminating stored XSS.
732 + if ( $is_fluent_form ) {
733 + $content = '';
734 + } else {
735 + $content = function_exists( 'sanitize_content_preserve_styles' )
736 + ? sanitize_content_preserve_styles( $raw_content, false )
737 + : wp_kses_post( $raw_content );
738 + }
614 739 $hover = function_exists( 'sanitize_content_preserve_styles' )
615 740 ? sanitize_content_preserve_styles( $raw_hover, false )
616 741 : wp_kses_post( $raw_hover );
617 742
@@ -629,8 +754,226 @@
629 754 'hotspot-customclass' => sanitize_text_field( $hotspot['customClass'] ?? '' ),
630 755 'hotspot-scene-list' => 'none',
631 756 ];
632 757
758 + if ( isset( $hotspot['fluentFormId'] ) ) {
759 + $hs['fluent-form-id'] = (string) absint( $hotspot['fluentFormId'] );
760 + } elseif ( isset( $hotspot['fluent-form-id'] ) ) {
761 + $hs['fluent-form-id'] = (string) absint( $hotspot['fluent-form-id'] );
762 + }
763 +
764 + if ( isset( $hotspot['productId'] ) ) {
765 + $hs['hotspot-product-id'] = sanitize_text_field( $hotspot['productId'] );
766 + } elseif ( isset( $hotspot['hotspot-product-id'] ) ) {
767 + $hs['hotspot-product-id'] = sanitize_text_field( $hotspot['hotspot-product-id'] );
768 + }
769 +
770 + // Sticker fields
771 + if ( isset( $hotspot['stickerTemplate'] ) || isset( $hotspot['hotspot-sticker-template'] ) ) {
772 + $hs['hotspot-sticker-template'] = sanitize_text_field( $hotspot['stickerTemplate'] ?? $hotspot['hotspot-sticker-template'] );
773 + }
774 + if ( isset( $hotspot['stickerReviewText'] ) || isset( $hotspot['hotspot-sticker-review-text'] ) ) {
775 + $hs['hotspot-sticker-review-text'] = sanitize_textarea_field( $hotspot['stickerReviewText'] ?? $hotspot['hotspot-sticker-review-text'] );
776 + }
777 + if ( isset( $hotspot['stickerClientName'] ) || isset( $hotspot['hotspot-sticker-client-name'] ) ) {
778 + $hs['hotspot-sticker-client-name'] = sanitize_text_field( $hotspot['stickerClientName'] ?? $hotspot['hotspot-sticker-client-name'] );
779 + }
780 + if ( isset( $hotspot['stickerClientAvatar'] ) || isset( $hotspot['hotspot-sticker-client-avatar'] ) ) {
781 + $hs['hotspot-sticker-client-avatar'] = esc_url_raw( $hotspot['stickerClientAvatar'] ?? $hotspot['hotspot-sticker-client-avatar'] );
782 + }
783 + if ( isset( $hotspot['stickerRating'] ) || isset( $hotspot['hotspot-sticker-rating'] ) ) {
784 + $hs['hotspot-sticker-rating'] = (string) max( 1, min( 5, (int) ( $hotspot['stickerRating'] ?? $hotspot['hotspot-sticker-rating'] ) ) );
785 + }
786 + if ( isset( $hotspot['stickerBgColor'] ) || isset( $hotspot['hotspot-sticker-bg-color'] ) ) {
787 + $hs['hotspot-sticker-bg-color'] = sanitize_text_field( $hotspot['stickerBgColor'] ?? $hotspot['hotspot-sticker-bg-color'] );
788 + }
789 + if ( isset( $hotspot['stickerBgOpacity'] ) || isset( $hotspot['hotspot-sticker-bg-opacity'] ) ) {
790 + $hs['hotspot-sticker-bg-opacity'] = max( 0, min( 100, (float) ( $hotspot['stickerBgOpacity'] ?? $hotspot['hotspot-sticker-bg-opacity'] ) ) );
791 + }
792 + if ( isset( $hotspot['stickerBlur'] ) || isset( $hotspot['hotspot-sticker-blur'] ) ) {
793 + $hs['hotspot-sticker-blur'] = max( 0, min( 40, (float) ( $hotspot['stickerBlur'] ?? $hotspot['hotspot-sticker-blur'] ) ) );
794 + }
795 + if ( isset( $hotspot['stickerBrightness'] ) || isset( $hotspot['hotspot-sticker-brightness'] ) ) {
796 + $hs['hotspot-sticker-brightness'] = max( 0, min( 200, (float) ( $hotspot['stickerBrightness'] ?? $hotspot['hotspot-sticker-brightness'] ) ) );
797 + }
798 + if ( isset( $hotspot['stickerTextColor'] ) || isset( $hotspot['hotspot-sticker-text-color'] ) ) {
799 + $hs['hotspot-sticker-text-color'] = sanitize_hex_color( $hotspot['stickerTextColor'] ?? $hotspot['hotspot-sticker-text-color'] ) ?: '#ffffff';
800 + }
801 + if ( isset( $hotspot['stickerBorderColor'] ) || isset( $hotspot['hotspot-sticker-border-color'] ) ) {
802 + $raw_border_color = strtolower( trim( (string) ( $hotspot['stickerBorderColor'] ?? $hotspot['hotspot-sticker-border-color'] ) ) );
803 + if ( $raw_border_color === 'none' || $raw_border_color === 'transparent' ) {
804 + $hs['hotspot-sticker-border-color'] = $raw_border_color;
805 + } else {
806 + $hs['hotspot-sticker-border-color'] = sanitize_hex_color( $raw_border_color ) ?: '#3a3051';
807 + }
808 + }
809 + if ( isset( $hotspot['stickerBorderRadius'] ) || isset( $hotspot['hotspot-sticker-border-radius'] ) ) {
810 + $raw_radius = $hotspot['stickerBorderRadius'] ?? $hotspot['hotspot-sticker-border-radius'];
811 + if ( is_array( $raw_radius ) ) {
812 + $hs['hotspot-sticker-border-radius'] = [
813 + 'topLeft' => max( 0, min( 500, (float) ( $raw_radius['topLeft'] ?? 20 ) ) ),
814 + 'topRight' => max( 0, min( 500, (float) ( $raw_radius['topRight'] ?? 20 ) ) ),
815 + 'bottomRight' => max( 0, min( 500, (float) ( $raw_radius['bottomRight'] ?? 20 ) ) ),
816 + 'bottomLeft' => max( 0, min( 500, (float) ( $raw_radius['bottomLeft'] ?? 20 ) ) ),
817 + ];
818 + } else {
819 + $val = max( 0, min( 500, (float) $raw_radius ) );
820 + $hs['hotspot-sticker-border-radius'] = [
821 + 'topLeft' => $val,
822 + 'topRight' => $val,
823 + 'bottomRight' => $val,
824 + 'bottomLeft' => $val,
825 + ];
826 + }
827 + }
828 + if ( isset( $hotspot['stickerPadding'] ) || isset( $hotspot['hotspot-sticker-padding'] ) ) {
829 + $raw_pad = $hotspot['stickerPadding'] ?? $hotspot['hotspot-sticker-padding'];
830 + if ( is_array( $raw_pad ) ) {
831 + $hs['hotspot-sticker-padding'] = [
832 + 'top' => max( 0, min( 200, (float) ( $raw_pad['top'] ?? 21 ) ) ),
833 + 'right' => max( 0, min( 200, (float) ( $raw_pad['right'] ?? 21 ) ) ),
834 + 'bottom' => max( 0, min( 200, (float) ( $raw_pad['bottom'] ?? 21 ) ) ),
835 + 'left' => max( 0, min( 200, (float) ( $raw_pad['left'] ?? 21 ) ) ),
836 + ];
837 + } else {
838 + $val = max( 0, min( 200, (float) $raw_pad ) );
839 + $hs['hotspot-sticker-padding'] = [
840 + 'top' => $val,
841 + 'right' => $val,
842 + 'bottom' => $val,
843 + 'left' => $val,
844 + ];
845 + }
846 + }
847 + if ( isset( $hotspot['stickerStarColor'] ) || isset( $hotspot['hotspot-sticker-star-color'] ) ) {
848 + $hs['hotspot-sticker-star-color'] = sanitize_hex_color( $hotspot['stickerStarColor'] ?? $hotspot['hotspot-sticker-star-color'] ) ?: '#EF991F';
849 + }
850 + // Discount button sticker fields
851 + if ( isset( $hotspot['stickerBtnText'] ) || isset( $hotspot['hotspot-sticker-btn-text'] ) ) {
852 + $hs['hotspot-sticker-btn-text'] = sanitize_text_field( $hotspot['stickerBtnText'] ?? $hotspot['hotspot-sticker-btn-text'] );
853 + }
854 + if ( isset( $hotspot['stickerBtnColor'] ) || isset( $hotspot['hotspot-sticker-btn-color'] ) ) {
855 + $hs['hotspot-sticker-btn-color'] = sanitize_hex_color( $hotspot['stickerBtnColor'] ?? $hotspot['hotspot-sticker-btn-color'] ) ?: '#EF991F';
856 + }
857 + if ( isset( $hotspot['stickerBtnTextColor'] ) || isset( $hotspot['hotspot-sticker-btn-text-color'] ) ) {
858 + $hs['hotspot-sticker-btn-text-color'] = sanitize_hex_color( $hotspot['stickerBtnTextColor'] ?? $hotspot['hotspot-sticker-btn-text-color'] ) ?: '#000000';
859 + }
860 + if ( isset( $hotspot['stickerBtnIconColor'] ) || isset( $hotspot['hotspot-sticker-btn-icon-color'] ) ) {
861 + $hs['hotspot-sticker-btn-icon-color'] = sanitize_hex_color( $hotspot['stickerBtnIconColor'] ?? $hotspot['hotspot-sticker-btn-icon-color'] ) ?: '#000000';
862 + }
863 + if ( isset( $hotspot['stickerBtnUrl'] ) || isset( $hotspot['hotspot-sticker-btn-url'] ) ) {
864 + $hs['hotspot-sticker-btn-url'] = esc_url_raw( $hotspot['stickerBtnUrl'] ?? $hotspot['hotspot-sticker-btn-url'] );
865 + }
866 + if ( isset( $hotspot['stickerBtnNewTab'] ) || isset( $hotspot['hotspot-sticker-btn-new-tab'] ) ) {
867 + $raw_new_tab = $hotspot['stickerBtnNewTab'] ?? $hotspot['hotspot-sticker-btn-new-tab'];
868 + $hs['hotspot-sticker-btn-new-tab'] = ( $raw_new_tab === 'on' || $raw_new_tab === true || $raw_new_tab === 'true' ) ? 'on' : 'off';
869 + }
870 + if ( isset( $hotspot['stickerMainBg'] ) || isset( $hotspot['hotspot-sticker-main-bg'] ) || isset( $hotspot['stickerCardBg'] ) || isset( $hotspot['hotspot-sticker-card-bg'] ) ) {
871 + $raw_main_bg = $hotspot['stickerMainBg'] ?? ( $hotspot['stickerCardBg'] ?? ( $hotspot['hotspot-sticker-main-bg'] ?? $hotspot['hotspot-sticker-card-bg'] ) );
872 + $val = ( $raw_main_bg === 'off' || $raw_main_bg === false || $raw_main_bg === 'false' ) ? 'off' : 'on';
873 + $hs['hotspot-sticker-main-bg'] = $val;
874 + $hs['hotspot-sticker-card-bg'] = $val;
875 + }
876 + if ( isset( $hotspot['stickerBtnBg'] ) || isset( $hotspot['hotspot-sticker-btn-bg'] ) ) {
877 + $raw_bg = $hotspot['stickerBtnBg'] ?? $hotspot['hotspot-sticker-btn-bg'];
878 + $hs['hotspot-sticker-btn-bg'] = ( $raw_bg === 'off' || $raw_bg === false || $raw_bg === 'false' ) ? 'off' : 'on';
879 + }
880 + if ( isset( $hotspot['stickerBtnWidth'] ) || isset( $hotspot['hotspot-sticker-btn-width'] ) ) {
881 + $raw_w = $hotspot['stickerBtnWidth'] ?? $hotspot['hotspot-sticker-btn-width'];
882 + $hs['hotspot-sticker-btn-width'] = ( $raw_w !== '' && $raw_w !== null ) ? sanitize_text_field( (string) $raw_w ) : '';
883 + }
884 + if ( isset( $hotspot['stickerBtnHeight'] ) || isset( $hotspot['hotspot-sticker-btn-height'] ) ) {
885 + $raw_h = $hotspot['stickerBtnHeight'] ?? $hotspot['hotspot-sticker-btn-height'];
886 + $hs['hotspot-sticker-btn-height'] = ( $raw_h !== '' && $raw_h !== null ) ? sanitize_text_field( (string) $raw_h ) : '';
887 + }
888 + if ( isset( $hotspot['stickerBtnRadius'] ) || isset( $hotspot['hotspot-sticker-btn-radius'] ) ) {
889 + $hs['hotspot-sticker-btn-radius'] = (float) ( $hotspot['stickerBtnRadius'] ?? $hotspot['hotspot-sticker-btn-radius'] );
890 + }
891 + if ( isset( $hotspot['stickerBtnBorder'] ) || isset( $hotspot['hotspot-sticker-btn-border'] ) ) {
892 + $hs['hotspot-sticker-btn-border'] = (float) ( $hotspot['stickerBtnBorder'] ?? $hotspot['hotspot-sticker-btn-border'] );
893 + }
894 + if ( isset( $hotspot['stickerBtnBorderColor'] ) || isset( $hotspot['hotspot-sticker-btn-border-color'] ) ) {
895 + $hs['hotspot-sticker-btn-border-color'] = sanitize_hex_color( $hotspot['stickerBtnBorderColor'] ?? $hotspot['hotspot-sticker-btn-border-color'] ) ?: '#EF991F';
896 + }
897 + if ( isset( $hotspot['stickerBtnTextSize'] ) || isset( $hotspot['hotspot-sticker-btn-text-size'] ) ) {
898 + $hs['hotspot-sticker-btn-text-size'] = (float) ( $hotspot['stickerBtnTextSize'] ?? $hotspot['hotspot-sticker-btn-text-size'] );
899 + }
900 + if ( isset( $hotspot['stickerBtnTextWeight'] ) || isset( $hotspot['hotspot-sticker-btn-text-weight'] ) ) {
901 + $hs['hotspot-sticker-btn-text-weight'] = sanitize_text_field( (string) ( $hotspot['stickerBtnTextWeight'] ?? $hotspot['hotspot-sticker-btn-text-weight'] ) );
902 + }
903 + if ( ( $hs['hotspot-sticker-template'] ?? '' ) === 'add_to_cart' || ( $hs['hotspot-sticker-template'] ?? '' ) === 'social_share' ) {
904 + $hs['hotspot-sticker-btn-icon'] = 'none';
905 + } elseif ( isset( $hotspot['stickerBtnIcon'] ) || isset( $hotspot['hotspot-sticker-btn-icon'] ) ) {
906 + $hs['hotspot-sticker-btn-icon'] = sanitize_text_field( $hotspot['stickerBtnIcon'] ?? $hotspot['hotspot-sticker-btn-icon'] );
907 + }
908 + // Add to cart text fields
909 + if ( isset( $hotspot['stickerPrefixText'] ) || isset( $hotspot['hotspot-sticker-prefix-text'] ) ) {
910 + $hs['hotspot-sticker-prefix-text'] = sanitize_text_field( $hotspot['stickerPrefixText'] ?? $hotspot['hotspot-sticker-prefix-text'] );
911 + }
912 + if ( isset( $hotspot['stickerSubText'] ) || isset( $hotspot['hotspot-sticker-sub-text'] ) ) {
913 + $hs['hotspot-sticker-sub-text'] = sanitize_text_field( $hotspot['stickerSubText'] ?? $hotspot['hotspot-sticker-sub-text'] );
914 + }
915 + // Button with separate icon fields
916 + if ( isset( $hotspot['stickerIconBoxBgColor'] ) || isset( $hotspot['hotspot-sticker-icon-box-bg-color'] ) ) {
917 + $hs['hotspot-sticker-icon-box-bg-color'] = sanitize_hex_color( $hotspot['stickerIconBoxBgColor'] ?? $hotspot['hotspot-sticker-icon-box-bg-color'] ) ?: '#ffffff';
918 + }
919 + if ( isset( $hotspot['stickerIconBoxRadius'] ) || isset( $hotspot['hotspot-sticker-icon-box-radius'] ) ) {
920 + $hs['hotspot-sticker-icon-box-radius'] = (float) ( $hotspot['stickerIconBoxRadius'] ?? $hotspot['hotspot-sticker-icon-box-radius'] );
921 + }
922 + if ( isset( $hotspot['stickerIconBoxBorder'] ) || isset( $hotspot['hotspot-sticker-icon-box-border'] ) ) {
923 + $hs['hotspot-sticker-icon-box-border'] = (float) ( $hotspot['stickerIconBoxBorder'] ?? $hotspot['hotspot-sticker-icon-box-border'] );
924 + }
925 + if ( isset( $hotspot['stickerIconBoxBorderColor'] ) || isset( $hotspot['hotspot-sticker-icon-box-border-color'] ) ) {
926 + $hs['hotspot-sticker-icon-box-border-color'] = sanitize_hex_color( $hotspot['stickerIconBoxBorderColor'] ?? $hotspot['hotspot-sticker-icon-box-border-color'] ) ?: '#ffffff';
927 + }
928 + if ( isset( $hotspot['stickerIconBoxSize'] ) || isset( $hotspot['hotspot-sticker-icon-box-size'] ) ) {
929 + $hs['hotspot-sticker-icon-box-size'] = (float) ( $hotspot['stickerIconBoxSize'] ?? $hotspot['hotspot-sticker-icon-box-size'] );
930 + }
931 + // Social share sticker fields
932 + if ( isset( $hotspot['stickerSocialColor'] ) || isset( $hotspot['hotspot-sticker-social-color'] ) ) {
933 + $hs['hotspot-sticker-social-color'] = sanitize_hex_color( $hotspot['stickerSocialColor'] ?? $hotspot['hotspot-sticker-social-color'] ) ?: '#ffffff';
934 + }
935 + if ( isset( $hotspot['stickerSocialSize'] ) || isset( $hotspot['hotspot-sticker-social-size'] ) ) {
936 + $hs['hotspot-sticker-social-size'] = (float) ( $hotspot['stickerSocialSize'] ?? $hotspot['hotspot-sticker-social-size'] );
937 + }
938 + if ( isset( $hotspot['stickerSocialGap'] ) || isset( $hotspot['hotspot-sticker-social-gap'] ) ) {
939 + $hs['hotspot-sticker-social-gap'] = (float) ( $hotspot['stickerSocialGap'] ?? $hotspot['hotspot-sticker-social-gap'] );
940 + }
941 + if ( isset( $hotspot['stickerSocialLinks'] ) || isset( $hotspot['hotspot-sticker-social-links'] ) ) {
942 + $raw_links = $hotspot['stickerSocialLinks'] ?? $hotspot['hotspot-sticker-social-links'];
943 + if ( is_string( $raw_links ) ) {
944 + $raw_links = json_decode( $raw_links, true );
945 + }
946 + $clean_links = [];
947 + if ( is_array( $raw_links ) ) {
948 + foreach ( $raw_links as $item ) {
949 + if ( ! is_array( $item ) ) continue;
950 + $clean_links[] = [
951 + 'id' => sanitize_text_field( (string) ( $item['id'] ?? wp_generate_uuid4() ) ),
952 + 'icon' => sanitize_text_field( (string) ( $item['icon'] ?? '' ) ),
953 + 'customSvg' => function_exists( 'wp_kses' ) ? wp_kses( (string) ( $item['customSvg'] ?? '' ), [
954 + 'svg' => [ 'class' => true, 'xmlns' => true, 'viewbox' => true, 'viewBox' => true, 'width' => true, 'height' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'style' => true ],
955 + 'path' => [ 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'style' => true ],
956 + 'g' => [ 'fill' => true, 'stroke' => true, 'style' => true ],
957 + 'circle' => [ 'cx' => true, 'cy' => true, 'r' => true, 'fill' => true, 'stroke' => true, 'style' => true ],
958 + 'rect' => [ 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true, 'ry' => true, 'fill' => true, 'stroke' => true, 'style' => true ],
959 + ] ) : (string) ( $item['customSvg'] ?? '' ),
960 + 'url' => esc_url_raw( (string) ( $item['url'] ?? '' ) ),
961 + 'openNewTab' => ( ( $item['openNewTab'] ?? 'on' ) === 'off' || ( $item['openNewTab'] ?? 'on' ) === false ) ? 'off' : 'on',
962 + ];
963 + }
964 + }
965 + $hs['hotspot-sticker-social-links'] = $clean_links;
966 + }
967 + if ( isset( $hotspot['stickerShowPlaceholderText'] ) || isset( $hotspot['hotspot-sticker-show-placeholder-text'] ) ) {
968 + $hs['hotspot-sticker-show-placeholder-text'] = sanitize_text_field( $hotspot['stickerShowPlaceholderText'] ?? $hotspot['hotspot-sticker-show-placeholder-text'] );
969 + }
970 + if ( isset( $hotspot['scale'] ) ) {
971 + $hs['hotspot-scale'] = $hotspot['scale'] ? 'on' : 'off';
972 + } elseif ( ( $hotspot['type'] ?? '' ) === 'sticker' ) {
973 + $hs['hotspot-scale'] = 'on';
974 + }
975 +
633 976 if ( $this->is_pro ) {
634 977 $hs = array_merge( $hs, [
635 978 // Pro styling fields
636 979 'hotspot-customclass-pro' => !empty( $hotspot['iconClass'] ) ? $hotspot['iconClass'] : 'none',
@@ -641,11 +984,10 @@
641 984 'hotspot-border' => $hotspot['border'] ?? 'off',
642 985 'hotspot-border-width' => $hotspot['borderWidth'] ?? '1',
643 986 'hotspot-border-style' => $hotspot['borderStyle'] ?? 'none',
644 987 'hotspot-border-color' => $hotspot['borderColor'] ?? '#00b4ff',
645 - // Pro navigation entry point fields
646 - 'hotspot-scene-pitch' => $hotspot['scenePitch'] !== null ? (string) $hotspot['scenePitch'] : '',
647 - 'hotspot-scene-yaw' => $hotspot['sceneYaw'] !== null ? (string) $hotspot['sceneYaw'] : '',
988 + 'hotspot-scene-pitch' => ( isset( $hotspot['scenePitch'] ) && $hotspot['scenePitch'] !== null ) ? (string) $hotspot['scenePitch'] : '',
989 + 'hotspot-scene-yaw' => ( isset( $hotspot['sceneYaw'] ) && $hotspot['sceneYaw'] !== null ) ? (string) $hotspot['sceneYaw'] : '',
648 990 'hotspot-scene-entry-point-mode' => in_array( $hotspot['sceneEntryPointMode'] ?? '', [ 'inherit', 'custom' ], true )
649 991 ? $hotspot['sceneEntryPointMode']
650 992 : 'inherit',
651 993 ] );
@@ -653,6 +995,116 @@
653 995
654 996 $hotspot_list[] = $hs;
655 997 }
656 998 return $hotspot_list;
999 + }
1000 +
1001 + protected function text_overlays_to_api( array $list ): array {
1002 + $overlays = [];
1003 + foreach ( $list as $item ) {
1004 + if ( ! is_array( $item ) ) {
1005 + continue;
1006 + }
1007 + $overlays[] = [
1008 + 'id' => (string) ( $item['id'] ?? ( 'overlay_' . wp_generate_uuid4() ) ),
1009 + 'name' => sanitize_text_field( (string) ( $item['name'] ?? 'Text Overlay Layer' ) ),
1010 + 'enabled' => ! isset( $item['enabled'] ) || ! empty( $item['enabled'] ),
1011 + 'template' => in_array( $item['template'] ?? '', [ 'left', 'right', 'top', 'bottom', 'custom' ], true ) ? $item['template'] : '',
1012 + 'bgColor' => sanitize_hex_color( $item['bgColor'] ?? '' ) ?: '#281E19',
1013 + 'bgOpacity' => isset( $item['bgOpacity'] ) ? (float) $item['bgOpacity'] : 55,
1014 + 'blur' => isset( $item['blur'] ) ? (float) $item['blur'] : 14,
1015 + 'brightness' => isset( $item['brightness'] ) ? (float) $item['brightness'] : 85,
1016 + 'text' => TextOverlayContent::sanitize( (string) ( $item['text'] ?? '' ) ),
1017 + 'showClose' => ! isset( $item['showClose'] ) || ! empty( $item['showClose'] ),
1018 + 'color' => sanitize_hex_color( $item['color'] ?? '' ) ?: '#ffffff',
1019 + 'fontSize' => isset( $item['fontSize'] ) ? (int) $item['fontSize'] : 18,
1020 + 'fontWeight' => in_array( $item['fontWeight'] ?? '', [ 'normal', 'bold' ], true ) ? $item['fontWeight'] : 'normal',
1021 + 'fontStyle' => in_array( $item['fontStyle'] ?? '', [ 'normal', 'italic' ], true ) ? $item['fontStyle'] : 'normal',
1022 + 'textAlign' => in_array( $item['textAlign'] ?? '', [ 'left', 'center', 'right' ], true ) ? $item['textAlign'] : 'left',
1023 + 'width' => isset( $item['width'] ) ? (float) $item['width'] : ( isset( $item['position']['width'] ) ? (float) $item['position']['width'] : 75 ),
1024 + 'position' => [
1025 + 'x' => isset( $item['position']['x'] ) ? (float) $item['position']['x'] : 10,
1026 + 'y' => isset( $item['position']['y'] ) ? (float) $item['position']['y'] : 15,
1027 + 'width' => isset( $item['position']['width'] ) ? (float) $item['position']['width'] : ( isset( $item['width'] ) ? (float) $item['width'] : 75 ),
1028 + ],
1029 + 'containerRect' => isset( $item['containerRect'] ) && is_array( $item['containerRect'] ) ? [
1030 + 'top' => isset( $item['containerRect']['top'] ) ? (float) $item['containerRect']['top'] : 20,
1031 + 'left' => isset( $item['containerRect']['left'] ) ? (float) $item['containerRect']['left'] : 20,
1032 + 'width' => isset( $item['containerRect']['width'] ) ? (float) $item['containerRect']['width'] : 60,
1033 + 'height' => isset( $item['containerRect']['height'] ) ? (float) $item['containerRect']['height'] : 60,
1034 + ] : null,
1035 + 'borderRadius' => isset( $item['borderRadius'] ) && is_array( $item['borderRadius'] ) ? [
1036 + 'topLeft' => isset( $item['borderRadius']['topLeft'] ) ? (float) $item['borderRadius']['topLeft'] : 0,
1037 + 'topRight' => isset( $item['borderRadius']['topRight'] ) ? (float) $item['borderRadius']['topRight'] : 0,
1038 + 'bottomRight' => isset( $item['borderRadius']['bottomRight'] ) ? (float) $item['borderRadius']['bottomRight'] : 0,
1039 + 'bottomLeft' => isset( $item['borderRadius']['bottomLeft'] ) ? (float) $item['borderRadius']['bottomLeft'] : 0,
1040 + ] : ( isset( $item['borderRadius'] ) && is_numeric( $item['borderRadius'] ) ? [
1041 + 'topLeft' => (float) $item['borderRadius'],
1042 + 'topRight' => (float) $item['borderRadius'],
1043 + 'bottomRight' => (float) $item['borderRadius'],
1044 + 'bottomLeft' => (float) $item['borderRadius'],
1045 + ] : [
1046 + 'topLeft' => 0,
1047 + 'topRight' => 0,
1048 + 'bottomRight' => 0,
1049 + 'bottomLeft' => 0,
1050 + ] ),
1051 + ];
1052 + }
1053 + return array_slice( $overlays, 0, 5 );
1054 + }
1055 +
1056 + protected function text_overlays_from_api( array $list ): array {
1057 + $overlays = [];
1058 + foreach ( $list as $item ) {
1059 + if ( ! is_array( $item ) ) {
1060 + continue;
1061 + }
1062 + $overlays[] = [
1063 + 'id' => sanitize_text_field( (string) ( $item['id'] ?? '' ) ),
1064 + 'name' => sanitize_text_field( (string) ( $item['name'] ?? 'Text Overlay Layer' ) ),
1065 + 'enabled' => ! isset( $item['enabled'] ) || ! empty( $item['enabled'] ),
1066 + 'template' => in_array( $item['template'] ?? '', [ 'left', 'right', 'top', 'bottom', 'custom' ], true ) ? $item['template'] : '',
1067 + 'bgColor' => sanitize_hex_color( $item['bgColor'] ?? '' ) ?: '#281E19',
1068 + 'bgOpacity' => isset( $item['bgOpacity'] ) ? (float) $item['bgOpacity'] : 55,
1069 + 'blur' => isset( $item['blur'] ) ? (float) $item['blur'] : 14,
1070 + 'brightness' => isset( $item['brightness'] ) ? (float) $item['brightness'] : 85,
1071 + 'text' => TextOverlayContent::sanitize( (string) ( $item['text'] ?? '' ) ),
1072 + 'showClose' => ! isset( $item['showClose'] ) || ! empty( $item['showClose'] ),
1073 + 'color' => sanitize_hex_color( $item['color'] ?? '' ) ?: '#ffffff',
1074 + 'fontSize' => isset( $item['fontSize'] ) ? (int) $item['fontSize'] : 18,
1075 + 'fontWeight' => in_array( $item['fontWeight'] ?? '', [ 'normal', 'bold' ], true ) ? $item['fontWeight'] : 'normal',
1076 + 'fontStyle' => in_array( $item['fontStyle'] ?? '', [ 'normal', 'italic' ], true ) ? $item['fontStyle'] : 'normal',
1077 + 'textAlign' => in_array( $item['textAlign'] ?? '', [ 'left', 'center', 'right' ], true ) ? $item['textAlign'] : 'left',
1078 + 'width' => isset( $item['width'] ) ? (float) $item['width'] : ( isset( $item['position']['width'] ) ? (float) $item['position']['width'] : 75 ),
1079 + 'position' => [
1080 + 'x' => isset( $item['position']['x'] ) ? (float) $item['position']['x'] : 10,
1081 + 'y' => isset( $item['position']['y'] ) ? (float) $item['position']['y'] : 15,
1082 + 'width' => isset( $item['position']['width'] ) ? (float) $item['position']['width'] : ( isset( $item['width'] ) ? (float) $item['width'] : 75 ),
1083 + ],
1084 + 'containerRect' => isset( $item['containerRect'] ) && is_array( $item['containerRect'] ) ? [
1085 + 'top' => isset( $item['containerRect']['top'] ) ? (float) $item['containerRect']['top'] : 20,
1086 + 'left' => isset( $item['containerRect']['left'] ) ? (float) $item['containerRect']['left'] : 20,
1087 + 'width' => isset( $item['containerRect']['width'] ) ? (float) $item['containerRect']['width'] : 60,
1088 + 'height' => isset( $item['containerRect']['height'] ) ? (float) $item['containerRect']['height'] : 60,
1089 + ] : null,
1090 + 'borderRadius' => isset( $item['borderRadius'] ) && is_array( $item['borderRadius'] ) ? [
1091 + 'topLeft' => isset( $item['borderRadius']['topLeft'] ) ? (float) $item['borderRadius']['topLeft'] : 0,
1092 + 'topRight' => isset( $item['borderRadius']['topRight'] ) ? (float) $item['borderRadius']['topRight'] : 0,
1093 + 'bottomRight' => isset( $item['borderRadius']['bottomRight'] ) ? (float) $item['borderRadius']['bottomRight'] : 0,
1094 + 'bottomLeft' => isset( $item['borderRadius']['bottomLeft'] ) ? (float) $item['borderRadius']['bottomLeft'] : 0,
1095 + ] : ( isset( $item['borderRadius'] ) && is_numeric( $item['borderRadius'] ) ? [
1096 + 'topLeft' => (float) $item['borderRadius'],
1097 + 'topRight' => (float) $item['borderRadius'],
1098 + 'bottomRight' => (float) $item['borderRadius'],
1099 + 'bottomLeft' => (float) $item['borderRadius'],
1100 + ] : [
1101 + 'topLeft' => 0,
1102 + 'topRight' => 0,
1103 + 'bottomRight' => 0,
1104 + 'bottomLeft' => 0,
1105 + ] ),
1106 + ];
1107 + }
1108 + return array_slice( $overlays, 0, 5 );
657 1109 }
658 1110 }