PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.2
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.2
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 8.5.38 8.5.39 8.5.4 All 221 releases
← All changes | wpvr.php +468 -3312 8.5.369.1.2 View file →
@@ -1,6 +1,8 @@
1 1 <?php
2 2
3 +use RexTheme\WPVR\Tracker\WPVRLinnoTelemetry;
4 +
3 5 /**
4 6 * The plugin bootstrap file
5 7 *
6 8 * This file is read by WordPress to generate the plugin information in the plugin
@@ -12,13 +14,13 @@
12 14 * @since 7.3.6
13 15 * @package Wpvr
14 16 *
15 17 * @wordpress-plugin
16 - * Plugin Name: WP VR
18 + * Plugin Name: WP VR - 360 Panorama and Virtual Tour Builder
17 19 * Plugin URI: https://rextheme.com/wpvr/
18 - * Description: WP VR - 360 Panorama and virtual tour creator for WordPress is a customized panaroma & virtual builder tool for WordPress Website.
19 - * Version: 8.5.36
20 - * Tested up to: 6.8.2
20 + * Description: WP VR - 360 Panorama and virtual tour creator is a customized panaroma & virtual builder tool for your website.
21 + * Version: 9.1.2
22 + * Tested up to: 7.1
21 23 * Author: Rextheme
22 24 * Author URI: http://rextheme.com/
23 25 * License: GPL-2.0+
24 26 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
@@ -30,3480 +32,634 @@
30 32 if (!defined('WPINC')) {
31 33 die;
32 34 }
33 35
34 -require plugin_dir_path(__FILE__) . 'elementor/elementor.php';
35 -
36 -if ( wp_get_theme('bricks')->exists() && 'bricks' === get_template()) {
37 - require_once plugin_dir_path(__FILE__) . 'bricks/bricks.php';
38 -}
39 -
40 -/**
41 - * Currently plugin version.
42 - * Start at version 1.0.0 and use SemVer - https://semver.org
43 - * Rename this for your plugin and update it as you release new versions.
44 - */
45 -define('WPVR_VERSION', '8.5.36');
36 +define('WPVR_VERSION', '9.1.2');
46 37 define('WPVR_FILE', __FILE__);
47 -define("WPVR_PLUGIN_DIR_URL", plugin_dir_url(__FILE__));
48 -define("WPVR_PLUGIN_DIR_PATH", plugin_dir_path(__FILE__));
49 -define("WPVR_PLUGIN_PUBLIC_DIR_URL", plugin_dir_url(__FILE__) . 'public/');
38 +define("WPVR_PLUGIN_DIR_URL", plugin_dir_url(__FILE__).'legacy/');
39 +define("WPVR_PLUGIN_DIR_PATH", plugin_dir_path(__FILE__).'legacy/');
40 +define("WPVR_PLUGIN_LEGACY_DIR_PATH", plugin_dir_path(__FILE__) . 'legacy/');
41 +define("WPVR_PLUGIN_PUBLIC_DIR_URL", plugin_dir_url(__FILE__) . 'legacy/public/');
50 42 define('WPVR_BASE', plugin_basename(WPVR_FILE));
51 43 define('WPVR_DEV_MODE', false);
52 -define('WPVR_JS_PATH', plugin_dir_url(__FILE__) . 'admin/js/');
53 -define('WPVR_ASSET_PATH', plugin_dir_url(__FILE__) . 'admin/');
54 -define( 'WPVR_WEBHOOK_URL', sanitize_url( 'https://rextheme.com/?mailmint=1&route=webhook&topic=contact&hash=bbd19901-6d42-4ae5-a7a8-01eb1013c553' ) );
44 +define('WPVR_JS_PATH', plugin_dir_url(__FILE__) . 'legacy/admin/js/');
45 +define('WPVR_CSS_PATH', plugin_dir_url(__FILE__) . 'legacy/admin/css/');
46 +define('WPVR_ASSET_PATH', plugin_dir_url(__FILE__) . 'legacy/admin/');
55 47
56 -/**
57 - * The code that runs during plugin activation.
58 - * This action is documented in includes/class-wpvr-activator.php
59 - */
60 -function activate_wpvr()
61 -{
62 - require_once plugin_dir_path(__FILE__) . 'includes/class-wpvr-activator.php';
63 - Wpvr_Activator::activate();
48 +$wpvr_composer_autoload = plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
49 +if ( file_exists( $wpvr_composer_autoload ) ) {
50 + require_once $wpvr_composer_autoload;
64 51 }
65 52
66 -/**
67 - * The code that runs during plugin deactivation.
68 - * This action is documented in includes/class-wpvr-deactivator.php
69 - */
70 -function deactivate_wpvr()
71 -{
72 - require_once plugin_dir_path(__FILE__) . 'includes/class-wpvr-deactivator.php';
73 - Wpvr_Deactivator::deactivate();
53 +if ( ! defined( 'WPVR_TELEMETRY_API_KEY' ) ) {
54 + define( 'WPVR_TELEMETRY_API_KEY', 'phc_amk3VQz1P5ZqZOMRRoWM1B41QMFpf3hu8pg7yRfzSXW' );
74 55 }
75 -
76 -register_activation_hook(__FILE__, 'activate_wpvr');
77 -register_deactivation_hook(__FILE__, 'deactivate_wpvr');
78 -
79 -/**
80 - * The core plugin class that is used to define internationalization,
81 - * admin-specific hooks, and public-facing site hooks.
82 - */
83 -require plugin_dir_path(__FILE__) . 'includes/class-wpvr.php';
84 -
85 -/**
86 - * Begins execution of the plugin.
87 - *
88 - * Since everything within the plugin is registered via hooks,
89 - * then kicking off the plugin from this point in the file does
90 - * not affect the page life cycle.
91 - *
92 - * @since 7.3.6
93 - */
94 -function run_wpvr()
95 -{
96 -
97 - $plugin = new Wpvr();
98 - $plugin->run();
99 -
100 - // black friday banner class initialization
101 - new WPVR_Special_Occasion_Banner(
102 - '4th_of_july_deal_2025',
103 - '2025-07-02 00:00:01',
104 - '2025-07-14 23:59:59'
105 - );
106 -
107 - // if (!defined('WPVR_PRO_VERSION') && 'no' === get_option('wpvr_sell_notification_bar', 'no')) {
108 - // new WPVR_Notification_Bar();
109 - // }
110 -
111 -
56 +if ( ! defined( 'WPVR_TELEMETRY_API_SECRET' ) ) {
57 + define( 'WPVR_TELEMETRY_API_SECRET', 'sec_dfb2ab8e84391ae7a0f9' );
112 58 }
113 -run_wpvr();
59 +if ( ! defined( 'WPVR_TELEMETRY_HOST' ) ) {
60 + define( 'WPVR_TELEMETRY_HOST', 'https://eu.i.posthog.com' );
61 +}
114 62
63 +if ( ! function_exists( 'activate_wpvr' ) ) {
64 + /**
65 + * The code that runs during plugin activation.
66 + */
67 + function activate_wpvr() {
68 + require_once WPVR_PLUGIN_LEGACY_DIR_PATH . 'includes/class-wpvr-activator.php';
69 + Wpvr_Activator::activate();
115 70
116 -/**
117 - * Array information checker
118 - *
119 - * @param mixed $needle
120 - * @param mixed $haystack
121 - * @param bool $strict
122 - *
123 - * @return bool
124 - * @since 7.3.6
125 - */
126 -function wpvr_in_array_r($needle, $haystack, $strict = false)
127 -{
128 - foreach ($haystack as $item) {
129 - if ((($strict ? $item === $needle : $item == $needle)) || is_array($item) && wpvr_in_array_r($needle, $item, $strict)) {
130 - return true;
131 - }
71 + // Trigger plugin activation tracking
72 + do_action( 'wpvr_plugin_activated' );
132 73 }
133 - return false;
134 74 }
135 75
76 +if ( ! function_exists( 'deactivate_wpvr' ) ) {
77 + /**
78 + * The code that runs during plugin deactivation.
79 + */
80 + function deactivate_wpvr() {
81 + require_once WPVR_PLUGIN_LEGACY_DIR_PATH . 'includes/class-wpvr-deactivator.php';
82 + Wpvr_Deactivator::deactivate();
136 83
137 -/**
138 - * Initialize the plugin tracker
139 - *
140 - * @return void
141 - * @since 7.3.6
142 - */
143 -function appsero_init_tracker_wpvr()
144 -{
145 - if (!class_exists('Appsero\Client')) {
146 - require_once __DIR__ . '/appsero/src/Client.php';
84 + // Trigger plugin deactivation tracking
85 + do_action( 'wpvr_plugin_deactivated' );
147 86 }
148 - $client = new Appsero\Client('cab9761e-b067-4824-9c71-042df5d58598', 'WP VR', __FILE__);
149 -
150 - // Active insights
151 - $client->insights()->init();
152 87 }
153 88
154 -appsero_init_tracker_wpvr();
89 +register_activation_hook( WPVR_FILE, 'activate_wpvr' );
90 +register_deactivation_hook( WPVR_FILE, 'deactivate_wpvr' );
155 91
92 +if ( class_exists( WPVRLinnoTelemetry::class ) ) {
93 + new WPVRLinnoTelemetry();
94 +}
156 95
157 -function wpvr_block()
158 -{
159 - wp_register_script(
160 - 'wpvr-block',
161 - plugins_url('build/index.build.js', __FILE__),
162 - array('wp-blocks', 'wp-element', 'wp-components', 'wp-editor')
163 - );
164 -
165 - if (is_admin()) {
166 - wp_enqueue_style(
167 - 'gutyblocks/guty-block',
168 - plugins_url('src/view.css', __FILE__),
169 - array()
170 - );
96 +if ( ! function_exists( 'wpvr_is_pro_active' ) ) {
97 + /**
98 + * Return the effective WP VR Pro entitlement state.
99 + *
100 + * A loaded Pro plugin alone is not enough; its license must also be valid.
101 + */
102 + function wpvr_is_pro_active(): bool {
103 + return defined( 'WPVR_PRO_VERSION' )
104 + && get_option( 'wpvr_edd_license_status' ) === 'valid'
105 + && (bool) apply_filters( 'is_wpvr_pro_active', false );
171 106 }
172 -
173 -
174 - if (function_exists('register_block_type')) {
175 - register_block_type('wpvr/wpvr-block', array(
176 - 'attributes' => array(
177 - 'id' => array(
178 - 'type' => 'string',
179 - 'default' => '0',
180 - ),
181 - 'width' => array(
182 - 'type' => 'string',
183 - 'default' => '600',
184 - ),
185 - 'width_unit' => array(
186 - 'type' => 'string',
187 - 'default' => 'px',
188 - ),
189 - 'height' => array(
190 - 'type' => 'string',
191 - 'default' => '400',
192 - ),
193 - 'height_unit' => array(
194 - 'type' => 'string',
195 - 'default' => 'px',
196 - ),
197 - 'mobile_height' => array(
198 - 'type' => 'string',
199 - 'default' => '300',
200 - ),
201 - 'mobile_height_unit' => array(
202 - 'type' => 'string',
203 - 'default' => 'px',
204 - ),
205 - 'radius' => array(
206 - 'type' => 'string',
207 - 'default' => '0',
208 - ),
209 - 'border_width' => array(
210 - 'type' => 'string',
211 - 'default' => '0px',
212 - ),
213 - 'border_style' => array(
214 - 'type' => 'string',
215 - 'default' => 'none',
216 - ),
217 - 'border_color' => array(
218 - 'type' => 'string',
219 - 'default' => 'none',
220 - ),
221 - 'radius_unit' => array(
222 - 'type' => 'string',
223 - 'default' => 'px',
224 - ),
225 - 'content' => array(
226 - 'type' => 'string',
227 - 'source' => 'html',
228 - 'default' => '<script> </script>'
229 - ),
230 - ),
231 - 'editor_script' => 'wpvr-block',
232 - 'render_callback' => 'wpvr_block_render',
233 - ));
234 - }
235 107 }
236 108
237 -add_action('init', 'wpvr_block');
238 -
239 -function wpvr_block_render($attributes)
240 -{
241 - if (isset($attributes['id'])) {
242 - $id = $attributes['id'];
243 - } else {
244 - $id = 0;
245 - }
246 -
247 - $memberpress_active = defined('MEPR_VERSION');
248 - $rcp_active = is_plugin_active( 'restrict-content-pro/restrict-content-pro.php' );
249 -
250 - if (($memberpress_active || $rcp_active ) && apply_filters('is_wpvr_pro_active', false)) {
251 -
252 - if (!is_user_logged_in()) {
253 - return esc_html__('You need to log in to access this content.', 'wpvr');
109 +if ( ! function_exists( 'wpvr_get_effective_panodata' ) ) {
110 + /**
111 + * Build a runtime-only Free-plan view of saved tour data.
112 + *
113 + * The stored meta is never changed, so reactivating Pro restores every value.
114 + * Also normalizes values written by newer editor clients to the legacy
115 + * string format expected by the shared preview and shortcode renderers.
116 + */
117 + function wpvr_get_effective_panodata( array $postdata ): array {
118 + if ( isset( $postdata['scene_navigation'] ) ) {
119 + $postdata['scene_navigation'] = in_array( $postdata['scene_navigation'], [ true, 1, '1', 'on' ], true ) ? 'on' : 'off';
254 120 }
255 121
256 - $user_id = get_current_user_id();
257 - $allowed_access = false;
258 -
259 - // Get saved membership levels from post meta
260 - $allowed_membership_levels = get_post_meta($id, '_wpvr_allowed_roles_levels', true);
261 - if ( isset($allowed_membership_levels) && 'none' !== $allowed_membership_levels ) {
262 - if (!is_array($allowed_membership_levels)) {
263 - $allowed_membership_levels = array($allowed_membership_levels);
264 - }
265 -
266 - // Check MemberPress Access
267 - if ($memberpress_active) {
268 - $user = new MeprUser($user_id);
269 - $active_memberships = $user->active_product_subscriptions();
270 - if (array_intersect($allowed_membership_levels, $active_memberships) ) {
271 - $allowed_access = true;
272 - }
273 - }
274 -
275 - // Check Restrict Content Pro Access
276 - if ($rcp_active) {
277 - $user_rcp_memberships = rcp_get_customer_memberships($user_id);
278 - foreach ($user_rcp_memberships as $membership) {
279 - $rcp_access_level = array(
280 - $membership->get_object_id()
281 - );
282 - if (array_intersect($allowed_membership_levels, $rcp_access_level) ) {
283 - $allowed_access = true;
284 - break;
285 - }
286 - }
287 - }
288 - } else {
289 - // If no membership restriction is set, allow access by default
290 - $allowed_access = true;
122 + if ( isset( $postdata['autoLoad'] ) ) {
123 + $postdata['autoLoad'] = in_array( $postdata['autoLoad'], [ true, 1, '1', 'on', 'true' ], true );
291 124 }
292 125
293 - if (!$allowed_access) {
294 - return esc_html__('You do not have access to this content.', 'wpvr');
126 + if ( wpvr_is_pro_active() ) {
127 + return $postdata;
295 128 }
296 - }
297 129
298 -
299 - if (isset($attributes['width'])) {
300 - $width = $attributes['width'];
301 - }
302 - if (isset($attributes['width_unit'])) {
303 - $width_unit = $attributes['width_unit'];
304 - }
305 - if (isset($attributes['height'])) {
306 - $height = $attributes['height'];
307 - }
308 - if (isset($attributes['height_unit'])) {
309 - $height_unit = $attributes['height_unit'];
310 - }
311 - if (isset($attributes['mobile_height'])) {
312 - $mobile_height = $attributes['mobile_height'];
313 - }
314 - if (isset($attributes['mobile_height_unit'])) {
315 - $mobile_height_unit = $attributes['mobile_height_unit'];
316 - }
317 - if (isset($attributes['radius']) && isset($attributes['radius_unit'])) {
318 - $radius = $attributes['radius'] . $attributes['radius_unit'];
319 - }
320 - $border_style = '';
321 - if (isset($attributes['border_width'], $attributes['border_style'], $attributes['border_color'])) {
322 - $border_style = $attributes['border_width'] . 'px ' . $attributes['border_style'] . ' ' . $attributes['border_color'];
323 - }
324 -
325 - if (isset($attributes['className'])) {
326 - $className = $attributes['className'];
327 - } else {
328 - $className = '';
329 - }
330 - $get_post = get_post_status($id);
331 - if ($get_post !== 'publish') {
332 - return esc_html__('Oops! It seems like this post isn\'t published yet. Stay tuned for updates!', 'wpvr');
333 - }
334 - if (post_password_required($id)) {
335 - return get_the_password_form();
336 - }
337 - $postdata = get_post_meta($id, 'panodata', true);
338 - $panoid = 'pano' . $id;
339 - $panoid2 = 'pano2' . $id;
340 - if (!isset($postdata) || empty($postdata)) {
341 - return wp_kses(
342 - __('Oops! It seems that you have not selected any tour yet. Please select a tour from the dropdown of WPVR block.<br>', 'wpvr'),
343 - ['br' => []]
344 - );
345 - }
346 - if (isset($postdata['streetviewdata'])) {
347 - if (empty($width)) {
348 - $width = '600px';
130 + $false_keys = [
131 + 'gyro', 'deviceorientationcontrol', 'compass', 'vrgallery',
132 + 'vrgallery_title', 'vrgallery_icon_size', 'vrgallery_display',
133 + ];
134 + foreach ( $false_keys as $key ) {
135 + $postdata[ $key ] = false;
349 136 }
350 - if (empty($height)) {
351 - $height = '400px';
352 - }
353 - $streetviewurl = $postdata['streetviewurl'];
354 - $html = '';
355 - $html .= '<div class="vr-streetview ' . esc_attr( $className ) . '" style="text-align: center; max-width:100%; width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '; height:' . esc_attr( $height ) . esc_attr( $height_unit ) . '; margin: 0 auto;">';
356 - $html .= '<iframe src="' . esc_url( $streetviewurl ) . '" frameborder="0" style="border:0; width:100px; height:100%;" allowfullscreen=""></iframe>';
357 - $html .= '</div>';
358 137
359 - return $html;
360 - }
361 - $is_pro = apply_filters('is_wpvr_pro_active', false);
362 -
363 - if (isset($postdata['vidid'])) {
364 - if (empty($width)) {
365 - $width = '600';
138 + $off_keys = [
139 + 'scene_navigation', 'sceneAnimation', 'bg_music',
140 + 'autoplay_bg_music', 'loop_bg_music', 'explainerSwitch',
141 + 'cpLogoSwitch', 'genericform', 'calltoaction', 'customcss_enable',
142 + 'floorplan-enabled', 'floorplan-compass',
143 + 'floor_plan_tour_enabler', 'floor_plan_direction_indicator',
144 + 'bg_tour_enabler', 'video-autoplay', 'video-loop',
145 + ];
146 + foreach ( $off_keys as $key ) {
147 + $postdata[ $key ] = 'off';
366 148 }
367 - if (empty($height)) {
368 - $height = '400';
369 - }
370 - $videourl = $postdata['vidurl'];
371 149
372 - $videourl = $postdata['vidurl'];
373 - $autoplay = 'off';
374 - if (isset($postdata['autoplay'])) {
375 - $autoplay = $postdata['autoplay'];
376 - }
377 - $loop = 'off';
378 - if (isset($postdata['loop'])) {
379 - $loop = $postdata['loop'];
380 - }
150 + $postdata['tourLayout'] = [
151 + 'layout' => 'default',
152 + 'layout_icon_bg_color' => '#5a536e',
153 + 'layout_icon_color' => '#ffffff',
154 + ];
155 + $postdata['draggable'] = true;
156 + $postdata['mouseZoom'] = true;
157 + $postdata['diskeyboard'] = false;
158 + $postdata['keyboardzoom'] = true;
159 + $postdata['hfov'] = '';
160 + $postdata['maxHfov'] = '';
161 + $postdata['minHfov'] = '';
162 + $postdata['cpLogoImg'] = '';
163 + $postdata['cpLogoContent'] = '';
381 164
382 - if (strpos($videourl, 'youtube') > 0 || strpos($videourl, 'youtu') > 0) {
383 - $explodeid = '';
384 - $explodeid = explode("=", $videourl);
385 - $foundid = '';
386 - $muted = '&mute=1';
387 -
388 - if ($autoplay == 'on') {
389 - $autoplay = '&autoplay=1';
390 - } else {
391 - $autoplay = '';
392 - }
393 -
394 - if ($loop == 'on') {
395 - $loop = '&loop=1';
396 - } else {
397 - $loop = '';
398 - }
399 -
400 - if (strpos($videourl, 'youtu') > 0) {
401 - $explodeid = explode("/", $videourl);
402 - $foundid = $explodeid[3] . '?' . $autoplay . $loop;
403 - $expdata = $explodeid[3];
404 - } else {
405 - $foundid = $explodeid[1] . '?' . $autoplay . $loop;
406 - $expdata = $explodeid[1];
407 - }
408 -
409 - $playlist = '&playlist=' . $expdata;
410 - $playlist = str_replace("?feature=shared", "", $playlist);
411 -
412 -
413 - $html = '';
414 - $html .= '<div class="' . esc_attr($className) . '" style="text-align:center; max-width:100%; width:' . esc_attr($width) . esc_attr($width_unit) . '; height:' . esc_attr($height) . esc_attr($height_unit) . '; border-radius: ' . esc_attr($radius) . '; margin: 0 auto;">';
415 -
416 - // Compatibility check script
417 - $html .= '<script>
418 - function wpvr_check_360_support() {
419 - var support = {
420 - supported: false,
421 - fullySupported: false,
422 - webgl: false,
423 - orientation: false,
424 - gyroscope: false,
425 - touch: false,
426 - browser: "unknown",
427 - isMobile: false,
428 - isIPhone: false,
429 - details: []
430 - };
431 -
432 - support.isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
433 - support.isIPhone = /iPhone/i.test(navigator.userAgent);
434 - if (support.isMobile) support.details.push("Mobile device detected");
435 - if (support.isIPhone) support.details.push("iPhone detected");
436 -
437 - var ua = navigator.userAgent;
438 - if (/^((?!chrome|android).)*safari/i.test(ua)) {
439 - support.browser = "safari";
440 - support.details.push("Safari browser detected");
441 - } else if (ua.indexOf("Chrome") > -1) {
442 - support.browser = "chrome";
443 - support.details.push("Chrome browser detected");
444 - } else if (ua.indexOf("Firefox") > -1) {
445 - support.browser = "firefox";
446 - support.details.push("Firefox browser detected");
447 - } else if (ua.indexOf("MSIE") > -1 || ua.indexOf("Trident") > -1) {
448 - support.browser = "ie";
449 - support.details.push("Internet Explorer detected");
450 - } else if (ua.indexOf("Edge") > -1 || ua.indexOf("Edg") > -1) {
451 - support.browser = "edge";
452 - support.details.push("Edge browser detected");
453 - } else if (ua.indexOf("Opera") > -1 || ua.indexOf("OPR") > -1) {
454 - support.browser = "opera";
455 - support.details.push("Opera browser detected");
456 - }
457 -
458 - try {
459 - var canvas = document.createElement("canvas");
460 - support.webgl = !!(window.WebGLRenderingContext &&
461 - (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")));
462 - support.details.push(support.webgl ? "WebGL supported" : "WebGL not supported");
463 - } catch (e) {
464 - support.webgl = false;
465 - support.details.push("WebGL detection error: " + e.message);
466 - }
467 -
468 - support.orientation = !!(window.DeviceOrientationEvent);
469 - support.details.push(support.orientation ? "Device Orientation API supported" : "Device Orientation API not supported");
470 -
471 - support.gyroscope = !!window.Gyroscope;
472 - support.details.push(support.gyroscope ? "Gyroscope supported" : "Gyroscope not supported");
473 -
474 - support.touch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
475 - support.details.push(support.touch ? "Touch supported" : "Touch not supported");
476 -
477 - support.supported = support.webgl;
478 - support.fullySupported = support.webgl && ((support.isMobile && support.orientation) || !support.isMobile);
479 -
480 - if (support.browser === "safari" && support.isIPhone) {
481 - support.browserWarning = "iPhone has limited support for 360 videos in browser. The experience may not be optimal.";
482 - support.fullySupported = false;
483 - } else if (support.browser === "ie") {
484 - support.browserWarning = "Internet Explorer has limited support for 360 videos.";
485 - support.fullySupported = false;
486 - } else if (!support.supported) {
487 - support.browserWarning = "Your browser does not support 360° videos. Use Chrome or Firefox with WebGL.";
488 - }
489 -
490 - return support;
491 - }
492 - </script>';
493 -
494 - $random_id = 'video-container-' . rand(10000, 99999);
495 - $html .= '<div id="' . $random_id . '-container" style="position:relative; width:100%; height:100%;">';
496 -
497 - // Compatibility check screen (initially hidden for all, will show only for iPhone)
498 - $html .= '<div id="' . $random_id . '-compatibility-check" style="position:absolute; top:0; left:0; width:100%; height:100%; display:none; flex-direction:column; justify-content:center; align-items:center; background-color:#f9f9f9; border-radius:' . esc_attr( $radius ) . ';">
499 - <div style="margin-bottom:20px; text-align:center;">
500 - <div class="wpvr-loading-spinner" style="border:5px solid #f3f3f3; border-top:5px solid #3498db; border-radius:50%; width:50px; height:50px; margin:0 auto 15px; animation:wpvr-spin 1s linear infinite;"></div>
501 - <p style="margin:0;">Checking browser compatibility...</p>
502 - </div>
503 - </div>';
504 -
505 - // Spinner animation
506 - $html .= '<style>@keyframes wpvr-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }</style>';
507 -
508 - // Iframe (initial display set to block)
509 - $html .= '<div id="' . $random_id . '-frame" class="' . esc_attr($className) . '" style="display:block; max-width:100%; width:' . esc_attr($width) . esc_attr($width_unit) . '; height:' . esc_attr($height) . esc_attr($height_unit) . '; border-radius: ' . esc_attr($radius) . '; margin: 0 auto;">';
510 - $html .= '<iframe id="' . $random_id . '-iframe" src="https://www.youtube.com/embed/' . rawurlencode(sanitize_text_field($expdata)) . '?rel=0&modestbranding=1' . esc_attr($loop) . '&autohide=1' . esc_attr($muted) . '&showinfo=0&controls=1' . esc_attr($autoplay) . esc_attr($playlist) . '&enablejsapi=1" width="100%" height="100%" style="border-radius: ' . esc_attr($radius) . ';" frameborder="0" allowfullscreen allow="accelerometer; gyroscope; picture-in-picture"></iframe>';
511 - $html .= '</div>';
512 -
513 - // Permission request (mobile only)
514 - $html .= '<div id="' . $random_id . '-permission-request" style="position:absolute; top:0; left:0; width:100%; height:100%; display:none; flex-direction:column; justify-content:center; align-items:center; background-color:rgba(0,0,0,0.7); color:white; text-align:center; border-radius:' . $radius . ';">';
515 - $html .= '<p style="font-size:16px; margin:0 20px 15px;">For the best 360° video experience on mobile</p>';
516 - $html .= '<button id="' . $random_id . '-permission-button" style="padding:10px 15px; background-color:#0085ba; color:#fff; border:none; border-radius:4px; cursor:pointer;">Allow motion and orientation access</button>';
517 - $html .= '</div>';
518 -
519 - // Browser warning
520 - $html .= '<div id="' . $random_id . '-browser-warning" style="position:absolute; top:0; left:0; width:100%; height:100%; display:none; flex-direction:column; justify-content:center; align-items:center; background-color:rgba(0,0,0,0.7); color:white; text-align:center; border-radius:' . $radius . ';">';
521 - $html .= '<p id="' . $random_id . '-warning-text" style="font-size:16px; margin:0 20px 5px;"></p>';
522 - $html .= '<p style="font-size:14px; margin:5px 20px 15px;">For the best experience, use Chrome or Firefox.</p>';
523 - $html .= '<button id="' . $random_id . '-browser-continue" style="padding:10px 15px; background-color:#0085ba; color:#fff; border:none; border-radius:4px; cursor:pointer;">Continue Anyway</button>';
524 - $html .= '</div>';
525 -
526 - // Main script
527 - $html .= '<script>
528 - document.addEventListener("DOMContentLoaded", function() {
529 - var supportInfo = wpvr_check_360_support();
530 - var compatibilityCheck = document.getElementById("' . $random_id . '-compatibility-check");
531 - var frameContainer = document.getElementById("' . $random_id . '-frame");
532 - var warning = document.getElementById("' . $random_id . '-browser-warning");
533 - var warningText = document.getElementById("' . $random_id . '-warning-text");
534 - var continueBtn = document.getElementById("' . $random_id . '-browser-continue");
535 -
536 - // Only show compatibility check and warning for iPhone
537 - if (supportInfo.isIPhone) {
538 - // Hide the iframe initially for iPhone
539 - frameContainer.style.display = "none";
540 -
541 - // Show compatibility check for iPhone
542 - compatibilityCheck.style.display = "flex";
543 -
544 - // After delay, hide compatibility check and show warning
545 - setTimeout(function() {
546 - compatibilityCheck.style.display = "none";
547 - warningText.textContent = supportInfo.browserWarning || "Your browser may not fully support 360° videos.";
548 - warning.style.display = "flex";
549 -
550 - continueBtn.addEventListener("click", function() {
551 - warning.style.display = "none";
552 -
553 - if (supportInfo.fullySupported && supportInfo.isMobile) {
554 - document.getElementById("' . $random_id . '-permission-request").style.display = "flex";
555 - document.getElementById("' . $random_id . '-permission-button").addEventListener("click", function() {
556 - requestDevicePermissions();
557 - });
558 - } else {
559 - showVideo();
560 - }
561 - });
562 - }, 1000);
563 - } else {
564 - // For non-iPhone devices, directly initialize the player
565 - initializeYouTubePlayer();
566 - }
567 -
568 - function requestDevicePermissions() {
569 - try {
570 - if (typeof DeviceOrientationEvent !== "undefined" &&
571 - typeof DeviceOrientationEvent.requestPermission === "function") {
572 - DeviceOrientationEvent.requestPermission().then(function(response) {
573 - if (response === "granted") {
574 - if (typeof DeviceMotionEvent !== "undefined" &&
575 - typeof DeviceMotionEvent.requestPermission === "function") {
576 - DeviceMotionEvent.requestPermission().then(showVideo).catch(showVideo);
577 - } else {
578 - showVideo();
579 - }
580 - } else {
581 - showVideo();
582 - }
583 - }).catch(showVideo);
584 - } else {
585 - showVideo();
586 - }
587 - } catch (e) {
588 - showVideo();
589 - }
590 - }
591 -
592 - function showVideo() {
593 - document.getElementById("' . $random_id . '-permission-request").style.display = "none";
594 - frameContainer.style.display = "block";
595 - initializeYouTubePlayer();
596 - }
597 -
598 - function initializeYouTubePlayer() {
599 - if (window.YT) {
600 - initPlayer();
601 - } else {
602 - var tag = document.createElement("script");
603 - tag.src = "https://www.youtube.com/iframe_api";
604 - var firstScriptTag = document.getElementsByTagName("script")[0];
605 - firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
606 - window.onYouTubeIframeAPIReady = initPlayer;
607 - }
608 -
609 - function initPlayer() {
610 - new YT.Player("' . $random_id . '-iframe", {
611 - events: {
612 - "onReady": function(event) {}
613 - }
614 - });
615 - }
616 - }
617 - });
618 - </script>';
619 -
620 - $html .= '</div>'; // Close container
621 - $html .= '</div>'; // Close outer wrapper
622 - } else {
623 - $html = '';
624 - $html .= '<div id="pano' . esc_attr($id) . '" class="pano-wrap ' . esc_attr($className) . '" style="max-width:100%; width:' . esc_attr($width) . esc_attr($width_unit) . '; height: ' . esc_attr($height) . esc_attr($height_unit) . '; border-radius:' . esc_attr($radius) . '; margin: 0 auto;">';
625 - $html .= '<div style="width:100%; height:100%; border-radius: ' . esc_attr($radius) . ';">' . $postdata['panoviddata'] . '</div>';
626 -
627 - $html .= '
628 - <style>
629 - .video-js {
630 - border-radius:' . $radius . ';
631 - }
632 - .video-js canvas{
633 - border-radius:' . $radius . ';
634 - }
635 - #pano' . $id . ' .vjs-poster {
636 - border-radius: ' . $radius . ';
637 - }
638 - </style>
639 -
640 - ';
641 -
642 - // $html .= '<script>';
643 - // $html .= 'videojs(' . $postdata['vidid'] . ', {';
644 - // $html .= 'plugins: {';
645 - // $html .= 'pannellum: {}';
646 - // $html .= '}';
647 - // $html .= '});';
648 - // $html .= '</script>';
649 - $html .= '</div>';
650 -
651 - //video js vr setup //
652 - $html .= '<script>';
653 - $html .= '
654 - (function (window, videojs) {
655 - var player = window.player = videojs("' . $postdata['vidid'] . '");
656 - player.mediainfo = player.mediainfo || {};
657 - player.mediainfo.projection = "equirectangular";
658 -
659 - // AUTO is the default and looks at mediainfo
660 - var vr = window.vr = player.vr({ projection: "AUTO", debug: true, forceCardboard: false, antialias: false });
661 - }(window, window.videojs));
662 -
663 - ';
664 - $html .= '</script>';
665 - //video js vr end //
165 + if ( ( $postdata['tour-type'] ?? '' ) === 'street-view' || isset( $postdata['streetviewdata'] ) ) {
166 + $postdata['tour-type'] = 'image';
167 + $postdata['streetview'] = 'off';
168 + $postdata['streetviewurl'] = '';
169 + unset( $postdata['streetviewdata'] );
666 170 }
667 - return $html;
668 - }
669 171
670 - $control = false;
671 - if (isset($postdata['showControls'])) {
672 - $control = $postdata['showControls'];
673 - }
674 -
675 - if ($control) {
676 - if (isset($postdata['customcontrol'])) {
677 - $custom_control = $postdata['customcontrol'];
678 - if ($custom_control['panupSwitch'] == "on" || $custom_control['panDownSwitch'] == "on" || $custom_control['panLeftSwitch'] == "on" || $custom_control['panRightSwitch'] == "on" || $custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $custom_control['panFullscreenSwitch'] == "on" || $custom_control['gyroscopeSwitch'] == "on" || $custom_control['backToHomeSwitch'] == "on") {
679 - $control = false;
680 - }
172 + $custom_control = isset( $postdata['customcontrol'] ) && is_array( $postdata['customcontrol'] )
173 + ? $postdata['customcontrol']
174 + : [];
175 + foreach ( [
176 + 'panupSwitch', 'panDownSwitch', 'panLeftSwitch', 'panRightSwitch',
177 + 'panZoomInSwitch', 'panZoomOutSwitch', 'panFullscreenSwitch',
178 + 'gyroscopeSwitch', 'backToHomeSwitch',
179 + ] as $key ) {
180 + $custom_control[ $key ] = 'off';
681 181 }
682 - }
182 + $postdata['customcontrol'] = $custom_control;
683 183
684 - $floor_plan_enable = 'off';
685 - $floor_plan_image = '';
686 - if (isset($postdata['floor_plan_tour_enabler']) && $postdata['floor_plan_tour_enabler'] == 'on') {
687 - $floor_plan_enable = $postdata['floor_plan_tour_enabler'];
688 - if (isset($postdata['floor_plan_attachment_url']) && !empty($postdata['floor_plan_attachment_url'])) {
689 - $floor_plan_image = $postdata['floor_plan_attachment_url'];
690 - }
691 - }
692 -
693 - $vrgallery = false;
694 - if (isset($postdata['vrgallery'])) {
695 - $vrgallery = $postdata['vrgallery'];
696 - }
697 -
698 - $vrgallery_title = false;
699 - if (isset($postdata['vrgallery_title'])) {
700 - $vrgallery_title = $postdata['vrgallery_title'];
701 - }
702 -
703 - $vrgallery_display = false;
704 - if (isset($postdata['vrgallery_display'])) {
705 - $vrgallery_display = $postdata['vrgallery_display'];
706 - }
707 - $vrgallery_icon_size = false;
708 - if (isset($postdata['vrgallery_icon_size'])) {
709 - $vrgallery_icon_size = $postdata['vrgallery_icon_size'];
710 - }
711 -
712 - $gyro = false;
713 - $gyro_orientation = false;
714 - if (isset($postdata['gyro'])) {
715 - $gyro = $postdata['gyro'];
716 - if (isset($postdata['deviceorientationcontrol'])) {
717 - $gyro_orientation = $postdata['deviceorientationcontrol'];
718 - }
719 - }
720 -
721 - $compass = false;
722 - $audio_right = "5px";
723 - if (isset($postdata['compass'])) {
724 - $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
725 - if ($compass) {
726 - $audio_right = "60px";
727 - }
728 - }
729 - $floor_map_right = "10px";
730 - if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
731 - $floor_map_right = "85px";
732 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
733 - $floor_map_right = "55px";
734 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
735 - $floor_map_right = "25px";
736 - }
737 -
738 - //===explainer handle===//
739 -
740 - //===explainer handle===//
741 - $explainer_right = "10px";
742 - if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
743 - $explainer_right = "130px";
744 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on' && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
745 - $explainer_right = "100px";
746 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
747 - $explainer_right = "60px";
748 - } elseif ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
749 - $explainer_right = "80px";
750 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
751 - $explainer_right = "55px";
752 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
753 - $explainer_right = "30px";
754 - } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image)) {
755 - $explainer_right = "40px";
756 - }
757 - $enable_cardboard = '';
758 - $is_cardboard = get_option('wpvr_cardboard_disable');
759 - if (wpvr_isMobileDevice() && $is_cardboard == 'true') {
760 - $enable_cardboard = 'enable-cardboard';
761 - $audio_right = "73px";
762 - if (isset($postdata['compass'])) {
763 - $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
764 - if ($compass) {
765 - $audio_right = "130px";
766 - }
767 - }
768 -
769 - $floor_map_right = "60px";
770 - if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
771 - $floor_map_right = "150px";
772 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
773 - $floor_map_right = "120px";
774 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
775 - $floor_map_right = "90px";
776 - }
777 -
778 - //===explainer handle===//
779 -
780 - $explainer_right = "65px";
781 -
782 - if ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
783 - $explainer_right = "150px";
784 - } elseif ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
785 - $explainer_right = "180px";
786 - } elseif (isset($postdata['compass']) && $postdata['compass'] == true && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
787 - $explainer_right = "150px";
788 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
789 - $explainer_right = "120px";
790 - } elseif (isset($postdata['compass']) && $postdata['compass'] == true) {
791 - $explainer_right = "130px";
792 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
793 - $explainer_right = "90px";
794 - } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image)) {
795 - $explainer_right = "90px";
796 - }
797 - }
798 -
799 - //===explainer handle===//
800 -
801 - $mouseZoom = true;
802 - if (isset($postdata['mouseZoom'])) {
803 - if ($postdata['mouseZoom'] == "off") {
804 - $mouseZoom = false;
805 - } else {
806 - $mouseZoom = true;
807 - }
808 - }
809 -
810 - $draggable = true;
811 - if (isset($postdata['draggable'])) {
812 - $draggable = $postdata['draggable'] == 'on' || $postdata['draggable'] != null ? true : false;
813 - if ($postdata['draggable'] === 'off') {
814 - $draggable = false;
815 - }
816 - }
817 - $diskeyboard = false;
818 - if (isset($postdata['diskeyboard'])) {
819 - $diskeyboard = $postdata['diskeyboard'] == 'off' || $postdata['diskeyboard'] == null ? false : true;
820 - }
821 -
822 - $keyboardzoom = true;
823 - if (isset($postdata['keyboardzoom'])) {
824 - $keyboardzoom = $postdata['keyboardzoom'];
825 - }
826 -
827 - $autoload = false;
828 -
829 - if (isset($postdata['autoLoad'])) {
830 - $autoload = $postdata['autoLoad'];
831 - }
832 -
833 - $default_scene = '';
834 - if (isset($postdata['defaultscene'])) {
835 - $default_scene = $postdata['defaultscene'];
836 - }
837 -
838 - $preview = '';
839 - if (isset($postdata['preview'])) {
840 - $preview = $postdata['preview'];
841 - }
842 -
843 - $autorotation = '';
844 - if (isset($postdata["autoRotate"])) {
845 - $autorotation = $postdata["autoRotate"];
846 - }
847 - $autorotationinactivedelay = '';
848 - if (isset($postdata["autoRotateInactivityDelay"])) {
849 - $autorotationinactivedelay = $postdata["autoRotateInactivityDelay"];
850 - }
851 - $autorotationstopdelay = '';
852 - if (isset($postdata["autoRotateStopDelay"])) {
853 - $autorotationstopdelay = $postdata["autoRotateStopDelay"];
854 - }
855 -
856 - $scene_fade_duration = '';
857 - if (isset($postdata['scenefadeduration'])) {
858 - $scene_fade_duration = $postdata['scenefadeduration'];
859 - }
860 -
861 - $panodata = array();
862 - if (isset($postdata['panodata'])) {
863 - $panodata = $postdata['panodata'];
864 - }
865 -
866 - $default_zoom_global = 100;
867 - if (isset($postdata['hfov']) && $postdata['hfov'] != '') {
868 - $default_zoom_global = $postdata['hfov'];
869 - }
870 -
871 - $min_zoom_global = 50;
872 - if (isset($postdata['minHfov']) && $postdata['minHfov'] != '') {
873 - $min_zoom_global = $postdata['minHfov'];
874 - }
875 -
876 - $max_zoom_global = 120;
877 - if (isset($postdata['maxHfov']) && $postdata['maxHfov'] != '') {
878 - $max_zoom_global = $postdata['maxHfov'];
879 - }
880 -
881 - $hotspoticoncolor = '#00b4ff';
882 - $hotspotblink = 'on';
883 - $default_data = array();
884 - $default_data = array('firstScene' => $default_scene, 'sceneFadeDuration' => $scene_fade_duration, 'hfov' => $default_zoom_global, 'maxHfov' => $max_zoom_global, 'minHfov' => $min_zoom_global);
885 - $scene_data = array();
886 - if (is_array($panodata) && isset($panodata['scene-list'])) {
887 - if (!empty($panodata['scene-list'])) {
888 - foreach ($panodata['scene-list'] as $panoscenes) {
889 - $scene_ititle = '';
890 - if (isset($panoscenes["scene-ititle"])) {
891 - $scene_ititle = sanitize_text_field($panoscenes["scene-ititle"]);
184 + if ( isset( $postdata['panodata']['scene-list'] ) && is_array( $postdata['panodata']['scene-list'] ) ) {
185 + foreach ( $postdata['panodata']['scene-list'] as &$scene ) {
186 + if ( ! is_array( $scene ) ) {
187 + continue;
892 188 }
893 189
894 - $scene_author = '';
895 - if (isset($panoscenes["scene-author"])) {
896 - $scene_author = sanitize_text_field($panoscenes["scene-author"]);
190 + if ( ( $scene['scene-type'] ?? 'equirectangular' ) === 'cubemap' ) {
191 + $scene['scene-type'] = 'equirectangular';
897 192 }
898 193
899 - $scene_author_url = '';
900 - if (isset($panoscenes["scene-author-url"])) {
901 - $scene_author_url = sanitize_text_field($panoscenes["scene-author-url"]);
194 + foreach ( [ 'ptyscene', 'cvgscene', 'chgscene', 'czscene' ] as $key ) {
195 + $scene[ $key ] = 'off';
902 196 }
903 -
904 - $scene_vaov = 180;
905 - if (isset($panoscenes["scene-vaov"])) {
906 - $scene_vaov = (float)$panoscenes["scene-vaov"];
197 + foreach ( [
198 + 'scene-author', 'scene-author-url', 'scene-vaov', 'scene-haov',
199 + 'scene-vertical-offset', 'scene-pitch', 'scene-yaw',
200 + 'scene-maxpitch', 'scene-minpitch', 'scene-maxyaw', 'scene-minyaw',
201 + 'scene-zoom', 'scene-maxzoom', 'scene-minzoom',
202 + ] as $key ) {
203 + $scene[ $key ] = '';
907 204 }
908 -
909 - $scene_haov = 360;
910 - if (isset($panoscenes["scene-haov"])) {
911 - $scene_haov = (float)$panoscenes["scene-haov"];
205 + for ( $face = 0; $face < 6; $face++ ) {
206 + $scene[ 'scene-attachment-url-face' . $face ] = '';
912 207 }
913 208
914 - $scene_vertical_offset = 0;
915 - if (isset($panoscenes["scene-vertical-offset"])) {
916 - $scene_vertical_offset = (float)$panoscenes["scene-vertical-offset"];
917 - }
918 -
919 - $default_scene_pitch = null;
920 - if (isset($panoscenes["scene-pitch"])) {
921 - $default_scene_pitch = (float)$panoscenes["scene-pitch"];
922 - }
923 -
924 - $default_scene_yaw = null;
925 - if (isset($panoscenes["scene-yaw"])) {
926 - $default_scene_yaw = (float)$panoscenes["scene-yaw"];
927 - }
928 -
929 - $scene_max_pitch = '';
930 - if (isset($panoscenes["scene-maxpitch"])) {
931 - $scene_max_pitch = (float)$panoscenes["scene-maxpitch"];
932 - }
933 -
934 -
935 - $scene_min_pitch = '';
936 - if (isset($panoscenes["scene-minpitch"])) {
937 - $scene_min_pitch = (float)$panoscenes["scene-minpitch"];
938 - }
939 -
940 -
941 - $scene_max_yaw = '';
942 - if (isset($panoscenes["scene-maxyaw"])) {
943 - $scene_max_yaw = (float)$panoscenes["scene-maxyaw"];
944 - }
945 -
946 -
947 - $scene_min_yaw = '';
948 - if (isset($panoscenes["scene-minyaw"])) {
949 - $scene_min_yaw = (float)$panoscenes["scene-minyaw"];
950 - }
951 -
952 - $default_zoom = 100;
953 - if (isset($panoscenes["scene-zoom"]) && $panoscenes["scene-zoom"] != '') {
954 - $default_zoom = (int)$panoscenes["scene-zoom"];
955 - } else {
956 - if ($default_zoom_global != '') {
957 - $default_zoom = (int)$default_zoom_global;
958 - }
959 - }
960 -
961 -
962 - $max_zoom = 120;
963 - if (isset($panoscenes["scene-maxzoom"]) && $panoscenes["scene-maxzoom"] != '') {
964 - $max_zoom = (int)$panoscenes["scene-maxzoom"];
965 - } else {
966 - if ($max_zoom_global != '') {
967 - $max_zoom = (int)$max_zoom_global;
968 - }
969 - }
970 -
971 - $min_zoom = 120;
972 - if (isset($panoscenes["scene-minzoom"]) && $panoscenes["scene-minzoom"] != '') {
973 - $min_zoom = (int)$panoscenes["scene-minzoom"];
974 - } else {
975 - if ($min_zoom_global != '') {
976 - $min_zoom = (int)$min_zoom_global;
977 - }
978 - }
979 -
980 - $hotspot_datas = array();
981 - if (isset($panoscenes['hotspot-list'])) {
982 - $hotspot_datas = $panoscenes['hotspot-list'];
983 - }
984 -
985 - $hotspots = array();
986 -
987 - foreach ($hotspot_datas as $hotspot_data) {
988 - $status = get_option('wpvr_edd_license_status');
989 - if ($status !== false && $status == 'valid') {
990 -
991 - if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') {
992 - $hotspot_data['hotspot-customclass'] = $hotspot_data["hotspot-customclass-pro"] . ' custom-' . $id . '-' . $panoscenes['scene-id'] . '-' . $hotspot_data['hotspot-title'];
209 + if ( isset( $scene['hotspot-list'] ) && is_array( $scene['hotspot-list'] ) ) {
210 + foreach ( $scene['hotspot-list'] as &$hotspot ) {
211 + if ( ! is_array( $hotspot ) ) {
212 + continue;
993 213 }
994 - if (isset($hotspot_data['hotspot-blink'])) {
995 - $hotspotblink = $hotspot_data['hotspot-blink'];
996 - }
214 + $hotspot['hotspot-customclass-pro'] = 'none';
215 + $hotspot['hotspot-blink'] = 'off';
216 + $hotspot['hotspot-shape'] = 'round';
217 + $hotspot['hotspot-border'] = 'off';
218 + $hotspot['hotspot-scene-pitch'] = '';
219 + $hotspot['hotspot-scene-yaw'] = '';
997 220 }
998 - $hotspot_scene_pitch = '';
999 - if (isset($hotspot_data["hotspot-scene-pitch"])) {
1000 - $hotspot_scene_pitch = $hotspot_data["hotspot-scene-pitch"];
1001 - }
1002 - $hotspot_scene_yaw = '';
1003 - if (isset($hotspot_data["hotspot-scene-yaw"])) {
1004 - $hotspot_scene_yaw = $hotspot_data["hotspot-scene-yaw"];
1005 - }
1006 -
1007 - $hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"];
1008 - $hotspot_content = '';
1009 -
1010 - ob_start();
1011 - do_action('wpvr_hotspot_content', $hotspot_data);
1012 - $hotspot_content = ob_get_clean();
1013 -
1014 - if (!$hotspot_content) {
1015 - $hotspot_content = $hotspot_data["hotspot-content"];
1016 - }
1017 -
1018 - if (isset($hotspot_data["wpvr_url_open"][0])) {
1019 - $wpvr_url_open = $hotspot_data["wpvr_url_open"][0];
1020 - } else {
1021 - $wpvr_url_open = "off";
1022 - }
1023 - $on_hover_content = preg_replace_callback(
1024 - '/<p>\s*(<img[^>]*>)\s*<br>\s*<\/p>/i',
1025 - function ($matches) {
1026 - return $matches[1];
1027 - },
1028 - $hotspot_data['hotspot-hover'] ?? ''
1029 - );
1030 - $on_hover_content = sanitize_content_preserve_styles($on_hover_content ?? '');
1031 - $on_click_content = preg_replace_callback('/<img[^>]*>/', "replace_callback", $hotspot_content ?? '');
1032 - $hotspot_shape = 'round';
1033 - if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') {
1034 - $hotspot_shape = isset($hotspot_data["hotspot-shape"]) ? $hotspot_data["hotspot-shape"] : 'round';
1035 - }
1036 -
1037 - $hotspot_data_for_on_click=[];
1038 - if('info' === $hotspot_type && !empty($on_click_content)){
1039 - $hotspot_data_for_on_click = [
1040 - 'on_click_content' => $on_click_content,
1041 - 'tour_id' => $id,
1042 - 'scene_id' => $panoscenes['scene-id'],
1043 - 'hotspot_id' => $hotspot_data['hotspot-title'],
1044 - ];
1045 - } elseif('info' === $hotspot_type && !empty($hotspot_data["hotspot-url"])){
1046 - $hotspot_data_for_on_click = [
1047 - 'on_click_content' => '',
1048 - 'tour_id' => $id,
1049 - 'scene_id' => $panoscenes['scene-id'],
1050 - 'hotspot_id' => $hotspot_data['hotspot-title'],
1051 - ];
1052 - }
1053 -
1054 - $hotspot_info = array(
1055 - 'text' => $hotspot_data['hotspot-title'],
1056 - 'pitch' => $hotspot_data['hotspot-pitch'],
1057 - 'yaw' => $hotspot_data['hotspot-yaw'],
1058 - 'type' => $hotspot_type,
1059 - 'cssClass' => $hotspot_data['hotspot-customclass'],
1060 - 'URL' => $hotspot_data['hotspot-url'],
1061 - "wpvr_url_open" => $wpvr_url_open,
1062 - "clickHandlerArgs" => $hotspot_data_for_on_click,
1063 - 'createTooltipArgs' => !empty(trim($on_hover_content)) ? trim($on_hover_content) : '',
1064 - "sceneId" => $hotspot_data["hotspot-scene"],
1065 - "targetPitch" => (float)$hotspot_scene_pitch,
1066 - "targetYaw" => (float)$hotspot_scene_yaw,
1067 - 'hotspot_type' => $hotspot_data['hotspot-type'],
1068 - 'hotspot_shape' => $hotspot_shape,
1069 - );
1070 -
1071 - $hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL'];
1072 -
1073 - if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') {
1074 - unset($hotspot_info["cssClass"]);
1075 - }
1076 - if (empty($hotspot_data["hotspot-scene"])) {
1077 - unset($hotspot_info['targetPitch']);
1078 - unset($hotspot_info['targetYaw']);
1079 - }
1080 - array_push($hotspots, $hotspot_info);
221 + unset( $hotspot );
1081 222 }
1082 -
1083 - $device_scene = $panoscenes['scene-attachment-url'];
1084 - $mobile_media_resize = get_option('mobile_media_resize');
1085 - $file_accessible = ini_get('allow_url_fopen');
1086 - if ($mobile_media_resize == "true" && $device_scene) {
1087 - if ($file_accessible == "1") {
1088 - $image_info = getimagesize($device_scene);
1089 - if ($image_info && $image_info[0] > 4096) {
1090 - $src_to_id_for_mobile = '';
1091 - $src_to_id_for_desktop = '';
1092 - if (wpvr_isMobileDevice()) {
1093 - $src_to_id_for_mobile = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1094 - if ($src_to_id_for_mobile) {
1095 - $mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile');
1096 - if ($mobile_scene[3]) {
1097 - $device_scene = $mobile_scene[0];
1098 - }
1099 - }
1100 - } else {
1101 - $src_to_id_for_desktop = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1102 - if ($src_to_id_for_desktop) {
1103 - $desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full');
1104 - if ($desktop_scene && $desktop_scene[0]) {
1105 - $device_scene = $desktop_scene[0];
1106 - }
1107 - }
1108 - }
1109 - }
1110 - }
1111 - }
1112 -
1113 - $scene_info = array();
1114 -
1115 - if ($panoscenes["scene-type"] == 'cubemap') {
1116 - $pano_type = 'cubemap';
1117 - $pano_attachment = array(
1118 - $panoscenes["scene-attachment-url-face0"],
1119 - $panoscenes["scene-attachment-url-face1"],
1120 - $panoscenes["scene-attachment-url-face2"],
1121 - $panoscenes["scene-attachment-url-face3"],
1122 - $panoscenes["scene-attachment-url-face4"],
1123 - $panoscenes["scene-attachment-url-face5"]
1124 - );
1125 -
1126 - $scene_info = array('type' => $panoscenes['scene-type'], 'cubeMap' => $pano_attachment, "pitch" => $default_scene_pitch, "maxPitch" => $scene_max_pitch, "minPitch" => $scene_min_pitch, "maxYaw" => $scene_max_yaw, "minYaw" => $scene_min_yaw, "yaw" => $default_scene_yaw, "hfov" => $default_zoom, "maxHfov" => $max_zoom, "minHfov" => $min_zoom, "title" => $scene_ititle, "author" => $scene_author, "authorURL" => $scene_author_url, "vaov" => $scene_vaov, "haov" => $scene_haov, "vOffset" => $scene_vertical_offset, 'hotSpots' => $hotspots);
1127 - } else {
1128 - $scene_info = array('type' => $panoscenes['scene-type'], 'panorama' => $device_scene, "pitch" => $default_scene_pitch, "maxPitch" => $scene_max_pitch, "minPitch" => $scene_min_pitch, "maxYaw" => $scene_max_yaw, "minYaw" => $scene_min_yaw, "yaw" => $default_scene_yaw, "hfov" => $default_zoom, "maxHfov" => $max_zoom, "minHfov" => $min_zoom, "title" => $scene_ititle, "author" => $scene_author, "authorURL" => $scene_author_url, "vaov" => $scene_vaov, "haov" => $scene_haov, "vOffset" => $scene_vertical_offset, 'hotSpots' => $hotspots);
1129 - }
1130 -
1131 -
1132 -
1133 - if (isset($panoscenes["ptyscene"])) {
1134 - if ($panoscenes["ptyscene"] == "off") {
1135 - unset($scene_info['pitch']);
1136 - unset($scene_info['yaw']);
1137 - }
1138 - }
1139 -
1140 - if (empty($panoscenes["scene-ititle"])) {
1141 - unset($scene_info['title']);
1142 - }
1143 - if (empty($panoscenes["scene-author"])) {
1144 - unset($scene_info['author']);
1145 - }
1146 - if (empty($panoscenes["scene-author-url"])) {
1147 - unset($scene_info['authorURL']);
1148 - }
1149 -
1150 - if (empty($scene_vaov)) {
1151 - unset($scene_info['vaov']);
1152 - }
1153 -
1154 - if (empty($scene_haov)) {
1155 - unset($scene_info['haov']);
1156 - }
1157 -
1158 - if (empty($scene_vertical_offset)) {
1159 - unset($scene_info['vOffset']);
1160 - }
1161 -
1162 - if (isset($panoscenes["cvgscene"])) {
1163 - if ($panoscenes["cvgscene"] == "off") {
1164 - unset($scene_info['maxPitch']);
1165 - unset($scene_info['minPitch']);
1166 - }
1167 - }
1168 - if (empty($panoscenes["scene-maxpitch"])) {
1169 - unset($scene_info['maxPitch']);
1170 - }
1171 -
1172 - if (empty($panoscenes["scene-minpitch"])) {
1173 - unset($scene_info['minPitch']);
1174 - }
1175 -
1176 - if (isset($panoscenes["chgscene"])) {
1177 - if ($panoscenes["chgscene"] == "off") {
1178 - unset($scene_info['maxYaw']);
1179 - unset($scene_info['minYaw']);
1180 - }
1181 - }
1182 - if (empty($panoscenes["scene-maxyaw"])) {
1183 - unset($scene_info['maxYaw']);
1184 - }
1185 -
1186 - if (empty($panoscenes["scene-minyaw"])) {
1187 - unset($scene_info['minYaw']);
1188 - }
1189 -
1190 - // if (isset($panoscenes["czscene"])) {
1191 - // if ($panoscenes["czscene"] == "off") {
1192 - // unset($scene_info['hfov']);
1193 - // unset($scene_info['maxHfov']);
1194 - // unset($scene_info['minHfov']);
1195 - // }
1196 - // }
1197 -
1198 - $scene_array = array();
1199 - $scene_array = array(
1200 - $panoscenes['scene-id'] => $scene_info
1201 - );
1202 -
1203 - $scene_data[$panoscenes['scene-id']] = $scene_info;
1204 223 }
224 + unset( $scene );
1205 225 }
1206 - }
1207 - $pano_id_array = array();
1208 - $pano_id_array = array('panoid' => $panoid);
1209 - $pano_response = array();
1210 - $pano_response = array('autoLoad' => $autoload, 'showControls' => $control, 'compass' => $compass, 'orientationOnByDefault' => $gyro_orientation, 'mouseZoom' => $mouseZoom, 'draggable' => $draggable, 'disableKeyboardCtrl' => $diskeyboard, 'keyboardZoom' => $keyboardzoom, "preview" => $preview, "autoRotate" => $autorotation, "autoRotateInactivityDelay" => $autorotationinactivedelay, "autoRotateStopDelay" => $autorotationstopdelay, 'default' => $default_data, 'scenes' => $scene_data);
1211 - if (empty($autorotation)) {
1212 - unset($pano_response['autoRotate']);
1213 - unset($pano_response['autoRotateInactivityDelay']);
1214 - unset($pano_response['autoRotateStopDelay']);
1215 - }
1216 - if (empty($autorotationinactivedelay)) {
1217 - unset($pano_response['autoRotateInactivityDelay']);
1218 - }
1219 - if (empty($autorotationstopdelay)) {
1220 - unset($pano_response['autoRotateStopDelay']);
1221 - }
1222 226
1223 - $response = array();
1224 - $response = array($pano_id_array, $pano_response);
1225 - if (!empty($response)) {
1226 - $response = json_encode($response, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
227 + return $postdata;
1227 228 }
1228 - if (empty($width)) {
1229 - $width = '600';
1230 - }
1231 - if (empty($height)) {
1232 - $height = '400';
1233 - }
1234 - if ('fullwidth' == $width) {
1235 - $width = "100%";
1236 - }
229 +}
1237 230
1238 - $foreground_color = '#fff';
1239 - $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1240 - $rgb = wpvr_HTMLToRGB($hotspoticoncolor);
1241 - $hsl = wpvr_RGBToHSL($rgb);
1242 - if ($hsl->lightness > 200) {
1243 - $foreground_color = '#000000';
1244 - } else {
1245 - $foreground_color = '#fff';
1246 - }
1247 -
1248 - $class = 'myclass';
1249 - $html = 'test';
1250 - $html = '';
1251 - $html .= '<style>';
1252 - if ($width == 'embed') {
1253 - $html .= 'body{
1254 - overflow: hidden;
1255 - }';
1256 - }
1257 - $status = get_option('wpvr_edd_license_status');
1258 - $status = get_option('wpvr_edd_license_status');
1259 - if ($status !== false && $status == 'valid') {
1260 - if (isset($postdata['customcss_enable']) && $postdata['customcss_enable'] == 'on') {
1261 - $html .= isset($postdata['customcss']) ? $postdata['customcss'] : '';
231 +if ( ! function_exists( 'wpvr_tour_uses_pro_features' ) ) {
232 + /**
233 + * Determine whether a saved tour contains enabled WP VR Pro features.
234 + *
235 + * @param mixed $postdata Saved tour data.
236 + * @return bool
237 + */
238 + function wpvr_tour_uses_pro_features( $postdata ) {
239 + if ( ! is_array( $postdata ) ) {
240 + return false;
1262 241 }
1263 - }
1264 - if ($status !== false && $status == 'valid') {
1265 - if (is_array($panodata) && isset($panodata['scene-list'])) {
1266 - foreach ($panodata['scene-list'] as $panoscenes) {
1267 242
1268 - foreach ($panoscenes['hotspot-list'] as $hotspot) {
1269 - if (isset($hotspot['hotspot-customclass-color-icon-value']) && !empty($hotspot['hotspot-customclass-color-icon-value'])) {
1270 - $hotspoticoncolor = $hotspot['hotspot-customclass-color-icon-value'];
1271 - } else {
1272 - $hotspoticoncolor = "#00b4ff";
1273 - }
1274 - $hotspot_border = '';
1275 - if(isset($hotspot['hotspot-border']) && $hotspot['hotspot-border'] == 'on'){
1276 - $border_width = $hotspot['hotspot-border-width'];
1277 - $border_color = $hotspot['hotspot-border-color'];
1278 - $border_style = $hotspot['hotspot-border-style'];
1279 -
1280 - $hotspot_border = 'border: '.$border_width.'px '.$border_style.' '.$border_color.';';
1281 - }
1282 - $hotspot_background_color = 'background-color: ' . $hotspoticoncolor . ';';
1283 - $hotspot_animation = ' animation: icon-pulse' . $panoid . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1284 - '. $hotspot_border.'';
243 + $is_on = static function ( $value ) {
244 + return in_array( $value, array( true, 1, '1', 'on', 'true' ), true );
245 + };
1285 246
1286 -
1287 - $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1288 - if (isset($hotspot["hotspot-customclass-pro"]) && $hotspot["hotspot-customclass-pro"] != 'none') {
1289 - $border_radius = ' border-radius: 100%;';
1290 - $hotspot_shape = isset($hotspot["hotspot-shape"]) ? $hotspot["hotspot-shape"] : 'round';
1291 - if($hotspot_shape === 'square'){
1292 - $border_radius = '';
1293 - }
1294 - if ($hotspot_shape === 'hexagon') {
1295 - $border_radius = '';
1296 - $hotspot_background_color = 'background-color: transparent;';
1297 - $hotspot_animation = '';
1298 - }
1299 -
1300 - if(isset($hotspot['hotspot-custom-icon-color-value']) && !empty($hotspot['hotspot-custom-icon-color-value'])){
1301 - $foreground_color = $hotspot['hotspot-custom-icon-color-value'];
1302 - }
1303 - $html .= '#' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fas.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1304 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fab.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1305 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fa.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1306 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fa-solid.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1307 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.far.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' {
1308 - display: block !important;
1309 - '.$hotspot_background_color.'
1310 - color: ' . $foreground_color . ';
1311 - '.$border_radius.'
1312 - width: 30px;
1313 - height: 30px;
1314 - font-size: 16px;
1315 - line-height: 30px;
1316 - '.$hotspot_animation.'
1317 - }';
1318 - if($hotspot_shape === 'hexagon'){
1319 -
1320 - $html .= '#' . esc_attr( $panoid ) . ' .custom-' . esc_attr( $id ) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' .hexagon-wrapper svg path {
1321 - fill: ' . $hotspoticoncolor . ';
1322 - }';
1323 -
1324 - $html .= '#' . esc_attr( $panoid ) . ' .custom-' . esc_attr( $id ) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . '.pnlm-tooltip:after{
1325 - content: "";
1326 - position: absolute;
1327 - left: 50%;
1328 - top: 50%;
1329 - transform: translate(-50%, -50%);
1330 - width: 85%;
1331 - height: 85%;
1332 - animation: icon-pulse' . esc_attr( $panoid ) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1333 - border-radius: 100%;
1334 - z-index: -2;
1335 - }';
1336 -
1337 - }
1338 - $html .= '#' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fas.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1339 - #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fab.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1340 - #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fa-solid.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1341 - #' . esc_attr( $panoid2) . ' div.pnlm-hotspot-base.fa.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1342 - #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.far.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' {
1343 - display: block !important;
1344 - '.esc_attr( $hotspot_background_color).'
1345 - color: ' . esc_attr( $foreground_color) . ';
1346 - '.esc_attr( $border_radius).'
1347 - width: 30px;
1348 - height: 30px;
1349 - font-size: 16px;
1350 - line-height: 30px;
1351 - '.esc_attr( $hotspot_animation).'
1352 - }';
1353 - }
1354 - if (isset($hotspot['hotspot-blink'])) {
1355 - $hotspotblink = $hotspot['hotspot-blink'];
1356 - if ($hotspotblink == 'on') {
1357 - $html .= '@-webkit-keyframes icon-pulse' . esc_attr( $panoid) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' {
1358 - 0% {
1359 - box-shadow: 0 0 0 0px rgba(' . esc_attr( $pulse_color[0]) . ', 1);
1360 - }
1361 - 100% {
1362 - box-shadow: 0 0 0 10px rgba(' . esc_attr( $pulse_color[0]) . ', 0);
1363 - }
1364 - }
1365 - @keyframes icon-pulse' . esc_attr( $panoid) . ' {
1366 - 0% {
1367 - box-shadow: 0 0 0 0px rgba(' . esc_attr( $pulse_color[0]) . ', 1);)
1368 - }
1369 - 100% {
1370 - box-shadow: 0 0 0 10px rgba(' . esc_attr( $pulse_color[0] ). ', 0);
1371 - }
1372 - }';
1373 - }
1374 - }
1375 - }
1376 - }
247 + if (
248 + isset( $postdata['streetviewdata'] )
249 + || ( isset( $postdata['streetview'] ) && $is_on( $postdata['streetview'] ) )
250 + || ! empty( $postdata['streetviewurl'] )
251 + ) {
252 + return true;
1377 253 }
1378 - }
1379 254
1380 - $status = get_option('wpvr_edd_license_status');
1381 - if ($status !== false && $status == 'valid') {
1382 - if (!$gyro) {
1383 - $html .= '#' . esc_attr( $panoid ). ' div.pnlm-orientation-button {
1384 - display: none;
1385 - }';
1386 - }
1387 - } else {
1388 - $html .= '#' . esc_attr( $panoid ). ' div.pnlm-orientation-button {
1389 - display: none;
1390 - }';
1391 - }
1392 - $floor_plan_custom_color = isset($postdata['floor_plan_custom_color']) ? $postdata['floor_plan_custom_color'] : '#cca92c';
1393 - $foreground_color_pointer = '#fff';
1394 - if ($floor_plan_custom_color != '') {
1395 - $pointer_pulse = wpvr_hex2rgb($floor_plan_custom_color);
1396 - $floor_rgb = wpvr_HTMLToRGB($floor_plan_custom_color);
1397 - $floor_hsl = wpvr_RGBToHSL($floor_rgb);
1398 - if ($floor_hsl->lightness > 200) {
1399 - $foreground_color_pointer = '#000000';
1400 - }
1401 - $html .= '
1402 - .wpvr-floor-map .floor-plan-pointer.add-pulse:before {
1403 - border: 17px solid ' . esc_attr( $floor_plan_custom_color ) . ';
255 + foreach ( array(
256 + 'bg_tour_enabler', 'floorplan-enabled', 'floor_plan_tour_enabler',
257 + 'floor_plan_compass', 'floor_plan_direction_indicator',
258 + 'gyro', 'deviceorientationcontrol', 'compass', 'vrgallery',
259 + 'vrgallery_title', 'vrgallery_icon_size', 'vrgallery_display',
260 + 'scene_navigation', 'sceneAnimation', 'bg_music',
261 + 'autoplay_bg_music', 'loop_bg_music', 'explainerSwitch',
262 + 'cpLogoSwitch', 'genericform', 'calltoaction', 'customcss_enable',
263 + ) as $key ) {
264 + if ( isset( $postdata[ $key ] ) && $is_on( $postdata[ $key ] ) ) {
265 + return true;
1404 266 }
1405 - @-webkit-keyframes pulse {
1406 - 0% {
1407 - -webkit-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1408 - }
1409 - 70% {
1410 - -webkit-box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1411 - }
1412 - 100% {
1413 - -webkit-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1414 - }
1415 - }
1416 - @keyframes pulse {
1417 - 0% {
1418 - -moz-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1419 - box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1420 - }
1421 - 70% {
1422 - -moz-box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1423 - box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1424 - }
1425 - 100% {
1426 - -moz-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1427 - box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1428 - }
1429 - }';
1430 - }
1431 - $html .= '</style>';
1432 -
1433 - $scene_animation = isset($postdata['sceneAnimation']) ? $postdata['sceneAnimation'] : 'off';
1434 -
1435 - if( $scene_animation === 'on'){
1436 - $animation_type = isset($postdata['sceneAnimationName']) ? $postdata['sceneAnimationName'] : 'none';
1437 - $animationDuration = isset($postdata['sceneAnimationTransitionDuration']) ? $postdata['sceneAnimationTransitionDuration'] : '500ms';
1438 - $animationDelay = isset($postdata['sceneAnimationTransitionDelay']) ? $postdata['sceneAnimationTransitionDelay'] : '0ms';
1439 - $animation_css = apply_filters('wpvr_tour_scene_animation',$animation_type,$animationDuration, $animationDelay, $postdata,$id);
1440 - $html .= $animation_css;
1441 - }
1442 -
1443 - if (wpvr_isMobileDevice()) {
1444 - $html .= '<div id="master-container" class="wpvr-cardboard ' . esc_attr( $className ) . ' ' . esc_attr( $enable_cardboard ) . ' " style="max-width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '; width: 100%; height: ' . esc_attr( $mobile_height ) . esc_attr( $mobile_height_unit ) . '; border-radius:' . esc_attr( $radius ) . '; direction:ltr; border : ' . esc_attr( $border_style ) . ' ">';
1445 - } else {
1446 - $html .= '<div id="master-container" class="wpvr-cardboard ' . esc_attr( $className ) . ' ' . esc_attr( $enable_cardboard ) . '" style="max-width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '; width: 100%; height: ' . esc_attr( $height ) . esc_attr( $height_unit ) . '; border-radius:' . esc_attr( $radius ) . '; direction:ltr; border : ' . esc_attr( $border_style ) . '">';
1447 - }
1448 - $status = get_option('wpvr_edd_license_status');
1449 - $is_cardboard = get_option('wpvr_cardboard_disable');
1450 - if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true') {
1451 - $html .= '<button class="fullscreen-button">';
1452 - $html .= '<span class="expand">';
1453 - $html .= '<i class="fa fa-expand" aria-hidden="true"></i>';
1454 - $html .= '</span>';
1455 -
1456 - $html .= '<span class="compress">';
1457 - $html .= '<i class="fa fa-compress" aria-hidden="true"></i>';
1458 - $html .= '</span>';
1459 - $html .= '</button>';
1460 - $html .= '<label class="wpvr-cardboard-switcher">
1461 - <input type="checkbox" class="vr_mode_change' . $id . '" name="vr_mode_change" value="off">
1462 - <span class="switcher-box">
1463 - <span class="normal-mode-tooltip">Normal VR Mode</span>
1464 - <svg width="78" height="60" viewBox="0 0 78 60" fill="none" xmlns="http://www.w3.org/2000/svg">
1465 - <path d="M42.25 21.4286C42.25 22.2811 41.9076 23.0986 41.2981 23.7014C40.6886 24.3042 39.862 24.6429 39 24.6429C38.138 24.6429 37.3114 24.3042 36.7019 23.7014C36.0924 23.0986 35.75 22.2811 35.75 21.4286C35.75 20.5761 36.0924 19.7585 36.7019 19.1557C37.3114 18.5529 38.138 18.2143 39 18.2143C39.862 18.2143 40.6886 18.5529 41.2981 19.1557C41.9076 19.7585 42.25 20.5761 42.25 21.4286ZM19.5 30C18.9254 30 18.3743 30.2258 17.9679 30.6276C17.5616 31.0295 17.3333 31.5745 17.3333 32.1429C17.3333 32.7112 17.5616 33.2562 17.9679 33.6581C18.3743 34.06 18.9254 34.2857 19.5 34.2857H28.1667C28.7413 34.2857 29.2924 34.06 29.6987 33.6581C30.1051 33.2562 30.3333 32.7112 30.3333 32.1429C30.3333 31.5745 30.1051 31.0295 29.6987 30.6276C29.2924 30.2258 28.7413 30 28.1667 30H19.5ZM47.6667 32.1429C47.6667 31.5745 47.8949 31.0295 48.3013 30.6276C48.7076 30.2258 49.2587 30 49.8333 30H58.5C59.0746 30 59.6257 30.2258 60.0321 30.6276C60.4384 31.0295 60.6667 31.5745 60.6667 32.1429C60.6667 32.7112 60.4384 33.2562 60.0321 33.6581C59.6257 34.06 59.0746 34.2857 58.5 34.2857H49.8333C49.2587 34.2857 48.7076 34.06 48.3013 33.6581C47.8949 33.2562 47.6667 32.7112 47.6667 32.1429ZM32.5 0C31.9254 0 31.3743 0.225765 30.9679 0.627629C30.5616 1.02949 30.3333 1.57454 30.3333 2.14286V8.57143H18.4167C14.8693 8.57183 11.4528 9.89617 8.84994 12.2798C6.24706 14.6634 4.64954 17.9306 4.37667 21.4286H2.16667C1.59203 21.4286 1.04093 21.6543 0.634602 22.0562C0.228273 22.4581 0 23.0031 0 23.5714V36.4286C0 36.9969 0.228273 37.5419 0.634602 37.9438C1.04093 38.3457 1.59203 38.5714 2.16667 38.5714H4.33333V46.0714C4.33333 49.7655 5.81711 53.3083 8.45825 55.9204C11.0994 58.5325 14.6815 60 18.4167 60H25.3933C29.1269 59.9986 32.7071 58.5311 35.347 55.92L37.921 53.3786C38.0618 53.2393 38.229 53.1288 38.4131 53.0534C38.5971 52.978 38.7943 52.9392 38.9935 52.9392C39.1927 52.9392 39.3899 52.978 39.5739 53.0534C39.758 53.1288 39.9252 53.2393 40.066 53.3786L42.6357 55.92C45.2766 58.5322 48.8586 59.9998 52.5937 60H59.5833C63.3185 60 66.9006 58.5325 69.5418 55.9204C72.1829 53.3083 73.6667 49.7655 73.6667 46.0714V38.5714H75.8333C76.408 38.5714 76.9591 38.3457 77.3654 37.9438C77.7717 37.5419 78 36.9969 78 36.4286V23.5714C78 23.0031 77.7717 22.4581 77.3654 22.0562C76.9591 21.6543 76.408 21.4286 75.8333 21.4286H73.6233C73.3505 17.9306 71.753 14.6634 69.1501 12.2798C66.5472 9.89617 63.1307 8.57183 59.5833 8.57143H47.6667V2.14286C47.6667 1.57454 47.4384 1.02949 47.0321 0.627629C46.6257 0.225765 46.0746 0 45.5 0H32.5ZM69.3333 22.5V46.0714C69.3333 48.6289 68.3061 51.0816 66.4776 52.89C64.6491 54.6983 62.1692 55.7143 59.5833 55.7143H52.5937C50.0093 55.7132 47.5311 54.6973 45.7037 52.89L43.1297 50.3486C42.5864 49.8108 41.9413 49.3842 41.2312 49.0931C40.5211 48.8021 39.76 48.6522 38.9913 48.6522C38.2227 48.6522 37.4616 48.8021 36.7515 49.0931C36.0414 49.3842 35.3963 49.8108 34.853 50.3486L32.2833 52.89C30.4559 54.6973 27.9777 55.7132 25.3933 55.7143H18.4167C15.8308 55.7143 13.3509 54.6983 11.5224 52.89C9.6939 51.0816 8.66667 48.6289 8.66667 46.0714V22.5C8.66667 19.9426 9.6939 17.4899 11.5224 15.6815C13.3509 13.8731 15.8308 12.8571 18.4167 12.8571H59.5833C62.1692 12.8571 64.6491 13.8731 66.4776 15.6815C68.3061 17.4899 69.3333 19.9426 69.3333 22.5Z" fill="#216DF0"/>
1466 - </svg>
1467 - </span>
1468 - </label>';
1469 - }
1470 -
1471 - if ($width == 'fullwidth') {
1472 - if (wpvr_isMobileDevice()) {
1473 - $html .= '<div class="cardboard-vrfullwidth vrfullwidth">';
1474 - $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left cardboard-half" style="width: 49%!important; border-radius:' . esc_attr( $radius ). ' ;text-align:center; direction:ltr;" ><div id="center-pointer2' . esc_attr( $id ). '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1475 - $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style="width: 100%; text-align:center; direction:ltr; border-radius:' . esc_attr( $radius ) . '" >';
1476 - } else {
1477 - $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . esc_attr( $radius ) . ';"><div id="center-pointer2' . esc_attr( $id ). '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1478 - $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . esc_attr( $height ) . esc_attr( $height_unit ) . '; border-radius:' . esc_attr( $radius ) . '; direction:ltr;" >';
1479 267 }
1480 - } else {
1481 - if (wpvr_isMobileDevice()) {
1482 - $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left cardboard-half" style="width: 49%; border-radius:' . esc_attr( $radius ) . ';">
1483 - <div id="center-pointer2' . esc_attr( $id ) . '" class="vr-pointer-container">
1484 - <span class="center-pointer"></span>
1485 - </div>
1486 - </div>';
1487 - $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style=" width: 100%; border-radius:' . esc_attr( $radius ) . ';">';
1488 - } else {
1489 268
1490 - $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . esc_attr( $radius ) . ';"><div id="center-pointer2' . esc_attr( $id ) . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1491 -
1492 - $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style="width: 100%; border-radius:' . esc_attr( $radius ) . ';">';
269 + if (
270 + ! empty( $postdata['hfov'] )
271 + || ! empty( $postdata['maxHfov'] )
272 + || ! empty( $postdata['minHfov'] )
273 + ) {
274 + return true;
1493 275 }
1494 - }
1495 - // Vr mode transction scene to scene
1496 - if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true') {
1497 - $html .= '<div id="center-pointer' . esc_attr( $id ) . '" class="vr-pointer-container" style="display:none"><span class="center-pointer"></span></div>';
1498 - }
1499 276
1500 -
1501 - //===company logo===//
1502 - if (isset($postdata['cpLogoSwitch'])) {
1503 - $cpLogoImg = $postdata['cpLogoImg'];
1504 - $cpLogoContent = $postdata['cpLogoContent'];
1505 - if ($postdata['cpLogoSwitch'] == 'on') {
1506 - $html .= '<div id="cp-logo-controls">';
1507 - $html .= '<div class="cp-logo-ctrl" id="cp-logo">';
1508 - if ($cpLogoImg) {
1509 - $html .= '<img loading="lazy" src="' . esc_attr( $cpLogoImg ) . '" alt="Company Logo">';
1510 - }
1511 -
1512 - if ($cpLogoContent) {
1513 - $html .= '<div class="cp-info">' . esc_attr( $cpLogoContent ) . '</div>';
1514 - }
1515 - $html .= '</div>';
1516 - $html .= '</div>';
277 + $tour_layout = isset( $postdata['tourLayout'] ) ? $postdata['tourLayout'] : 'default';
278 + $tour_layout = is_array( $tour_layout )
279 + ? ( isset( $tour_layout['layout'] ) ? $tour_layout['layout'] : 'default' )
280 + : $tour_layout;
281 + if ( $tour_layout !== '' && $tour_layout !== 'default' ) {
282 + return true;
1517 283 }
1518 - }
1519 - //===company logo ends===//
1520 284
1521 - //===Background Tour===//
1522 - if (isset($postdata['bg_tour_enabler'])) {
1523 -
1524 - $bg_tour_enabler = $postdata['bg_tour_enabler'];
1525 - if ($bg_tour_enabler == 'on') {
1526 - $bg_tour_navmenu = $postdata['bg_tour_navmenu'] ?? 'off';
1527 - $bg_tour_title = $postdata['bg_tour_title'] ?? '';
1528 - $bg_tour_subtitle = $postdata['bg_tour_subtitle'] ?? '';
1529 -
1530 - if ($bg_tour_navmenu == 'on') {
1531 - $menuLocations = get_nav_menu_locations();
1532 - $menuID = $menuLocations['primary'];
1533 - $primaryNav = wp_get_nav_menu_items($menuID);
1534 -
1535 - if ($primaryNav) {
1536 - $html .= '<div class="wpvr-navbar-container">';
1537 - foreach ($primaryNav as $primaryNav_key => $primaryNav_value) {
1538 - if ($primaryNav_value->menu_item_parent == "0") {
1539 - $html .= '<li>';
1540 - $html .= '<a href="' . esc_url( $primaryNav_value->url ) . '">' . esc_attr( $primaryNav_value->title ) . '</a>';
1541 - $html .= '<ul class="wpvr-navbar-dropdown">';
1542 - foreach ($primaryNav as $pm_key => $pm_value) {
1543 - if ($pm_value->menu_item_parent == $primaryNav_value->ID) {
1544 - $html .= '<li>';
1545 - $html .= '<a href="' . esc_url( $pm_value->url ) . '">' . esc_attr( $pm_value->title ) . '</a>';
1546 - $html .= '</li>';
1547 - }
1548 - }
1549 - $html .= '</ul>';
1550 - $html .= '</li>';
1551 - }
1552 - }
1553 - $html .= '</div>';
1554 - }
285 + $custom_control = isset( $postdata['customcontrol'] ) && is_array( $postdata['customcontrol'] )
286 + ? $postdata['customcontrol']
287 + : array();
288 + foreach ( array(
289 + 'panupSwitch', 'panDownSwitch', 'panLeftSwitch', 'panRightSwitch',
290 + 'panZoomInSwitch', 'panZoomOutSwitch', 'panFullscreenSwitch',
291 + 'gyroscopeSwitch', 'backToHomeSwitch',
292 + ) as $key ) {
293 + if ( isset( $custom_control[ $key ] ) && $is_on( $custom_control[ $key ] ) ) {
294 + return true;
1555 295 }
1556 -
1557 - $html .= '<div class="wpvr-home-content">';
1558 - $html .= '<div class="wpvr-home-title">' . esc_attr( $bg_tour_title ) . '</div>';
1559 - $html .= '<div class="wpvr-home-subtitle">' . esc_attr( $bg_tour_subtitle ) . '</div>';
1560 - $html .= '</div>';
1561 296 }
1562 - }
1563 - //===Background Tour End===//
1564 297
1565 - //===Custom Control===//
1566 - if (isset($custom_control)) {
1567 - if ($custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $custom_control['gyroscopeSwitch'] == "on" || $custom_control['backToHomeSwitch'] == "on") {
1568 - $html .= '<div id="zoom-in-out-controls' . esc_attr( $id ) . '" class="zoom-in-out-controls">';
1569 -
1570 - if ($custom_control['backToHomeSwitch'] == "on") {
1571 - $html .= '<div class="ctrl" id="backToHome' . esc_attr( $id ) . '"><i class="' . $custom_control['backToHomeIcon'] . '" style="color:' . esc_attr( $custom_control['backToHomeColor'] ) . ';"></i></div>';
1572 - }
1573 -
1574 - if ($custom_control['panZoomInSwitch'] == "on") {
1575 - $html .= '<div class="ctrl" id="zoom-in' . esc_attr( $id ) . '"><i class="' . $custom_control['panZoomInIcon'] . '" style="color:' . esc_attr( $custom_control['panZoomInColor'] ) . ';"></i></div>';
1576 - }
1577 -
1578 - if ($custom_control['panZoomOutSwitch'] == "on") {
1579 - $html .= '<div class="ctrl" id="zoom-out' . esc_attr( $id ) . '"><i class="' . $custom_control['panZoomOutIcon'] . '" style="color:' . esc_attr( $custom_control['panZoomOutColor'] ) . ';"></i></div>';
1580 - }
1581 -
1582 - if ($custom_control['gyroscopeSwitch'] == "on") {
1583 - $html .= '<div class="ctrl" id="gyroscope' . esc_attr( $id ) . '"><i class="' . $custom_control['gyroscopeIcon'] . '" style="color:' . esc_attr( $custom_control['gyroscopeColor'] ) . ';"></i></div>';
1584 - }
1585 -
1586 - $html .= '</div>';
298 + $scenes = isset( $postdata['panodata']['scene-list'] ) ? $postdata['panodata']['scene-list'] : array();
299 + if ( ! is_array( $scenes ) ) {
300 + return false;
1587 301 }
1588 - //===zoom in out Control===//
1589 302
1590 - if ($custom_control['panupSwitch'] == "on" || $custom_control['panDownSwitch'] == "on" || $custom_control['panLeftSwitch'] == "on" || $custom_control['panRightSwitch'] == "on" || $custom_control['panFullscreenSwitch'] == "on") {
303 + $pro_scene_fields = array(
304 + 'scene-vaov', 'scene-haov', 'scene-vertical-offset', 'scene-pitch',
305 + 'scene-yaw', 'scene-maxpitch', 'scene-minpitch', 'scene-maxyaw',
306 + 'scene-minyaw', 'scene-zoom', 'scene-maxzoom', 'scene-minzoom',
307 + );
1591 308
1592 - //===Custom Control===//
1593 - $html .= '<div class="controls" id="controls' . esc_attr( $id ) . '">';
1594 -
1595 - if ($custom_control['panupSwitch'] == "on") {
1596 - $html .= '<div class="ctrl pan-up" id="pan-up' . esc_attr( $id ) . '"><i class="' . $custom_control['panupIcon'] . '" style="color:' . esc_attr( $custom_control['panupColor'] ) . ';"></i></div>';
309 + foreach ( $scenes as $scene ) {
310 + if ( ! is_array( $scene ) ) {
311 + continue;
1597 312 }
1598 313
1599 - if ($custom_control['panDownSwitch'] == "on") {
1600 - $html .= '<div class="ctrl pan-down" id="pan-down' . esc_attr( $id ) . '"><i class="' . $custom_control['panDownIcon'] . '" style="color:' . esc_attr( $custom_control['panDownColor'] ) . ';"></i></div>';
314 + if ( isset( $scene['scene-type'] ) && 'cubemap' === $scene['scene-type'] ) {
315 + return true;
1601 316 }
1602 317
1603 - if ($custom_control['panLeftSwitch'] == "on") {
1604 - $html .= '<div class="ctrl pan-left" id="pan-left' . esc_attr( $id ) . '"><i class="' . $custom_control['panLeftIcon'] . '" style="color:' . esc_attr( $custom_control['panLeftColor'] ) . ';"></i></div>';
318 + foreach ( array( 'ptyscene', 'cvgscene', 'chgscene', 'czscene' ) as $key ) {
319 + if ( isset( $scene[ $key ] ) && $is_on( $scene[ $key ] ) ) {
320 + return true;
321 + }
1605 322 }
1606 323
1607 - if ($custom_control['panRightSwitch'] == "on") {
1608 - $html .= '<div class="ctrl pan-right" id="pan-right' . esc_attr( $id ) . '"><i class="' . $custom_control['panRightIcon'] . '" style="color:' . esc_attr( $custom_control['panRightColor'] ) . ';"></i></div>';
324 + foreach ( $pro_scene_fields as $key ) {
325 + if ( isset( $scene[ $key ] ) && '' !== $scene[ $key ] && null !== $scene[ $key ] ) {
326 + return true;
327 + }
1609 328 }
1610 329
1611 - if ($custom_control['panFullscreenSwitch'] == "on") {
1612 - $html .= '<div class="ctrl fullscreen" id="fullscreen' . esc_attr( $id ) . '"><i class="' . $custom_control['panFullscreenIcon'] . '" style="color:' . esc_attr( $custom_control['panFullscreenColor'] ) . ';"></i></div>';
330 + $hotspots = isset( $scene['hotspot-list'] ) ? $scene['hotspot-list'] : array();
331 + if ( ! is_array( $hotspots ) ) {
332 + continue;
1613 333 }
1614 - $html .= '</div>';
1615 - }
1616 334
1617 - //===explainer button===//
1618 - $explainerControlSwitch = '';
1619 - if (isset($custom_control['explainerSwitch'])) {
1620 - $explainerControlSwitch = $custom_control['explainerSwitch'];
1621 - }
1622 - if ($custom_control['explainerSwitch'] == "on") {
1623 - $explainer_style = empty($postdata['explainerContent']) || ( isset( $postdata['explainerSwitch'] ) && 'off' === $postdata['explainerSwitch'] )? 'pointer-events: none; opacity: 0.5;' : '';
1624 - $html .= '<div class="explainer_button" id="explainer_button_' . esc_attr( $id ) . '" style="right:' . esc_attr( $explainer_right ) . '; ' . esc_attr( $explainer_style ) . '">';
1625 - $html .= '<div class="ctrl" id="explainer_target_' . esc_attr( $id ) . '"><i class="' . $custom_control['explainerIcon'] . '" style="color:' . esc_attr( $custom_control['explainerColor'] ) . ';"></i></div>';
1626 - $html .= '</div>';
1627 - }
1628 -
1629 - //===explainer button===//
1630 -
1631 - }
1632 - //===Custom Control===//
1633 -
1634 - //===Scene navigation Control===//
1635 - if (isset($postdata['scene_navigation']) && $postdata['scene_navigation'] === 'on') {
1636 - $html .= '<style>
1637 - #et-boc .et-l .pnlm-controls-container,
1638 - .pnlm-controls-container{
1639 - top: 33px;
335 + foreach ( $hotspots as $hotspot ) {
336 + if ( ! is_array( $hotspot ) ) {
337 + continue;
1640 338 }
1641 -
1642 - #et-boc .et-l .zoom-in-out-controls,
1643 - .zoom-in-out-controls {
1644 - top: 37px;
1645 - }
1646 - </style>';
1647 - $html .= '<div id="custom-scene-navigation' . esc_attr( $id ) . '" class="custom-scene-navigation">
1648 - <span class="hamburger-menu"><svg width="16" height="10" fill="none" viewBox="0 0 22 15" xmlns="http://www.w3.org/2000/svg"><rect width="21.177" height="2.647" fill="#f7fffb" rx="1.324"/><rect width="21.177" height="2.647" y="6.177" fill="#f7fffb" rx="1.324"/><rect width="21.177" height="2.647" y="12.352" fill="#f7fffb" rx="1.324"/></svg></span>
1649 - </div>
1650 -
1651 - <div id="custom-scene-navigation-nav' . esc_attr( $id ) . '" class="custom-scene-navigation-nav">
1652 - <ul></ul>
1653 - </div>
1654 - ';
1655 - }
1656 339
1657 - //===Scene navigation Control===//
1658 -
1659 - /**
1660 - * Generic Form Handler
1661 - * Renders a generic form with modal functionality if enabled in post data
1662 - *
1663 - * @param array $postdata Array containing form configuration data
1664 - * @param string $id Unique identifier for the form instance
1665 - * @return string $html Generated HTML content
1666 - */
1667 -
1668 - // Check if generic form is enabled and validate the setting
1669 - if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on') {
1670 -
1671 - // $shortcode_val = isset($postdata["genericformshortcode"]) && $postdata["genericformshortcode"] !== "" ? do_shortcode($postdata["genericformshortcode"]) : "No shortcode found or shortcode is empty";
1672 -
1673 - // Process shortcode with fallback handling
1674 - $shortcode_content = '';
1675 - if (isset($postdata["genericformshortcode"]) && !empty(trim($postdata["genericformshortcode"]))) {
1676 - $shortcode_content = do_shortcode($postdata["genericformshortcode"]);
1677 - } else {
1678 - $shortcode_content = '<p class="error-message">No shortcode found.</p>';
1679 - }
1680 -
1681 - // Generate the form trigger button
1682 - $html .= '<div class="generic_form_button" id="generic_form_button_' . esc_attr( $id ) . '">';
1683 - $html .= '<div class="generic-form-icon" title ="Generic Form" id="generic_form_target_' . esc_attr( $id ) . '"><i class="fab fa-wpforms" style="color:#f7fffb;"></i></div>';
1684 - $html .= '</div>';
1685 -
1686 - // Generate the modal form container
1687 - $html .= '<div class="wpvr-generic-form" id="wpvr-generic-form' . esc_attr( $id ) . '" style="display: none">';
1688 - $html .= '<span class="close-generic-form"><i class="fa fa-times"></i></span>';
1689 - $html .= '<div class="generic-form-container">' . $shortcode_content . '</div>';
1690 - $html .= '</div>';
1691 - }
1692 - //=====custom generic form=====//
1693 -
1694 - //===Floor map button===//
1695 - $status = get_option('wpvr_edd_license_status');
1696 - if ($status !== false && 'valid' == $status && $is_pro) {
1697 - if ($floor_plan_enable == "on" && !empty($floor_plan_image)) {
1698 - $html .= '<div class="floor_map_button" id="floor_map_button_' . esc_attr( $id ) . '" style="right:' . esc_attr( $floor_map_right ) . '">';
1699 - $html .= '<div class="ctrl" id="floor_map_target_' . esc_attr( $id ) . '"><i class="fas fa-map" style="color:#f7fffb;"></i></div>';
1700 - $html .= '</div>';
1701 - }
1702 - }
1703 -
1704 - //===floor map button===//
1705 - if ($vrgallery) {
1706 - //===Carousal setup===//
1707 - $size = '';
1708 - if ($vrgallery_icon_size) {
1709 - $size = 'vrg-icon-size-large';
1710 - }
1711 - $html .= '<div id="vrgcontrols' . esc_attr( $id ) . '" class="vrgcontrols">';
1712 -
1713 - $html .= '<div class="vrgctrl' . esc_attr( $id ) . ' vrbounce ' . esc_attr( $size ) . '">';
1714 - $html .= '</div>';
1715 - $html .= '</div>';
1716 -
1717 - $html .= '<div id="sccontrols' . esc_attr( $id ) . '" class="scene-gallery vrowl-carousel owl-theme">';
1718 - if (isset($panodata["scene-list"])) {
1719 - foreach ($panodata["scene-list"] as $panoscenes) {
1720 - $scene_key = $panoscenes['scene-id'];
1721 - if ($vrgallery_title == 'on') {
1722 - $scene_key_title = $panoscenes['scene-ititle'];
1723 - // $scene_key_title = $panoscenes['scene-id'];
1724 - } else {
1725 - $scene_key_title = "";
340 + if (
341 + ( ! empty( $hotspot['hotspot-customclass-pro'] ) && 'none' !== $hotspot['hotspot-customclass-pro'] )
342 + || ( ! empty( $hotspot['hotspot-shape'] ) && 'round' !== $hotspot['hotspot-shape'] )
343 + || ( isset( $hotspot['hotspot-border'] ) && $is_on( $hotspot['hotspot-border'] ) )
344 + || ! empty( $hotspot['hotspot-scene-pitch'] )
345 + || ! empty( $hotspot['hotspot-scene-yaw'] )
346 + || ( isset( $hotspot['hotspot-scene-entry-point-mode'] ) && 'custom' === $hotspot['hotspot-scene-entry-point-mode'] )
347 + ) {
348 + return true;
1726 349 }
1727 -
1728 - if ($panoscenes['scene-type'] == 'cubemap') {
1729 - $img_src_url = $panoscenes['scene-attachment-url-face0'];
1730 - } else {
1731 - $img_src_url = $panoscenes['scene-attachment-url'];
1732 - }
1733 -
1734 -
1735 - $src_to_id = attachment_url_to_postid($img_src_url);
1736 - $thumbnail_array = wp_get_attachment_image_src($src_to_id, 'thumbnail');
1737 - if ($thumbnail_array) {
1738 - $thumbnail = $thumbnail_array[0];
1739 - } else {
1740 - $thumbnail = $img_src_url;
1741 - }
1742 - if( isset($postdata['tourLayout']['layout']) && 'layout1' !== $postdata['tourLayout']['layout']) {
1743 - $html .= '<ul><li title="Double click to view scene"><span class="scene-title">' . $scene_key_title . '</span><img loading="lazy" class="scctrl" id="' . $scene_key . '_gallery_' . $id . '" src="' . $thumbnail . '"></li></ul>';
1744 - }else {
1745 - $html .= '<ul><li title="Double click to view scene"><span class="scene-title">' . $scene_key_title . '</span><img loading="lazy" class="scctrl" id="' . $scene_key . '_gallery_' . $id . '" src="' . $thumbnail . '"></li></ul>';
1746 - }
1747 350 }
1748 351 }
1749 - $html .= '</div>';
1750 - $html .= '
1751 - <div class="owl-nav wpvr_slider_nav">
1752 - <button type="button" role="presentation" class="owl-prev wpvr_owl_prev">
1753 - <div class="nav-btn prev-slide"><i class="fa fa-angle-left"></i></div>
1754 - </button>
1755 - <button type="button" role="presentation" class="owl-next wpvr_owl_next">
1756 - <div class="nav-btn next-slide"><i class="fa fa-angle-right"></i></div>
1757 - </button>
1758 - </div>
1759 - ';
1760 - //===Carousal setup end===//
1761 - }
1762 352
1763 - $bg_music = isset($postdata['bg_music']) ? $postdata['bg_music'] : 'off';
1764 - $bg_music_url = isset($postdata['bg_music_url']) ? $postdata['bg_music_url'] : '';
1765 - $autoplay_bg_music = isset($postdata['autoplay_bg_music']) ? $postdata['autoplay_bg_music'] : 'off';
1766 - $loop_bg_music = isset($postdata['loop_bg_music']) ? $postdata['loop_bg_music'] : 'off';
1767 -
1768 - $bg_loop = ($loop_bg_music === 'on') ? 'loop' : '';
1769 - $autoplay_attr = ($autoplay_bg_music === 'on') ? 'autoplay' : '';
1770 - $audio_muted_attr = ($autoplay_bg_music === 'on') ? 'muted' : '';
1771 - $audio_icon_class = 'fa-volume-mute'; // Always start with mute icon
1772 -
1773 - if ($bg_music === 'on') {
1774 - $html .= '<div id="adcontrol' . esc_attr( $id ) . '" class="adcontrol" style="right:' . esc_attr( $audio_right ) . '">';
1775 - $html .= '<audio id="vrAudio' . esc_attr($id) . '" class="vrAudioDefault" data-autoplay="' . esc_attr($autoplay_bg_music) . '" onended="audionEnd' . esc_attr($id) . '()" ' . $autoplay_attr . ' ' . $audio_muted_attr . ' ' . $bg_loop . '>
1776 - <source src="' . esc_url($bg_music_url) . '" type="audio/mpeg">
1777 - Your browser does not support the audio element.
1778 - </audio>';
1779 - $html .= '<button onclick="playPause' . esc_attr($id) . '()" class="ctrl audio_control" id="audio_control' . esc_attr($id) . '">
1780 - <i id="vr-volume' . esc_attr($id) . '" class="wpvrvolumeicon' . esc_attr($id) . ' fas ' . esc_attr($audio_icon_class) . '" style="color:#fff;"></i>
1781 - </button>';
1782 - $html .= '</div>';
353 + return false;
1783 354 }
355 +}
1784 356
1785 - //===Explainer video section===//
1786 - $explainerContent = "";
1787 - if (isset($postdata['explainerContent'])) {
1788 - $explainerContent = $postdata['explainerContent'];
1789 - }
1790 - $html .= '<div class="explainer" id="explainer' . esc_attr( $id ) . '" style="display: none">';
1791 - $html .= '<span class="close-explainer-video"><i class="fa fa-times"></i></span>';
1792 - $html .= '' . $explainerContent . '';
1793 - $html .= '</div>';
1794 - //===Explainer video section End===//
357 +if ( ! function_exists( 'wpvr_get_pro_feature_tour_ids' ) ) {
358 + /**
359 + * Return IDs of tours that use at least one enabled Pro feature.
360 + *
361 + * @return array
362 + */
363 + function wpvr_get_pro_feature_tour_ids() {
364 + static $tour_ids = null;
1795 365
1796 - //===Floor plan section===//
1797 - $floor_map_image = "";
1798 - $floor_map_pointer = array();
1799 - $floor_map_scene_id = '';
1800 - $floor_plan_custom_color = '#cca92c';
1801 -
1802 - if (isset($postdata['floor_plan_attachment_url'])) {
1803 - $floor_map_image = $postdata['floor_plan_attachment_url'];
1804 - $floor_map_pointer = $postdata['floor_plan_pointer_position'];
1805 - $floor_map_scene_id = $postdata['floor_plan_data_list'];
1806 - $floor_plan_custom_color = $postdata['floor_plan_custom_color'];
1807 - }
1808 - $html .= '<div class="wpvr-floor-map" id="wpvr-floor-map' . $id . '" style="display: none">';
1809 - $html .= '<span class="close-floor-map-plan"><i class="fa fa-times"></i></span>';
1810 - $html .= '<img loading="lazy" src="' . $floor_map_image . '">';
1811 -
1812 - foreach ($floor_map_pointer as $key => $pointer_position) {
1813 - $html .= '<div class="floor-plan-pointer ui-draggable ui-draggable-handle" scene_id = "' . esc_attr( $floor_map_scene_id[$key]->value ) . '" id="' . esc_attr( $pointer_position->id ) . '" data-top="' . esc_attr( $pointer_position->data_top ) . '" data-left="' . esc_attr( $pointer_position->data_left ) . '" style="' . esc_attr( $pointer_position->style ) . '">
1814 -
1815 - <svg class="floor-pointer-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1816 - <circle cx="12" cy="12" r="11.5" stroke="' . esc_attr( $floor_plan_custom_color ) . '"/>
1817 - <circle cx="12" cy="12" r="5" fill="' . esc_attr( $foreground_color_pointer ) . '"/>
1818 - </svg>
1819 - <svg class="floor-pointer-flash" width="54" height="35" viewBox="0 0 54 35" fill="none" xmlns="http://www.w3.org/2000/svg">
1820 - <path d="M0.454054 1.32433L11.7683 34.3243C11.9069 34.7285 12.287 35 12.7143 35H41.2857C41.713 35 42.0931 34.7285 42.2317 34.3243L53.5459 1.32432C53.7685 0.675257 53.2862 0 52.6 0H1.4C0.713843 0 0.231517 0.675258 0.454054 1.32433Z" fill="url(#paint0_linear_1_10)"/>
1821 - <defs>
1822 - <linearGradient id="paint0_linear_1_10" x1="27" y1="4.59807e-08" x2="26.5" y2="28" gradientUnits="userSpaceOnUse">
1823 - <stop stop-color="' . esc_attr( $floor_plan_custom_color ) . '" stop-opacity="0"/>
1824 - <stop offset="1" stop-color="' . esc_attr( $floor_plan_custom_color ) . '"/>
1825 - </linearGradient>
1826 - </defs>
1827 - </svg>
1828 -
1829 - </div>';
1830 - }
1831 - $html .= '</div>';
1832 - //===Floor plan section===//
1833 -
1834 - $html .= '<div class="wpvr-hotspot-tweak-contents-wrapper" style="display: none">';
1835 - $html .= '<i class="fa fa-times cross" data-id="' . esc_attr( $id ) . '"></i>';
1836 - $html .= '<div class="wpvr-hotspot-tweak-contents-flex">';
1837 - $html .= '<div class="wpvr-hotspot-tweak-contents">';
1838 - ob_start();
1839 - do_action('wpvr_hotspot_tweak_contents', $scene_data);
1840 - $hotspot_content = ob_get_clean();
1841 - $html .= $hotspot_content;
1842 - $html .= '</div>';
1843 - $html .= '</div>';
1844 - $html .= '</div>';
1845 -
1846 - $html .= '<div class="custom-ifram-wrapper" style="display: none;">';
1847 - $html .= '<i class="fa fa-times cross" data-id="' . esc_attr( $id ) . '"></i>';
1848 - $html .= '<div class="custom-ifram-flex">';
1849 - $html .= '<div class="custom-ifram">';
1850 - $html .= '</div>';
1851 - $html .= '</div>';
1852 - $html .= '</div>';
1853 - $html .= '</div>';
1854 - $html .= '</div>';
1855 -
1856 -
1857 - if ("fullwidth" == $width) {
1858 - $html .= '</div>';
1859 - }
1860 - if ($status !== false && 'valid' == $status && $is_pro) {
1861 - $call_to_action = isset($postdata['calltoaction']) ? $postdata['calltoaction'] : 'off';
1862 - if ('on' == $call_to_action) {
1863 - $buttontext = isset($postdata['buttontext']) ? $postdata['buttontext'] : '';
1864 - $buttonurl = isset($postdata['buttonurl']) ? $postdata['buttonurl'] : '';
1865 - $cta_btn_style = isset($postdata['button_configuration']) ? $postdata['button_configuration'] : array();
1866 -
1867 - $button_open_new_tab = isset($cta_btn_style['button_open_new_tab']) ? $cta_btn_style['button_open_new_tab'] : "off";
1868 - $target = '_self';
1869 - $button_position = isset($cta_btn_style['button_position']) ? $cta_btn_style['button_position'] : "";
1870 - $background_color = isset($cta_btn_style['button_background_color']) ? $cta_btn_style['button_background_color'] : "";
1871 - $color = isset($cta_btn_style['button_font_color']) ? $cta_btn_style['button_font_color'] : "";
1872 - $font_size = isset($cta_btn_style['button_font_size']) ? $cta_btn_style['button_font_size'] : "";
1873 - $font_weight = isset($cta_btn_style['button_font_weight']) ? $cta_btn_style['button_font_weight'] : "";
1874 - $text_align = isset($cta_btn_style['button_alignment']) ? $cta_btn_style['button_alignment'] : "";
1875 - $text_transform = isset($cta_btn_style['button_transform']) ? $cta_btn_style['button_transform'] : "";
1876 - $font_style = isset($cta_btn_style['button_text_style']) ? $cta_btn_style['button_text_style'] : "";
1877 - $text_decoration = isset($cta_btn_style['button_text_decoration']) ? $cta_btn_style['button_text_decoration'] : "";
1878 - $line_height = isset($cta_btn_style['button_line_height']) ? $cta_btn_style['button_line_height'] : "";
1879 - $letter_spacing = isset($cta_btn_style['button_letter_spacing']) ? $cta_btn_style['button_letter_spacing'] : "";
1880 - $word_spacing = isset($cta_btn_style['button_word_spacing']) ? $cta_btn_style['button_word_spacing'] : "";
1881 -
1882 - $border_width = isset($cta_btn_style['button_border_width']) ? $cta_btn_style['button_border_width'] : "";
1883 - $border_style = isset($cta_btn_style['button_border_style']) ? $cta_btn_style['button_border_style'] : "";
1884 - $border_color = isset($cta_btn_style['button_border_color']) ? $cta_btn_style['button_border_color'] : "";
1885 - $border_radius = isset($cta_btn_style['button_border_radius']) ? $cta_btn_style['button_border_radius'] : "";
1886 -
1887 - $button_pt = isset($cta_btn_style['button_pt']) ? $cta_btn_style['button_pt'] : "";
1888 - $button_pr = isset($cta_btn_style['button_pr']) ? $cta_btn_style['button_pr'] : "";
1889 - $button_pb = isset($cta_btn_style['button_pb']) ? $cta_btn_style['button_pb'] : "";
1890 - $button_pl = isset($cta_btn_style['button_pl']) ? $cta_btn_style['button_pl'] : "";
1891 -
1892 - if ($button_open_new_tab == 'on') {
1893 - $target = '_blank';
1894 - }
1895 - $style = 'background-color: ' . esc_attr( $background_color ) . ';
1896 - color: ' . esc_attr( $color ) . ';
1897 - font-size: ' . esc_attr( $font_size ) . 'px;
1898 - font-weight: ' . esc_attr( $font_weight ) . ';
1899 - text-align: center;
1900 - display: inline-block;
1901 - text-transform: ' . esc_attr( $text_transform ) . ';
1902 - font-style: ' . esc_attr( $font_style ) . ';
1903 - text-decoration: ' . esc_attr( $text_decoration ) . ';
1904 - line-height: ' . esc_attr( $line_height ) . ';
1905 - letter-spacing: ' . esc_attr( $letter_spacing ) . 'px;
1906 - word-spacing: ' . esc_attr( $word_spacing ) . 'px;
1907 - border: ' . esc_attr( $border_width ) . 'px ' . esc_attr( $border_style ) . ' ' . esc_attr( $border_color ) . ';
1908 - border-radius: ' . esc_attr( $border_radius ). 'px;
1909 - padding: ' . esc_attr( $button_pt ) . 'px ' . esc_attr( $button_pr ) . 'px ' . esc_attr( $button_pb ) . 'px ' . esc_attr( $button_pl ) . 'px;
1910 - ';
1911 - $html .= '<div class="wpvr-call-to-action-button position-' . esc_attr( $text_align ) . '" style="max-width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '">
1912 - <a href="' . esc_url( $buttonurl ) . '" style="' . esc_attr( $style ) . '" target="' . esc_attr( $target ) . '">' . esc_attr( $buttontext ) . '</a>
1913 - </div>';
366 + if ( is_array( $tour_ids ) ) {
367 + return $tour_ids;
1914 368 }
1915 - }
1916 369
1917 - //script started
370 + $tour_ids = array();
371 + $posts = get_posts( array(
372 + 'post_type' => 'wpvr_item',
373 + 'post_status' => 'any',
374 + 'posts_per_page' => -1,
375 + 'fields' => 'ids',
376 + 'no_found_rows' => true,
377 + 'update_post_meta_cache' => true,
378 + 'update_post_term_cache' => false,
379 + ) );
1918 380
1919 - $html .= '<script>';
1920 - if (isset($postdata['bg_music']) && $bg_music == 'on') {
1921 - $html .= '
1922 - var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
1923 - var playing' . $id . ' = false;
1924 - var autoplaySupported' . $id . ' = false;
1925 - var alertShown' . $id . ' = false;
1926 - var autoplayChecked' . $id . ' = false;
1927 -
1928 - function playPause' . $id . '() {
1929 - if (playing' . $id . ') {
1930 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1931 - x' . $id . '.pause();
1932 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
1933 - playing' . $id . ' = false;
1934 - } else {
1935 - x' . $id . '.muted = false;
1936 - x' . $id . '.play().then(function() {
1937 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
1938 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
1939 - playing' . $id . ' = true;
1940 - }).catch(function(e) {
1941 - console.log("Play failed:", e);
1942 - });
1943 - }
381 + foreach ( $posts as $tour_id ) {
382 + $postdata = get_post_meta( (int) $tour_id, 'panodata', true );
383 + if ( wpvr_tour_uses_pro_features( $postdata ) ) {
384 + $tour_ids[] = (int) $tour_id;
1944 385 }
1945 -
1946 - function audionEnd' . $id . '() {
1947 - playing' . $id . ' = false;
1948 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1949 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
1950 - }
1951 -
1952 - x' . $id . '.addEventListener("ended", audionEnd' . $id . ');';
1953 -
1954 - if ($autoplay_bg_music == 'on') {
1955 - $html .= '
1956 -
1957 - x' . $id . '.addEventListener("loadeddata", function() {
1958 - if (!autoplayChecked' . $id . ') {
1959 - checkAutoplayStatus' . $id . '();
1960 - }
1961 - });
1962 -
1963 - x' . $id . '.addEventListener("canplay", function() {
1964 - if (!autoplayChecked' . $id . ') {
1965 - checkAutoplayStatus' . $id . '();
1966 - }
1967 - });
1968 -
1969 - x' . $id . '.addEventListener("canplaythrough", function() {
1970 - if (!autoplayChecked' . $id . ') {
1971 - checkAutoplayStatus' . $id . '();
1972 - }
1973 - });
1974 -
1975 - setTimeout(function() {
1976 - if (!autoplayChecked' . $id . ') {
1977 - checkAutoplayStatus' . $id . '();
1978 - }
1979 - }, 1000);
1980 -
1981 - x' . $id . '.addEventListener("play", function() {
1982 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
1983 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
1984 - playing' . $id . ' = true;
1985 - });
1986 -
1987 - x' . $id . '.addEventListener("pause", function() {
1988 - if (!playing' . $id . ') {
1989 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1990 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
1991 - }
1992 - });
1993 -
1994 - function checkAutoplayStatus' . $id . '() {
1995 - autoplayChecked' . $id . ' = true;
1996 -
1997 - x' . $id . '.muted = true;
1998 - var playPromise = x' . $id . '.play();
1999 -
2000 - if (playPromise !== undefined) {
2001 - playPromise.then(function () {
2002 - if (x' . $id . '.muted || x' . $id . '.volume === 0) {
2003 - handleAutoplayBlocked' . $id . '();
2004 - } else {
2005 - autoplaySupported' . $id . ' = true;
2006 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2007 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2008 - playing' . $id . ' = true;
2009 - }
2010 - }).catch(function () {
2011 - handleAutoplayBlocked' . $id . '();
2012 - });
2013 - } else {
2014 - setTimeout(function () {
2015 - if (x' . $id . '.paused || x' . $id . '.currentTime === 0) {
2016 - handleAutoplayBlocked' . $id . '();
2017 - } else {
2018 - autoplaySupported' . $id . ' = true;
2019 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2020 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2021 - playing' . $id . ' = true;
2022 - }
2023 - }, 300);
2024 - }
2025 - }
2026 -
2027 - function handleAutoplayBlocked' . $id . '() {
2028 - autoplaySupported' . $id . ' = false;
2029 - if (!alertShown' . $id . ') {
2030 - alert("Autoplay is not supported in your browser. Please click the audio button to play music.");
2031 - alertShown' . $id . ' = true;
2032 - }
2033 -
2034 - x' . $id . '.pause();
2035 - x' . $id . '.currentTime = 0;
2036 - x' . $id . '.muted = true;
2037 -
2038 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2039 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2040 -
2041 - document.getElementById("pano' . $id . '").addEventListener("click", musicPlay' . $id . ');
2042 - document.addEventListener("touchstart", musicPlay' . $id . ', { once: true });
2043 - document.addEventListener("click", musicPlay' . $id . ', { once: true });
2044 - }
2045 -
2046 - function musicPlay' . $id . '() {
2047 - x' . $id . '.muted = false;
2048 - var playPromise = x' . $id . '.play();
2049 -
2050 - if (playPromise !== undefined) {
2051 - playPromise.then(function () {
2052 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2053 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2054 - playing' . $id . ' = true;
2055 - }).catch(function(e) {
2056 - console.log("Play failed:", e);
2057 - });
2058 - } else {
2059 - setTimeout(function () {
2060 - if (!x' . $id . '.paused) {
2061 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2062 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2063 - playing' . $id . ' = true;
2064 - }
2065 - }, 100);
2066 - }
2067 -
2068 - document.getElementById("pano' . $id . '").removeEventListener("click", musicPlay' . $id . ');
2069 - document.removeEventListener("touchstart", musicPlay' . $id . ');
2070 - document.removeEventListener("click", musicPlay' . $id . ');
2071 - }
2072 - ';
2073 386 }
2074 - }
2075 - $html .= 'jQuery(document).ready(function() {';
2076 - $html .= 'var response = ' . $response . ';';
2077 - $html .= 'var scenes = response[1];';
2078 - $html .= 'if(scenes) {';
2079 - $html .= 'var scenedata = scenes.scenes;';
2080 - $html .= 'for(var i in scenedata) {';
2081 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2082 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2083 - $html .= 'if(scenehotspot[i].type === "info") {';
2084 - $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2085 - $html .= '} else if(scenehotspot[i].type === "scene") {';
2086 - $html .= ' scenehotspot[i]["clickHandlerArgs"] = scenehotspot[i]["text"];';
2087 - $html .='if(wpvr_public.is_pro_active) {';
2088 - $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspotscene;';
2089 - $html .='}';
2090 - $html .= '}';
2091 - if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2092 - } else {
2093 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2094 - $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2095 - $html .= '}';
2096 - }
2097 - $html .= '}';
2098 - $html .= '}';
2099 - $html .= '}';
2100 - $html .= 'var panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);';
2101 387
2102 -
2103 - //===Dplicate mode only for vr mode===//
2104 - $response2 = json_decode($response);
2105 - $response2[1]->compass = false;
2106 - $response2[1]->autoRotate = false;
2107 - $response = json_encode($response2, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
2108 - $html .= 'var response_duplicate = ' . $response . ';';
2109 - $html .= 'var scenes_duplicate = response_duplicate[1];';
2110 -
2111 - $html .= 'if(scenes_duplicate) {';
2112 - $html .= 'var scenedata = scenes_duplicate.scenes;';
2113 - $html .= 'for(var i in scenedata) {';
2114 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2115 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2116 - $html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {';
2117 - $html .= 'scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2118 - $html .= '}';
2119 - if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2120 - } else {
2121 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2122 - $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2123 - $html .= '}';
388 + return $tour_ids;
2124 389 }
2125 - $html .= '}';
2126 - $html .= '}';
2127 - $html .= '}';
2128 - $html .= 'var vr_mode = "off";';
2129 - $status = get_option('wpvr_edd_license_status');
2130 - if ($status !== false && 'valid' == $status && $is_pro) {
2131 - $html .= 'var panoshow2' . $id . ' = pannellum.viewer("pano2' . $id . '", scenes_duplicate);';
390 +}
2132 391
2133 - // Show Cardboard Mode in Tour
2134 - $html .= '
2135 - var tim;
2136 - var im = 0;
2137 - var active_scene = "' . $default_scene . '";
2138 - var c_time;
2139 - c_time = new Date();
2140 - var timer = c_time.getTime() + 2000;
2141 - function panoShowCardBoardOnTrigger(data){
2142 - if(scenes_duplicate) {
2143 - var scenedata = scenes_duplicate.scenes;
2144 - for(var i in scenedata) {
2145 - if(active_scene === i) {
2146 - var scenehotspot = scenedata[i].hotSpots;
2147 - for(var j in scenehotspot) {
2148 - var plusFiveYaw = Math.round(scenehotspot[j].yaw) + 5;
2149 - var minusFiveYaw = Math.round(scenehotspot[j].yaw) - 5;
2150 - var plusFivePitch = Math.round(scenehotspot[j].pitch) + 5;
2151 - var minusFivePitch = Math.round(scenehotspot[j].pitch) - 5;
2152 - var firstCondition = ( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ;
2153 - var secCondition = (Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw);
2154 - if(( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ){
2155 - if((Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw)){
2156 - jQuery(".center-pointer").addClass("wpvr-pluse-effect")
2157 - var getScene = scenehotspot[j].sceneId;
2158 - if(scenehotspot[j].type == "scene"){
2159 - panoshow' . $id . '.loadScene(getScene);
2160 - panoshow2' . $id . '.loadScene(getScene);
2161 -// var inside_current_time_object = new Date();
2162 -// var inside_timer = inside_current_time_object.getTime();
2163 -// if(inside_timer > timer) {
2164 -// panoshow' . $id . '.loadScene(getScene);
2165 -// panoshow2' . $id . '.loadScene(getScene);
2166 -// jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2167 -// }
2168 - }else{
2169 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2170 - }
2171 - }
2172 - else {
2173 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2174 - c_time = new Date();
2175 - timer = c_time.getTime() + 2000;
2176 - }
2177 - }
2178 - else {
2179 - c_time = new Date();
2180 - timer = c_time.getTime() + 2000;
2181 - }
2182 - }
2183 - }
2184 - }
2185 - }
2186 - };
2187 -
2188 - function vrDeviseOrientation(){
2189 - var data = {
2190 - pitch: panoshow' . $id . '.getPitch(),
2191 - yaw: panoshow' . $id . '.getYaw(),
2192 - };
2193 - panoShowCardBoardOnTrigger(data);
2194 - }
2195 - ';
2196 - $html .= '
2197 -
2198 - function requestFullScreen(){
2199 - var elem = document.getElementById("master-container");
2200 - if (elem.requestFullscreen) {
2201 - elem.requestFullscreen();
2202 - } else if (elem.webkitRequestFullscreen) { /* Safari */
2203 - elem.webkitRequestFullscreen();
2204 - } else if (elem.msRequestFullscreen) { /* IE11 */
2205 - elem.msRequestFullscreen();
2206 - }
2207 - }
2208 - function requestExitFullscreen(){
2209 - var elem = document.getElementById("master-container");
2210 - if (document.exitFullscreen) {
2211 - document.exitFullscreen();
2212 - } else if (document.webkitExitFullscreen) { /* Safari */
2213 - document.webkitExitFullscreen();
2214 - } else if (document.msExitFullscreen) { /* IE11 */
2215 - document.msExitFullscreen();
2216 - }
2217 - }
2218 - jQuery(document).on("click",".fullscreen-button .expand",function() {
2219 - jQuery(this).hide()
2220 - jQuery(this).parent().find(".compress").show()
2221 - requestFullScreen()
2222 - screen.orientation.lock("landscape-primary")
2223 - .then(function() {
2224 - })
2225 - .catch(function(error) {
2226 - alert("Not Supported for this devise");
2227 - });
2228 -
2229 - });
2230 - jQuery(document).on("click",".fullscreen-button .compress",function() {
2231 - jQuery(this).hide()
2232 - jQuery(this).parent().find(".expand").show()
2233 - requestExitFullscreen()
2234 - screen.orientation.unlock();
2235 -
2236 - });
2237 -
2238 - let onLoadAnalytics = false;
2239 - let sceneLoadAnalytics = false;
2240 - function storeAnalyticsData(data) {
2241 - if(wpvr_public.is_pro_active) {
2242 - jQuery.ajax({
2243 - url: wpvrAnalyticsObj.ajaxUrl,
2244 - type: "POST",
2245 - data: {
2246 - action: "store_scene_hotspot_data",
2247 - scene_id: data.scene_id,
2248 - tour_id: data.tour_id,
2249 - type: data.type,
2250 - hotspot_id: data.hotspot_id || "",
2251 - user_agent: navigator.userAgent,
2252 - device_type: getDeviceType() || "desktop",
2253 - nonce: wpvrAnalyticsObj.nonce,
2254 - },
2255 - success: function (response) {
2256 - console.log("Data stored successfully");
2257 - },
2258 - error: function (error) {
2259 - console.log("Error in storing data");
2260 - }
2261 - });
2262 - }
2263 - }
2264 -
2265 - function getDeviceType() {
2266 - const userAgent = navigator.userAgent.toLowerCase();
2267 -
2268 - if (/mobile|android|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent)) {
2269 - return "mobile";
2270 - } else if (/tablet|ipad/i.test(userAgent)) {
2271 - return "tablet";
2272 - } else {
2273 - return "desktop";
2274 - }
2275 - }
2276 -
2277 - panoshow' . $id . '.on("scenechange", function(scene) {
2278 - onLoadAnalytics = true;
2279 - sceneLoadAnalytics = true;
2280 - let scene_id = scene;
2281 - let tour_id = ' . $id . ';
2282 - let type = "scene";
2283 - let hotspot_id = "";
2284 - let user_agent = navigator.userAgent;
2285 - let device_type = getDeviceType() ? getDeviceType() : "desktop";
2286 - storeAnalyticsData({
2287 - scene_id: scene_id,
2288 - tour_id: tour_id,
2289 - type: type,
2290 - hotspot_id: hotspot_id,
2291 - user_agent: user_agent,
2292 - device_type: device_type,
2293 - });
2294 - });
2295 -
2296 - panoshow' . $id . '.on("load", function() {
2297 - let scene_id = panoshow' . $id . '.getScene();
2298 - let tour_id = ' . $id . ';
2299 - let type = "scene";
2300 - let hotspot_id = "";
2301 - let user_agent = navigator.userAgent;
2302 - let device_type = getDeviceType() ? getDeviceType() : "desktop";
2303 - if(!onLoadAnalytics && !sceneLoadAnalytics){
2304 - storeAnalyticsData({
2305 - scene_id: scene_id,
2306 - tour_id: tour_id,
2307 - type: type,
2308 - hotspot_id: hotspot_id,
2309 - user_agent: user_agent,
2310 - device_type: device_type,
2311 - });
2312 - }
2313 - });
2314 -
2315 - function wpvrhotspotscene(hotSpotDiv, args) {
2316 - onLoadAnalytics = true;
2317 - let scene_id = panoshow' . $id . '.getScene();
2318 - let tour_id = ' . $id . ';
2319 - let type = "hotspot";
2320 - let hotspot_id = args;
2321 - let user_agent = navigator.userAgent;
2322 - let device_type = getDeviceType() ? getDeviceType() : "desktop";
2323 - storeAnalyticsData({
2324 - scene_id: scene_id,
2325 - tour_id: tour_id,
2326 - type: type,
2327 - hotspot_id: hotspot_id,
2328 - user_agent: user_agent,
2329 - device_type: device_type
2330 - });
2331 - }
2332 -
2333 - ';
2334 -
2335 - $html .= '
2336 - panoshow' . $id . '.on("scenechange", function (scene){
2337 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2338 - active_scene = scene;
2339 - });
2340 - var compassBlock = "";
2341 - var infoBlock = "";
2342 - var getValue = "";
2343 - jQuery(document).on("click",".vr_mode_change' . $id . '",function (){
2344 -
2345 - jQuery("#pano2' . $id . ' .pnlm-load-button").trigger("click");
2346 - jQuery("#pano' . $id . ' .pnlm-load-button").trigger("click");
2347 -
2348 - getValue = jQuery(this).val();
2349 - var getParent = jQuery(this).parent().parent();
2350 - var fullWidthParent = getParent.parent();
2351 - var compass = getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display");
2352 - var panoInfo = getParent.find("#pano' . $id . ' .pnlm-panorama-info").css("display");
2353 - if(compass == "block"){
2354 - compassBlock = "block";
2355 - }
2356 - if(panoInfo == "block"){
2357 - infoBlock = "block";
2358 - }
2359 - if (getValue == "off") {
2360 - requestFullScreen()
2361 - screen.orientation.lock("landscape-primary")
2362 - .then(function() {
2363 - })
2364 - .catch(function(error) {
2365 - alert("VR Glass Mode not supported in this device");
2366 - });
2367 - getParent.find(".pano-wrap").addClass("wpvr-cardboard-disable-event");
2368 - // localStorage.setItem("vr_mode", "on");
2369 - vr_mode = "on";
2370 - jQuery(".vr-mode-title").show();
2371 - jQuery(this).val("on");
2372 - getParent.find("#pano2' . $id . '").css({
2373 - "opacity": "1",
2374 - "visibility": "visible",
2375 - "position": "relative",
2376 - });
2377 - gyroSwitch = true;
2378 - panoshow' . $id . '.startOrientation();
2379 - panoshow2' . $id . '.startOrientation();
2380 - panoshow2' . $id . '.setPitch(panoshow' . $id . '.getPitch(), 0);
2381 - panoshow2' . $id . '.setYaw(panoshow' . $id . '.getYaw(), 0);
2382 - getParent.find("#pano' . $id . ' #zoom-in-out-controls' . $id . '").hide();
2383 - getParent.find("#pano' . $id . ' #controls' . $id . '").hide();
2384 - getParent.find("#pano' . $id . ' #explainer_button_' . $id . '").hide();
2385 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").hide();
2386 - getParent.find("#pano' . $id . ' #floor_map_button_' . $id . '").hide();
2387 - getParent.find("#pano' . $id . ' #vrgcontrols' . $id . '").hide();
2388 - getParent.find("#pano' . $id . ' #sccontrols' . $id . '").hide();
2389 - getParent.find("#pano' . $id . ' #adcontrol' . $id . '").hide();
2390 - getParent.find("#pano' . $id . ' .owl-nav.wpvr_slider_nav").hide();
2391 - getParent.find("#pano' . $id . ' #cp-logo-controls").hide();
2392 -
2393 - getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").hide();
2394 -
2395 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").hide();
2396 - getParent.find("#pano' . $id . ' .pnlm-controls-container").hide();
2397 -
2398 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2399 - getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2400 -
2401 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").hide();
2402 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").hide();
2403 - getParent.find("#pano' . $id . '").addClass("cardboard-half");
2404 -
2405 - getParent.find("#center-pointer' . $id . '").show();
2406 - getParent.find(".fullscreen-button").hide();
2407 -
2408 -
2409 - if (window.DeviceOrientationEvent) {
2410 - window.addEventListener("deviceorientation", vrDeviseOrientation);
2411 - }
2412 -
2413 - panoshow' . $id . '.on("mousemove", function (data){
2414 - panoshow2' . $id . '.setPitch(data.pitch, 0);
2415 - panoshow2' . $id . '.setYaw(data.yaw, 0);
2416 - panoShowCardBoardOnTrigger(data);
2417 -
2418 - });
2419 - panoshow2' . $id . '.on("mousemove", function (data){
2420 - panoshow2' . $id . '.setPitch(data.pitch, 0);
2421 - panoshow' . $id . '.setYaw(data.yaw, 0);
2422 - panoShowCardBoardOnTrigger(data);
2423 -
2424 - });
2425 -
2426 - panoshow' . $id . '.on("zoomchange", function (data){
2427 - panoshow2' . $id . '.setHfov(data, 0);
2428 - });
2429 -
2430 - panoshow2' . $id . '.on("zoomchange", function (data){
2431 - panoshow' . $id . '.setHfov(data, 0);
2432 - });
2433 -
2434 - panoshow' . $id . '.on("touchmove", function (data){
2435 - panoshow' . $id . '.stopOrientation();
2436 - panoshow2' . $id . '.stopOrientation();
2437 - panoshow2' . $id . '.setPitch(data.pitch, 0);
2438 - panoshow2' . $id . '.setYaw(data.yaw, 0);
2439 - panoShowCardBoardOnTrigger(data);
2440 -
2441 - });
2442 -
2443 - panoshow2' . $id . '.on("touchmove", function (data){
2444 - panoshow' . $id . '.stopOrientation();
2445 - panoshow2' . $id . '.stopOrientation();
2446 - panoshow' . $id . '.setPitch(data.pitch, 0);
2447 - panoshow' . $id . '.setYaw(data.yaw, 0);
2448 - panoShowCardBoardOnTrigger(data);
2449 -
2450 - });
2451 -
2452 - }
2453 - else if(getValue == "on") {
2454 - screen.orientation.unlock();
2455 - requestExitFullscreen();
2456 - // localStorage.setItem("vr_mode", "off");
2457 - vr_mode = "off";
2458 - jQuery(".vr-mode-title").hide();
2459 - jQuery(this).val("off");
2460 - getParent.find("#pano2' . $id . '").css({
2461 - "opacity": "0",
2462 - "visibility": "hidden",
2463 - "position": "absolute",
2464 - });
2465 - panoshow' . $id . '.stopOrientation();
2466 - panoshow2' . $id . '.stopOrientation();
2467 - getParent.find(".pano-wrap").removeClass("wpvr-cardboard-disable-event");
2468 - getParent.find("#pano' . $id . ' #zoom-in-out-controls' . $id . '").show();
2469 - getParent.find("#pano' . $id . ' #controls' . $id . '").show();
2470 - getParent.find("#pano' . $id . ' #explainer_button_' . $id . '").show();
2471 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").show();
2472 - getParent.find("#pano' . $id . ' #floor_map_button_' . $id . '").show();
2473 -
2474 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").show();
2475 - getParent.find("#pano' . $id . ' .pnlm-controls-container").show();
2476 - getParent.find("#pano' . $id . ' #vrgcontrols' . $id . '").show();
2477 - getParent.find("#pano' . $id . ' #sccontrols' . $id . '").hide();
2478 - getParent.find("#pano' . $id . ' #adcontrol' . $id . '").show();
2479 - getParent.find("#pano' . $id . ' .owl-nav.wpvr_slider_nav").hide();
2480 - getParent.find("#pano' . $id . ' #cp-logo-controls").show();
2481 - getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").show();
2482 -
2483 - if(compassBlock == "block"){
2484 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2485 - getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2486 - }
2487 - if(infoBlock == "block"){
2488 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").show();
2489 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").show();
2490 - }
2491 -
2492 - getParent.find("#pano' . $id . '").removeClass("cardboard-half");
2493 - getParent.find("#center-pointer' . $id . '").hide();
2494 - getParent.find(".fullscreen-button").hide();
2495 - panoshow' . $id . '.off("mousemove");
2496 - panoshow' . $id . '.off("touchmove");
2497 - panoshow2' . $id . '.off("mousemove");
2498 - panoshow2' . $id . '.off("touchmove");
2499 - if (window.DeviceOrientationEvent) {
2500 - window.removeEventListener("deviceorientation", vrDeviseOrientation);
2501 - }
2502 - }
2503 - });';
2504 -
2505 - $html .= 'panoshow2' . $id . '.on("load", function (){
2506 -// if(localStorage.getItem("vr_mode") == "off") {
2507 - if( vr_mode == "off") {
2508 - jQuery(".vr-mode-title").hide();
2509 - }
2510 - else {
2511 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2512 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2513 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2514 - jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
2515 - jQuery(".vr-mode-title").show();
2516 - }
2517 - });';
392 +if ( ! function_exists( 'wpvr_has_pro_feature_tours' ) ) {
393 + function wpvr_has_pro_feature_tours() {
394 + return ! empty( wpvr_get_pro_feature_tour_ids() );
2518 395 }
396 +}
2519 397
2520 - $html .= 'jQuery("#pano' . $id . ' .wpvr-floor-map .floor-plan-pointer").on("click",function(){
2521 - var scene_id = jQuery(this).attr("scene_id");
2522 - panoshow' . $id . '.loadScene(scene_id)
2523 - jQuery(".floor-plan-pointer").removeClass("add-pulse")
2524 - jQuery(this).addClass("add-pulse")
2525 - });';
2526 -
2527 - if ($scene_animation == 'on') {
2528 - $animation_js = apply_filters('wpvr_scene_animation_js', $id, $animation_type, $animationDuration, $animationDelay);
2529 - if (!empty($animation_js)) {
2530 - $html .= $animation_js;
2531 - $html .= 'panoshow' . $id . '.on("load", function (scene){
2532 - if (typeof changeScene === "function") {
2533 - changeScene();
2534 - } else {
2535 - console.warn("changeScene function is not defined.");
2536 - }
2537 - });';
398 +if ( ! function_exists( 'wpvr_enqueue_license_notice_assets' ) ) {
399 + /**
400 + * Enqueue the global license notice styles while Pro is installed and inactive.
401 + *
402 + * @return void
403 + */
404 + function wpvr_enqueue_license_notice_assets() {
405 + if (
406 + ! is_admin()
407 + || ! defined( 'WPVR_PRO_VERSION' )
408 + || wpvr_is_pro_active()
409 + ) {
410 + return;
2538 411 }
2539 - }
2540 412
2541 -
2542 - $html .= '
2543 - panoshow' . $id . '.on("mousemove", function (data){
2544 - jQuery(".add-pulse").css({"transform":"rotate("+data.yaw+"deg)"});
2545 - });
2546 -';
2547 -
2548 -
2549 -
2550 - $status = get_option('wpvr_edd_license_status');
2551 - if ($status !== false && 'valid' == $status && $is_pro) {
2552 - $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2553 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2554 - jQuery(".floor-plan-pointer").each(function(index ,element){
2555 - var scene_id = jQuery(this).attr("scene_id");
2556 - if( active_scene == scene_id ){
2557 - jQuery(".floor-plan-pointer").removeClass("add-pulse")
2558 - jQuery(this).addClass("add-pulse")
2559 - }
2560 - });
2561 -
2562 - });';
2563 - $html .= 'panoshow' . $id . '.on("load", function (){
2564 - if(jQuery(".floor-plan-pointer").length > 0){
2565 - jQuery(".floor-plan-pointer").each(function(index ,element){
2566 - var scene_id = jQuery(this).attr("scene_id");
2567 - if( active_scene == scene_id ){
2568 - jQuery(".floor-plan-pointer").removeClass("add-pulse")
2569 - jQuery(this).addClass("add-pulse")
2570 - }
2571 - });
2572 - }
2573 - });';
413 + wp_enqueue_style(
414 + 'wpvr-license-notice-fontawesome',
415 + WPVR_PLUGIN_DIR_URL . 'admin/lib/fontawesome/css/all.css',
416 + array(),
417 + WPVR_VERSION
418 + );
419 + wp_enqueue_style(
420 + 'wpvr-license-notice',
421 + WPVR_PLUGIN_DIR_URL . 'admin/css/wpvr-license-notice.css',
422 + array( 'wpvr-license-notice-fontawesome' ),
423 + WPVR_VERSION
424 + );
425 + wp_enqueue_script(
426 + 'wpvr-license-notice',
427 + WPVR_PLUGIN_DIR_URL . 'admin/js/wpvr-license-notice.js',
428 + array(),
429 + WPVR_VERSION,
430 + true
431 + );
2574 432 }
433 +}
2575 434
2576 - if ($status !== false && 'valid' == $status && $is_pro) {
2577 - $scene_navigation_content_type = isset($postdata['scene_navigation_content_type']) ? $postdata['scene_navigation_content_type'] : 'scene_id';
2578 - $html .= '
2579 - jQuery("#pano' . $id . ' .custom-scene-navigation").on("click",function(){
2580 - jQuery("#custom-scene-navigation-nav' . $id . ' ul").empty()
2581 - if(scenes){
2582 - var scene_navigation_content_type = ' . "'" . $scene_navigation_content_type . "'" . ';
2583 - var sceneList = scenes.scenes;
2584 - var getScene = panoshow' . $id . '.getScene();
2585 - for (const key in sceneList) {
2586 - let title;
2587 - if (scene_navigation_content_type === "scene_title") {
2588 - if (sceneList[key].title) {
2589 - title = sceneList[key].title;
2590 -
2591 - }else{
2592 - if(title == "" || title == undefined){
2593 - if (sceneList[key].panorama) {
2594 - title = getImageNameWithoutExtension(sceneList[key].panorama);
2595 - }
2596 - }
2597 - }
2598 - } else if (scene_navigation_content_type === "scene_image_name") {
2599 - if (sceneList[key].panorama) {
2600 - title = getImageNameWithoutExtension(sceneList[key].panorama);
2601 - }
2602 - } else {
2603 - title = key;
2604 - }
2605 - if (sceneList.hasOwnProperty(key)) {
2606 - if( key === getScene){
2607 - jQuery("#custom-scene-navigation-nav' . $id . ' ul").append("<li class=\"scene-navigation-list active\" scene_id= " + key + " >" + title + "</li>");
2608 - }else{
2609 - jQuery("#custom-scene-navigation-nav' . $id . ' ul").append("<li class=\"scene-navigation-list\" scene_id= " + key + " >" + title + "</li>");
2610 - }
2611 - }
2612 - }
2613 - }
2614 - jQuery("#custom-scene-navigation-nav' . $id . '").toggleClass("visible");
2615 - });
2616 - ';
435 +add_action( 'admin_enqueue_scripts', 'wpvr_enqueue_license_notice_assets', 10 );
2617 436
2618 - $html .= 'function getImageNameWithoutExtension(imageUrl) {
2619 - // Split the URL by "/"
2620 - var parts = imageUrl.split("/");
2621 -
2622 - // Get the last part which contains the image name
2623 - var imageNameWithExtension = parts[parts.length - 1];
2624 -
2625 - // Split the image name by period (.)
2626 - var imageNameParts = imageNameWithExtension.split(".");
2627 -
2628 - // Remove the last part (which is the extension) and join the remaining parts
2629 - var imageNameWithoutExtension = imageNameParts.slice(0, -1).join(".");
2630 -
2631 - // Return the image name without extension
2632 - return imageNameWithoutExtension;
2633 - }';
2634 -
2635 -
2636 - $html .= '
2637 - jQuery("#pano' . $id . ' #custom-scene-navigation-nav' . $id . ' ul").on("click", "li.scene-navigation-list", function() {
2638 - if (scenes) {
2639 - jQuery(this).siblings("li").removeClass("active");
2640 - jQuery(this).addClass("active");
2641 -
2642 - var scene_key = jQuery(this).attr("scene_id");
2643 - panoshow' . $id . '.loadScene(scene_key);
2644 - }
2645 - });
2646 - ';
2647 - }
2648 -
2649 - //Duplicate mode only for vr mode end===//
2650 - $html .= 'panoshow' . $id . '.on("load", function (){
2651 -
2652 -// if(localStorage.getItem("vr_mode") == "off") {
2653 - if( vr_mode == "off") {
2654 - jQuery(".vr-mode-title").hide();
2655 - }
2656 - else {
2657 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2658 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2659 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2660 - jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
2661 - jQuery(".vr-mode-title").show();
2662 - }
2663 -
2664 -
2665 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
2666 - jQuery("#controls' . $id . '").css("bottom", "55px");
2667 - }
2668 - else {
2669 - jQuery("#controls' . $id . '").css("bottom", "5px");
2670 - }
2671 - });';
2672 -
2673 -
2674 - $html .= '
2675 - if (scenes.autoRotate) {
2676 - panoshow' . $id . '.on("load", function (){
2677 - setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000);
2678 - });
2679 - panoshow' . $id . '.on("scenechange", function (){
2680 - setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000);
2681 - });
437 +if ( ! function_exists( 'wpvr_render_pro_feature_fallback_notice' ) ) {
438 + /**
439 + * Render the global Pro license notice and explain the saved-tour fallback.
440 + *
441 + * @return void
442 + */
443 + function wpvr_render_pro_feature_fallback_notice() {
444 + if (
445 + ! is_admin()
446 + || ! current_user_can( 'edit_posts' )
447 + || ! defined( 'WPVR_PRO_VERSION' )
448 + || wpvr_is_pro_active()
449 + ) {
450 + return;
2682 451 }
2683 - ';
2684 - $html .= 'var touchtime = 0;';
2685 - if ($vrgallery) {
2686 - if (isset($panodata["scene-list"])) {
2687 - foreach ($panodata["scene-list"] as $panoscenes) {
2688 - $scene_key = $panoscenes['scene-id'];
2689 - $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $id;
2690 - $img_src_url = $panoscenes['scene-attachment-url'];
2691 - // $html .= 'document.getElementById("' . $scene_key_gallery . '").addEventListener("click", function(e) { ';
2692 - // $html .= 'if (touchtime == 0) {';
2693 - // $html .= 'touchtime = new Date().getTime();';
2694 - // $html .= '} else {';
2695 - // $html .= 'if (((new Date().getTime()) - touchtime) < 800) {';
2696 - // $html .= 'panoshow' . $id . '.loadScene("' . $scene_key . '");';
2697 - // $html .= 'touchtime = 0;';
2698 - // $html .= '} else {';
2699 - // $html .= 'touchtime = new Date().getTime();';
2700 - // $html .= '}';
2701 - // $html .= '}';
2702 - // $html .= '});';
2703 - $html .= '
2704 - jQuery(document).on("click","#' . $scene_key_gallery . '",function() {
2705 - panoshow' . $id . '.loadScene("' . $scene_key . '");
2706 - });
2707 - ';
2708 - }
2709 - }
2710 - }
2711 452
453 + $status = strtolower( (string) get_option( 'wpvr_edd_license_status', 'no' ) );
454 + $needs_activation = in_array( $status, array( '', 'no' ), true );
2712 455
2713 -
2714 - //===Custom Control===//
2715 - if (isset($custom_control)) {
2716 - if ($custom_control['panupSwitch'] == "on") {
2717 - $html .= 'document.getElementById("pan-up' . $id . '").addEventListener("click", function(e) {';
2718 - $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() + 10);';
2719 - $html .= '});';
456 + if ( ! $needs_activation && ! wpvr_has_pro_feature_tours() ) {
457 + return;
2720 458 }
2721 459
2722 - if ($custom_control['panDownSwitch'] == "on") {
2723 - $html .= 'document.getElementById("pan-down' . $id . '").addEventListener("click", function(e) {';
2724 - $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() - 10);';
2725 - $html .= '});';
2726 - }
2727 -
2728 - if ($custom_control['panLeftSwitch'] == "on") {
2729 - $html .= 'document.getElementById("pan-left' . $id . '").addEventListener("click", function(e) {';
2730 - $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() - 10);';
2731 - $html .= '});';
2732 - }
2733 -
2734 - if ($custom_control['panRightSwitch'] == "on") {
2735 - $html .= 'document.getElementById("pan-right' . $id . '").addEventListener("click", function(e) {';
2736 - $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() + 10);';
2737 - $html .= '});';
2738 - }
2739 -
2740 - if ($custom_control['panZoomInSwitch'] == "on") {
2741 - $html .= 'document.getElementById("zoom-in' . $id . '").addEventListener("click", function(e) {';
2742 - $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() - 10);';
2743 - $html .= '});';
2744 - }
2745 -
2746 - if ($custom_control['panZoomOutSwitch'] == "on") {
2747 - $html .= 'document.getElementById("zoom-out' . $id . '").addEventListener("click", function(e) {';
2748 - $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() + 10);';
2749 - $html .= '});';
2750 - }
2751 -
2752 - if ($custom_control['panFullscreenSwitch'] == "on") {
2753 - $html .= 'document.getElementById("fullscreen' . $id . '").addEventListener("click", function(e) {';
2754 - $html .= 'panoshow' . $id . '.toggleFullscreen();';
2755 - $html .= '});';
2756 - }
2757 -
2758 - if ($custom_control['backToHomeSwitch'] == "on") {
2759 - $html .= 'document.getElementById("backToHome' . $id . '").addEventListener("click", function(e) {';
2760 - $html .= 'panoshow' . $id . '.loadScene("' . $default_scene . '");';
2761 - $html .= '});';
2762 - }
2763 -
2764 - if ($custom_control['gyroscopeSwitch'] == "on") {
2765 - $html .= '
2766 - var element = document.getElementById("gyroscope' . $id . '");
2767 - var gyroSwitch = true;
2768 - var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
2769 - var permissionGranted = false;
2770 -
2771 - function requestOrientationPermission() {
2772 - if (isIOS) {
2773 - if (typeof DeviceOrientationEvent.requestPermission === "function") {
2774 - DeviceOrientationEvent.requestPermission()
2775 - .then(function(state) {
2776 - if (state === "granted") {
2777 - permissionGranted = true;
2778 - startOrientation();
2779 - } else {
2780 - element.children[0].style.color = "red";
2781 - gyroSwitch = false;
2782 - alert("Permission to use motion sensors was denied.");
2783 - }
2784 - })
2785 - .catch(function(error) {
2786 - element.children[0].style.color = "red";
2787 - gyroSwitch = false;
2788 - console.error("Error requesting device orientation permission:", error);
2789 - });
2790 - }
460 + if ( $needs_activation ) {
461 + $title = __( 'Please Activate your license key to enjoy the pro features for WPVR', 'wpvr' );
462 + $subtitle = '';
463 + $action_label = __( 'Activate', 'wpvr' );
464 + $action_url = admin_url( 'admin.php?page=wpvrpro' );
465 + $action_target = '';
466 + $action_icon = 'fa-key';
2791 467 } else {
2792 - startOrientation();
468 + $title = 'expired' === $status
469 + ? __( 'Your WPVR Pro license has expired.', 'wpvr' )
470 + : __( 'Your WPVR Pro license is not active.', 'wpvr' );
471 + $subtitle = __( 'Pro features are no longer available. Upgrade to Pro now to restore access to all premium features.', 'wpvr' );
472 + $action_label = __( 'Upgrade to Pro', 'wpvr' );
473 + $action_url = 'https://rextheme.com/your-account/#purchase';
474 + $action_target = ' target="_blank" rel="noopener noreferrer"';
475 + $action_icon = 'fa-crown';
2793 476 }
2794 - }
2795 477
2796 - function startOrientation() {
2797 - panoshow' . $id . '.startOrientation();
2798 - element.children[0].style.color = "'.$custom_control['gyroscopeColor'].'";
2799 - gyroSwitch = true;
2800 - }
2801 -
2802 - panoshow' . $id . '.on("load", function() {
2803 - if (!isIOS || permissionGranted) {
2804 - if (gyroSwitch) {
2805 - startOrientation();
2806 - } else {
2807 - panoshow' . $id . '.stopOrientation();
2808 - element.children[0].style.color = "red";
2809 - }
478 + $notice_classes = 'notice notice-error is-dismissible wpvr-license-fallback-notice';
479 + if ( '' === $subtitle ) {
480 + $notice_classes .= ' wpvr-license-fallback-notice--single-line';
2810 481 }
2811 - });
2812 482
2813 - panoshow' . $id . '.on("scenechange", function() {
2814 - if (!isIOS || permissionGranted) {
2815 - if (panoshow' . $id . '.isOrientationActive()) {
2816 - element.children[0].style.color = "'.$custom_control['gyroscopeColor'].'";
2817 - } else {
2818 - element.children[0].style.color = "red";
2819 - }
483 + echo '<div id="wpvr-license-fallback-notice" class="' . esc_attr( $notice_classes ) . '">';
484 + echo '<img class="wpvr-license-fallback-notice__icon" src="' . esc_url( WPVR_PLUGIN_DIR_URL . 'admin/images/wpvr-license-warning.svg' ) . '" width="20" height="19" alt="" aria-hidden="true">';
485 + echo '<div class="wpvr-license-fallback-notice__content">';
486 + echo '<p class="wpvr-license-fallback-notice__title">' . esc_html( $title ) . '</p>';
487 + if ( '' !== $subtitle ) {
488 + echo '<p class="wpvr-license-fallback-notice__subtitle">' . esc_html( $subtitle ) . '</p>';
2820 489 }
2821 - });
2822 -
2823 - panoshow' . $id . '.on("touchstart", function() {
2824 - if (!isIOS || permissionGranted) {
2825 - if (panoshow' . $id . '.isOrientationActive()) {
2826 - gyroSwitch = true;
2827 - element.children[0].style.color = "'.$custom_control['gyroscopeColor'].'";
2828 - } else {
2829 - gyroSwitch = false;
2830 - element.children[0].style.color = "red";
2831 - }
2832 - }
2833 - });';
2834 -
2835 - $html .= 'document.getElementById("gyroscope' . $id . '").addEventListener("click", function(e) {
2836 - var element = document.getElementById("gyroscope' . $id . '");
2837 - if (isIOS && typeof DeviceOrientationEvent.requestPermission === "function" && !permissionGranted) {
2838 - requestOrientationPermission();
2839 - } else {
2840 - if (panoshow' . $id . '.isOrientationActive()) {
2841 - panoshow' . $id . '.stopOrientation();
2842 - gyroSwitch = false;
2843 - element.children[0].style.color = "red";
2844 - } else {
2845 - startOrientation();
2846 - }
2847 - }
2848 - });';
2849 - }
490 + echo '</div>';
491 + echo '<a class="wpvr-license-fallback-notice__action" href="' . esc_url( $action_url ) . '"' . $action_target . '>';
492 + echo '<span class="wpvr-license-fallback-notice__action-icon fa-solid ' . esc_attr( $action_icon ) . '" aria-hidden="true"></span>';
493 + echo '<span>' . esc_html( $action_label ) . '</span>';
494 + echo '</a>';
495 + echo '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . esc_html__( 'Dismiss this notice.', 'wpvr' ) . '</span></button>';
496 + echo '</div>';
2850 497 }
498 +}
2851 499
2852 - $angle_up = '<i class="fa fa-angle-up"></i>';
2853 - $angle_down = '<i class="fa fa-angle-down"></i>';
2854 - $sin_qout = "'";
500 +add_action( 'admin_notices', 'wpvr_render_pro_feature_fallback_notice', 10 );
2855 501
2856 - //===Explainer Script===//
2857 - $html .= '
2858 - jQuery(document).on("click","#explainer_button_' . $id . '",function() {
2859 - jQuery("#explainer' . $id . '").slideToggle();
2860 - // jQuery(".explainer").slideToggle();
2861 - });
2862 -
2863 - jQuery(document).on("click",".close-explainer-video",function() {
2864 - jQuery(this).parent(".explainer").hide();
2865 - });
2866 - jQuery(document).on("click","#pano' . $id . '",function(event) {
2867 - var isActiveModal = event.target.closest(".custom-ifram-wrapper");
2868 - var isForm = event.target.closest(".wpvr-hotspot-tweak-contents");
2869 - if( isActiveModal == null && isForm == null){
2870 - jQuery(".custom-ifram-wrapper").hide();
2871 - jQuery(this).removeClass("show-modal");
2872 - jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide("show-modal");
2873 - }else if(isForm != null){
2874 - jQuery(this).addClass("show-modal");
502 +if ( ! function_exists( 'wpvr_add_pro_feature_tour_row_class' ) ) {
503 + /**
504 + * Add a class to affected tour rows while the Pro entitlement is inactive.
505 + *
506 + * @param array $classes Existing post classes.
507 + * @param array $class Additional classes supplied by WordPress.
508 + * @param int $post_id Post ID.
509 + * @return array
510 + */
511 + function wpvr_add_pro_feature_tour_row_class( $classes, $class = array(), $post_id = 0 ) {
512 + if (
513 + ! is_admin()
514 + || ! defined( 'WPVR_PRO_VERSION' )
515 + || wpvr_is_pro_active()
516 + || 'wpvr_item' !== get_post_type( $post_id )
517 + ) {
518 + return $classes;
2875 519 }
2876 - });
2877 520
2878 - ';
2879 - //===Explainer Script End===//
2880 -
2881 - //===generic form script===//
2882 - if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on') {
2883 - $html .= '
2884 - jQuery(document).on("click","#generic_form_button_' . $id . '",function() {
2885 - jQuery("#wpvr-generic-form' . $id . '").fadeToggle();
2886 - });
2887 -
2888 - jQuery(document).on("click",".close-generic-form",function() {
2889 - jQuery(this).parent(".wpvr-generic-form").fadeOut()
2890 - });
2891 - ';
2892 - }
2893 -
2894 - //===generic from script===//
2895 -
2896 - //===Floor map Script===//
2897 - $html .= '
2898 - jQuery(document).on("click","#floor_map_button_' . $id . '",function() {
2899 - jQuery("#wpvr-floor-map' . $id . '").toggle().removeClass("fullwindow");
2900 - });
2901 -
2902 - jQuery(document).on("dblclick","#wpvr-floor-map' . $id . '",function(){
2903 - jQuery(this).addClass("fullwindow");
2904 - jQuery(this).parents(".pano-wrap").addClass("show-modal");
2905 - });
2906 -
2907 - jQuery(document).on("click",".close-floor-map-plan",function() {
2908 - jQuery(this).parent(".wpvr-floor-map").hide();
2909 - jQuery(this).parent(".wpvr-floor-map").removeClass("fullwindow");
2910 - jQuery(this).parents(".pano-wrap").removeClass("show-modal");
2911 - });
2912 -
2913 - ';
2914 - //===Floor map Script End===//
2915 -
2916 - if ($vrgallery_display) {
2917 - if (!$autoload) {
2918 - $html .= '
2919 - jQuery(document).ready(function($){
2920 - jQuery("#sccontrols' . $id . '").hide();
2921 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2922 - jQuery("#sccontrols' . $id . '").hide();
2923 - jQuery(".wpvr_slider_nav").hide();
2924 - });
2925 - ';
2926 -
2927 - $html .= '
2928 - var slide' . $id . ' = "down";
2929 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
2930 -
2931 - if (slide' . $id . ' == "up") {
2932 - jQuery(".vrgctrl' . $id . '").empty();
2933 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2934 - slide' . $id . ' = "down";
2935 - jQuery(".wpvr_slider_nav").slideToggle();
2936 - jQuery("#sccontrols' . $id . '").slideToggle();
2937 - }
2938 - else {
2939 - jQuery(".vrgctrl' . $id . '").empty();
2940 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2941 - slide' . $id . ' = "up";
2942 - jQuery(".wpvr_slider_nav").slideToggle();
2943 - jQuery("#sccontrols' . $id . '").slideToggle();
2944 - }
2945 - });
2946 - ';
2947 - } else {
2948 - $html .= '
2949 - jQuery(document).ready(function($){
2950 - jQuery("#sccontrols' . $id . '").show();
2951 - jQuery(".wpvr_slider_nav").show();
2952 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2953 - });
2954 - ';
2955 -
2956 - $html .= '
2957 - var slide' . $id . ' = "down";
2958 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
2959 -
2960 - if (slide' . $id . ' == "up") {
2961 - jQuery(".vrgctrl' . $id . '").empty();
2962 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2963 - slide' . $id . ' = "down";
2964 - }
2965 - else {
2966 - jQuery(".vrgctrl' . $id . '").empty();
2967 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2968 - slide' . $id . ' = "up";
2969 - }
2970 - jQuery(".wpvr_slider_nav").slideToggle();
2971 - jQuery("#sccontrols' . $id . '").slideToggle();
2972 - });
2973 - ';
521 + $postdata = get_post_meta( (int) $post_id, 'panodata', true );
522 + if ( wpvr_tour_uses_pro_features( $postdata ) ) {
523 + $classes[] = 'wpvr-pro-feature-tour';
2974 524 }
2975 - } else {
2976 - $html .= '
2977 - jQuery(document).ready(function($){
2978 - jQuery("#sccontrols' . $id . '").hide();
2979 - jQuery(".wpvr_slider_nav").hide();
2980 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2981 - });
2982 - ';
2983 525
2984 - $html .= '
2985 - var slide' . $id . ' = "down";
2986 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
2987 -
2988 - if (slide' . $id . ' == "up") {
2989 - jQuery(".vrgctrl' . $id . '").empty();
2990 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2991 - slide' . $id . ' = "down";
2992 - }
2993 - else {
2994 - jQuery(".vrgctrl' . $id . '").empty();
2995 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2996 - slide' . $id . ' = "up";
2997 - }
2998 - jQuery(".wpvr_slider_nav").slideToggle();
2999 - jQuery("#sccontrols' . $id . '").slideToggle();
3000 - });
3001 - ';
526 + return $classes;
3002 527 }
3003 -
3004 - if (!$autoload) {
3005 - $html .= '
3006 -
3007 - jQuery(document).ready(function(){
3008 - jQuery("#controls' . $id . '").hide();
3009 - jQuery("#zoom-in-out-controls' . $id . '").hide();
3010 - jQuery("#adcontrol' . $id . '").hide();
3011 - jQuery("#explainer_button_' . $id . '").hide();
3012 - jQuery("#generic_form_button_' . $id . '").hide();
3013 - jQuery("#floor_map_button_' . $id . '").hide();
3014 - jQuery("#vrgcontrols' . $id . '").hide();
3015 - jQuery("#cp-logo-controls").hide();
3016 - jQuery(".custom-scene-navigation").hide();
3017 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").hide();
3018 - });
3019 -
3020 - ';
3021 -
3022 - if ($vrgallery_display) {
3023 - $html .= 'var load_once = "true";';
3024 - $html .= 'panoshow' . $id . '.on("load", function (){
3025 - if (load_once == "true") {
3026 - load_once = "false";
3027 - jQuery("#sccontrols' . $id . '").slideToggle();
3028 - jQuery(".wpvr_slider_nav").slideToggle();
3029 - }
3030 - });';
3031 - }
3032 -
3033 - $html .= 'panoshow' . $id . '.on("load", function (){
3034 - jQuery("#controls' . $id . '").show();
3035 - jQuery("#zoom-in-out-controls' . $id . '").show();
3036 - jQuery("#adcontrol' . $id . '").show();
3037 - jQuery("#explainer_button_' . $id . '").show();
3038 - jQuery("#generic_form_button_' . $id . '").show();
3039 - jQuery("#floor_map_button_' . $id . '").show();
3040 - jQuery("#vrgcontrols' . $id . '").show();
3041 - jQuery("#cp-logo-controls").show();
3042 - jQuery(".custom-scene-navigation").show();
3043 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").show();
3044 - });';
3045 - }
3046 -
3047 - $previewText = $postdata['previewtext'] ?? 'Click To Load Panorama';
3048 - if ($previewText) {
3049 - $html .= '
3050 - jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previewText. '")
3051 - ';
3052 - } else {
3053 - $html .= '
3054 - jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("Click To Load Panorama")
3055 - ';
3056 - }
3057 -
3058 - $html .= 'jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseenter", function(){
3059 - jQuery(this).attr("title", jQuery(this).text());
3060 - });
3061 - jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseleave", function(){
3062 - jQuery(this).removeAttr("title");
3063 - });';
3064 - $html .= '});';
3065 -
3066 -
3067 -
3068 - $html .= '</script>';
3069 -
3070 - $tour_data = [];
3071 - if(defined("WPVR_PRO_VERSION")){
3072 - $tour_data = array(
3073 - 'explainerControlSwitch' => $explainerControlSwitch ?? false,
3074 - 'floor_plan_enable' => $floor_plan_enable ?? false,
3075 - 'floor_plan_image' => $floor_plan_image ?? '',
3076 - 'custom_control' => $custom_control ?? [],
3077 - );
3078 - }
3079 -
3080 - return apply_filters('wpvr_generate_tour_layout_html', $html ,$postdata ,$id, $tour_data);
3081 528 }
3082 529
3083 -function sanitize_content_preserve_styles($content) {
3084 - // Remove script tags completely
3085 - $content = preg_replace('/<script\b[^>]*>.*?<\/script>/si', '', $content);
530 +add_filter( 'post_class', 'wpvr_add_pro_feature_tour_row_class', 10, 3 );
3086 531
3087 - // Remove dangerous protocols
3088 - $content = preg_replace('/javascript:/i', '', $content);
3089 - $content = preg_replace('/vbscript:/i', '', $content);
3090 - $content = preg_replace('/data:/i', '', $content);
3091 - $content = preg_replace('/about:/i', '', $content);
532 +require_once plugin_dir_path( __FILE__ ) . 'src/Admin/UiModeSwitcher.php';
533 +\RexTheme\WPVR\Admin\UiModeSwitcher::init();
3092 534
3093 - // Remove all event handlers (onclick, onload, etc.)
3094 - $content = preg_replace('/\s*on\w+\s*=\s*["\'][^"\']*["\']/i', '', $content);
3095 - $content = preg_replace('/\s*on\w+\s*=\s*[^>\s]+/i', '', $content);
535 +add_action( 'wp_ajax_wpvr_export_tour', 'wpvr_handle_export_tour' );
536 +/**
537 + * AJAX handler: return a signed URL for the Pro tour exporter.
538 + *
539 + * WPVR Pro creates and streams the ZIP through its admin-post endpoint. This
540 + * handler authorizes the New UI request and returns that endpoint URL.
541 + */
542 +function wpvr_handle_export_tour(): void {
543 + check_ajax_referer( 'wpvr_export_tour', 'nonce' );
3096 544
3097 - // Remove dangerous tags that can execute code
3098 - $content = preg_replace('/<(object|embed|applet|iframe|frame|frameset|meta|link|base|form|input|button|textarea|select|option)\b[^>]*>/i', '', $content);
3099 - $content = preg_replace('/<\/(object|embed|applet|iframe|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content);
545 + if ( ! current_user_can( 'edit_posts' ) ) {
546 + wp_send_json_error( [ 'message' => 'Insufficient permissions.' ], 403 );
547 + }
3100 548
3101 - // Sanitize CSS in style attributes - remove dangerous CSS functions
3102 - $content = preg_replace_callback('/style\s*=\s*["\']([^"\']*)["\']/', function($matches) {
3103 - $style = $matches[1];
549 + if ( ! wpvr_is_pro_active() ) {
550 + wp_send_json_error( [ 'message' => 'A valid WP VR Pro license is required.' ], 403 );
551 + }
3104 552
3105 - // Remove dangerous CSS functions
3106 - $style = preg_replace('/expression\s*\(/i', '', $style);
3107 - $style = preg_replace('/javascript:/i', '', $style);
3108 - $style = preg_replace('/vbscript:/i', '', $style);
3109 - $style = preg_replace('/data:/i', '', $style);
3110 - $style = preg_replace('/about:/i', '', $style);
3111 - $style = preg_replace('/url\s*\(\s*["\']?\s*javascript:/i', '', $style);
3112 - $style = preg_replace('/url\s*\(\s*["\']?\s*vbscript:/i', '', $style);
3113 - $style = preg_replace('/url\s*\(\s*["\']?\s*data:/i', '', $style);
3114 - $style = preg_replace('/import\s*["\']?\s*javascript:/i', '', $style);
3115 - $style = preg_replace('/behavior\s*:/i', '', $style);
3116 - $style = preg_replace('/-moz-binding\s*:/i', '', $style);
553 + $tour_id = isset( $_POST['tour_id'] ) ? absint( $_POST['tour_id'] ) : 0;
554 + if ( ! $tour_id ) {
555 + wp_send_json_error( [ 'message' => 'Missing tour ID.' ] );
556 + }
3117 557
3118 - return 'style="' . $style . '"';
3119 - }, $content);
558 + $post = get_post( $tour_id );
559 + if ( ! $post || $post->post_type !== 'wpvr_item' ) {
560 + wp_send_json_error( [ 'message' => 'Tour not found.' ] );
561 + }
3120 562
3121 - // Sanitize CSS in style tags
3122 - $content = preg_replace_callback('/<style\b[^>]*>(.*?)<\/style>/si', function($matches) {
3123 - $css = $matches[1];
563 + if ( ! current_user_can( 'edit_post', $tour_id ) ) {
564 + wp_send_json_error( [ 'message' => 'You are not allowed to export this tour.' ], 403 );
565 + }
3124 566
3125 - // Remove dangerous CSS functions
3126 - $css = preg_replace('/expression\s*\(/i', '', $css);
3127 - $css = preg_replace('/javascript:/i', '', $css);
3128 - $css = preg_replace('/vbscript:/i', '', $css);
3129 - $css = preg_replace('/data:/i', '', $css);
3130 - $css = preg_replace('/about:/i', '', $css);
3131 - $css = preg_replace('/url\s*\(\s*["\']?\s*javascript:/i', '', $css);
3132 - $css = preg_replace('/url\s*\(\s*["\']?\s*vbscript:/i', '', $css);
3133 - $css = preg_replace('/url\s*\(\s*["\']?\s*data:/i', '', $css);
3134 - $css = preg_replace('/import\s*["\']?\s*javascript:/i', '', $css);
3135 - $css = preg_replace('/behavior\s*:/i', '', $css);
3136 - $css = preg_replace('/-moz-binding\s*:/i', '', $css);
567 + $export_url = add_query_arg(
568 + [
569 + 'action' => 'wpvr_export_tour',
570 + 'post_id' => $tour_id,
571 + '_wpnonce' => wp_create_nonce( 'wpvr_export_tour_' . $tour_id ),
572 + ],
573 + admin_url( 'admin-post.php' )
574 + );
3137 575
3138 - return '<style>' . $css . '</style>';
3139 - }, $content);
3140 -
3141 - // Remove dangerous attributes from any tag
3142 - $content = preg_replace('/\s*srcdoc\s*=\s*["\'][^"\']*["\']/i', '', $content);
3143 - $content = preg_replace('/\s*formaction\s*=\s*["\'][^"\']*["\']/i', '', $content);
3144 - $content = preg_replace('/\s*action\s*=\s*["\'][^"\']*["\']/i', '', $content);
3145 -
3146 - // Clean up malformed HTML that might bypass filters
3147 - $content = preg_replace('/<[^>]*script[^>]*>/i', '', $content);
3148 - $content = preg_replace('/<[^>]*on\w+[^>]*>/i', '', $content);
3149 -
3150 - // Remove comments that might contain dangerous code
3151 - $content = preg_replace('/<!--.*?-->/s', '', $content);
3152 -
3153 - // Remove any remaining dangerous patterns
3154 - $content = preg_replace('/\beval\s*\(/i', '', $content);
3155 - $content = preg_replace('/\bsetTimeout\s*\(/i', '', $content);
3156 - $content = preg_replace('/\bsetInterval\s*\(/i', '', $content);
3157 -
3158 - // Final cleanup - remove any orphaned closing tags from removed elements
3159 - $content = preg_replace('/<\/(script|object|embed|applet|iframe|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content);
3160 - error_log(wp_kses_post($content));
3161 - // Final pass with wp_kses_post for additional security
3162 - return wp_kses_post($content);
576 + wp_send_json_success( [ 'url' => $export_url ] );
3163 577 }
3164 578
3165 -function wpvr_hex2rgb($colour)
3166 -{
3167 - if (isset($colour[0]) && $colour[0] == '#') {
3168 - $colour = substr($colour, 1);
579 +/**
580 + * Ensure legacy Street View keys always exist in panodata.
581 + *
582 + * WPVR Pro reads these keys directly in classic editor screens. Tours created
583 + * through newer flows may miss them, which triggers PHP warnings.
584 + */
585 +function wpvr_backfill_legacy_streetview_keys() {
586 + if ( ! is_admin() ) {
587 + return;
3169 588 }
3170 - if (strlen($colour) == 6) {
3171 - list($r, $g, $b) = array($colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5]);
3172 - } elseif (strlen($colour) == 3) {
3173 - list($r, $g, $b) = array($colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2]);
3174 - } else {
3175 - return false;
3176 - }
3177 - $r = hexdec($r);
3178 - $g = hexdec($g);
3179 - $b = hexdec($b);
3180 - return array($r . ', ' . $g . ', ' . $b);
3181 -}
3182 589
3183 -function wpvr_HTMLToRGB($htmlCode)
3184 -{
3185 - $r = 0;
3186 - $g = 0;
3187 - $b = 0;
3188 - if (isset($htmlCode[0]) && $htmlCode[0] == '#') {
3189 - $htmlCode = substr($htmlCode, 1);
590 + $post_id = isset( $_GET['post'] ) ? absint( $_GET['post'] ) : 0;
591 + if ( ! $post_id ) {
592 + return;
3190 593 }
3191 594
3192 - if (strlen($htmlCode) == 3) {
3193 - $htmlCode = $htmlCode[0] . $htmlCode[0] . $htmlCode[1] . $htmlCode[1] . $htmlCode[2] . $htmlCode[2];
595 + $post = get_post( $post_id );
596 + if ( ! $post || $post->post_type !== 'wpvr_item' ) {
597 + return;
3194 598 }
3195 599
3196 - if (isset($htmlCode[0]) && isset($htmlCode[1])) {
3197 - $r = hexdec($htmlCode[0] . $htmlCode[1]);
600 + $panodata = get_post_meta( $post_id, 'panodata', true );
601 + if ( ! is_array( $panodata ) ) {
602 + return;
3198 603 }
3199 - if (isset($htmlCode[2]) && isset($htmlCode[3])) {
3200 - $g = hexdec($htmlCode[2] . $htmlCode[3]);
3201 - }
3202 - if (isset($htmlCode[4]) && isset($htmlCode[5])) {
3203 - $b = hexdec($htmlCode[4] . $htmlCode[5]);
3204 - }
3205 604
3206 - return $b + ($g << 0x8) + ($r << 0x10);
3207 -}
605 + $changed = false;
3208 606
3209 -function wpvr_RGBToHSL($RGB)
3210 -{
3211 - $r = 0xFF & ($RGB >> 0x10);
3212 - $g = 0xFF & ($RGB >> 0x8);
3213 - $b = 0xFF & $RGB;
3214 -
3215 - $r = ((float)$r) / 255.0;
3216 - $g = ((float)$g) / 255.0;
3217 - $b = ((float)$b) / 255.0;
3218 -
3219 - $maxC = max($r, $g, $b);
3220 - $minC = min($r, $g, $b);
3221 -
3222 - $l = ($maxC + $minC) / 2.0;
3223 -
3224 - if ($maxC == $minC) {
3225 - $s = 0;
3226 - $h = 0;
3227 - } else {
3228 - if ($l < .5) {
3229 - $s = ($maxC - $minC) / ($maxC + $minC);
3230 - } else {
3231 - $s = ($maxC - $minC) / (2.0 - $maxC - $minC);
3232 - }
3233 - if ($r == $maxC) {
3234 - $h = ($g - $b) / ($maxC - $minC);
3235 - }
3236 - if ($g == $maxC) {
3237 - $h = 2.0 + ($b - $r) / ($maxC - $minC);
3238 - }
3239 - if ($b == $maxC) {
3240 - $h = 4.0 + ($r - $g) / ($maxC - $minC);
3241 - }
3242 -
3243 - $h = $h / 6.0;
607 + if ( ! array_key_exists( 'streetview', $panodata ) ) {
608 + $panodata['streetview'] = 'off';
609 + $changed = true;
3244 610 }
3245 611
3246 - $h = (int)round(255.0 * $h);
3247 - $s = (int)round(255.0 * $s);
3248 - $l = (int)round(255.0 * $l);
3249 -
3250 - return (object) array('hue' => $h, 'saturation' => $s, 'lightness' => $l);
3251 -}
3252 -
3253 -add_action('rest_api_init', 'wpvr_rest_data_route');
3254 -function wpvr_rest_data_route()
3255 -{
3256 - register_rest_route('wpvr/v1', '/panodata/', array(
3257 - 'methods' => 'GET',
3258 - 'callback' => 'wpvr_rest_data_set',
3259 - 'permission_callback' => 'wpvr_rest_route_permission'
3260 - ));
3261 -}
3262 -
3263 -function wpvr_rest_route_permission()
3264 -{
3265 - return true;
3266 -}
3267 -
3268 -function wpvr_rest_data_set()
3269 -{
3270 - $query = new WP_Query(array(
3271 - 'post_type' => 'wpvr_item',
3272 - 'posts_per_page' => -1,
3273 - ));
3274 -
3275 - $wpvr_list = array();
3276 - $list_none = array('value' => 0, 'label' => 'None');
3277 - array_push($wpvr_list, $list_none);
3278 - while ($query->have_posts()) {
3279 - $query->the_post();
3280 - $title = mb_convert_encoding(get_the_title(), 'UTF-8', 'HTML-ENTITIES');
3281 - $post_id = get_the_ID();
3282 - $title = $post_id . ' : ' . $title;
3283 - $list_ob = array('value' => $post_id, 'label' => $title);
3284 - array_push($wpvr_list, $list_ob);
612 + if ( ! array_key_exists( 'streetviewurl', $panodata ) ) {
613 + $panodata['streetviewurl'] = '';
614 + $changed = true;
3285 615 }
3286 616
3287 - return $wpvr_list;
3288 -}
3289 -
3290 -function wpvr_isMobileDevice()
3291 -{
3292 - return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
3293 -}
3294 -
3295 -function wpvr_directory()
3296 -{
3297 - $upload = wp_upload_dir();
3298 - $upload_dir = $upload['basedir'];
3299 - $upload_dir_temp = $upload_dir . '/wpvr/temp/';
3300 - if (!is_dir($upload_dir_temp)) {
3301 - wp_mkdir_p($upload_dir_temp, 0700);
617 + if ( $changed ) {
618 + update_post_meta( $post_id, 'panodata', $panodata );
3302 619 }
3303 620 }
3304 621
3305 -add_action('admin_init', 'wpvr_directory');
622 +add_action( 'load-post.php', 'wpvr_backfill_legacy_streetview_keys', 1 );
3306 623
624 +/**
625 + * Register a lightweight PSR-4 autoloader for src/ classes.
626 + */
627 +function wpvr_register_src_autoloader() {
628 + static $loaded = false;
3307 629
3308 -function wpvr_add_role_cap()
3309 -{
3310 - $editor_active = get_option('wpvr_editor_active');
3311 -
3312 - $author_active = get_option('wpvr_author_active');
3313 -
3314 - $admin = get_role('administrator');
3315 - $admin->add_cap('publish_wpvr_tour');
3316 - $admin->add_cap('edit_wpvr_tours');
3317 - $admin->add_cap('read_wpvr_tour');
3318 - $admin->add_cap('edit_wpvr_tour');
3319 - $admin->add_cap('edit_wpvr_tours');
3320 - $admin->add_cap('publish_wpvr_tours');
3321 - $admin->add_cap('publish_wpvr_tour');
3322 - $admin->add_cap('delete_wpvr_tour');
3323 - $admin->add_cap('edit_other_wpvr_tours');
3324 - $admin->add_cap('delete_other_wpvr_tours');
3325 -
3326 - if ($editor_active == "true") {
3327 - $editor = get_role('editor');
3328 - if ($editor) {
3329 - $editor->add_cap('publish_wpvr_tour');
3330 - $editor->add_cap('edit_wpvr_tours');
3331 - $editor->add_cap('read_wpvr_tour');
3332 - $editor->add_cap('edit_wpvr_tour');
3333 - $editor->add_cap('edit_wpvr_tours');
3334 - $editor->add_cap('publish_wpvr_tours');
3335 - $editor->add_cap('publish_wpvr_tour');
3336 - $editor->add_cap('delete_wpvr_tour');
3337 - $editor->add_cap('edit_other_wpvr_tours');
3338 - $editor->add_cap('delete_other_wpvr_tours');
3339 - }
3340 - } else {
3341 - $editor = get_role('editor');
3342 - if ($editor) {
3343 - $editor->remove_cap('publish_wpvr_tour');
3344 - $editor->remove_cap('edit_wpvr_tours');
3345 - $editor->remove_cap('read_wpvr_tour');
3346 - $editor->remove_cap('edit_wpvr_tour');
3347 - $editor->remove_cap('edit_wpvr_tours');
3348 - $editor->remove_cap('publish_wpvr_tours');
3349 - $editor->remove_cap('publish_wpvr_tour');
3350 - $editor->remove_cap('delete_wpvr_tour');
3351 - $editor->remove_cap('edit_other_wpvr_tours');
3352 - $editor->remove_cap('delete_other_wpvr_tours');
3353 - }
630 + if ( $loaded ) {
631 + return;
3354 632 }
3355 633
3356 - if ($author_active == "true") {
3357 - $author = get_role('author');
3358 - if ($author) {
3359 - $author->add_cap('read_wpvr_tour');
3360 - $author->add_cap('edit_wpvr_tour');
3361 - $author->add_cap('edit_wpvr_tours');
3362 - $author->add_cap('publish_wpvr_tours');
3363 - $author->add_cap('publish_wpvr_tour');
3364 - $author->add_cap('delete_wpvr_tour');
3365 - }
3366 - } else {
3367 - $author = get_role('author');
3368 - if ($author) {
3369 - $author->remove_cap('read_wpvr_tour');
3370 - $author->remove_cap('edit_wpvr_tour');
3371 - $author->remove_cap('edit_wpvr_tours');
3372 - $author->remove_cap('publish_wpvr_tours');
3373 - $author->remove_cap('publish_wpvr_tour');
3374 - $author->remove_cap('delete_wpvr_tour');
3375 - }
3376 - }
634 + spl_autoload_register(
635 + static function ( $class ) {
636 + $prefix = 'RexTheme\\WPVR\\';
3377 637
3378 - if(is_plugin_active( 'dokan-lite/dokan.php' ) || is_plugin_active( 'dokan-pro/dokan.php' )){
3379 - $dokan_vendor_active = get_option('dokan_vendor_active');
3380 -
3381 - if( 'true' === $dokan_vendor_active){
3382 - $seller = get_role('seller');
3383 - if ($seller) {
3384 - $seller->add_cap('read_wpvr_tour');
3385 - $seller->add_cap('edit_wpvr_tour');
3386 - $seller->add_cap('edit_wpvr_tours');
3387 - $seller->add_cap('publish_wpvr_tours');
3388 - $seller->add_cap('publish_wpvr_tour');
3389 - $seller->add_cap('delete_wpvr_tour');
638 + if ( strpos( $class, $prefix ) !== 0 ) {
639 + return;
3390 640 }
3391 - } else{
3392 - $seller = get_role('seller');
3393 - if ($seller) {
3394 - $seller->remove_cap('read_wpvr_tour');
3395 - $seller->remove_cap('edit_wpvr_tour');
3396 - $seller->remove_cap('edit_wpvr_tours');
3397 - $seller->remove_cap('publish_wpvr_tours');
3398 - $seller->remove_cap('publish_wpvr_tour');
3399 - $seller->remove_cap('delete_wpvr_tour');
3400 - }
3401 - }
3402 - }
3403 641
642 + $relative_class = substr( $class, strlen( $prefix ) );
643 + $file = plugin_dir_path( __FILE__ ) . 'src/' . str_replace( '\\', '/', $relative_class ) . '.php';
3404 644
3405 -}
3406 -
3407 -add_action('admin_init', 'wpvr_add_role_cap', 999);
3408 -
3409 -function wpvr_role_management_from_post_type($args, $post_type)
3410 -{
3411 - if ('wpvr_item' !== $post_type) {
3412 - return $args;
3413 - }
3414 -
3415 - $editor_active = get_option('wpvr_editor_active');
3416 - $author_active = get_option('wpvr_author_active');
3417 - $user = wp_get_current_user();
3418 -
3419 - if ($editor_active == "true") {
3420 - if (in_array('editor', (array) $user->roles)) {
3421 - $args['show_in_menu'] = true;
3422 - }
3423 - }
3424 -
3425 - if ($author_active == "true") {
3426 - if (in_array('author', (array) $user->roles)) {
3427 - $args['show_in_menu'] = true;
3428 - }
3429 - }
3430 -
3431 - if(is_plugin_active( 'dokan-lite/dokan.php' ) || is_plugin_active( 'dokan-pro/dokan.php' )){
3432 - $dokan_vendor_active = get_option('dokan_vendor_active');
3433 - if( 'true' === $dokan_vendor_active){
3434 - if (in_array('seller', (array) $user->roles)) {
3435 - $args['show_in_menu'] = true;
645 + if ( file_exists( $file ) ) {
646 + require_once $file;
3436 647 }
3437 648 }
649 + );
3438 650
3439 - }
3440 -
3441 - return $args;
651 + $loaded = true;
3442 652 }
3443 -add_filter('register_post_type_args', 'wpvr_role_management_from_post_type', 10, 2);
3444 653
3445 -function wpvr_cache_admin_notice()
3446 -{
3447 - $option = get_option('wpvr_warning');
3448 - if (!$option) {
3449 - ?>
3450 - <div class="notice notice-warning" id="wpvr-warning" style="position: relative;">
3451 - <p><?php _e('Since you have updated the plugin, please clear the browser cache for smooth functioning. Follow these steps if you are using <a href="https://support.google.com/accounts/answer/32050?co=GENIE.Platform%3DDesktop&hl=en" target="_blank">Google Chrome</a>, <a href="https://support.mozilla.org/en-US/kb/how-clear-firefox-cache" target="_blank">Mozilla Firefox</a>, <a href="https://clear-my-cache.com/en/apple-mac-os/safari.html" target="_blank">Safai</a> or <a href="https://support.microsoft.com/en-us/help/10607/microsoft-edge-view-delete-browser-history" target="_blank">Microsoft Edge</a>', 'wpvr'); ?></p>
3452 - <button type="button" id="wpvr-dismissible" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
3453 - </div>
3454 - <?php
3455 - }
3456 -}
3457 -// add_action('admin_notices', 'wpvr_cache_admin_notice');
654 +// UI/UX Mode Switch: legacy/classic or latest
655 +// Option: wpvr_ui_mode (default: legacy)
656 +wpvr_register_src_autoloader();
3458 657
3459 -//===Oxygen widget===//
3460 -add_action('plugins_loaded', function () {
3461 - if (!class_exists('OxyEl')) {
3462 - return;
3463 - }
3464 - require_once __DIR__ . '/oxygen/oxy-manager.php';
3465 -});
3466 -
3467 -add_action('init', 'wpvr_mobile_media_handle');
3468 -function wpvr_mobile_media_handle()
3469 -{
3470 - add_image_size('wpvr_mobile', 4096, 2048); //mobile
658 +$wpvr_ui_mode = get_option('wpvr_ui_mode', 'legacy');
659 +if ($wpvr_ui_mode === 'latest') {
660 + require_once plugin_dir_path(__FILE__) . 'src/Bootstrap.php';
661 + \RexTheme\WPVR\Bootstrap::init();
662 +} else {
663 + require_once plugin_dir_path(__FILE__) . 'legacy/wpvr.php';
664 + new \RexTheme\WPVR\Admin\Admin( false );
3471 665 }
3472 -
3473 -
3474 -add_action(
3475 -/**
3476 - * @param $api \VisualComposer\Modules\Api\Factory
3477 - */
3478 - 'vcv:api',
3479 - function ($api) {
3480 - $elementsToRegister = [
3481 - 'wpvrelement',
3482 - ];
3483 - $pluginBaseUrl = rtrim(plugins_url(basename(__DIR__)), '\\/');
3484 - /** @var \VisualComposer\Modules\Elements\ApiController $elementsApi */
3485 - $elementsApi = $api->elements;
3486 - foreach ($elementsToRegister as $tag) {
3487 - $manifestPath = __DIR__ . '/vc/' . $tag . '/manifest.json';
3488 - $elementBaseUrl = $pluginBaseUrl . '/vc/' . $tag;
3489 - $elementsApi->add($manifestPath, $elementBaseUrl);
3490 - }
3491 - }
3492 -);
3493 -
3494 -function wpvr_redirect_after_activation($plugin)
3495 -{
3496 - if ($plugin == plugin_basename(__FILE__)) {
3497 - $url = admin_url('admin.php?page=wpvr-setup-wizard');
3498 - $url = esc_url($url, FILTER_SANITIZE_URL);
3499 - exit(wp_safe_redirect($url));
3500 - }
3501 -}
3502 -//add_action('activated_plugin', 'wpvr_redirect_after_activation');
3503 -
3504 -function replace_callback($matches)
3505 -{
3506 - foreach ($matches as $match) {
3507 - return str_replace('<img', '<img decoding="async" ', $match);
3508 - }
3509 -}