PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.2.0
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.2.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 8.5.37 All 224 releases
← All changes | src/Api/Transformers/TourTransformer.php +460 -10 9.0.3 → 9.2.0 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace RexTheme\WPVR\Api\Transformers;
4 4
5 5 use RexTheme\WPVR\Api\Contracts\TransformerInterface;
6 +use RexTheme\WPVR\Content\TextOverlayContent;
6 7
7 8 class TourTransformer implements TransformerInterface {
8 9
9 10 protected bool $is_pro;
@@ -53,8 +54,9 @@
53 54 'previewImage' => $raw['preview'] ?? '',
54 55 'sceneFadeDuration' => isset( $raw['scenefadeduration'] ) ? (int) $raw['scenefadeduration'] : 0,
55 56 'showSceneInfo' => ( $raw['scene-info-enabled'] ?? 'on' ) !== 'off',
56 57 'autoRotate' => $auto_rotate,
58 + 'socialShare' => ( $raw['wpvr_social_share'] ?? 'off' ) === 'on',
57 59 ],
58 60 'floorPlan' => $this->floor_plan_to_api( $raw ),
59 61 'backgroundTour' => [
60 62 'enabled' => ( $raw['bg_tour_enabler'] ?? 'off' ) === 'on',
@@ -62,10 +64,10 @@
62 64 'subtitle' => $raw['bg_tour_subtitle'] ?? '',
63 65 ],
64 66 'videoData' => [
65 67 'url' => $raw['vidurl'] ?? '',
66 - 'autoplay' => ( $raw['video-autoplay'] ?? 'off' ) === 'on',
67 - 'loop' => ( $raw['video-loop'] ?? 'off' ) === 'on',
68 + 'autoplay' => ( $raw['video-autoplay'] ?? $raw['autoplay'] ?? 'off' ) === 'on',
69 + 'loop' => ( $raw['video-loop'] ?? $raw['loop'] ?? 'off' ) === 'on',
68 70 ],
69 71 'streetViewData' => [
70 72 'embedUrl' => $raw['streetviewurl'] ?? '',
71 73 ],
@@ -161,8 +163,10 @@
161 163 'tour-type' => $tour_type,
162 164 'vidurl' => esc_url_raw( $video_data['url'] ?? '' ),
163 165 'video-autoplay' => ! empty( $video_data['autoplay'] ) ? 'on' : 'off',
164 166 'video-loop' => ! empty( $video_data['loop'] ) ? 'on' : 'off',
167 + 'autoplay' => ! empty( $video_data['autoplay'] ) ? 'on' : 'off',
168 + 'loop' => ! empty( $video_data['loop'] ) ? 'on' : 'off',
165 169 'streetviewurl' => esc_url_raw( $street_view_data['embedUrl'] ?? '' ),
166 170 'streetview' => ! empty( $street_view_data['embedUrl'] ) ? 'on' : 'off',
167 171 'panodata' => [
168 172 'scene-list' => $this->scenes_from_api(
@@ -170,10 +174,15 @@
170 174 $default_scene_id,
171 175 ( $settings['showSceneInfo'] ?? true ) !== false
172 176 ),
173 177 ],
178 + 'wpvr_social_share' => ! empty( $settings['socialShare'] ) ? 'on' : 'off',
174 179 ];
175 180
181 + if ( $tour_type === 'video' && ! empty( $video_data['url'] ) ) {
182 + $raw['vidid'] = 'vid' . ( $data['tourId'] ?? $data['id'] ?? wp_rand( 1000, 99999 ) );
183 + }
184 +
176 185 return $raw;
177 186 }
178 187
179 188 // -------------------------------------------------------------------------
@@ -266,9 +275,9 @@
266 275 }
267 276 if ( isset( $raw['streetviewdata'] ) || ! empty( $raw['streetviewurl'] ) ) {
268 277 return 'street-view';
269 278 }
270 - if ( isset( $raw['vidid'] ) || ! empty( $raw['vidurl'] ) ) {
279 + if ( ! empty( $raw['vidid'] ) || ! empty( $raw['vidurl'] ) ) {
271 280 return 'video';
272 281 }
273 282 return 'image';
274 283 }
@@ -472,8 +481,10 @@
472 481 $scene['scene-attachment-url-face3'] ?? null,
473 482 $scene['scene-attachment-url-face4'] ?? null,
474 483 $scene['scene-attachment-url-face5'] ?? null,
475 484 ],
485 + 'textOverlays' => $this->text_overlays_to_api( $scene['text-overlays'] ?? [] ),
486 + 'showLayerToggle' => ( $scene['scene-show-layer-toggle'] ?? 'on' ) === 'on',
476 487 ];
477 488 }
478 489 // Older tours did not store whether a hotspot entry point inherited
479 490 // the target scene face or was edited manually. Keep those links in
@@ -506,9 +517,12 @@
506 517 'scene-type' => $this->is_pro && ( $scene['type'] ?? '' ) === 'cubemap' ? 'cubemap' : 'equirectangular',
507 518 'scene-attachment-url' => $scene['imageUrl'] ?? '',
508 519 'scene-show-info' => $show_scene_info ? 'on' : 'off',
509 520 'hotspot-list' => $this->hotspots_from_api( $scene['hotspots'] ?? [] ),
510 - 'dscene' => ( $default_scene_id !== '' && $scene_id === $default_scene_id ) ? 'on' : 'off',
521 + 'dscene' => ( $default_scene_id !== '' && $scene_id === $default_scene_id ) ? 'on' : 'off',
522 + 'text-overlays' => $this->text_overlays_from_api( $scene['textOverlays'] ?? [] ),
523 + 'scene-show-layer-toggle' => ( ! isset( $scene['showLayerToggle'] ) || ! empty( $scene['showLayerToggle'] ) ) ? 'on' : 'off',
524 + 'showLayerToggle' => ( ! isset( $scene['showLayerToggle'] ) || ! empty( $scene['showLayerToggle'] ) ),
511 525 ];
512 526
513 527 if ( $this->is_pro ) {
514 528 $scene_data = array_merge( $scene_data, [
@@ -541,8 +555,9 @@
541 555 'scene-attachment-url-face2' => $faces[2] ?? '',
542 556 'scene-attachment-url-face3' => $faces[3] ?? '',
543 557 'scene-attachment-url-face4' => $faces[4] ?? '',
544 558 'scene-attachment-url-face5' => $faces[5] ?? '',
559 + 'text-overlays' => $this->text_overlays_from_api( $scene['textOverlays'] ?? [] ),
545 560 ] );
546 561 }
547 562
548 563 $scene_list[ $index ] = $scene_data;
@@ -562,8 +577,23 @@
562 577 : null;
563 578 $scene_yaw = isset( $hotspot['hotspot-scene-yaw'] ) && $hotspot['hotspot-scene-yaw'] !== ''
564 579 ? (float) $hotspot['hotspot-scene-yaw']
565 580 : null;
581 + $product_id = isset( $hotspot['hotspot-product-id'] ) ? (string) $hotspot['hotspot-product-id'] : '';
582 + $product_name = '';
583 + if ( ! empty( $product_id ) && function_exists( 'wc_get_product' ) ) {
584 + $product_obj = wc_get_product( $product_id );
585 + if ( is_object( $product_obj ) ) {
586 + $product_name = $product_obj->get_formatted_name();
587 + }
588 + }
589 +
590 + $template_val = $hotspot['hotspot-sticker-template'] ?? '';
591 + $is_separate_icon = $template_val === 'button_with_separate_icon';
592 + $is_add_to_cart = $template_val === 'add_to_cart';
593 + $is_social_share = $template_val === 'social_share';
594 + $default_card_radius = $is_separate_icon ? 135 : ( ( $is_add_to_cart || $is_social_share ) ? 15 : 20 );
595 +
566 596 $hotspots[] = [
567 597 'id' => $hotspot['hotspot-id'] ?? wp_generate_uuid4(),
568 598 'type' => $hotspot['hotspot-type'] ?? 'info',
569 599 'pitch' => isset( $hotspot['hotspot-pitch'] ) ? (float) $hotspot['hotspot-pitch'] : 0,
@@ -574,8 +604,95 @@
574 604 'urlOpen' => $hotspot['hotspot-url-open'] ?? 'off',
575 605 'hover' => $hotspot['hotspot-hover'] ?? '',
576 606 'targetSceneId' => $hotspot['hotspot-scene'] ?? '',
577 607 'customClass' => $hotspot['hotspot-customclass'] ?? '',
608 + 'fluentFormId' => isset( $hotspot['fluent-form-id'] ) ? (string) $hotspot['fluent-form-id'] : '',
609 + 'productId' => $product_id,
610 + 'productName' => $product_name,
611 + // Sticker fields
612 + 'stickerTemplate' => $template_val ?: 'social_proof',
613 + '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!',
614 + 'stickerClientName' => $hotspot['hotspot-sticker-client-name'] ?? 'Elena R.',
615 + 'stickerClientAvatar' => $hotspot['hotspot-sticker-client-avatar'] ?? '',
616 + 'stickerRating' => isset( $hotspot['hotspot-sticker-rating'] ) ? (int) $hotspot['hotspot-sticker-rating'] : 5,
617 + 'stickerBgColor' => $hotspot['hotspot-sticker-bg-color'] ?? '#201b2c',
618 + '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 ),
619 + 'stickerBlur' => isset( $hotspot['hotspot-sticker-blur'] ) ? (float) $hotspot['hotspot-sticker-blur'] : 12,
620 + 'stickerBrightness' => isset( $hotspot['hotspot-sticker-brightness'] ) ? (float) $hotspot['hotspot-sticker-brightness'] : 100,
621 + 'stickerTextColor' => $hotspot['hotspot-sticker-text-color'] ?? '#ffffff',
622 + 'stickerBorderColor' => $hotspot['hotspot-sticker-border-color'] ?? ( ( $is_separate_icon || $is_add_to_cart || $is_social_share ) ? '#40355a' : '#3a3051' ),
623 + 'stickerBorderRadius' => isset( $hotspot['hotspot-sticker-border-radius'] ) && is_array( $hotspot['hotspot-sticker-border-radius'] ) ? [
624 + 'topLeft' => isset( $hotspot['hotspot-sticker-border-radius']['topLeft'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['topLeft'] : $default_card_radius,
625 + 'topRight' => isset( $hotspot['hotspot-sticker-border-radius']['topRight'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['topRight'] : $default_card_radius,
626 + 'bottomRight' => isset( $hotspot['hotspot-sticker-border-radius']['bottomRight'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['bottomRight'] : $default_card_radius,
627 + 'bottomLeft' => isset( $hotspot['hotspot-sticker-border-radius']['bottomLeft'] ) ? (float) $hotspot['hotspot-sticker-border-radius']['bottomLeft'] : $default_card_radius,
628 + ] : ( isset( $hotspot['hotspot-sticker-border-radius'] ) && is_numeric( $hotspot['hotspot-sticker-border-radius'] ) ? [
629 + 'topLeft' => (float) $hotspot['hotspot-sticker-border-radius'],
630 + 'topRight' => (float) $hotspot['hotspot-sticker-border-radius'],
631 + 'bottomRight' => (float) $hotspot['hotspot-sticker-border-radius'],
632 + 'bottomLeft' => (float) $hotspot['hotspot-sticker-border-radius'],
633 + ] : [
634 + 'topLeft' => $default_card_radius,
635 + 'topRight' => $default_card_radius,
636 + 'bottomRight' => $default_card_radius,
637 + 'bottomLeft' => $default_card_radius,
638 + ] ),
639 + 'stickerPadding' => isset( $hotspot['hotspot-sticker-padding'] ) && is_array( $hotspot['hotspot-sticker-padding'] ) ? [
640 + 'top' => isset( $hotspot['hotspot-sticker-padding']['top'] ) ? (float) $hotspot['hotspot-sticker-padding']['top'] : 21,
641 + 'right' => isset( $hotspot['hotspot-sticker-padding']['right'] ) ? (float) $hotspot['hotspot-sticker-padding']['right'] : 21,
642 + 'bottom' => isset( $hotspot['hotspot-sticker-padding']['bottom'] ) ? (float) $hotspot['hotspot-sticker-padding']['bottom'] : 21,
643 + 'left' => isset( $hotspot['hotspot-sticker-padding']['left'] ) ? (float) $hotspot['hotspot-sticker-padding']['left'] : 21,
644 + ] : ( isset( $hotspot['hotspot-sticker-padding'] ) && is_numeric( $hotspot['hotspot-sticker-padding'] ) ? [
645 + 'top' => (float) $hotspot['hotspot-sticker-padding'],
646 + 'right' => (float) $hotspot['hotspot-sticker-padding'],
647 + 'bottom' => (float) $hotspot['hotspot-sticker-padding'],
648 + 'left' => (float) $hotspot['hotspot-sticker-padding'],
649 + ] : [
650 + 'top' => 21,
651 + 'right' => 21,
652 + 'bottom' => 21,
653 + 'left' => 21,
654 + ] ),
655 + 'stickerStarColor' => $hotspot['hotspot-sticker-star-color'] ?? '#EF991F',
656 + // Text before button (for add_to_cart)
657 + 'stickerPrefixText' => $hotspot['hotspot-sticker-prefix-text'] ?? '$1,090 -',
658 + 'stickerSubText' => $hotspot['hotspot-sticker-sub-text'] ?? 'Ready to ship',
659 + // Discount button, add to cart & social share sticker fields
660 + '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' ) ) ),
661 + 'stickerBtnColor' => $hotspot['hotspot-sticker-btn-color'] ?? ( $is_social_share ? '#201a2b' : ( $is_add_to_cart ? '#3f04fe' : ( $is_separate_icon ? '#ffffff' : '#EF991F' ) ) ),
662 + 'stickerBtnTextColor' => $hotspot['hotspot-sticker-btn-text-color'] ?? ( ( $is_add_to_cart || $is_social_share ) ? '#ffffff' : '#000000' ),
663 + 'stickerBtnIconColor' => $hotspot['hotspot-sticker-btn-icon-color'] ?? '#000000',
664 + 'stickerBtnUrl' => $hotspot['hotspot-sticker-btn-url'] ?? '',
665 + 'stickerBtnNewTab' => $hotspot['hotspot-sticker-btn-new-tab'] ?? 'off',
666 + 'stickerMainBg' => $hotspot['hotspot-sticker-main-bg'] ?? ( $hotspot['hotspot-sticker-card-bg'] ?? 'on' ),
667 + 'stickerCardBg' => $hotspot['hotspot-sticker-card-bg'] ?? ( $hotspot['hotspot-sticker-main-bg'] ?? 'on' ),
668 + 'stickerBtnBg' => $hotspot['hotspot-sticker-btn-bg'] ?? 'on',
669 + '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 : '' ) ) ),
670 + '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 : '' ),
671 + 'stickerBtnRadius' => isset( $hotspot['hotspot-sticker-btn-radius'] ) && $hotspot['hotspot-sticker-btn-radius'] !== '' ? (float) $hotspot['hotspot-sticker-btn-radius'] : ( $is_separate_icon ? 30 : 10 ),
672 + 'stickerBtnBorder' => isset( $hotspot['hotspot-sticker-btn-border'] ) && $hotspot['hotspot-sticker-btn-border'] !== '' ? (float) $hotspot['hotspot-sticker-btn-border'] : ( $is_social_share ? 1 : 0 ),
673 + 'stickerBtnBorderColor' => $hotspot['hotspot-sticker-btn-border-color'] ?? ( $is_social_share ? '#3a3051' : ( ( $is_add_to_cart || $is_separate_icon ) ? '#ffffff' : '#EF991F' ) ),
674 + 'stickerBtnTextSize' => isset( $hotspot['hotspot-sticker-btn-text-size'] ) && $hotspot['hotspot-sticker-btn-text-size'] !== '' ? (float) $hotspot['hotspot-sticker-btn-text-size'] : 18,
675 + 'stickerBtnTextWeight' => $hotspot['hotspot-sticker-btn-text-weight'] ?? ( ( $is_social_share || $is_add_to_cart || $is_separate_icon ) ? '600' : '700' ),
676 + 'stickerBtnIcon' => ( $is_add_to_cart || $is_social_share ) ? 'none' : ( $hotspot['hotspot-sticker-btn-icon'] ?? 'fas fa-tag' ),
677 + // Button with separate icon fields
678 + 'stickerIconBoxBgColor' => $hotspot['hotspot-sticker-icon-box-bg-color'] ?? '#ffffff',
679 + 'stickerIconBoxRadius' => isset( $hotspot['hotspot-sticker-icon-box-radius'] ) && $hotspot['hotspot-sticker-icon-box-radius'] !== '' ? (float) $hotspot['hotspot-sticker-icon-box-radius'] : 30,
680 + 'stickerIconBoxBorder' => isset( $hotspot['hotspot-sticker-icon-box-border'] ) && $hotspot['hotspot-sticker-icon-box-border'] !== '' ? (float) $hotspot['hotspot-sticker-icon-box-border'] : 0,
681 + 'stickerIconBoxBorderColor' => $hotspot['hotspot-sticker-icon-box-border-color'] ?? '#ffffff',
682 + 'stickerIconBoxSize' => isset( $hotspot['hotspot-sticker-icon-box-size'] ) && $hotspot['hotspot-sticker-icon-box-size'] !== '' ? (float) $hotspot['hotspot-sticker-icon-box-size'] : 60,
683 + // Social share sticker fields
684 + 'stickerSocialColor' => $hotspot['hotspot-sticker-social-color'] ?? '#ffffff',
685 + 'stickerSocialSize' => isset( $hotspot['hotspot-sticker-social-size'] ) && $hotspot['hotspot-sticker-social-size'] !== '' ? (float) $hotspot['hotspot-sticker-social-size'] : 20,
686 + 'stickerSocialGap' => isset( $hotspot['hotspot-sticker-social-gap'] ) && $hotspot['hotspot-sticker-social-gap'] !== '' ? (float) $hotspot['hotspot-sticker-social-gap'] : 16,
687 + '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 ) ) : [
688 + [ 'id' => '1', 'icon' => 'fab fa-linkedin-in', 'customSvg' => '', 'url' => 'https://linkedin.com', 'openNewTab' => 'on' ],
689 + [ 'id' => '2', 'icon' => 'fab fa-facebook-f', 'customSvg' => '', 'url' => 'https://facebook.com', 'openNewTab' => 'on' ],
690 + [ 'id' => '3', 'icon' => 'fab fa-instagram', 'customSvg' => '', 'url' => 'https://instagram.com', 'openNewTab' => 'on' ],
691 + [ 'id' => '4', 'icon' => 'fab fa-dribbble', 'customSvg' => '', 'url' => 'https://dribbble.com', 'openNewTab' => 'on' ],
692 + ],
693 + 'stickerShowPlaceholderText' => $hotspot['hotspot-sticker-show-placeholder-text'] ?? 'on',
694 + 'scale' => isset( $hotspot['hotspot-scale'] ) ? ( $hotspot['hotspot-scale'] === 'on' || $hotspot['hotspot-scale'] === true ) : ( ( $hotspot['hotspot-type'] ?? '' ) === 'sticker' ),
578 695 // Pro styling fields
579 696 'iconClass' => ( ( $hotspot['hotspot-customclass-pro'] ?? '' ) === 'none' || ( $hotspot['hotspot-customclass-pro'] ?? '' ) === '' ) ? '' : $hotspot['hotspot-customclass-pro'],
580 697 'iconBgColor' => $hotspot['hotspot-customclass-color-icon-value'] ?? '#00b4ff',
581 698 'iconColor' => $hotspot['hotspot-custom-icon-color-value'] ?? '#ffffff',
@@ -601,11 +718,17 @@
601 718 $is_fluent_form = $hotspot_type === 'fluent_form';
602 719 $raw_content = (string) ( $hotspot['content'] ?? '' );
603 720 $raw_hover = (string) ( $hotspot['hover'] ?? '' );
604 721
605 - $content = function_exists( 'sanitize_content_preserve_styles' )
606 - ? sanitize_content_preserve_styles( $raw_content, $is_fluent_form )
607 - : wp_kses_post( $raw_content );
722 + // For fluent_form hotspots, content is dynamically rendered server-side from fluent-form-id.
723 + // User-supplied content is never used and must not be saved, completely eliminating stored XSS.
724 + if ( $is_fluent_form ) {
725 + $content = '';
726 + } else {
727 + $content = function_exists( 'sanitize_content_preserve_styles' )
728 + ? sanitize_content_preserve_styles( $raw_content, false )
729 + : wp_kses_post( $raw_content );
730 + }
608 731 $hover = function_exists( 'sanitize_content_preserve_styles' )
609 732 ? sanitize_content_preserve_styles( $raw_hover, false )
610 733 : wp_kses_post( $raw_hover );
611 734
@@ -623,8 +746,226 @@
623 746 'hotspot-customclass' => sanitize_text_field( $hotspot['customClass'] ?? '' ),
624 747 'hotspot-scene-list' => 'none',
625 748 ];
626 749
750 + if ( isset( $hotspot['fluentFormId'] ) ) {
751 + $hs['fluent-form-id'] = (string) absint( $hotspot['fluentFormId'] );
752 + } elseif ( isset( $hotspot['fluent-form-id'] ) ) {
753 + $hs['fluent-form-id'] = (string) absint( $hotspot['fluent-form-id'] );
754 + }
755 +
756 + if ( isset( $hotspot['productId'] ) ) {
757 + $hs['hotspot-product-id'] = sanitize_text_field( $hotspot['productId'] );
758 + } elseif ( isset( $hotspot['hotspot-product-id'] ) ) {
759 + $hs['hotspot-product-id'] = sanitize_text_field( $hotspot['hotspot-product-id'] );
760 + }
761 +
762 + // Sticker fields
763 + if ( isset( $hotspot['stickerTemplate'] ) || isset( $hotspot['hotspot-sticker-template'] ) ) {
764 + $hs['hotspot-sticker-template'] = sanitize_text_field( $hotspot['stickerTemplate'] ?? $hotspot['hotspot-sticker-template'] );
765 + }
766 + if ( isset( $hotspot['stickerReviewText'] ) || isset( $hotspot['hotspot-sticker-review-text'] ) ) {
767 + $hs['hotspot-sticker-review-text'] = sanitize_textarea_field( $hotspot['stickerReviewText'] ?? $hotspot['hotspot-sticker-review-text'] );
768 + }
769 + if ( isset( $hotspot['stickerClientName'] ) || isset( $hotspot['hotspot-sticker-client-name'] ) ) {
770 + $hs['hotspot-sticker-client-name'] = sanitize_text_field( $hotspot['stickerClientName'] ?? $hotspot['hotspot-sticker-client-name'] );
771 + }
772 + if ( isset( $hotspot['stickerClientAvatar'] ) || isset( $hotspot['hotspot-sticker-client-avatar'] ) ) {
773 + $hs['hotspot-sticker-client-avatar'] = esc_url_raw( $hotspot['stickerClientAvatar'] ?? $hotspot['hotspot-sticker-client-avatar'] );
774 + }
775 + if ( isset( $hotspot['stickerRating'] ) || isset( $hotspot['hotspot-sticker-rating'] ) ) {
776 + $hs['hotspot-sticker-rating'] = (string) max( 1, min( 5, (int) ( $hotspot['stickerRating'] ?? $hotspot['hotspot-sticker-rating'] ) ) );
777 + }
778 + if ( isset( $hotspot['stickerBgColor'] ) || isset( $hotspot['hotspot-sticker-bg-color'] ) ) {
779 + $hs['hotspot-sticker-bg-color'] = sanitize_text_field( $hotspot['stickerBgColor'] ?? $hotspot['hotspot-sticker-bg-color'] );
780 + }
781 + if ( isset( $hotspot['stickerBgOpacity'] ) || isset( $hotspot['hotspot-sticker-bg-opacity'] ) ) {
782 + $hs['hotspot-sticker-bg-opacity'] = max( 0, min( 100, (float) ( $hotspot['stickerBgOpacity'] ?? $hotspot['hotspot-sticker-bg-opacity'] ) ) );
783 + }
784 + if ( isset( $hotspot['stickerBlur'] ) || isset( $hotspot['hotspot-sticker-blur'] ) ) {
785 + $hs['hotspot-sticker-blur'] = max( 0, min( 40, (float) ( $hotspot['stickerBlur'] ?? $hotspot['hotspot-sticker-blur'] ) ) );
786 + }
787 + if ( isset( $hotspot['stickerBrightness'] ) || isset( $hotspot['hotspot-sticker-brightness'] ) ) {
788 + $hs['hotspot-sticker-brightness'] = max( 0, min( 200, (float) ( $hotspot['stickerBrightness'] ?? $hotspot['hotspot-sticker-brightness'] ) ) );
789 + }
790 + if ( isset( $hotspot['stickerTextColor'] ) || isset( $hotspot['hotspot-sticker-text-color'] ) ) {
791 + $hs['hotspot-sticker-text-color'] = sanitize_hex_color( $hotspot['stickerTextColor'] ?? $hotspot['hotspot-sticker-text-color'] ) ?: '#ffffff';
792 + }
793 + if ( isset( $hotspot['stickerBorderColor'] ) || isset( $hotspot['hotspot-sticker-border-color'] ) ) {
794 + $raw_border_color = strtolower( trim( (string) ( $hotspot['stickerBorderColor'] ?? $hotspot['hotspot-sticker-border-color'] ) ) );
795 + if ( $raw_border_color === 'none' || $raw_border_color === 'transparent' ) {
796 + $hs['hotspot-sticker-border-color'] = $raw_border_color;
797 + } else {
798 + $hs['hotspot-sticker-border-color'] = sanitize_hex_color( $raw_border_color ) ?: '#3a3051';
799 + }
800 + }
801 + if ( isset( $hotspot['stickerBorderRadius'] ) || isset( $hotspot['hotspot-sticker-border-radius'] ) ) {
802 + $raw_radius = $hotspot['stickerBorderRadius'] ?? $hotspot['hotspot-sticker-border-radius'];
803 + if ( is_array( $raw_radius ) ) {
804 + $hs['hotspot-sticker-border-radius'] = [
805 + 'topLeft' => max( 0, min( 500, (float) ( $raw_radius['topLeft'] ?? 20 ) ) ),
806 + 'topRight' => max( 0, min( 500, (float) ( $raw_radius['topRight'] ?? 20 ) ) ),
807 + 'bottomRight' => max( 0, min( 500, (float) ( $raw_radius['bottomRight'] ?? 20 ) ) ),
808 + 'bottomLeft' => max( 0, min( 500, (float) ( $raw_radius['bottomLeft'] ?? 20 ) ) ),
809 + ];
810 + } else {
811 + $val = max( 0, min( 500, (float) $raw_radius ) );
812 + $hs['hotspot-sticker-border-radius'] = [
813 + 'topLeft' => $val,
814 + 'topRight' => $val,
815 + 'bottomRight' => $val,
816 + 'bottomLeft' => $val,
817 + ];
818 + }
819 + }
820 + if ( isset( $hotspot['stickerPadding'] ) || isset( $hotspot['hotspot-sticker-padding'] ) ) {
821 + $raw_pad = $hotspot['stickerPadding'] ?? $hotspot['hotspot-sticker-padding'];
822 + if ( is_array( $raw_pad ) ) {
823 + $hs['hotspot-sticker-padding'] = [
824 + 'top' => max( 0, min( 200, (float) ( $raw_pad['top'] ?? 21 ) ) ),
825 + 'right' => max( 0, min( 200, (float) ( $raw_pad['right'] ?? 21 ) ) ),
826 + 'bottom' => max( 0, min( 200, (float) ( $raw_pad['bottom'] ?? 21 ) ) ),
827 + 'left' => max( 0, min( 200, (float) ( $raw_pad['left'] ?? 21 ) ) ),
828 + ];
829 + } else {
830 + $val = max( 0, min( 200, (float) $raw_pad ) );
831 + $hs['hotspot-sticker-padding'] = [
832 + 'top' => $val,
833 + 'right' => $val,
834 + 'bottom' => $val,
835 + 'left' => $val,
836 + ];
837 + }
838 + }
839 + if ( isset( $hotspot['stickerStarColor'] ) || isset( $hotspot['hotspot-sticker-star-color'] ) ) {
840 + $hs['hotspot-sticker-star-color'] = sanitize_hex_color( $hotspot['stickerStarColor'] ?? $hotspot['hotspot-sticker-star-color'] ) ?: '#EF991F';
841 + }
842 + // Discount button sticker fields
843 + if ( isset( $hotspot['stickerBtnText'] ) || isset( $hotspot['hotspot-sticker-btn-text'] ) ) {
844 + $hs['hotspot-sticker-btn-text'] = sanitize_text_field( $hotspot['stickerBtnText'] ?? $hotspot['hotspot-sticker-btn-text'] );
845 + }
846 + if ( isset( $hotspot['stickerBtnColor'] ) || isset( $hotspot['hotspot-sticker-btn-color'] ) ) {
847 + $hs['hotspot-sticker-btn-color'] = sanitize_hex_color( $hotspot['stickerBtnColor'] ?? $hotspot['hotspot-sticker-btn-color'] ) ?: '#EF991F';
848 + }
849 + if ( isset( $hotspot['stickerBtnTextColor'] ) || isset( $hotspot['hotspot-sticker-btn-text-color'] ) ) {
850 + $hs['hotspot-sticker-btn-text-color'] = sanitize_hex_color( $hotspot['stickerBtnTextColor'] ?? $hotspot['hotspot-sticker-btn-text-color'] ) ?: '#000000';
851 + }
852 + if ( isset( $hotspot['stickerBtnIconColor'] ) || isset( $hotspot['hotspot-sticker-btn-icon-color'] ) ) {
853 + $hs['hotspot-sticker-btn-icon-color'] = sanitize_hex_color( $hotspot['stickerBtnIconColor'] ?? $hotspot['hotspot-sticker-btn-icon-color'] ) ?: '#000000';
854 + }
855 + if ( isset( $hotspot['stickerBtnUrl'] ) || isset( $hotspot['hotspot-sticker-btn-url'] ) ) {
856 + $hs['hotspot-sticker-btn-url'] = esc_url_raw( $hotspot['stickerBtnUrl'] ?? $hotspot['hotspot-sticker-btn-url'] );
857 + }
858 + if ( isset( $hotspot['stickerBtnNewTab'] ) || isset( $hotspot['hotspot-sticker-btn-new-tab'] ) ) {
859 + $raw_new_tab = $hotspot['stickerBtnNewTab'] ?? $hotspot['hotspot-sticker-btn-new-tab'];
860 + $hs['hotspot-sticker-btn-new-tab'] = ( $raw_new_tab === 'on' || $raw_new_tab === true || $raw_new_tab === 'true' ) ? 'on' : 'off';
861 + }
862 + if ( isset( $hotspot['stickerMainBg'] ) || isset( $hotspot['hotspot-sticker-main-bg'] ) || isset( $hotspot['stickerCardBg'] ) || isset( $hotspot['hotspot-sticker-card-bg'] ) ) {
863 + $raw_main_bg = $hotspot['stickerMainBg'] ?? ( $hotspot['stickerCardBg'] ?? ( $hotspot['hotspot-sticker-main-bg'] ?? $hotspot['hotspot-sticker-card-bg'] ) );
864 + $val = ( $raw_main_bg === 'off' || $raw_main_bg === false || $raw_main_bg === 'false' ) ? 'off' : 'on';
865 + $hs['hotspot-sticker-main-bg'] = $val;
866 + $hs['hotspot-sticker-card-bg'] = $val;
867 + }
868 + if ( isset( $hotspot['stickerBtnBg'] ) || isset( $hotspot['hotspot-sticker-btn-bg'] ) ) {
869 + $raw_bg = $hotspot['stickerBtnBg'] ?? $hotspot['hotspot-sticker-btn-bg'];
870 + $hs['hotspot-sticker-btn-bg'] = ( $raw_bg === 'off' || $raw_bg === false || $raw_bg === 'false' ) ? 'off' : 'on';
871 + }
872 + if ( isset( $hotspot['stickerBtnWidth'] ) || isset( $hotspot['hotspot-sticker-btn-width'] ) ) {
873 + $raw_w = $hotspot['stickerBtnWidth'] ?? $hotspot['hotspot-sticker-btn-width'];
874 + $hs['hotspot-sticker-btn-width'] = ( $raw_w !== '' && $raw_w !== null ) ? sanitize_text_field( (string) $raw_w ) : '';
875 + }
876 + if ( isset( $hotspot['stickerBtnHeight'] ) || isset( $hotspot['hotspot-sticker-btn-height'] ) ) {
877 + $raw_h = $hotspot['stickerBtnHeight'] ?? $hotspot['hotspot-sticker-btn-height'];
878 + $hs['hotspot-sticker-btn-height'] = ( $raw_h !== '' && $raw_h !== null ) ? sanitize_text_field( (string) $raw_h ) : '';
879 + }
880 + if ( isset( $hotspot['stickerBtnRadius'] ) || isset( $hotspot['hotspot-sticker-btn-radius'] ) ) {
881 + $hs['hotspot-sticker-btn-radius'] = (float) ( $hotspot['stickerBtnRadius'] ?? $hotspot['hotspot-sticker-btn-radius'] );
882 + }
883 + if ( isset( $hotspot['stickerBtnBorder'] ) || isset( $hotspot['hotspot-sticker-btn-border'] ) ) {
884 + $hs['hotspot-sticker-btn-border'] = (float) ( $hotspot['stickerBtnBorder'] ?? $hotspot['hotspot-sticker-btn-border'] );
885 + }
886 + if ( isset( $hotspot['stickerBtnBorderColor'] ) || isset( $hotspot['hotspot-sticker-btn-border-color'] ) ) {
887 + $hs['hotspot-sticker-btn-border-color'] = sanitize_hex_color( $hotspot['stickerBtnBorderColor'] ?? $hotspot['hotspot-sticker-btn-border-color'] ) ?: '#EF991F';
888 + }
889 + if ( isset( $hotspot['stickerBtnTextSize'] ) || isset( $hotspot['hotspot-sticker-btn-text-size'] ) ) {
890 + $hs['hotspot-sticker-btn-text-size'] = (float) ( $hotspot['stickerBtnTextSize'] ?? $hotspot['hotspot-sticker-btn-text-size'] );
891 + }
892 + if ( isset( $hotspot['stickerBtnTextWeight'] ) || isset( $hotspot['hotspot-sticker-btn-text-weight'] ) ) {
893 + $hs['hotspot-sticker-btn-text-weight'] = sanitize_text_field( (string) ( $hotspot['stickerBtnTextWeight'] ?? $hotspot['hotspot-sticker-btn-text-weight'] ) );
894 + }
895 + if ( ( $hs['hotspot-sticker-template'] ?? '' ) === 'add_to_cart' || ( $hs['hotspot-sticker-template'] ?? '' ) === 'social_share' ) {
896 + $hs['hotspot-sticker-btn-icon'] = 'none';
897 + } elseif ( isset( $hotspot['stickerBtnIcon'] ) || isset( $hotspot['hotspot-sticker-btn-icon'] ) ) {
898 + $hs['hotspot-sticker-btn-icon'] = sanitize_text_field( $hotspot['stickerBtnIcon'] ?? $hotspot['hotspot-sticker-btn-icon'] );
899 + }
900 + // Add to cart text fields
901 + if ( isset( $hotspot['stickerPrefixText'] ) || isset( $hotspot['hotspot-sticker-prefix-text'] ) ) {
902 + $hs['hotspot-sticker-prefix-text'] = sanitize_text_field( $hotspot['stickerPrefixText'] ?? $hotspot['hotspot-sticker-prefix-text'] );
903 + }
904 + if ( isset( $hotspot['stickerSubText'] ) || isset( $hotspot['hotspot-sticker-sub-text'] ) ) {
905 + $hs['hotspot-sticker-sub-text'] = sanitize_text_field( $hotspot['stickerSubText'] ?? $hotspot['hotspot-sticker-sub-text'] );
906 + }
907 + // Button with separate icon fields
908 + if ( isset( $hotspot['stickerIconBoxBgColor'] ) || isset( $hotspot['hotspot-sticker-icon-box-bg-color'] ) ) {
909 + $hs['hotspot-sticker-icon-box-bg-color'] = sanitize_hex_color( $hotspot['stickerIconBoxBgColor'] ?? $hotspot['hotspot-sticker-icon-box-bg-color'] ) ?: '#ffffff';
910 + }
911 + if ( isset( $hotspot['stickerIconBoxRadius'] ) || isset( $hotspot['hotspot-sticker-icon-box-radius'] ) ) {
912 + $hs['hotspot-sticker-icon-box-radius'] = (float) ( $hotspot['stickerIconBoxRadius'] ?? $hotspot['hotspot-sticker-icon-box-radius'] );
913 + }
914 + if ( isset( $hotspot['stickerIconBoxBorder'] ) || isset( $hotspot['hotspot-sticker-icon-box-border'] ) ) {
915 + $hs['hotspot-sticker-icon-box-border'] = (float) ( $hotspot['stickerIconBoxBorder'] ?? $hotspot['hotspot-sticker-icon-box-border'] );
916 + }
917 + if ( isset( $hotspot['stickerIconBoxBorderColor'] ) || isset( $hotspot['hotspot-sticker-icon-box-border-color'] ) ) {
918 + $hs['hotspot-sticker-icon-box-border-color'] = sanitize_hex_color( $hotspot['stickerIconBoxBorderColor'] ?? $hotspot['hotspot-sticker-icon-box-border-color'] ) ?: '#ffffff';
919 + }
920 + if ( isset( $hotspot['stickerIconBoxSize'] ) || isset( $hotspot['hotspot-sticker-icon-box-size'] ) ) {
921 + $hs['hotspot-sticker-icon-box-size'] = (float) ( $hotspot['stickerIconBoxSize'] ?? $hotspot['hotspot-sticker-icon-box-size'] );
922 + }
923 + // Social share sticker fields
924 + if ( isset( $hotspot['stickerSocialColor'] ) || isset( $hotspot['hotspot-sticker-social-color'] ) ) {
925 + $hs['hotspot-sticker-social-color'] = sanitize_hex_color( $hotspot['stickerSocialColor'] ?? $hotspot['hotspot-sticker-social-color'] ) ?: '#ffffff';
926 + }
927 + if ( isset( $hotspot['stickerSocialSize'] ) || isset( $hotspot['hotspot-sticker-social-size'] ) ) {
928 + $hs['hotspot-sticker-social-size'] = (float) ( $hotspot['stickerSocialSize'] ?? $hotspot['hotspot-sticker-social-size'] );
929 + }
930 + if ( isset( $hotspot['stickerSocialGap'] ) || isset( $hotspot['hotspot-sticker-social-gap'] ) ) {
931 + $hs['hotspot-sticker-social-gap'] = (float) ( $hotspot['stickerSocialGap'] ?? $hotspot['hotspot-sticker-social-gap'] );
932 + }
933 + if ( isset( $hotspot['stickerSocialLinks'] ) || isset( $hotspot['hotspot-sticker-social-links'] ) ) {
934 + $raw_links = $hotspot['stickerSocialLinks'] ?? $hotspot['hotspot-sticker-social-links'];
935 + if ( is_string( $raw_links ) ) {
936 + $raw_links = json_decode( $raw_links, true );
937 + }
938 + $clean_links = [];
939 + if ( is_array( $raw_links ) ) {
940 + foreach ( $raw_links as $item ) {
941 + if ( ! is_array( $item ) ) continue;
942 + $clean_links[] = [
943 + 'id' => sanitize_text_field( (string) ( $item['id'] ?? wp_generate_uuid4() ) ),
944 + 'icon' => sanitize_text_field( (string) ( $item['icon'] ?? '' ) ),
945 + 'customSvg' => function_exists( 'wp_kses' ) ? wp_kses( (string) ( $item['customSvg'] ?? '' ), [
946 + '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 ],
947 + 'path' => [ 'd' => true, 'fill' => true, 'stroke' => true, 'stroke-width' => true, 'stroke-linecap' => true, 'stroke-linejoin' => true, 'style' => true ],
948 + 'g' => [ 'fill' => true, 'stroke' => true, 'style' => true ],
949 + 'circle' => [ 'cx' => true, 'cy' => true, 'r' => true, 'fill' => true, 'stroke' => true, 'style' => true ],
950 + 'rect' => [ 'x' => true, 'y' => true, 'width' => true, 'height' => true, 'rx' => true, 'ry' => true, 'fill' => true, 'stroke' => true, 'style' => true ],
951 + ] ) : (string) ( $item['customSvg'] ?? '' ),
952 + 'url' => esc_url_raw( (string) ( $item['url'] ?? '' ) ),
953 + 'openNewTab' => ( ( $item['openNewTab'] ?? 'on' ) === 'off' || ( $item['openNewTab'] ?? 'on' ) === false ) ? 'off' : 'on',
954 + ];
955 + }
956 + }
957 + $hs['hotspot-sticker-social-links'] = $clean_links;
958 + }
959 + if ( isset( $hotspot['stickerShowPlaceholderText'] ) || isset( $hotspot['hotspot-sticker-show-placeholder-text'] ) ) {
960 + $hs['hotspot-sticker-show-placeholder-text'] = sanitize_text_field( $hotspot['stickerShowPlaceholderText'] ?? $hotspot['hotspot-sticker-show-placeholder-text'] );
961 + }
962 + if ( isset( $hotspot['scale'] ) ) {
963 + $hs['hotspot-scale'] = $hotspot['scale'] ? 'on' : 'off';
964 + } elseif ( ( $hotspot['type'] ?? '' ) === 'sticker' ) {
965 + $hs['hotspot-scale'] = 'on';
966 + }
967 +
627 968 if ( $this->is_pro ) {
628 969 $hs = array_merge( $hs, [
629 970 // Pro styling fields
630 971 'hotspot-customclass-pro' => !empty( $hotspot['iconClass'] ) ? $hotspot['iconClass'] : 'none',
@@ -635,11 +976,10 @@
635 976 'hotspot-border' => $hotspot['border'] ?? 'off',
636 977 'hotspot-border-width' => $hotspot['borderWidth'] ?? '1',
637 978 'hotspot-border-style' => $hotspot['borderStyle'] ?? 'none',
638 979 'hotspot-border-color' => $hotspot['borderColor'] ?? '#00b4ff',
639 - // Pro navigation entry point fields
640 - 'hotspot-scene-pitch' => $hotspot['scenePitch'] !== null ? (string) $hotspot['scenePitch'] : '',
641 - 'hotspot-scene-yaw' => $hotspot['sceneYaw'] !== null ? (string) $hotspot['sceneYaw'] : '',
980 + 'hotspot-scene-pitch' => ( isset( $hotspot['scenePitch'] ) && $hotspot['scenePitch'] !== null ) ? (string) $hotspot['scenePitch'] : '',
981 + 'hotspot-scene-yaw' => ( isset( $hotspot['sceneYaw'] ) && $hotspot['sceneYaw'] !== null ) ? (string) $hotspot['sceneYaw'] : '',
642 982 'hotspot-scene-entry-point-mode' => in_array( $hotspot['sceneEntryPointMode'] ?? '', [ 'inherit', 'custom' ], true )
643 983 ? $hotspot['sceneEntryPointMode']
644 984 : 'inherit',
645 985 ] );
@@ -647,6 +987,116 @@
647 987
648 988 $hotspot_list[] = $hs;
649 989 }
650 990 return $hotspot_list;
991 + }
992 +
993 + protected function text_overlays_to_api( array $list ): array {
994 + $overlays = [];
995 + foreach ( $list as $item ) {
996 + if ( ! is_array( $item ) ) {
997 + continue;
998 + }
999 + $overlays[] = [
1000 + 'id' => (string) ( $item['id'] ?? ( 'overlay_' . wp_generate_uuid4() ) ),
1001 + 'name' => sanitize_text_field( (string) ( $item['name'] ?? 'Text Overlay Layer' ) ),
1002 + 'enabled' => ! isset( $item['enabled'] ) || ! empty( $item['enabled'] ),
1003 + 'template' => in_array( $item['template'] ?? '', [ 'left', 'right', 'top', 'bottom', 'custom' ], true ) ? $item['template'] : '',
1004 + 'bgColor' => sanitize_hex_color( $item['bgColor'] ?? '' ) ?: '#281E19',
1005 + 'bgOpacity' => isset( $item['bgOpacity'] ) ? (float) $item['bgOpacity'] : 55,
1006 + 'blur' => isset( $item['blur'] ) ? (float) $item['blur'] : 14,
1007 + 'brightness' => isset( $item['brightness'] ) ? (float) $item['brightness'] : 85,
1008 + 'text' => TextOverlayContent::sanitize( (string) ( $item['text'] ?? '' ) ),
1009 + 'showClose' => ! isset( $item['showClose'] ) || ! empty( $item['showClose'] ),
1010 + 'color' => sanitize_hex_color( $item['color'] ?? '' ) ?: '#ffffff',
1011 + 'fontSize' => isset( $item['fontSize'] ) ? (int) $item['fontSize'] : 18,
1012 + 'fontWeight' => in_array( $item['fontWeight'] ?? '', [ 'normal', 'bold' ], true ) ? $item['fontWeight'] : 'normal',
1013 + 'fontStyle' => in_array( $item['fontStyle'] ?? '', [ 'normal', 'italic' ], true ) ? $item['fontStyle'] : 'normal',
1014 + 'textAlign' => in_array( $item['textAlign'] ?? '', [ 'left', 'center', 'right' ], true ) ? $item['textAlign'] : 'left',
1015 + 'width' => isset( $item['width'] ) ? (float) $item['width'] : ( isset( $item['position']['width'] ) ? (float) $item['position']['width'] : 75 ),
1016 + 'position' => [
1017 + 'x' => isset( $item['position']['x'] ) ? (float) $item['position']['x'] : 10,
1018 + 'y' => isset( $item['position']['y'] ) ? (float) $item['position']['y'] : 15,
1019 + 'width' => isset( $item['position']['width'] ) ? (float) $item['position']['width'] : ( isset( $item['width'] ) ? (float) $item['width'] : 75 ),
1020 + ],
1021 + 'containerRect' => isset( $item['containerRect'] ) && is_array( $item['containerRect'] ) ? [
1022 + 'top' => isset( $item['containerRect']['top'] ) ? (float) $item['containerRect']['top'] : 20,
1023 + 'left' => isset( $item['containerRect']['left'] ) ? (float) $item['containerRect']['left'] : 20,
1024 + 'width' => isset( $item['containerRect']['width'] ) ? (float) $item['containerRect']['width'] : 60,
1025 + 'height' => isset( $item['containerRect']['height'] ) ? (float) $item['containerRect']['height'] : 60,
1026 + ] : null,
1027 + 'borderRadius' => isset( $item['borderRadius'] ) && is_array( $item['borderRadius'] ) ? [
1028 + 'topLeft' => isset( $item['borderRadius']['topLeft'] ) ? (float) $item['borderRadius']['topLeft'] : 0,
1029 + 'topRight' => isset( $item['borderRadius']['topRight'] ) ? (float) $item['borderRadius']['topRight'] : 0,
1030 + 'bottomRight' => isset( $item['borderRadius']['bottomRight'] ) ? (float) $item['borderRadius']['bottomRight'] : 0,
1031 + 'bottomLeft' => isset( $item['borderRadius']['bottomLeft'] ) ? (float) $item['borderRadius']['bottomLeft'] : 0,
1032 + ] : ( isset( $item['borderRadius'] ) && is_numeric( $item['borderRadius'] ) ? [
1033 + 'topLeft' => (float) $item['borderRadius'],
1034 + 'topRight' => (float) $item['borderRadius'],
1035 + 'bottomRight' => (float) $item['borderRadius'],
1036 + 'bottomLeft' => (float) $item['borderRadius'],
1037 + ] : [
1038 + 'topLeft' => 0,
1039 + 'topRight' => 0,
1040 + 'bottomRight' => 0,
1041 + 'bottomLeft' => 0,
1042 + ] ),
1043 + ];
1044 + }
1045 + return array_slice( $overlays, 0, 5 );
1046 + }
1047 +
1048 + protected function text_overlays_from_api( array $list ): array {
1049 + $overlays = [];
1050 + foreach ( $list as $item ) {
1051 + if ( ! is_array( $item ) ) {
1052 + continue;
1053 + }
1054 + $overlays[] = [
1055 + 'id' => sanitize_text_field( (string) ( $item['id'] ?? '' ) ),
1056 + 'name' => sanitize_text_field( (string) ( $item['name'] ?? 'Text Overlay Layer' ) ),
1057 + 'enabled' => ! isset( $item['enabled'] ) || ! empty( $item['enabled'] ),
1058 + 'template' => in_array( $item['template'] ?? '', [ 'left', 'right', 'top', 'bottom', 'custom' ], true ) ? $item['template'] : '',
1059 + 'bgColor' => sanitize_hex_color( $item['bgColor'] ?? '' ) ?: '#281E19',
1060 + 'bgOpacity' => isset( $item['bgOpacity'] ) ? (float) $item['bgOpacity'] : 55,
1061 + 'blur' => isset( $item['blur'] ) ? (float) $item['blur'] : 14,
1062 + 'brightness' => isset( $item['brightness'] ) ? (float) $item['brightness'] : 85,
1063 + 'text' => TextOverlayContent::sanitize( (string) ( $item['text'] ?? '' ) ),
1064 + 'showClose' => ! isset( $item['showClose'] ) || ! empty( $item['showClose'] ),
1065 + 'color' => sanitize_hex_color( $item['color'] ?? '' ) ?: '#ffffff',
1066 + 'fontSize' => isset( $item['fontSize'] ) ? (int) $item['fontSize'] : 18,
1067 + 'fontWeight' => in_array( $item['fontWeight'] ?? '', [ 'normal', 'bold' ], true ) ? $item['fontWeight'] : 'normal',
1068 + 'fontStyle' => in_array( $item['fontStyle'] ?? '', [ 'normal', 'italic' ], true ) ? $item['fontStyle'] : 'normal',
1069 + 'textAlign' => in_array( $item['textAlign'] ?? '', [ 'left', 'center', 'right' ], true ) ? $item['textAlign'] : 'left',
1070 + 'width' => isset( $item['width'] ) ? (float) $item['width'] : ( isset( $item['position']['width'] ) ? (float) $item['position']['width'] : 75 ),
1071 + 'position' => [
1072 + 'x' => isset( $item['position']['x'] ) ? (float) $item['position']['x'] : 10,
1073 + 'y' => isset( $item['position']['y'] ) ? (float) $item['position']['y'] : 15,
1074 + 'width' => isset( $item['position']['width'] ) ? (float) $item['position']['width'] : ( isset( $item['width'] ) ? (float) $item['width'] : 75 ),
1075 + ],
1076 + 'containerRect' => isset( $item['containerRect'] ) && is_array( $item['containerRect'] ) ? [
1077 + 'top' => isset( $item['containerRect']['top'] ) ? (float) $item['containerRect']['top'] : 20,
1078 + 'left' => isset( $item['containerRect']['left'] ) ? (float) $item['containerRect']['left'] : 20,
1079 + 'width' => isset( $item['containerRect']['width'] ) ? (float) $item['containerRect']['width'] : 60,
1080 + 'height' => isset( $item['containerRect']['height'] ) ? (float) $item['containerRect']['height'] : 60,
1081 + ] : null,
1082 + 'borderRadius' => isset( $item['borderRadius'] ) && is_array( $item['borderRadius'] ) ? [
1083 + 'topLeft' => isset( $item['borderRadius']['topLeft'] ) ? (float) $item['borderRadius']['topLeft'] : 0,
1084 + 'topRight' => isset( $item['borderRadius']['topRight'] ) ? (float) $item['borderRadius']['topRight'] : 0,
1085 + 'bottomRight' => isset( $item['borderRadius']['bottomRight'] ) ? (float) $item['borderRadius']['bottomRight'] : 0,
1086 + 'bottomLeft' => isset( $item['borderRadius']['bottomLeft'] ) ? (float) $item['borderRadius']['bottomLeft'] : 0,
1087 + ] : ( isset( $item['borderRadius'] ) && is_numeric( $item['borderRadius'] ) ? [
1088 + 'topLeft' => (float) $item['borderRadius'],
1089 + 'topRight' => (float) $item['borderRadius'],
1090 + 'bottomRight' => (float) $item['borderRadius'],
1091 + 'bottomLeft' => (float) $item['borderRadius'],
1092 + ] : [
1093 + 'topLeft' => 0,
1094 + 'topRight' => 0,
1095 + 'bottomRight' => 0,
1096 + 'bottomLeft' => 0,
1097 + ] ),
1098 + ];
1099 + }
1100 + return array_slice( $overlays, 0, 5 );
651 1101 }
652 1102 }