PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.4
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.4
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 +1 -414 9.2.0 → 9.1.4 View file →
@@ -2,9 +2,8 @@
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;
7 6
8 7 class TourTransformer implements TransformerInterface {
9 8
10 9 protected bool $is_pro;
@@ -481,10 +480,8 @@
481 480 $scene['scene-attachment-url-face3'] ?? null,
482 481 $scene['scene-attachment-url-face4'] ?? null,
483 482 $scene['scene-attachment-url-face5'] ?? null,
484 483 ],
485 - 'textOverlays' => $this->text_overlays_to_api( $scene['text-overlays'] ?? [] ),
486 - 'showLayerToggle' => ( $scene['scene-show-layer-toggle'] ?? 'on' ) === 'on',
487 484 ];
488 485 }
489 486 // Older tours did not store whether a hotspot entry point inherited
490 487 // the target scene face or was edited manually. Keep those links in
@@ -517,12 +514,9 @@
517 514 'scene-type' => $this->is_pro && ( $scene['type'] ?? '' ) === 'cubemap' ? 'cubemap' : 'equirectangular',
518 515 'scene-attachment-url' => $scene['imageUrl'] ?? '',
519 516 'scene-show-info' => $show_scene_info ? 'on' : 'off',
520 517 'hotspot-list' => $this->hotspots_from_api( $scene['hotspots'] ?? [] ),
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'] ) ),
518 + 'dscene' => ( $default_scene_id !== '' && $scene_id === $default_scene_id ) ? 'on' : 'off',
525 519 ];
526 520
527 521 if ( $this->is_pro ) {
528 522 $scene_data = array_merge( $scene_data, [
@@ -555,9 +549,8 @@
555 549 'scene-attachment-url-face2' => $faces[2] ?? '',
556 550 'scene-attachment-url-face3' => $faces[3] ?? '',
557 551 'scene-attachment-url-face4' => $faces[4] ?? '',
558 552 'scene-attachment-url-face5' => $faces[5] ?? '',
559 - 'text-overlays' => $this->text_overlays_from_api( $scene['textOverlays'] ?? [] ),
560 553 ] );
561 554 }
562 555
563 556 $scene_list[ $index ] = $scene_data;
@@ -586,14 +579,8 @@
586 579 $product_name = $product_obj->get_formatted_name();
587 580 }
588 581 }
589 582
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 -
596 583 $hotspots[] = [
597 584 'id' => $hotspot['hotspot-id'] ?? wp_generate_uuid4(),
598 585 'type' => $hotspot['hotspot-type'] ?? 'info',
599 586 'pitch' => isset( $hotspot['hotspot-pitch'] ) ? (float) $hotspot['hotspot-pitch'] : 0,
@@ -607,92 +594,8 @@
607 594 'customClass' => $hotspot['hotspot-customclass'] ?? '',
608 595 'fluentFormId' => isset( $hotspot['fluent-form-id'] ) ? (string) $hotspot['fluent-form-id'] : '',
609 596 'productId' => $product_id,
610 597 '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' ),
695 598 // Pro styling fields
696 599 'iconClass' => ( ( $hotspot['hotspot-customclass-pro'] ?? '' ) === 'none' || ( $hotspot['hotspot-customclass-pro'] ?? '' ) === '' ) ? '' : $hotspot['hotspot-customclass-pro'],
697 600 'iconBgColor' => $hotspot['hotspot-customclass-color-icon-value'] ?? '#00b4ff',
698 601 'iconColor' => $hotspot['hotspot-custom-icon-color-value'] ?? '#ffffff',
@@ -758,214 +661,8 @@
758 661 } elseif ( isset( $hotspot['hotspot-product-id'] ) ) {
759 662 $hs['hotspot-product-id'] = sanitize_text_field( $hotspot['hotspot-product-id'] );
760 663 }
761 664
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 -
968 665 if ( $this->is_pro ) {
969 666 $hs = array_merge( $hs, [
970 667 // Pro styling fields
971 668 'hotspot-customclass-pro' => !empty( $hotspot['iconClass'] ) ? $hotspot['iconClass'] : 'none',
@@ -987,116 +684,6 @@
987 684
988 685 $hotspot_list[] = $hs;
989 686 }
990 687 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 );
1101 688 }
1102 689 }