hotspot = new WPVR_Hotspot(); $this->format = new WPVR_Format(); $this->validator = new WPVR_Validator(); $this->status = apply_filters( 'check_pro_license_status', $this->status ); if ($this->status !== false && $this->status == 'valid') { $this->data_limit = 999999999; } else { $this->data_limit = 5; } } /** * Render Scene Settings Content * * @param array $postdata * * @return void * @since 8.0.0 */ public function render_scene($postdata) { ob_start(); ?>
Warning: Please add SSL to enable Gyroscope for WP VR.
'); die(); } $gyro = true; $deviceorientationcontrol = $this->format->set_checkbox_value(@$_POST['deviceorientationcontrol']); } else { $gyro = false; $deviceorientationcontrol = false; } //===Gyroscopre control===// $autoload = $this->format->set_checkbox_value($_POST['autoload']); $control = $this->format->set_checkbox_value($_POST['control']); $scene_fade_duration = $_POST['scenefadeduration']; $preview = esc_url($_POST['preview']); $rotation = sanitize_text_field($_POST['rotation']); $autorotation = sanitize_text_field($_POST['autorotation']); $autorotationinactivedelay = sanitize_text_field($_POST['autorotationinactivedelay']); $autorotationstopdelay = sanitize_text_field($_POST['autorotationstopdelay']); //===generic form===// $genericform = sanitize_text_field(isset($_POST['genericform']) ? $_POST['genericform'] : 'off'); $genericformshortcode = isset($_POST['genericformshortcode']) ? $_POST['genericformshortcode'] : '' ; //===generic form===// $this->validator->basic_setting_validation($autorotationinactivedelay, $autorotationstopdelay); // Basic setting error control and validation // //===Company Logo===// $cpLogoSwitch = isset($_POST['cpLogoSwitch']) ? $_POST['cpLogoSwitch'] : 'off'; $cpLogoImg = isset($_POST['cpLogoImg']) ? $_POST['cpLogoImg'] : ''; $cpLogoContent = isset($_POST['cpLogoContent']) ? sanitize_text_field($_POST['cpLogoContent']) : ''; //===Company Logo===// //===Explainer video===// $explainerSwitch = isset($_POST['explainerSwitch']) ? $_POST['explainerSwitch'] : 'off'; $explainerContent = ''; $explainerContent = isset($_POST['explainerContent']) ? $_POST['explainerContent'] : ''; //===Explainer video===// $scene_fade_duration = ''; $scene_fade_duration = $_POST['scenefadeduration']; $this->validator->scene_validation($panodata); // Scene content error control and validation // $this->validator->empty_scene_validation($panodata); // Empty scene content error control and validation // $this->validator->duplicate_hotspot_validation($panodata); // Duplicate error control and validation // $panodata = $this->format->remove_empty_scene_and_hotspot($panodata); // Remove Empty scene and hotspot // //===audio===// $bg_music = isset($_POST['bg_music']) ? sanitize_text_field($_POST['bg_music']) : 'off'; $bg_music_url = isset($_POST['bg_music_url']) ? esc_url_raw($_POST['bg_music_url']) : ''; $autoplay_bg_music = isset($_POST['autoplay_bg_music']) ? sanitize_text_field($_POST['autoplay_bg_music']) : 'off'; $loop_bg_music = isset($_POST['loop_bg_music']) ? sanitize_text_field($_POST['loop_bg_music']) : 'off'; if ($bg_music == 'on') { if (empty($bg_music_url)) { wp_send_json_error('Warning: Please add an audio file as you enabled audio for this tour
'); die(); } } //===audio===// $advanced_control = array( 'keyboardzoom' => $keyboardzoom, 'diskeyboard' => $diskeyboard, 'draggable' => $draggable, 'mouseZoom' => $mouseZoom, 'gyro' => $gyro, 'deviceorientationcontrol' => $deviceorientationcontrol, 'compass' => $compass, 'vrgallery' => $vrgallery, 'vrgallery_title' => $vrgallery_title, 'vrgallery_display' => $vrgallery_display, 'vrgallery_icon_size' => $vrgallery_icon_size, 'bg_music' => $bg_music, 'bg_music_url' => $bg_music_url, 'autoplay_bg_music' => $autoplay_bg_music, 'loop_bg_music' => $loop_bg_music, 'cpLogoSwitch' => $cpLogoSwitch, 'cpLogoImg' => $cpLogoImg, 'cpLogoContent' => $cpLogoContent, 'hfov' => $default_global_zoom, 'maxHfov' => $max_global_zoom, 'minHfov' => $min_global_zoom, 'explainerSwitch' => $explainerSwitch, 'explainerContent' => $explainerContent, ); $pano_array = array(); $pano_array = array( "panoid" => $panoid, "autoLoad" => $autoload, "showControls" => $control, "customcontrol" => $custom_control, "autoRotate" => $autorotation, "autoRotateInactivityDelay" => $autorotationinactivedelay, "autoRotateStopDelay" => $autorotationstopdelay, "genericform" => $genericform, "genericformshortcode" => $genericformshortcode, "preview" => $preview, "defaultscene" => $default_scene, "scenefadeduration" => $scene_fade_duration, "panodata" => $panodata, "previewtext" => $previewtext); $pano_array = apply_filters( 'prepare_scene_pano_array_with_pro_version', $pano_array, $_POST, $advanced_control ); $pano_array = $this->format->prepare_rotation_wrapper_data($pano_array, $rotation); // Prepare tour rotation wrapper data / update_post_meta($postid, 'panodata', $pano_array); $response = array( 'success' => true, 'data' => array( 'post_ID' => $postid, 'post_status' => get_post_status($postid) ) ); wp_send_json($response); die(); } /** * Responsible for showing Scene Preview * * @param string $panoid * @param string $panovideo * * @return wp_send_json_success * @since 8.0.0 */ public function wpvr_scene_preview($panoid, $panovideo) { $panodata = $this->format->prepare_panodata($_POST['panodata']); $control = $this->format->set_checkbox_value($_POST['control']); $autoload = $this->format->set_checkbox_value($_POST['autoload']); $compass = $this->format->set_checkbox_on_value(@$_POST['compass']); $mouseZoom = $this->format->set_pro_checkbox_value(@$_POST['mouseZoom']); $draggable = $this->format->set_checkbox_value(@$_POST['draggable']); $gzoom = $this->format->set_pro_checkbox_value(@$_POST['gzoom']); $diskeyboard = $this->format->set_checkbox_value(@$_POST['diskeyboard']); $keyboardzoom = $this->format->set_checkbox_value(@$_POST['keyboardzoom']); $floor_plan_enabler = $this->format->set_pro_checkbox_value(@$_POST['wpvr_floor_plan_enabler']); $floor_plan_image = isset($_POST['wpvr_floor_plan_image']) ? $_POST['wpvr_floor_plan_image'] : ''; $scene_fade_duration = sanitize_text_field($_POST['scenefadeduration']); $preview = esc_url($_POST['preview']); $default_scene = ''; $rotation = sanitize_text_field($_POST['rotation']); $autorotation = sanitize_text_field($_POST['autorotation']); $autorotationinactivedelay = sanitize_text_field($_POST['autorotationinactivedelay']); $autorotationstopdelay = sanitize_text_field($_POST['autorotationstopdelay']); $default_global_zoom = ''; $max_global_zoom = ''; $min_global_zoom = ''; if ($gzoom == 'on') { $default_global_zoom = $_POST['dzoom']; $max_global_zoom = $_POST['maxzoom']; $min_global_zoom = $_POST['minzoom']; } $default_scene = $this->format->prepare_default_scene($panodata); $this->validator->basic_setting_validation($autorotationinactivedelay, $autorotationstopdelay); // Basic setting error control and validation // $this->validator->scene_validation($panodata); // Scene content error control and validation // $this->validator->empty_scene_validation($panodata); // Empty scene content error control and validation // $this->validator->duplicate_hotspot_validation($panodata); if($floor_plan_enabler == 'on'){ $this->validator->empty_floor_plan_image_validation($floor_plan_image); } $default_data = array(); if ($gzoom == 'on') { $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration, "hfov" => $default_global_zoom, "maxHfov" => $max_global_zoom, "minHfov" => $min_global_zoom); } else { $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration); } $scene_data = $this->format->prepare_scene_data_for_preview($panodata); $pano_id_array = array(); $pano_id_array = array("panoid" => $panoid); $pano_response = array(); $pano_response = array("autoLoad" => $autoload, "defaultZoom" => $default_global_zoom, "minZoom" => $min_global_zoom, "maxZoom" => $max_global_zoom, "showControls" => $control, "compass" => $compass, "mouseZoom" => $mouseZoom, "draggable" => $draggable, "disableKeyboardCtrl" => $diskeyboard, 'keyboardZoom' => $keyboardzoom, "preview" => $preview, "autoRotate" => $autorotation, "autoRotateInactivityDelay" => $autorotationinactivedelay, "autoRotateStopDelay" => $autorotationstopdelay, "default" => $default_data, "scenes" => $scene_data); $pano_response = $this->format->prepare_rotation_wrapper_data($pano_response, $rotation); $is_pro = apply_filters('is_wpvr_pro_active',false); $status = get_option('wpvr_edd_license_status'); $pano_floor_plan = array(); $call_to_action = array(); if ($status !== false && 'valid' == $status && $is_pro) { $pano_floor_plan = array( "floor_plan_tour_enabler" => $floor_plan_enabler, "floor_plan_attachment_url" => $floor_plan_image ); $call_to_action = array( 'button_enable' =>sanitize_text_field($_POST['callToAction']), 'button_text' =>sanitize_text_field($_POST['buttontext']), 'button_url' =>sanitize_text_field($_POST['buttonurl']) ); } $response = array(); $response = array($pano_id_array, $pano_response, $panovideo,$pano_floor_plan,$call_to_action); wp_send_json_success($response); } /** * Render shortcode for scene and hotspot post data * * @param array $postdata * @param string $panoid * @param integer $id * @param mixed $radius * @param mixed $width * @param mixed $height * * @return string * @since 8.0.0 */ public function render_scene_shortcode($postdata, $panoid, $id, $radius, $width, $height, $mobile_height) { $control = false; if (isset($postdata['showControls'])) { $control = $postdata['showControls']; } if ($control) { if (isset($postdata['customcontrol'])) { $custom_control = $postdata['customcontrol']; 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") { $control = false; } } } $vrgallery = false; if (isset($postdata['vrgallery'])) { $vrgallery = $postdata['vrgallery']; } $vrgallery_title = false; if (isset($postdata['vrgallery_title'])) { $vrgallery_title = $postdata['vrgallery_title']; } $vrgallery_display = false; if (isset($postdata['vrgallery_display'])) { $vrgallery_display = $postdata['vrgallery_display']; } $vrgallery_icon_size = false; if (isset($postdata['vrgallery_icon_size'])) { $vrgallery_icon_size = $postdata['vrgallery_icon_size']; } $gyro = false; $gyro_orientation = false; if (isset($postdata['gyro'])) { $gyro = $postdata['gyro']; if (isset($postdata['deviceorientationcontrol'])) { $gyro_orientation = $postdata['deviceorientationcontrol']; } } //== Floor plan handle ==// $floor_plan_enable = 'off'; $floor_plan_image = ''; if (isset($postdata['floor_plan_tour_enabler']) && $postdata['floor_plan_tour_enabler'] == 'on'){ $floor_plan_enable = $postdata['floor_plan_tour_enabler']; if(isset($postdata['floor_plan_attachment_url']) && !empty($postdata['floor_plan_attachment_url'])){ $floor_plan_image = $postdata['floor_plan_attachment_url']; } } $compass = false; $audio_right = "5px"; if (isset($postdata['compass'])) { $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false; if ($compass) { $audio_right = "60px"; } } $floor_map_right = "10px"; if((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')){ $floor_map_right = "85px"; }elseif(isset($postdata['compass']) && $postdata['compass'] == 'on'){ $floor_map_right = "55px"; }elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") { $floor_map_right = "25px"; } //===explainer handle===// $explainer_right = "10px"; if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ( $floor_plan_enable == 'on' && !empty($floor_plan_image) ) ) { $explainer_right = "130px"; } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on' && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) { $explainer_right = "100px"; } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) { $explainer_right = "60px"; } elseif((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') ) { $explainer_right = "80px"; }elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') { $explainer_right = "55px"; } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") { $explainer_right = "30px"; } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image) ) { $explainer_right = "40px"; } $enable_cardboard = ''; $is_cardboard = get_option('wpvr_cardboard_disable'); if(wpvr_isMobileDevice() && $is_cardboard == 'true' ){ $enable_cardboard = 'enable-cardboard'; $audio_right = "73px"; if (isset($postdata['compass'])) { $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false; if ($compass) { $audio_right = "130px"; } } //===Floor plan handle===// $floor_map_right = "60px"; if((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')){ $floor_map_right = "150px"; }elseif(isset($postdata['compass']) && $postdata['compass'] == 'on'){ $floor_map_right = "120px"; }elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") { $floor_map_right = "90px"; } //===explainer handle===// $explainer_right = "65px"; if ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) { $explainer_right = "150px"; } elseif((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) { $explainer_right = "180px"; } elseif (isset($postdata['compass']) && $postdata['compass'] == true && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) { $explainer_right = "150px"; } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) { $explainer_right = "120px"; }elseif (isset($postdata['compass']) && $postdata['compass'] == true) { $explainer_right = "130px"; } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") { $explainer_right = "90px"; }elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image) ) { $explainer_right = "90px"; } } //===explainer handle===// $mouseZoom = true; if (isset($postdata['mouseZoom'])) { if($postdata['mouseZoom'] == "off") { $mouseZoom = false; } else { $mouseZoom = true; } } $draggable = true; if (isset($postdata['draggable'])) { $draggable = $postdata['draggable'] == 'off' || $postdata['draggable'] == null ? false : true; } $diskeyboard = false; if (isset($postdata['diskeyboard'])) { $diskeyboard = $postdata['diskeyboard'] == 'off' || $postdata['diskeyboard'] == null ? false : true; } $keyboardzoom = true; if (isset($postdata['keyboardzoom'])) { $keyboardzoom = $postdata['keyboardzoom']; } $autoload = false; if (isset($postdata['autoLoad'])) { $autoload = $postdata['autoLoad']; } $default_scene = ''; if (isset($postdata['defaultscene'])) { $default_scene = $postdata['defaultscene']; } $default_global_zoom = ''; if (isset($postdata['hfov'])) { $default_global_zoom = $postdata['hfov']; } $max_global_zoom = ''; if (isset($postdata['maxHfov'])) { $max_global_zoom = $postdata['maxHfov']; } $min_global_zoom = ''; if (isset($postdata['minHfov'])) { $min_global_zoom = $postdata['minHfov']; } $preview = ''; if (isset($postdata['preview'])) { $preview = $postdata['preview']; } $autorotation = ''; if (isset($postdata["autoRotate"])) { $autorotation = $postdata["autoRotate"]; } $autorotationinactivedelay = ''; if (isset($postdata["autoRotateInactivityDelay"])) { $autorotationinactivedelay = $postdata["autoRotateInactivityDelay"]; } $autorotationstopdelay = ''; if (isset($postdata["autoRotateStopDelay"])) { $autorotationstopdelay = $postdata["autoRotateStopDelay"]; } $scene_fade_duration = ''; if (isset($postdata['scenefadeduration'])) { $scene_fade_duration = $postdata['scenefadeduration']; } $panodata = ''; if (isset($postdata['panodata'])) { $panodata = $postdata['panodata']; } $hotspoticoncolor = '#00b4ff'; $hotspotblink = 'on'; $default_data = array(); if ($default_global_zoom != '' && $max_global_zoom != '' && $min_global_zoom != '') { $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration, "hfov" => $default_global_zoom, "maxHfov" => $max_global_zoom, "minHfov" => $min_global_zoom); } else { $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration); } $scene_data = array(); if (!empty($panodata["scene-list"])) { foreach ($panodata["scene-list"] as $panoscenes) { $scene_ititle = ''; if (isset($panoscenes["scene-ititle"])) { $scene_ititle = sanitize_text_field($panoscenes["scene-ititle"]); } $scene_author = ''; if (isset($panoscenes["scene-author"])) { $scene_author = sanitize_text_field($panoscenes["scene-author"]); } $scene_author_url = ''; if (isset($panoscenes["scene-author-url"])) { $scene_author_url = sanitize_text_field($panoscenes["scene-author-url"]); } $scene_vaov = 180; if (isset($panoscenes["scene-vaov"])) { $scene_vaov = (float)$panoscenes["scene-vaov"]; } $scene_haov = 360; if (isset($panoscenes["scene-haov"])) { $scene_haov = (float)$panoscenes["scene-haov"]; } $scene_vertical_offset = 0; if (isset($panoscenes["scene-vertical-offset"])) { $scene_vertical_offset = (float)$panoscenes["scene-vertical-offset"]; } $default_scene_pitch = null; if (isset($panoscenes["scene-pitch"])) { $default_scene_pitch = (float)$panoscenes["scene-pitch"]; } $default_scene_yaw = null; if (isset($panoscenes["scene-yaw"])) { $default_scene_yaw = (float)$panoscenes["scene-yaw"]; } $scene_max_pitch = ''; if (isset($panoscenes["scene-maxpitch"])) { $scene_max_pitch = (float)$panoscenes["scene-maxpitch"]; } $scene_min_pitch = ''; if (isset($panoscenes["scene-minpitch"])) { $scene_min_pitch = (float)$panoscenes["scene-minpitch"]; } $scene_max_yaw = ''; if (isset($panoscenes["scene-maxyaw"])) { $scene_max_yaw = (float)$panoscenes["scene-maxyaw"]; } $scene_min_yaw = ''; if (isset($panoscenes["scene-minyaw"])) { $scene_min_yaw = (float)$panoscenes["scene-minyaw"]; } $default_zoom = 100; if (isset($panoscenes["scene-zoom"]) && $panoscenes["scene-zoom"] != "") { $default_zoom = $panoscenes["scene-zoom"]; } else { if ($default_global_zoom != '') { $default_zoom = (int)$default_global_zoom; } } $max_zoom = 120; if (isset($panoscenes["scene-maxzoom"]) && $panoscenes["scene-maxzoom"] != '') { $max_zoom = (int)$panoscenes["scene-maxzoom"]; } else { if ($max_global_zoom != '') { $max_zoom = (int)$max_global_zoom; } } $min_zoom = 50; if (isset($panoscenes["scene-minzoom"]) && $panoscenes["scene-minzoom"] != '') { $min_zoom = (int)$panoscenes["scene-minzoom"]; } else { if ($min_global_zoom != '') { $min_zoom = (int)$min_global_zoom; } } $hotspot_datas = array(); if (isset($panoscenes["hotspot-list"])) { $hotspot_datas = $panoscenes["hotspot-list"]; } $hotspots = array(); foreach ($hotspot_datas as $hotspot_data) { $status = get_option('wpvr_edd_license_status'); if ($status !== false && $status == 'valid') { if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') { $hotspot_data['hotspot-customclass'] = $hotspot_data["hotspot-customclass-pro"] . ' custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. $hotspot_data['hotspot-title']; } if (isset($hotspot_data['hotspot-blink'])) { $hotspotblink = $hotspot_data['hotspot-blink']; } } $hotspot_scene_pitch = ''; if (isset($hotspot_data["hotspot-scene-pitch"])) { $hotspot_scene_pitch = $hotspot_data["hotspot-scene-pitch"]; } $hotspot_scene_yaw = ''; if (isset($hotspot_data["hotspot-scene-yaw"])) { $hotspot_scene_yaw = $hotspot_data["hotspot-scene-yaw"]; } $hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"]; $hotspot_content = ''; ob_start(); do_action('wpvr_hotspot_content', $hotspot_data); $hotspot_content = ob_get_clean(); if (!$hotspot_content) { $hotspot_content = $hotspot_data["hotspot-content"]; } if (isset($hotspot_data["wpvr_url_open"][0])) { $wpvr_url_open = $hotspot_data["wpvr_url_open"][0]; } else { $wpvr_url_open = "off"; } $on_hover_content = preg_replace_callback('/