PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.3
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.3
9.1.3 9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 All 222 releases
← All changes | public/class-wpvr-public.php +2 -709 8.5.719.1.3 View file →
@@ -1,710 +1,3 @@
1 1 <?php
2 -
3 -/**
4 - * The public-facing functionality of the plugin.
5 - *
6 - * @link http://rextheme.com/
7 - * @since 8.0.0
8 - *
9 - * @package Wpvr
10 - * @subpackage Wpvr/public
11 - */
12 -
13 -use WPVR\Builder\DIVI\WPVR_Divi_modules;
14 -
15 -/**
16 - * The public-facing functionality of the plugin.
17 - *
18 - * Defines the plugin name, version, and two examples hooks for how to
19 - * enqueue the public-facing stylesheet and JavaScript.
20 - *
21 - * @package Wpvr
22 - * @subpackage Wpvr/public
23 - * @author Rextheme <support@rextheme.com>
24 - */
25 -class Wpvr_Public {
26 -
27 - /**
28 - * The ID of this plugin.
29 - *
30 - * @since 8.0.0
31 - * @access private
32 - * @var string $plugin_name The ID of this plugin.
33 - */
34 - private $plugin_name;
35 -
36 - /**
37 - * The version of this plugin.
38 - *
39 - * @since 8.0.0
40 - * @access private
41 - * @var string $version The current version of this plugin.
42 - */
43 - private $version;
44 -
45 -
46 - /**
47 - * Instance of WPVR_Shortcode class
48 - *
49 - * @var object
50 - * @since 8.0.0
51 - */
52 - private $shortcode;
53 -
54 - /**
55 - * Initialize the class and set its properties.
56 - *
57 - * @since 8.0.0
58 - * @param string $plugin_name The name of the plugin.
59 - * @param string $version The version of this plugin.
60 - */
61 - public function __construct( $plugin_name, $version ) {
62 -
63 - $this->plugin_name = $plugin_name;
64 - $this->version = $version;
65 - $this->shortcode = new WPVR_Shortcode($this->plugin_name);
66 -
67 - }
68 -
69 - /**
70 - * Extract WPVR tour IDs from Elementor _elementor_data JSON.
71 - * Parses vr_id from Wpvr-widget settings blocks.
72 - *
73 - * @param string $elementor_data Raw JSON string from _elementor_data meta.
74 - * @return int[]
75 - */
76 - private function extract_elementor_wpvr_tour_ids( $elementor_data ) {
77 - $tour_ids = array();
78 - // vr_id is WPVR-specific; present only inside Wpvr-widget settings objects
79 - preg_match_all( '/"vr_id"\s*:\s*"?(\d+)"?/', $elementor_data, $matches );
80 - if ( ! empty( $matches[1] ) ) {
81 - $tour_ids = array_values( array_unique( array_map( 'intval', $matches[1] ) ) );
82 - }
83 - return $tour_ids;
84 - }
85 -
86 - /**
87 - * Extract WPVR tour IDs from Bricks _bricks_page_content_2 meta array.
88 - * Returns [-1] (sentinel) when a WPVR element exists but has no resolvable tour ID,
89 - * so callers can fall back to loading all assets (legacy safe).
90 - *
91 - * @param array $bricks_data Value of _bricks_page_content_2 post meta.
92 - * @return int[] Tour IDs, or [-1] as fallback sentinel.
93 - */
94 - private function extract_bricks_wpvr_tour_ids( $bricks_data ) {
95 - $tour_ids = array();
96 - $has_wpvr_el = false;
97 -
98 - if ( ! is_array( $bricks_data ) ) {
99 - return $tour_ids;
100 - }
101 -
102 - foreach ( $bricks_data as $element ) {
103 - if ( ! isset( $element['name'] ) || $element['name'] !== 'wpvr' ) {
104 - continue;
105 - }
106 - $has_wpvr_el = true;
107 - $tour_id = isset( $element['settings']['select_wpvr'] ) ? intval( $element['settings']['select_wpvr'] ) : 0;
108 - if ( $tour_id > 0 ) {
109 - $tour_ids[] = $tour_id;
110 - }
111 - }
112 -
113 - $tour_ids = array_values( array_unique( $tour_ids ) );
114 -
115 - // Fallback sentinel: WPVR element found but no tour ID resolved → load all assets.
116 - if ( $has_wpvr_el && empty( $tour_ids ) ) {
117 - return array( -1 );
118 - }
119 -
120 - return $tour_ids;
121 - }
122 -
123 - /**
124 - * Extract WPVR tour IDs from Oxygen ct_builder_shortcodes string.
125 - * Parses oxy-wp-vr-tour_tour_id from ct_options JSON on oxy-wp-vr-tour elements.
126 - * Returns [-1] sentinel when element found but no tour ID resolvable (legacy safe).
127 - *
128 - * @param string $oxygen_data Value of ct_builder_shortcodes post meta.
129 - * @return int[] Tour IDs, or [-1] as fallback sentinel.
130 - */
131 - private function extract_oxygen_wpvr_tour_ids( $oxygen_data ) {
132 - $tour_ids = array();
133 - $has_wpvr_el = false;
134 -
135 - if ( empty( $oxygen_data ) || ! is_string( $oxygen_data ) ) {
136 - return $tour_ids;
137 - }
138 -
139 - // Match all oxy-wp-vr-tour tags and capture their ct_options attribute value.
140 - preg_match_all( '/\[oxy-wp-vr-tour[^\]]*ct_options=\'([^\']+)\'/', $oxygen_data, $matches );
141 -
142 - if ( empty( $matches[1] ) ) {
143 - // Tag present but ct_options not parseable — still a WPVR element.
144 - if ( strpos( $oxygen_data, 'oxy-wp-vr-tour' ) !== false ) {
145 - return array( -1 );
146 - }
147 - return $tour_ids;
148 - }
149 -
150 - foreach ( $matches[1] as $ct_options_raw ) {
151 - $has_wpvr_el = true;
152 - $ct_options = json_decode( $ct_options_raw, true );
153 - $tour_id = isset( $ct_options['original']['oxy-wp-vr-tour_tour_id'] )
154 - ? intval( $ct_options['original']['oxy-wp-vr-tour_tour_id'] )
155 - : 0;
156 - if ( $tour_id > 0 ) {
157 - $tour_ids[] = $tour_id;
158 - }
159 - }
160 -
161 - $tour_ids = array_values( array_unique( $tour_ids ) );
162 -
163 - if ( $has_wpvr_el && empty( $tour_ids ) ) {
164 - return array( -1 );
165 - }
166 -
167 - return $tour_ids;
168 - }
169 -
170 - /**
171 - * Check if the current page contains a WP VR tour
172 - *
173 - * @since 8.5.67
174 - * @return bool True if tour is present, false otherwise
175 - */
176 - protected function has_wpvr_tour_on_page() {
177 - global $post;
178 -
179 - // Use queried object as fallback when $post is not set
180 - if (!$post) {
181 - $post = get_queried_object();
182 - }
183 -
184 - if (!($post instanceof WP_Post)) {
185 - return false;
186 - }
187 -
188 - // Check if current post is a wpvr_item
189 - if ('wpvr_item' === $post->post_type) {
190 - return true;
191 - }
192 -
193 - // Check for shortcode in post content
194 - if (has_shortcode($post->post_content, 'wpvr') || has_shortcode($post->post_content, 'wpvr_divi')) {
195 - return true;
196 - }
197 -
198 - // Check for Gutenberg block
199 - if (function_exists('has_block') && has_block('wpvr/wpvr-block', $post)) {
200 - return true;
201 - }
202 -
203 - // Check for page builder content
204 - // Elementor stores content in _elementor_data meta (widget name is 'Wpvr-widget' — use case-insensitive search)
205 - $elementor_data = get_post_meta($post->ID, '_elementor_data', true);
206 - if (!empty($elementor_data) && stripos($elementor_data, 'wpvr') !== false) {
207 - return true;
208 - }
209 -
210 -
211 - // Bricks stores content in _bricks_page_content_2 meta
212 - $bricks_data = get_post_meta($post->ID, '_bricks_page_content_2', true);
213 - if (!empty($bricks_data) && is_array($bricks_data)) {
214 - $bricks_json = json_encode($bricks_data);
215 - if (strpos($bricks_json, 'wpvr') !== false) {
216 - return true;
217 - }
218 - }
219 -
220 - // Oxygen stores content in ct_builder_shortcodes meta
221 - $oxygen_data = get_post_meta($post->ID, 'ct_builder_shortcodes', true);
222 - if (!empty($oxygen_data) && (strpos($oxygen_data, 'wpvr') !== false || strpos($oxygen_data, 'oxy-wp-vr-tour') !== false)) {
223 - return true;
224 - }
225 -
226 - // Divi stores content in post_content with shortcodes
227 - // Already covered by has_shortcode check above
228 -
229 - // WPBakery stores content in post_content with shortcodes
230 - // Already covered by has_shortcode check above
231 -
232 - return false;
233 - }
234 -
235 - /**
236 - * Check if the current page contains both video and panorama tours
237 - *
238 - * @since 8.5.68
239 - * @return bool True if page contains both tour types, false otherwise
240 - */
241 - protected function has_mixed_tours_on_page() {
242 - $has_video = $this->has_video_tour_on_page();
243 - $has_panorama = $this->has_panorama_tour_on_page();
244 - return $has_video && $has_panorama;
245 - }
246 -
247 - /**
248 - * Check if the current page contains a panorama (360 image) tour
249 - *
250 - * @since 8.5.68
251 - * @return bool True if page contains panorama tour, false otherwise
252 - */
253 - protected function has_panorama_tour_on_page() {
254 - global $post;
255 -
256 - // Use queried object as fallback when $post is not set
257 - if (!$post) {
258 - $post = get_queried_object();
259 - }
260 -
261 - if (!($post instanceof WP_Post)) {
262 - return false;
263 - }
264 -
265 - // Check if current post is a wpvr_item without video
266 - if ('wpvr_item' === $post->post_type) {
267 - $panodata = get_post_meta($post->ID, 'panodata', true);
268 - if (empty($panodata) || !isset($panodata['vidid']) || empty($panodata['vidid'])) {
269 - return true;
270 - }
271 - }
272 -
273 - // Check for shortcode with panorama tour ID
274 - if (has_shortcode($post->post_content, 'wpvr') || has_shortcode($post->post_content, 'wpvr_divi')) {
275 - // Extract tour IDs from shortcodes
276 - preg_match_all('/\[wpvr[^\]]*id=["\']?(\d+)["\']?[^\]]*\]/i', $post->post_content, $matches);
277 - if (isset($matches[1]) && !empty($matches[1])) {
278 - foreach ($matches[1] as $tour_id) {
279 - $panodata = get_post_meta($tour_id, 'panodata', true);
280 - if (empty($panodata) || !isset($panodata['vidid']) || empty($panodata['vidid'])) {
281 - return true;
282 - }
283 - }
284 - }
285 - }
286 -
287 - // For Gutenberg blocks, parse block content to extract tour IDs
288 - if (function_exists('has_block') && has_block('wpvr/wpvr-block', $post)) {
289 - $blocks = parse_blocks($post->post_content);
290 - foreach ($blocks as $block) {
291 - if ($block['blockName'] === 'wpvr/wpvr-block' && isset($block['attrs']['id'])) {
292 - $tour_id = $block['attrs']['id'];
293 - $panodata = get_post_meta($tour_id, 'panodata', true);
294 - if (empty($panodata) || !isset($panodata['vidid']) || empty($panodata['vidid'])) {
295 - return true;
296 - }
297 - }
298 - }
299 - }
300 -
301 - // Check Elementor data — extract vr_id from Wpvr-widget settings
302 - $elementor_data = get_post_meta( $post->ID, '_elementor_data', true );
303 - if ( ! empty( $elementor_data ) && stripos( $elementor_data, 'Wpvr-widget' ) !== false ) {
304 - foreach ( $this->extract_elementor_wpvr_tour_ids( $elementor_data ) as $tour_id ) {
305 - $panodata = get_post_meta( $tour_id, 'panodata', true );
306 - if ( empty( $panodata ) || ! isset( $panodata['vidid'] ) || empty( $panodata['vidid'] ) ) {
307 - return true;
308 - }
309 - }
310 - }
311 -
312 - // Check Oxygen data — extract tour IDs from oxy-wp-vr-tour elements
313 - $oxygen_data = get_post_meta( $post->ID, 'ct_builder_shortcodes', true );
314 - if ( ! empty( $oxygen_data ) ) {
315 - $oxygen_tour_ids = $this->extract_oxygen_wpvr_tour_ids( $oxygen_data );
316 - foreach ( $oxygen_tour_ids as $tour_id ) {
317 - if ( $tour_id === -1 ) {
318 - // Sentinel: WPVR element exists but no tour ID — assume panorama (legacy safe).
319 - return true;
320 - }
321 - $panodata = get_post_meta( $tour_id, 'panodata', true );
322 - if ( empty( $panodata ) || ! isset( $panodata['vidid'] ) || empty( $panodata['vidid'] ) ) {
323 - return true;
324 - }
325 - }
326 - }
327 -
328 - // Check Bricks data — extract tour IDs from wpvr elements
329 - $bricks_data = get_post_meta( $post->ID, '_bricks_page_content_2', true );
330 - if ( ! empty( $bricks_data ) && is_array( $bricks_data ) ) {
331 - $bricks_tour_ids = $this->extract_bricks_wpvr_tour_ids( $bricks_data );
332 - foreach ( $bricks_tour_ids as $tour_id ) {
333 - if ( $tour_id === -1 ) {
334 - // Sentinel: WPVR element exists but no tour ID — assume panorama (legacy safe).
335 - return true;
336 - }
337 - $panodata = get_post_meta( $tour_id, 'panodata', true );
338 - if ( empty( $panodata ) || ! isset( $panodata['vidid'] ) || empty( $panodata['vidid'] ) ) {
339 - return true;
340 - }
341 - }
342 - }
343 -
344 - return false;
345 - }
346 -
347 - /**
348 - * Check if the current page contains a video tour
349 - * Video tours require video.js and videojs-vr libraries
350 - *
351 - * @since 8.5.68
352 - * @return bool True if page contains video tour, false otherwise
353 - */
354 - protected function has_video_tour_on_page() {
355 - global $post;
356 -
357 - // Use queried object as fallback when $post is not set
358 - if (!$post) {
359 - $post = get_queried_object();
360 - }
361 -
362 - if (!($post instanceof WP_Post)) {
363 - return false;
364 - }
365 -
366 - // Check if current post is a wpvr_item with video
367 - if ('wpvr_item' === $post->post_type) {
368 - $panodata = get_post_meta($post->ID, 'panodata', true);
369 - if (isset($panodata['vidid']) && !empty($panodata['vidid'])) {
370 - return true;
371 - }
372 - }
373 -
374 - // Check for shortcode with video tour ID
375 - if (has_shortcode($post->post_content, 'wpvr') || has_shortcode($post->post_content, 'wpvr_divi')) {
376 - // Extract tour IDs from shortcodes
377 - preg_match_all('/\[wpvr[^\]]*id=["\']?(\d+)["\']?[^\]]*\]/i', $post->post_content, $matches);
378 - if (isset($matches[1]) && !empty($matches[1])) {
379 - foreach ($matches[1] as $tour_id) {
380 - $panodata = get_post_meta($tour_id, 'panodata', true);
381 - if (isset($panodata['vidid']) && !empty($panodata['vidid'])) {
382 - return true;
383 - }
384 - }
385 - }
386 - }
387 -
388 - // For Gutenberg blocks and page builders, we need to check all wpvr_item posts
389 - // to see if any contain video tours. This is a conservative approach.
390 - // If we can't determine definitively, we'll check if ANY tour on the page is a video tour
391 - if (function_exists('has_block') && has_block('wpvr/wpvr-block', $post)) {
392 - // Parse block content to extract tour IDs
393 - $blocks = parse_blocks($post->post_content);
394 - foreach ($blocks as $block) {
395 - if ($block['blockName'] === 'wpvr/wpvr-block' && isset($block['attrs']['id'])) {
396 - $tour_id = $block['attrs']['id'];
397 - $panodata = get_post_meta($tour_id, 'panodata', true);
398 - if (isset($panodata['vidid']) && !empty($panodata['vidid'])) {
399 - return true;
400 - }
401 - }
402 - }
403 - }
404 -
405 - // Check Elementor data — extract vr_id from Wpvr-widget settings
406 - $elementor_data = get_post_meta( $post->ID, '_elementor_data', true );
407 - if ( ! empty( $elementor_data ) && stripos( $elementor_data, 'Wpvr-widget' ) !== false ) {
408 - foreach ( $this->extract_elementor_wpvr_tour_ids( $elementor_data ) as $tour_id ) {
409 - $panodata = get_post_meta( $tour_id, 'panodata', true );
410 - if ( isset( $panodata['vidid'] ) && ! empty( $panodata['vidid'] ) ) {
411 - return true;
412 - }
413 - }
414 - }
415 -
416 - // Check Oxygen data — extract tour IDs from oxy-wp-vr-tour elements
417 - $oxygen_data = get_post_meta( $post->ID, 'ct_builder_shortcodes', true );
418 - if ( ! empty( $oxygen_data ) ) {
419 - $oxygen_tour_ids = $this->extract_oxygen_wpvr_tour_ids( $oxygen_data );
420 - foreach ( $oxygen_tour_ids as $tour_id ) {
421 - if ( $tour_id === -1 ) {
422 - // Sentinel: WPVR element exists but no tour ID — cannot confirm video, skip.
423 - continue;
424 - }
425 - $panodata = get_post_meta( $tour_id, 'panodata', true );
426 - if ( isset( $panodata['vidid'] ) && ! empty( $panodata['vidid'] ) ) {
427 - return true;
428 - }
429 - }
430 - }
431 -
432 - // Check Bricks data — extract tour IDs from wpvr elements
433 - $bricks_data = get_post_meta( $post->ID, '_bricks_page_content_2', true );
434 - if ( ! empty( $bricks_data ) && is_array( $bricks_data ) ) {
435 - $bricks_tour_ids = $this->extract_bricks_wpvr_tour_ids( $bricks_data );
436 - foreach ( $bricks_tour_ids as $tour_id ) {
437 - if ( $tour_id === -1 ) {
438 - // Sentinel: WPVR element exists but no tour ID — cannot confirm video, skip.
439 - continue;
440 - }
441 - $panodata = get_post_meta( $tour_id, 'panodata', true );
442 - if ( isset( $panodata['vidid'] ) && ! empty( $panodata['vidid'] ) ) {
443 - return true;
444 - }
445 - }
446 - }
447 -
448 - return false;
449 - }
450 -
451 - /**
452 - * Register the stylesheets for the public-facing side of the site.
453 - *
454 - * @since 8.0.0
455 - */
456 - public function enqueue_styles() {
457 -
458 - /**
459 - * This function is provided for demonstration purposes only.
460 - *
461 - * An instance of this class should be passed to the run() function
462 - * defined in Wpvr_Loader as all of the hooks are defined
463 - * in that particular class.
464 - *
465 - * The Wpvr_Loader will then create the relationship
466 - * between the defined hooks and the functions defined in this
467 - * class.
468 - */
469 -
470 - global $wp;
471 - $wpvr_script_control = get_option('wpvr_script_control');
472 - $wpvr_script_list = get_option('wpvr_script_list');
473 - $allowed_pages_modified = array();
474 - $allowed_pages = isset($wpvr_script_list) && !empty($wpvr_script_list) ? array_map('sanitize_text_field', explode(",", $wpvr_script_list)) : array();
475 - foreach ($allowed_pages as $value) {
476 - $allowed_pages_modified[] = untrailingslashit($value);
477 - }
478 - $current_url = home_url(add_query_arg(isset($_GET) ? array_map('sanitize_text_field', wp_unslash($_GET)) : array(), isset($wp->request) ? sanitize_text_field($wp->request) : ''));
479 - if ($wpvr_script_control == 'true') {
480 - foreach ($allowed_pages_modified as $value) {
481 - if ($value) {
482 - if (strpos($current_url, $value) !== false) {
483 - $fontawesome_disable = get_option('wpvr_fontawesome_disable');
484 - if ($fontawesome_disable == 'true') {
485 - } else {
486 - wp_enqueue_style($this->plugin_name . 'fontawesome', plugin_dir_url(__FILE__) . 'css/fontawesome/css/all.css', array(), $this->version, 'all');
487 - wp_enqueue_style(
488 - $this->plugin_name . '-icons-fix',
489 - plugin_dir_url(__FILE__) . 'css/fontawesome/css/icons-fix.css',
490 - array($this->plugin_name . 'fontawesome'),
491 - $this->version
492 - );
493 - }
494 -
495 - // Check if page contains mixed tours (both video and panorama)
496 - $has_mixed = $this->has_mixed_tours_on_page();
497 - $is_video_tour = $this->has_video_tour_on_page();
498 - $is_panorama_tour = $this->has_panorama_tour_on_page();
499 -
500 - if ($has_mixed) {
501 - // Load all resources for mixed tours
502 - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true);
503 - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true);
504 - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true);
505 - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all');
506 - } elseif ($is_video_tour) {
507 - // For video tours: only load video CSS
508 - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true);
509 - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true);
510 - } elseif ($is_panorama_tour) {
511 - // For panorama tours: load panorama CSS
512 - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true);
513 - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all');
514 - }
515 -
516 - wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-public.css', array(), $this->version, 'all');
517 - }
518 - }
519 - }
520 - } else {
521 - // Only load assets if tour is present on the page
522 - if ($this->has_wpvr_tour_on_page()) {
523 - $fontawesome_disable = get_option('wpvr_fontawesome_disable');
524 - if ($fontawesome_disable == 'true') {
525 - } else {
526 - wp_enqueue_style($this->plugin_name . 'fontawesome', plugin_dir_url(__FILE__) . 'css/fontawesome/css/all.css', array(), $this->version, 'all');
527 - wp_enqueue_style(
528 - $this->plugin_name . '-icons-fix',
529 - plugin_dir_url(__FILE__) . 'css/fontawesome/css/icons-fix.css',
530 - array($this->plugin_name . 'fontawesome'),
531 - $this->version
532 - );
533 - }
534 -
535 - // Check if page contains mixed tours (both video and panorama)
536 - $has_mixed = $this->has_mixed_tours_on_page();
537 - $is_video_tour = $this->has_video_tour_on_page();
538 - $is_panorama_tour = $this->has_panorama_tour_on_page();
539 - if ($has_mixed) {
540 - // Load all resources for mixed tours
541 - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true);
542 - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true);
543 - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true);
544 - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all');
545 - } elseif ($is_video_tour) {
546 - // For video tours: only load video CSS
547 - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true);
548 - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true);
549 - } elseif ($is_panorama_tour) {
550 - // For panorama tours: load panorama CSS
551 - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true);
552 - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all');
553 - }
554 -
555 - wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-public.css', array(), $this->version, 'all');
556 - }
557 - }
558 -
559 - }
560 -
561 - /**
562 - * Register the JavaScript for the public-facing side of the site.
563 - *
564 - * @since 8.0.0
565 - */
566 - public function enqueue_scripts() {
567 -
568 - $notice = '';
569 - $wpvr_frontend_notice = get_option('wpvr_frontend_notice');
570 - if ($wpvr_frontend_notice) {
571 - $notice = sanitize_text_field( get_option('wpvr_frontend_notice_area') );
572 - }
573 - global $wp;
574 - $wpvr_script_control = get_option('wpvr_script_control');
575 - $wpvr_script_list = get_option('wpvr_script_list');
576 - $allowed_pages_modified = array();
577 - $allowed_pages = isset($wpvr_script_list) && !empty($wpvr_script_list) ? array_map('sanitize_text_field', explode(",", $wpvr_script_list)) : array();
578 - foreach ($allowed_pages as $value) {
579 - $allowed_pages_modified[] = untrailingslashit($value);
580 - }
581 -
582 - $wpvr_video_script_control = get_option('wpvr_video_script_control');
583 - $wpvr_video_script_list = get_option('wpvr_video_script_list');
584 - $allowed_video_pages_modified = array();
585 - $allowed_video_pages = isset($wpvr_video_script_list) && !empty($wpvr_video_script_list) ? array_map('sanitize_text_field', explode(",", $wpvr_video_script_list)) : array();
586 - foreach ($allowed_video_pages as $value) {
587 - $allowed_video_pages_modified[] = untrailingslashit($value);
588 - }
589 -
590 - $current_url = home_url(add_query_arg(isset($_GET) ? array_map('sanitize_text_field', wp_unslash($_GET)) : array(), isset($wp->request) ? sanitize_text_field($wp->request) : ''));
591 -
592 - if ($wpvr_script_control == 'true') {
593 - foreach ($allowed_pages_modified as $value) {
594 - if (strpos($current_url, $value) !== false) {
595 - // Check if page contains mixed tours (both video and panorama)
596 - $has_mixed = $this->has_mixed_tours_on_page();
597 - $is_video_tour = $this->has_video_tour_on_page();
598 - $is_panorama_tour = $this->has_panorama_tour_on_page();
599 -
600 - if ($has_mixed) {
601 - // Load all resources for mixed tours
602 - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true);
603 - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true);
604 - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true);
605 - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true);
606 - wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array('videojs-js', 'videojsvr-js', 'panellium-js', 'panelliumlib-js'), true);
607 - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false);
608 - } elseif ($is_video_tour) {
609 - // For video tours: only load video JS
610 - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true);
611 - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true);
612 - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true);
613 - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true);
614 - wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array('videojs-js', 'videojsvr-js', 'panellium-js', 'panelliumlib-js'), true);
615 - } elseif ($is_panorama_tour) {
616 - // For panorama tours: load panorama JS
617 - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true);
618 - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true);
619 - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false);
620 - }
621 -
622 - wp_enqueue_script('jquery_cookie', plugin_dir_url(__FILE__) . 'js/jquery.cookie.js', array('jquery'), true);
623 - wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvr-public.js', array('jquery', 'jquery_cookie'), $this->version, false);
624 - wp_localize_script('wpvr', 'wpvr_public', array(
625 - 'notice_active' => $wpvr_frontend_notice,
626 - 'notice' => $notice,
627 - 'is_pro_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'),
628 - 'is_license_active' => get_option('wpvr_edd_license_status') == 'valid' ? true : false,
629 - 'dis_on_hover' => get_option('dis_on_hover') === 'true' ? true : false,
630 - 'mobile_hotspot_tip' => get_option('wpvr_mobile_hotspot_tip') === 'true' ? true : false,
631 - ));
632 - }
633 - }
634 - } else {
635 - // Only load scripts if tour is present on the page
636 - if ($this->has_wpvr_tour_on_page()) {
637 - // Check if page contains mixed tours (both video and panorama)
638 - $has_mixed = $this->has_mixed_tours_on_page();
639 - $is_video_tour = $this->has_video_tour_on_page();
640 - $is_panorama_tour = $this->has_panorama_tour_on_page();
641 -
642 - if ($has_mixed) {
643 - // Load all resources for mixed tours
644 - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true);
645 - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true);
646 - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true);
647 - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true);
648 - wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array('videojs-js', 'videojsvr-js', 'panellium-js', 'panelliumlib-js'), true);
649 - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false);
650 - } elseif ($is_video_tour) {
651 - // For video tours: only load video JS
652 - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true);
653 - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true);
654 - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true);
655 - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true);
656 - wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array('videojs-js', 'videojsvr-js', 'panellium-js', 'panelliumlib-js'), true);
657 - } elseif ($is_panorama_tour) {
658 - // For panorama tours: load panorama JS
659 - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true);
660 - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true);
661 - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false);
662 - }
663 -
664 - wp_enqueue_script('jquery_cookie', plugin_dir_url(__FILE__) . 'js/jquery.cookie.js', array('jquery'), true);
665 - wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvr-public.js', array('jquery', 'jquery_cookie'), $this->version, true);
666 - wp_localize_script('wpvr', 'wpvr_public', array(
667 - 'notice_active' => $wpvr_frontend_notice,
668 - 'notice' => $notice,
669 - 'is_pro_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'),
670 - 'is_license_active' => get_option('wpvr_edd_license_status') == 'valid' ? true : false,
671 - 'dis_on_hover' => get_option('dis_on_hover') === 'true' ? true : false,
672 - 'mobile_hotspot_tip' => get_option('wpvr_mobile_hotspot_tip') === 'true' ? true : false,
673 - ));
674 - }
675 - }
676 -
677 - $match_found = false;
678 - if ($wpvr_video_script_control == 'true') {
679 - foreach ($allowed_video_pages_modified as $value) {
680 - if (strpos($current_url, $value) !== false) {
681 - // Only enqueue video scripts if the page actually contains a video tour
682 - if ($this->has_video_tour_on_page()) {
683 - $match_found = true;
684 - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); // commented for video js vr
685 - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array(), true); //video js vr
686 - wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array(), true);
687 - }
688 - }
689 - }
690 - if (!$match_found) {
691 - wp_dequeue_script('videojs-js');
692 - wp_dequeue_script('videojsvr-js');
693 - wp_dequeue_script('panelliumvid-js');
694 - }
695 - }
696 -
697 - }
698 -
699 - /**
700 - * Init the edit screen of the plugin post type item
701 - *
702 - * @since 8.0.0
703 - */
704 - public function public_init()
705 - {
706 - add_shortcode($this->plugin_name, array( $this->shortcode , 'wpvr_shortcode'));
707 -
708 - }
709 -
710 -}
2 +// Backward-compatibility shim. Path moved to legacy/ in new UI architecture.
3 +require_once plugin_dir_path( __FILE__ ) . '../legacy/public/class-wpvr-public.php';