| @@ -81,10 +81,10 @@ | ||
| 81 | 81 | foreach ($panodata["scene-list"] as $panoscenes) { |
| 82 | 82 | if (!empty($panoscenes['scene-id'])) { |
| 83 | 83 | array_push($allsceneids, $panoscenes['scene-id']); |
| 84 | 84 | } |
| 85 | - if ($panoscenes['dscene'] == 'on') { | |
| 86 | - return $default_scene = $panoscenes['scene-id']; | |
| 85 | + if (($panoscenes['dscene'] ?? 'off') == 'on') { | |
| 86 | + return $default_scene = $panoscenes['scene-id'] ?? ''; | |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if (empty($default_scene)) { |
| @@ -122,8 +122,14 @@ | ||
| 122 | 122 | } |
| 123 | 123 | if (isset($temp_hotspot['hotspot-yaw'])) { |
| 124 | 124 | $temp_hotspot['hotspot-yaw'] = trim($temp_hotspot['hotspot-yaw']); |
| 125 | 125 | } |
| 126 | + if (isset($temp_hotspot['hotspot-type']) && $temp_hotspot['hotspot-type'] === 'fluent_form') { | |
| 127 | + $temp_hotspot['hotspot-content'] = ''; | |
| 128 | + if (isset($temp_hotspot['fluent-form-id'])) { | |
| 129 | + $temp_hotspot['fluent-form-id'] = (string) absint($temp_hotspot['fluent-form-id']); | |
| 130 | + } | |
| 131 | + } | |
| 126 | 132 | $_hotspot_array[] = $temp_hotspot; |
| 127 | 133 | } |
| 128 | 134 | } |
| 129 | 135 | |
| @@ -536,11 +542,17 @@ | ||
| 536 | 542 | do_action('wpvr_hotspot_content_admin', $hotspot_data); |
| 537 | 543 | $hotspot_content = ob_get_clean(); |
| 538 | 544 | |
| 539 | 545 | |
| 540 | - if (!$hotspot_content) $hotspot_content = $hotspot_data["hotspot-content"]; | |
| 546 | + $is_fluent_form = ($hotspot_data['hotspot-type'] ?? '') === 'fluent_form'; | |
| 547 | + if ($is_fluent_form) { | |
| 548 | + if ($hotspot_content) { | |
| 549 | + $hotspot_content = preg_replace('/<script\b[^>]*>[\s\S]*?<\/script>/i', '', $hotspot_content); | |
| 550 | + } | |
| 551 | + } else { | |
| 552 | + if (!$hotspot_content) $hotspot_content = $hotspot_data["hotspot-content"] ?? ''; | |
| 553 | + } | |
| 541 | 554 | |
| 542 | - | |
| 543 | 555 | $hotspot_info = array( |
| 544 | 556 | "text" => $hotspot_data["hotspot-title"], |
| 545 | 557 | "pitch" => $hotspot_data["hotspot-pitch"], |
| 546 | 558 | "yaw" => $hotspot_data["hotspot-yaw"], |
| @@ -545,10 +557,10 @@ | ||
| 545 | 557 | "pitch" => $hotspot_data["hotspot-pitch"], |
| 546 | 558 | "yaw" => $hotspot_data["hotspot-yaw"], |
| 547 | 559 | "type" => $hotspot_type, |
| 548 | 560 | "URL" => $hotspot_data["hotspot-url"], |
| 549 | - "clickHandlerArgs" => $hotspot_content, | |
| 550 | - "createTooltipArgs" => $hotspot_data["hotspot-hover"], | |
| 561 | + "clickHandlerArgs" => sanitize_content_preserve_styles($hotspot_content, $is_fluent_form), | |
| 562 | + "createTooltipArgs" => sanitize_content_preserve_styles($hotspot_data["hotspot-hover"] ?? '', false), | |
| 551 | 563 | "sceneId" => $hotspot_data["hotspot-scene"], |
| 552 | 564 | 'hotspot_type' => $hotspot_data['hotspot-type'] |
| 553 | 565 | ); |
| 554 | 566 | |
| @@ -1962,25 +1974,36 @@ | ||
| 1962 | 1974 | * @since 8.0.0 |
| 1963 | 1975 | */ |
| 1964 | 1976 | public function prepare_regular_video_shortcode_data($id, $postdata, $width, $height, $radius) |
| 1965 | 1977 | { |
| 1978 | + $unique_suffix = wp_rand(1000, 99999); | |
| 1979 | + $pano_id = 'pano' . $id . '_' . $unique_suffix; | |
| 1980 | + $vid_id = 'wpvr-vid-' . $id . '-' . $unique_suffix; | |
| 1981 | + | |
| 1982 | + if ( ! empty( $postdata['vidurl'] ) ) { | |
| 1983 | + $panoviddata = $this->prepare_selfhost_video_meta_data( $postdata['vidurl'], $vid_id, $postdata ); | |
| 1984 | + } elseif ( ! empty( $postdata['panoviddata'] ) ) { | |
| 1985 | + $panoviddata = preg_replace( '/\bid=["\'][^"\']*["\']/i', 'id="' . esc_attr( $vid_id ) . '"', $postdata['panoviddata'], 1 ); | |
| 1986 | + } else { | |
| 1987 | + $panoviddata = ''; | |
| 1988 | + } | |
| 1989 | + | |
| 1966 | 1990 | $html = ''; |
| 1967 | - $html .= '<div id="pano' . $id . '" class="pano-wrap" style="max-width:100%; width: ' . $width . '; height: ' . $height . '; border-radius: ' . $radius . '; margin: 0 auto;">'; | |
| 1968 | - $html .= '<div style="width:100%; height:100%; ">' . $postdata['panoviddata'] . '</div>'; | |
| 1991 | + $html .= '<div id="' . esc_attr( $pano_id ) . '" class="pano-wrap" style="max-width:100%; width: ' . $width . '; height: ' . $height . '; border-radius: ' . $radius . '; margin: 0 auto;">'; | |
| 1992 | + $html .= '<div style="width:100%; height:100%; ">' . $panoviddata . '</div>'; | |
| 1969 | 1993 | |
| 1970 | 1994 | $html .= ' |
| 1971 | 1995 | <style> |
| 1972 | - .video-js { | |
| 1996 | + #' . esc_attr( $pano_id ) . ' .video-js { | |
| 1973 | 1997 | border-radius:' . $radius . '; |
| 1974 | 1998 | } |
| 1975 | - .video-js canvas{ | |
| 1999 | + #' . esc_attr( $pano_id ) . ' .video-js canvas{ | |
| 1976 | 2000 | border-radius:' . $radius . '; |
| 1977 | 2001 | } |
| 1978 | - #pano' . $id . ' .vjs-poster { | |
| 2002 | + #' . esc_attr( $pano_id ) . ' .vjs-poster { | |
| 1979 | 2003 | border-radius: ' . $radius . '; |
| 1980 | - } | |
| 2004 | + } | |
| 1981 | 2005 | </style> |
| 1982 | - | |
| 1983 | 2006 | '; |
| 1984 | 2007 | |
| 1985 | 2008 | $html .= '</div>'; |
| 1986 | 2009 | |
| @@ -1986,17 +2009,65 @@ | ||
| 1986 | 2009 | |
| 1987 | 2010 | //video js vr setup // |
| 1988 | 2011 | $html .= '<script>'; |
| 1989 | 2012 | $html .= ' |
| 1990 | - (function (window, videojs) { | |
| 1991 | - var player = window.player = videojs("' . $postdata['vidid'] . '"); | |
| 1992 | - player.mediainfo = player.mediainfo || {}; | |
| 1993 | - player.mediainfo.projection = "equirectangular"; | |
| 1994 | - | |
| 1995 | - // AUTO is the default and looks at mediainfo | |
| 1996 | - var vr = window.vr = player.vr({ projection: "AUTO", debug: true, forceCardboard: false, antialias: false }); | |
| 1997 | - }(window, window.videojs)); | |
| 1998 | - | |
| 2013 | + (function () { | |
| 2014 | + function initWPVRVideoPlayer() { | |
| 2015 | + if (typeof window.videojs !== "function") { | |
| 2016 | + return false; | |
| 2017 | + } | |
| 2018 | + var playerEl = document.getElementById("' . esc_js( $vid_id ) . '"); | |
| 2019 | + if (!playerEl) { | |
| 2020 | + return false; | |
| 2021 | + } | |
| 2022 | + try { | |
| 2023 | + var player = window.videojs(playerEl, { | |
| 2024 | + controls: true, | |
| 2025 | + autoplay: ' . ( ( isset( $postdata['autoplay'] ) && $postdata['autoplay'] === 'on' ) ? 'true' : 'false' ) . ', | |
| 2026 | + loop: ' . ( ( isset( $postdata['loop'] ) && $postdata['loop'] === 'on' ) ? 'true' : 'false' ) . ', | |
| 2027 | + preload: "auto", | |
| 2028 | + fluid: true | |
| 2029 | + }); | |
| 2030 | + | |
| 2031 | + player.mediainfo = player.mediainfo || {}; | |
| 2032 | + player.mediainfo.projection = "equirectangular"; | |
| 2033 | + | |
| 2034 | + if (typeof player.vr === "function") { | |
| 2035 | + var vr = player.vr({ projection: "360", debug: false, forceCardboard: false, antialias: false }); | |
| 2036 | + | |
| 2037 | + // If video metadata is already loaded or readyState >= 1, | |
| 2038 | + // trigger vr.init() directly because loadedmetadata won\'t fire again. | |
| 2039 | + if (player.readyState() >= 1 || (playerEl.readyState && playerEl.readyState >= 1) || (player.videoWidth && player.videoWidth() > 0)) { | |
| 2040 | + if (vr && typeof vr.init === "function" && !vr.initialized_) { | |
| 2041 | + vr.init(); | |
| 2042 | + } | |
| 2043 | + } else { | |
| 2044 | + player.one("loadedmetadata", function() { | |
| 2045 | + if (vr && typeof vr.init === "function" && !vr.initialized_) { | |
| 2046 | + vr.init(); | |
| 2047 | + } | |
| 2048 | + }); | |
| 2049 | + } | |
| 2050 | + } | |
| 2051 | + return true; | |
| 2052 | + } catch (e) { | |
| 2053 | + console.error("Error initializing WPVR video player:", e); | |
| 2054 | + return false; | |
| 2055 | + } | |
| 2056 | + } | |
| 2057 | + | |
| 2058 | + if (!initWPVRVideoPlayer()) { | |
| 2059 | + if (document.readyState === "loading") { | |
| 2060 | + document.addEventListener("DOMContentLoaded", function() { | |
| 2061 | + if (!initWPVRVideoPlayer()) { | |
| 2062 | + window.addEventListener("load", initWPVRVideoPlayer); | |
| 2063 | + } | |
| 2064 | + }); | |
| 2065 | + } else { | |
| 2066 | + window.addEventListener("load", initWPVRVideoPlayer); | |
| 2067 | + } | |
| 2068 | + } | |
| 2069 | + })(); | |
| 1999 | 2070 | '; |
| 2000 | 2071 | $html .= '</script>'; |
| 2001 | 2072 | //video js vr end // |
| 2002 | 2073 | return $html; |
| @@ -2060,9 +2131,9 @@ | ||
| 2060 | 2131 | { |
| 2061 | 2132 | $hotspots = array(); |
| 2062 | 2133 | foreach ($hotspot_datas as $hotspot_data) { |
| 2063 | 2134 | $hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"]; |
| 2064 | - $hotspot_content = $hotspot_data["hotspot-content"]; | |
| 2135 | + $hotspot_content = ($hotspot_data["hotspot-type"] ?? '') === 'fluent_form' ? '' : ($hotspot_data["hotspot-content"] ?? ''); | |
| 2065 | 2136 | $hotspot_info = $this->get_shortcode_hotspot_info($hotspot_data, $hotspot_type, $hotspot_content); |
| 2066 | 2137 | array_push($hotspots, $hotspot_info); |
| 2067 | 2138 | } |
| 2068 | 2139 | return $hotspots; |
| @@ -2088,10 +2159,10 @@ | ||
| 2088 | 2159 | "type" => $hotspot_type, |
| 2089 | 2160 | "cssClass" => $hotspot_data["hotspot-customclass"], |
| 2090 | 2161 | "URL" => $hotspot_data["hotspot-url"], |
| 2091 | 2162 | "wpvr_url_open" => isset($hotspot_data["wpvr_url_open"][0]) ? $hotspot_data["wpvr_url_open"][0] : 'off', |
| 2092 | - "clickHandlerArgs" => $hotspot_content, | |
| 2093 | - "createTooltipArgs" => $hotspot_data["hotspot-hover"], | |
| 2163 | + "clickHandlerArgs" => sanitize_content_preserve_styles($hotspot_content, ($hotspot_data['hotspot-type'] ?? '') === 'fluent_form'), | |
| 2164 | + "createTooltipArgs" => sanitize_content_preserve_styles($hotspot_data["hotspot-hover"] ?? '', false), | |
| 2094 | 2165 | "sceneId" => $hotspot_data["hotspot-scene"], |
| 2095 | 2166 | 'hotspot_type' => $hotspot_data['hotspot-type'] |
| 2096 | 2167 | ); |
| 2097 | 2168 | |
| @@ -2488,9 +2559,9 @@ | ||
| 2488 | 2559 | // JQuery scripts for on-click content for vr tour tab // |
| 2489 | 2560 | $html = $this->render_vr_tour_tab_click_content($html, $id, $default_scene); |
| 2490 | 2561 | |
| 2491 | 2562 | if (isset($previeword ) && $previeword != '') { |
| 2492 | - $html .= 'jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previeword . '")'; | |
| 2563 | + $html .= 'jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text(' . wp_json_encode( (string) $previeword ) . ');'; | |
| 2493 | 2564 | } |
| 2494 | 2565 | |
| 2495 | 2566 | $html .= '});'; |
| 2496 | 2567 | $html .= '</script>'; |
| @@ -2509,23 +2580,26 @@ | ||
| 2509 | 2580 | private function get_shortcode_hotspot_script_content($html) |
| 2510 | 2581 | { |
| 2511 | 2582 | $html .= 'if(scenes) {'; |
| 2512 | 2583 | $html .= 'var scenedata = scenes.scenes;'; |
| 2513 | - $html .= 'for(var i in scenedata) {'; | |
| 2514 | - $html .= 'var scenehotspot = scenedata[i].hotSpots;'; | |
| 2515 | - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {'; | |
| 2516 | - $html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {'; | |
| 2517 | - $html .= 'scenehotspot[i]["clickHandlerFunc"] = function(div, args) { if (typeof window.wpvrhotspot === "function") { window.wpvrhotspot(div, args); } };'; | |
| 2584 | + $html .= 'for(var scId in scenedata) {'; | |
| 2585 | + $html .= 'if(!scenedata.hasOwnProperty(scId)) continue;'; | |
| 2586 | + $html .= 'var scenehotspot = scenedata[scId].hotSpots;'; | |
| 2587 | + $html .= 'if(scenehotspot && scenehotspot.length) {'; | |
| 2588 | + $html .= 'for(var hIdx = 0; hIdx < scenehotspot.length; hIdx++) {'; | |
| 2589 | + $html .= 'if(scenehotspot[hIdx]["clickHandlerArgs"] != "") {'; | |
| 2590 | + $html .= 'scenehotspot[hIdx]["clickHandlerFunc"] = function(div, args) { if (typeof window.wpvrhotspot === "function") { window.wpvrhotspot(div, args); } };'; | |
| 2518 | 2591 | $html .= '}'; |
| 2519 | 2592 | if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") { |
| 2520 | 2593 | } else { |
| 2521 | - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {'; | |
| 2522 | - $html .= 'scenehotspot[i]["createTooltipFunc"] = function(div, args) { if (typeof window.wpvrtooltip === "function") { window.wpvrtooltip(div, args); } };'; | |
| 2594 | + $html .= 'if(scenehotspot[hIdx]["createTooltipArgs"] != "") {'; | |
| 2595 | + $html .= 'scenehotspot[hIdx]["createTooltipFunc"] = function(div, args) { if (typeof window.wpvrtooltip === "function") { window.wpvrtooltip(div, args); } };'; | |
| 2523 | 2596 | $html .= '}'; |
| 2524 | 2597 | } |
| 2525 | 2598 | $html .= '}'; |
| 2526 | 2599 | $html .= '}'; |
| 2527 | 2600 | $html .= '}'; |
| 2601 | + $html .= '}'; | |
| 2528 | 2602 | return $html; |
| 2529 | 2603 | } |
| 2530 | 2604 | |
| 2531 | 2605 | |
| @@ -2646,9 +2720,9 @@ | ||
| 2646 | 2720 | if (pano_id == "' . $id . '") { |
| 2647 | 2721 | jQuery("#pano' . $id . '").children(".pnlm-render-container").remove(); |
| 2648 | 2722 | jQuery("#pano' . $id . '").children(".pnlm-ui").remove(); |
| 2649 | 2723 | panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes); |
| 2650 | - jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previeword . '") | |
| 2724 | + jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text(' . wp_json_encode( (string) $previeword ) . '); | |
| 2651 | 2725 | setTimeout(function() { |
| 2652 | 2726 | // panoshow' . $id . '.loadScene("' . $default_scene . '"); |
| 2653 | 2727 | window.dispatchEvent(new Event("resize")); |
| 2654 | 2728 | if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) { |