| @@ -344,33 +344,48 @@ | ||
| 344 | 344 | if ($adscreen->id == "wpvr_item") { |
| 345 | 345 | wp_enqueue_script($this->plugin_name . '-shortcode', plugin_dir_url(__FILE__) . 'js/wpvr-shortcode.js', array('jquery'), $this->version, true); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | - wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); | |
| 349 | - wp_enqueue_script('wpvr-global', $asset_url . 'js/wpvr-global.js', array('jquery'), $this->version, false); | |
| 348 | + $is_wpvr_screen = false; | |
| 349 | + if ( isset( $adscreen->id ) ) { | |
| 350 | + $is_wpvr_screen = ( | |
| 351 | + $adscreen->id === 'wpvr_item' || | |
| 352 | + $adscreen->id === 'edit-wpvr_item' || | |
| 353 | + $adscreen->id === 'toplevel_page_wpvr' || | |
| 354 | + $adscreen->id === 'wp-vr_page_wpvr-setting' || | |
| 355 | + false !== strpos( $adscreen->id, 'wpvr' ) || | |
| 356 | + false !== strpos( $adscreen->id, 'wp-vr' ) || | |
| 357 | + ( isset( $adscreen->post_type ) && 'wpvr_item' === $adscreen->post_type ) | |
| 358 | + ); | |
| 359 | + } | |
| 350 | 360 | |
| 351 | - $admin_user = wp_get_current_user(); | |
| 352 | - $admin_name = $admin_user->display_name ?? ''; | |
| 361 | + if ( $is_wpvr_screen ) { | |
| 362 | + wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false); | |
| 363 | + wp_enqueue_script('wpvr-global', $asset_url . 'js/wpvr-global.js', array('jquery'), $this->version, false); | |
| 353 | 364 | |
| 354 | - wp_localize_script('wpvr-global', 'wpvr_global_obj', array( | |
| 355 | - 'ajaxurl' => admin_url('admin-ajax.php'), | |
| 356 | - 'site_url' => site_url() . '/wp-json/', | |
| 357 | - 'ajax_nonce' => wp_create_nonce('wpvr'), | |
| 358 | - 'user_information' => $this->get_logged_in_user_information(), | |
| 359 | - 'is_wpvr_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'), | |
| 360 | - 'admin_name' => $admin_name, | |
| 361 | - 'url_info' => array( | |
| 362 | - 'admin_url' => admin_url(), | |
| 363 | - 'screen' => $adscreen->action, | |
| 364 | - 'url' => isset( $_SERVER['PHP_SELF'] ) ? sanitize_text_field( wp_unslash( $_SERVER['PHP_SELF'] ) ) : '', | |
| 365 | - 'param' => $_GET, | |
| 366 | - ), | |
| 367 | - 'active_tab_url' => admin_url('post-new.php?post_type=wpvr_item&active_tab=scene'), | |
| 368 | - 'hotspot_warning_text' => __('Please upload a scene before proceeding to set hotspot!', 'wpvr'), | |
| 369 | - 'negative_number_warning_text' =>__('Negative numbers are not allowed!', 'wpvr'), | |
| 370 | - )); | |
| 365 | + $admin_user = wp_get_current_user(); | |
| 366 | + $admin_name = $admin_user->display_name ?? ''; | |
| 371 | 367 | |
| 372 | - wp_localize_script('wpvr-global', 'wpvr_id_options', $wpvr_list); | |
| 368 | + wp_localize_script('wpvr-global', 'wpvr_global_obj', array( | |
| 369 | + 'ajaxurl' => admin_url('admin-ajax.php'), | |
| 370 | + 'site_url' => site_url() . '/wp-json/', | |
| 371 | + 'ajax_nonce' => wp_create_nonce('wpvr'), | |
| 372 | + 'user_information' => $this->get_logged_in_user_information(), | |
| 373 | + 'is_wpvr_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'), | |
| 374 | + 'admin_name' => $admin_name, | |
| 375 | + 'url_info' => array( | |
| 376 | + 'admin_url' => admin_url(), | |
| 377 | + 'screen' => $adscreen->action, | |
| 378 | + 'url' => isset( $_SERVER['PHP_SELF'] ) ? sanitize_text_field( wp_unslash( $_SERVER['PHP_SELF'] ) ) : '', | |
| 379 | + 'param' => $_GET, | |
| 380 | + ), | |
| 381 | + 'active_tab_url' => admin_url('post-new.php?post_type=wpvr_item&active_tab=scene'), | |
| 382 | + 'hotspot_warning_text' => __('Please upload a scene before proceeding to set hotspot!', 'wpvr'), | |
| 383 | + 'negative_number_warning_text' =>__('Negative numbers are not allowed!', 'wpvr'), | |
| 384 | + )); | |
| 385 | + | |
| 386 | + wp_localize_script('wpvr-global', 'wpvr_id_options', $wpvr_list); | |
| 387 | + } | |
| 373 | 388 | } |
| 374 | 389 | |
| 375 | 390 | /** |
| 376 | 391 | * Retrieve the currently logged-in user's email and name. |