| @@ -1,530 +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 | - * Check if the current page contains a WP VR tour | |
| 71 | - * | |
| 72 | - * @since 8.5.67 | |
| 73 | - * @return bool True if tour is present, false otherwise | |
| 74 | - */ | |
| 75 | - protected function has_wpvr_tour_on_page() { | |
| 76 | - global $post; | |
| 77 | - | |
| 78 | - // Use queried object as fallback when $post is not set | |
| 79 | - if (!$post) { | |
| 80 | - $post = get_queried_object(); | |
| 81 | - } | |
| 82 | - | |
| 83 | - if (!($post instanceof WP_Post)) { | |
| 84 | - return false; | |
| 85 | - } | |
| 86 | - | |
| 87 | - // Check if current post is a wpvr_item | |
| 88 | - if ('wpvr_item' === $post->post_type) { | |
| 89 | - return true; | |
| 90 | - } | |
| 91 | - | |
| 92 | - // Check for shortcode in post content | |
| 93 | - if (has_shortcode($post->post_content, 'wpvr')) { | |
| 94 | - return true; | |
| 95 | - } | |
| 96 | - | |
| 97 | - // Check for Gutenberg block | |
| 98 | - if (function_exists('has_block') && has_block('wpvr/wpvr-block', $post)) { | |
| 99 | - return true; | |
| 100 | - } | |
| 101 | - | |
| 102 | - // Check for page builder content | |
| 103 | - // Elementor stores content in _elementor_data meta | |
| 104 | - $elementor_data = get_post_meta($post->ID, '_elementor_data', true); | |
| 105 | - if (!empty($elementor_data) && strpos($elementor_data, 'wpvr') !== false) { | |
| 106 | - return true; | |
| 107 | - } | |
| 108 | - | |
| 109 | - // Bricks stores content in _bricks_page_content_2 meta | |
| 110 | - $bricks_data = get_post_meta($post->ID, '_bricks_page_content_2', true); | |
| 111 | - if (!empty($bricks_data) && is_array($bricks_data)) { | |
| 112 | - $bricks_json = json_encode($bricks_data); | |
| 113 | - if (strpos($bricks_json, 'wpvr') !== false) { | |
| 114 | - return true; | |
| 115 | - } | |
| 116 | - } | |
| 117 | - | |
| 118 | - // Oxygen stores content in ct_builder_shortcodes meta | |
| 119 | - $oxygen_data = get_post_meta($post->ID, 'ct_builder_shortcodes', true); | |
| 120 | - if (!empty($oxygen_data) && strpos($oxygen_data, 'wpvr') !== false) { | |
| 121 | - return true; | |
| 122 | - } | |
| 123 | - | |
| 124 | - // Divi stores content in post_content with shortcodes | |
| 125 | - // Already covered by has_shortcode check above | |
| 126 | - | |
| 127 | - // WPBakery stores content in post_content with shortcodes | |
| 128 | - // Already covered by has_shortcode check above | |
| 129 | - | |
| 130 | - return false; | |
| 131 | - } | |
| 132 | - | |
| 133 | - /** | |
| 134 | - * Check if the current page contains both video and panorama tours | |
| 135 | - * | |
| 136 | - * @since 8.5.68 | |
| 137 | - * @return bool True if page contains both tour types, false otherwise | |
| 138 | - */ | |
| 139 | - protected function has_mixed_tours_on_page() { | |
| 140 | - $has_video = $this->has_video_tour_on_page(); | |
| 141 | - $has_panorama = $this->has_panorama_tour_on_page(); | |
| 142 | - return $has_video && $has_panorama; | |
| 143 | - } | |
| 144 | - | |
| 145 | - /** | |
| 146 | - * Check if the current page contains a panorama (360 image) tour | |
| 147 | - * | |
| 148 | - * @since 8.5.68 | |
| 149 | - * @return bool True if page contains panorama tour, false otherwise | |
| 150 | - */ | |
| 151 | - protected function has_panorama_tour_on_page() { | |
| 152 | - global $post; | |
| 153 | - | |
| 154 | - // Use queried object as fallback when $post is not set | |
| 155 | - if (!$post) { | |
| 156 | - $post = get_queried_object(); | |
| 157 | - } | |
| 158 | - | |
| 159 | - if (!($post instanceof WP_Post)) { | |
| 160 | - return false; | |
| 161 | - } | |
| 162 | - | |
| 163 | - // Check if current post is a wpvr_item without video | |
| 164 | - if ('wpvr_item' === $post->post_type) { | |
| 165 | - $panodata = get_post_meta($post->ID, 'panodata', true); | |
| 166 | - if (empty($panodata) || !isset($panodata['vidid']) || empty($panodata['vidid'])) { | |
| 167 | - return true; | |
| 168 | - } | |
| 169 | - } | |
| 170 | - | |
| 171 | - // Check for shortcode with panorama tour ID | |
| 172 | - if (has_shortcode($post->post_content, 'wpvr')) { | |
| 173 | - // Extract tour IDs from shortcodes | |
| 174 | - preg_match_all('/\[wpvr[^\]]*id=["\']?(\d+)["\']?[^\]]*\]/i', $post->post_content, $matches); | |
| 175 | - if (isset($matches[1]) && !empty($matches[1])) { | |
| 176 | - foreach ($matches[1] as $tour_id) { | |
| 177 | - $panodata = get_post_meta($tour_id, 'panodata', true); | |
| 178 | - if (empty($panodata) || !isset($panodata['vidid']) || empty($panodata['vidid'])) { | |
| 179 | - return true; | |
| 180 | - } | |
| 181 | - } | |
| 182 | - } | |
| 183 | - } | |
| 184 | - | |
| 185 | - // For Gutenberg blocks, parse block content to extract tour IDs | |
| 186 | - if (function_exists('has_block') && has_block('wpvr/wpvr-block', $post)) { | |
| 187 | - $blocks = parse_blocks($post->post_content); | |
| 188 | - foreach ($blocks as $block) { | |
| 189 | - if ($block['blockName'] === 'wpvr/wpvr-block' && isset($block['attrs']['id'])) { | |
| 190 | - $tour_id = $block['attrs']['id']; | |
| 191 | - $panodata = get_post_meta($tour_id, 'panodata', true); | |
| 192 | - if (empty($panodata) || !isset($panodata['vidid']) || empty($panodata['vidid'])) { | |
| 193 | - return true; | |
| 194 | - } | |
| 195 | - } | |
| 196 | - } | |
| 197 | - } | |
| 198 | - | |
| 199 | - // For page builders (Elementor, Bricks, Oxygen), we can't easily extract tour IDs | |
| 200 | - // So we return false and let the general tour detection handle it | |
| 201 | - | |
| 202 | - return false; | |
| 203 | - } | |
| 204 | - | |
| 205 | - /** | |
| 206 | - * Check if the current page contains a video tour | |
| 207 | - * Video tours require video.js and videojs-vr libraries | |
| 208 | - * | |
| 209 | - * @since 8.5.68 | |
| 210 | - * @return bool True if page contains video tour, false otherwise | |
| 211 | - */ | |
| 212 | - protected function has_video_tour_on_page() { | |
| 213 | - global $post; | |
| 214 | - | |
| 215 | - // Use queried object as fallback when $post is not set | |
| 216 | - if (!$post) { | |
| 217 | - $post = get_queried_object(); | |
| 218 | - } | |
| 219 | - | |
| 220 | - if (!($post instanceof WP_Post)) { | |
| 221 | - return false; | |
| 222 | - } | |
| 223 | - | |
| 224 | - // Check if current post is a wpvr_item with video | |
| 225 | - if ('wpvr_item' === $post->post_type) { | |
| 226 | - $panodata = get_post_meta($post->ID, 'panodata', true); | |
| 227 | - if (isset($panodata['vidid']) && !empty($panodata['vidid'])) { | |
| 228 | - return true; | |
| 229 | - } | |
| 230 | - } | |
| 231 | - | |
| 232 | - // Check for shortcode with video tour ID | |
| 233 | - if (has_shortcode($post->post_content, 'wpvr')) { | |
| 234 | - // Extract tour IDs from shortcodes | |
| 235 | - preg_match_all('/\[wpvr[^\]]*id=["\']?(\d+)["\']?[^\]]*\]/i', $post->post_content, $matches); | |
| 236 | - if (isset($matches[1]) && !empty($matches[1])) { | |
| 237 | - foreach ($matches[1] as $tour_id) { | |
| 238 | - $panodata = get_post_meta($tour_id, 'panodata', true); | |
| 239 | - if (isset($panodata['vidid']) && !empty($panodata['vidid'])) { | |
| 240 | - return true; | |
| 241 | - } | |
| 242 | - } | |
| 243 | - } | |
| 244 | - } | |
| 245 | - | |
| 246 | - // For Gutenberg blocks and page builders, we need to check all wpvr_item posts | |
| 247 | - // to see if any contain video tours. This is a conservative approach. | |
| 248 | - // If we can't determine definitively, we'll check if ANY tour on the page is a video tour | |
| 249 | - if (function_exists('has_block') && has_block('wpvr/wpvr-block', $post)) { | |
| 250 | - // Parse block content to extract tour IDs | |
| 251 | - $blocks = parse_blocks($post->post_content); | |
| 252 | - foreach ($blocks as $block) { | |
| 253 | - if ($block['blockName'] === 'wpvr/wpvr-block' && isset($block['attrs']['id'])) { | |
| 254 | - $tour_id = $block['attrs']['id']; | |
| 255 | - $panodata = get_post_meta($tour_id, 'panodata', true); | |
| 256 | - if (isset($panodata['vidid']) && !empty($panodata['vidid'])) { | |
| 257 | - return true; | |
| 258 | - } | |
| 259 | - } | |
| 260 | - } | |
| 261 | - } | |
| 262 | - | |
| 263 | - // For page builders (Elementor, Bricks, Oxygen), we can't easily extract tour IDs | |
| 264 | - // So we'll return false and let Video Script Control handle video-specific pages | |
| 265 | - // This is a conservative approach to avoid loading video libraries unnecessarily | |
| 266 | - | |
| 267 | - return false; | |
| 268 | - } | |
| 269 | - | |
| 270 | - /** | |
| 271 | - * Register the stylesheets for the public-facing side of the site. | |
| 272 | - * | |
| 273 | - * @since 8.0.0 | |
| 274 | - */ | |
| 275 | - public function enqueue_styles() { | |
| 276 | - | |
| 277 | - /** | |
| 278 | - * This function is provided for demonstration purposes only. | |
| 279 | - * | |
| 280 | - * An instance of this class should be passed to the run() function | |
| 281 | - * defined in Wpvr_Loader as all of the hooks are defined | |
| 282 | - * in that particular class. | |
| 283 | - * | |
| 284 | - * The Wpvr_Loader will then create the relationship | |
| 285 | - * between the defined hooks and the functions defined in this | |
| 286 | - * class. | |
| 287 | - */ | |
| 288 | - | |
| 289 | - global $wp; | |
| 290 | - $wpvr_script_control = get_option('wpvr_script_control'); | |
| 291 | - $wpvr_script_list = get_option('wpvr_script_list'); | |
| 292 | - $allowed_pages_modified = array(); | |
| 293 | - $allowed_pages = isset($wpvr_script_list) && !empty($wpvr_script_list) ? array_map('sanitize_text_field', explode(",", $wpvr_script_list)) : array(); | |
| 294 | - foreach ($allowed_pages as $value) { | |
| 295 | - $allowed_pages_modified[] = untrailingslashit($value); | |
| 296 | - } | |
| 297 | - $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) : '')); | |
| 298 | - if ($wpvr_script_control == 'true') { | |
| 299 | - foreach ($allowed_pages_modified as $value) { | |
| 300 | - if ($value) { | |
| 301 | - if (strpos($current_url, $value) !== false) { | |
| 302 | - $fontawesome_disable = get_option('wpvr_fontawesome_disable'); | |
| 303 | - if ($fontawesome_disable == 'true') { | |
| 304 | - } else { | |
| 305 | - wp_enqueue_style($this->plugin_name . 'fontawesome', plugin_dir_url(__FILE__) . 'css/fontawesome/css/all.css', array(), $this->version, 'all'); | |
| 306 | - wp_enqueue_style( | |
| 307 | - $this->plugin_name . '-icons-fix', | |
| 308 | - plugin_dir_url(__FILE__) . 'css/fontawesome/css/icons-fix.css', | |
| 309 | - array($this->plugin_name . 'fontawesome'), | |
| 310 | - $this->version | |
| 311 | - ); | |
| 312 | - } | |
| 313 | - | |
| 314 | - // Check if page contains mixed tours (both video and panorama) | |
| 315 | - $has_mixed = $this->has_mixed_tours_on_page(); | |
| 316 | - $is_video_tour = $this->has_video_tour_on_page(); | |
| 317 | - $is_panorama_tour = $this->has_panorama_tour_on_page(); | |
| 318 | - | |
| 319 | - if ($has_mixed) { | |
| 320 | - // Load all resources for mixed tours | |
| 321 | - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true); | |
| 322 | - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true); | |
| 323 | - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true); | |
| 324 | - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all'); | |
| 325 | - } elseif ($is_video_tour) { | |
| 326 | - // For video tours: only load video CSS | |
| 327 | - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true); | |
| 328 | - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true); | |
| 329 | - } elseif ($is_panorama_tour) { | |
| 330 | - // For panorama tours: load panorama CSS | |
| 331 | - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true); | |
| 332 | - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all'); | |
| 333 | - } | |
| 334 | - | |
| 335 | - wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-public.css', array(), $this->version, 'all'); | |
| 336 | - } | |
| 337 | - } | |
| 338 | - } | |
| 339 | - } else { | |
| 340 | - // Only load assets if tour is present on the page | |
| 341 | - if ($this->has_wpvr_tour_on_page()) { | |
| 342 | - $fontawesome_disable = get_option('wpvr_fontawesome_disable'); | |
| 343 | - if ($fontawesome_disable == 'true') { | |
| 344 | - } else { | |
| 345 | - wp_enqueue_style($this->plugin_name . 'fontawesome', plugin_dir_url(__FILE__) . 'css/fontawesome/css/all.css', array(), $this->version, 'all'); | |
| 346 | - wp_enqueue_style( | |
| 347 | - $this->plugin_name . '-icons-fix', | |
| 348 | - plugin_dir_url(__FILE__) . 'css/fontawesome/css/icons-fix.css', | |
| 349 | - array($this->plugin_name . 'fontawesome'), | |
| 350 | - $this->version | |
| 351 | - ); | |
| 352 | - } | |
| 353 | - | |
| 354 | - // Check if page contains mixed tours (both video and panorama) | |
| 355 | - $has_mixed = $this->has_mixed_tours_on_page(); | |
| 356 | - $is_video_tour = $this->has_video_tour_on_page(); | |
| 357 | - $is_panorama_tour = $this->has_panorama_tour_on_page(); | |
| 358 | - | |
| 359 | - if ($has_mixed) { | |
| 360 | - // Load all resources for mixed tours | |
| 361 | - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true); | |
| 362 | - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true); | |
| 363 | - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true); | |
| 364 | - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all'); | |
| 365 | - } elseif ($is_video_tour) { | |
| 366 | - // For video tours: only load video CSS | |
| 367 | - wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true); | |
| 368 | - wp_enqueue_style('videojs-vr-css', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.css', array(), true); | |
| 369 | - } elseif ($is_panorama_tour) { | |
| 370 | - // For panorama tours: load panorama CSS | |
| 371 | - wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true); | |
| 372 | - wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all'); | |
| 373 | - } | |
| 374 | - | |
| 375 | - wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-public.css', array(), $this->version, 'all'); | |
| 376 | - } | |
| 377 | - } | |
| 378 | - | |
| 379 | - } | |
| 380 | - | |
| 381 | - /** | |
| 382 | - * Register the JavaScript for the public-facing side of the site. | |
| 383 | - * | |
| 384 | - * @since 8.0.0 | |
| 385 | - */ | |
| 386 | - public function enqueue_scripts() { | |
| 387 | - | |
| 388 | - $notice = ''; | |
| 389 | - $wpvr_frontend_notice = get_option('wpvr_frontend_notice'); | |
| 390 | - if ($wpvr_frontend_notice) { | |
| 391 | - $notice = sanitize_text_field( get_option('wpvr_frontend_notice_area') ); | |
| 392 | - } | |
| 393 | - global $wp; | |
| 394 | - $wpvr_script_control = get_option('wpvr_script_control'); | |
| 395 | - $wpvr_script_list = get_option('wpvr_script_list'); | |
| 396 | - $allowed_pages_modified = array(); | |
| 397 | - $allowed_pages = isset($wpvr_script_list) && !empty($wpvr_script_list) ? array_map('sanitize_text_field', explode(",", $wpvr_script_list)) : array(); | |
| 398 | - foreach ($allowed_pages as $value) { | |
| 399 | - $allowed_pages_modified[] = untrailingslashit($value); | |
| 400 | - } | |
| 401 | - | |
| 402 | - $wpvr_video_script_control = get_option('wpvr_video_script_control'); | |
| 403 | - $wpvr_video_script_list = get_option('wpvr_video_script_list'); | |
| 404 | - $allowed_video_pages_modified = array(); | |
| 405 | - $allowed_video_pages = isset($wpvr_video_script_list) && !empty($wpvr_video_script_list) ? array_map('sanitize_text_field', explode(",", $wpvr_video_script_list)) : array(); | |
| 406 | - foreach ($allowed_video_pages as $value) { | |
| 407 | - $allowed_video_pages_modified[] = untrailingslashit($value); | |
| 408 | - } | |
| 409 | - | |
| 410 | - $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) : '')); | |
| 411 | - | |
| 412 | - if ($wpvr_script_control == 'true') { | |
| 413 | - foreach ($allowed_pages_modified as $value) { | |
| 414 | - if (strpos($current_url, $value) !== false) { | |
| 415 | - // Check if page contains mixed tours (both video and panorama) | |
| 416 | - $has_mixed = $this->has_mixed_tours_on_page(); | |
| 417 | - $is_video_tour = $this->has_video_tour_on_page(); | |
| 418 | - $is_panorama_tour = $this->has_panorama_tour_on_page(); | |
| 419 | - | |
| 420 | - if ($has_mixed) { | |
| 421 | - // Load all resources for mixed tours | |
| 422 | - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); | |
| 423 | - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true); | |
| 424 | - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); | |
| 425 | - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true); | |
| 426 | - 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); | |
| 427 | - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); | |
| 428 | - } elseif ($is_video_tour) { | |
| 429 | - // For video tours: only load video JS | |
| 430 | - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); | |
| 431 | - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true); | |
| 432 | - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); | |
| 433 | - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true); | |
| 434 | - 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); | |
| 435 | - } elseif ($is_panorama_tour) { | |
| 436 | - // For panorama tours: load panorama JS | |
| 437 | - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); | |
| 438 | - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true); | |
| 439 | - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); | |
| 440 | - } | |
| 441 | - | |
| 442 | - wp_enqueue_script('jquery_cookie', plugin_dir_url(__FILE__) . 'js/jquery.cookie.js', array('jquery'), true); | |
| 443 | - wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvr-public.js', array('jquery', 'jquery_cookie'), $this->version, false); | |
| 444 | - wp_localize_script('wpvr', 'wpvr_public', array( | |
| 445 | - 'notice_active' => $wpvr_frontend_notice, | |
| 446 | - 'notice' => $notice, | |
| 447 | - 'is_pro_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'), | |
| 448 | - 'is_license_active' => get_option('wpvr_edd_license_status') == 'valid' ? true : false, | |
| 449 | - 'dis_on_hover' => get_option('dis_on_hover') === 'true' ? true : false, | |
| 450 | - 'mobile_hotspot_tip' => get_option('wpvr_mobile_hotspot_tip') === 'true' ? true : false, | |
| 451 | - )); | |
| 452 | - } | |
| 453 | - } | |
| 454 | - } else { | |
| 455 | - // Only load scripts if tour is present on the page | |
| 456 | - if ($this->has_wpvr_tour_on_page()) { | |
| 457 | - // Check if page contains mixed tours (both video and panorama) | |
| 458 | - $has_mixed = $this->has_mixed_tours_on_page(); | |
| 459 | - $is_video_tour = $this->has_video_tour_on_page(); | |
| 460 | - $is_panorama_tour = $this->has_panorama_tour_on_page(); | |
| 461 | - | |
| 462 | - if ($has_mixed) { | |
| 463 | - // Load all resources for mixed tours | |
| 464 | - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); | |
| 465 | - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true); | |
| 466 | - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); | |
| 467 | - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true); | |
| 468 | - 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); | |
| 469 | - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); | |
| 470 | - } elseif ($is_video_tour) { | |
| 471 | - // For video tours: only load video JS | |
| 472 | - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); | |
| 473 | - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array('videojs-js'), true); | |
| 474 | - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); | |
| 475 | - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true); | |
| 476 | - 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); | |
| 477 | - } elseif ($is_panorama_tour) { | |
| 478 | - // For panorama tours: load panorama JS | |
| 479 | - wp_enqueue_script('panellium-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/pannellum.js', array(), true); | |
| 480 | - wp_enqueue_script('panelliumlib-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/libpannellum.js', array('panellium-js'), true); | |
| 481 | - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); | |
| 482 | - } | |
| 483 | - | |
| 484 | - wp_enqueue_script('jquery_cookie', plugin_dir_url(__FILE__) . 'js/jquery.cookie.js', array('jquery'), true); | |
| 485 | - wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpvr-public.js', array('jquery', 'jquery_cookie'), $this->version, true); | |
| 486 | - wp_localize_script('wpvr', 'wpvr_public', array( | |
| 487 | - 'notice_active' => $wpvr_frontend_notice, | |
| 488 | - 'notice' => $notice, | |
| 489 | - 'is_pro_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'), | |
| 490 | - 'is_license_active' => get_option('wpvr_edd_license_status') == 'valid' ? true : false, | |
| 491 | - 'dis_on_hover' => get_option('dis_on_hover') === 'true' ? true : false, | |
| 492 | - 'mobile_hotspot_tip' => get_option('wpvr_mobile_hotspot_tip') === 'true' ? true : false, | |
| 493 | - )); | |
| 494 | - } | |
| 495 | - } | |
| 496 | - | |
| 497 | - $match_found = false; | |
| 498 | - if ($wpvr_video_script_control == 'true') { | |
| 499 | - foreach ($allowed_video_pages_modified as $value) { | |
| 500 | - if (strpos($current_url, $value) !== false) { | |
| 501 | - // Only enqueue video scripts if the page actually contains a video tour | |
| 502 | - if ($this->has_video_tour_on_page()) { | |
| 503 | - $match_found = true; | |
| 504 | - wp_enqueue_script('videojs-js', plugin_dir_url(__FILE__) . 'js/video.js', array(), true); // commented for video js vr | |
| 505 | - wp_enqueue_script('videojsvr-js', plugin_dir_url(__FILE__) . 'lib/videojs-vr/videojs-vr.js', array(), true); //video js vr | |
| 506 | - wp_enqueue_script('panelliumvid-js', plugin_dir_url(__FILE__) . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array(), true); | |
| 507 | - } | |
| 508 | - } | |
| 509 | - } | |
| 510 | - if (!$match_found) { | |
| 511 | - wp_dequeue_script('videojs-js'); | |
| 512 | - wp_dequeue_script('videojsvr-js'); | |
| 513 | - wp_dequeue_script('panelliumvid-js'); | |
| 514 | - } | |
| 515 | - } | |
| 516 | - | |
| 517 | - } | |
| 518 | - | |
| 519 | - /** | |
| 520 | - * Init the edit screen of the plugin post type item | |
| 521 | - * | |
| 522 | - * @since 8.0.0 | |
| 523 | - */ | |
| 524 | - public function public_init() | |
| 525 | - { | |
| 526 | - add_shortcode($this->plugin_name, array( $this->shortcode , 'wpvr_shortcode')); | |
| 527 | - | |
| 528 | - } | |
| 529 | - | |
| 530 | -} | |
| 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'; | |