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(); ?>
render_scene_repeater_list($postdata); ?>
render_default_repeater_item(); ?>
render_repeater_item_with_panodata($pano_scene, $s); ?>

render_default_repeater_item_scene_content(); ?>
hotspot->render_hotspot($s = 0, $h =1)?>

render_repeater_scene_content_with_data($pano_scene); ?>
render_repeater_item_hotspot_content($pano_scene, $s); ?>
hotspot->render_hotspot_with_panodata($pano_scene['hotspot-list'], $s); //Render hotspot while scene has hotspot data ?>
hotspot->render_hotspot($s, $h = 1); //Render hotspot while scene has no hotspot data ?>
format->prepare_panodata($_POST['panodata']); $default_scene = $this->format->prepare_default_scene($panodata); $previewtext = $this->validator->preview_text_validation($_POST['previewtext']); $gzoom = $this->format->set_pro_checkbox_value(@$_POST['gzoom']); $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']; } $custom_control = isset($_POST['customcontrol']) ? $_POST['customcontrol'] : null; $vrgallery = $this->format->set_checkbox_value(@$_POST['vrgallery']); $vrgallery_title = $this->format->set_checkbox_value(@$_POST['vrgallery_title']); $vrgallery_display = $this->format->set_checkbox_value(@$_POST['vrgallery_display']); $vrgallery_icon_size = $this->format->set_checkbox_value(@$_POST['vrgallery_icon_size']); $mouseZoom = $this->format->set_pro_checkbox_value(@$_POST['mouseZoom']); $draggable = $this->format->set_pro_checkbox_value(@$_POST['draggable']); $diskeyboard = $this->format->set_pro_checkbox_value(@$_POST['diskeyboard']); $keyboardzoom = $this->format->set_checkbox_value(@$_POST['keyboardzoom']); $compass = $this->format->set_checkbox_on_value(@$_POST['compass']); //===Gyroscopre control===// $gyro = $this->format->set_pro_checkbox_value(@$_POST['gyro']); if ($gyro == 'on') { if (!is_ssl()) { wp_send_json_error('

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===// if(isset($_POST['rotation']) && sanitize_text_field($_POST['rotation']) === 'on' ) { $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) ) ); /** * Delete orphaned analytics data * * @param integer $postid POST ID * * @return void * @since 8.5.16 */ do_action('wpvr_pro_delete_orphaned_analytics_data', $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'] ?? null); $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); if(isset($_POST['rotation']) && sanitize_text_field($_POST['rotation']) === 'on' ) { $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) { do_action('rex_wpvr_embadded_tour', $id, 'scene'); $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( '/

\s*(]*>)\s*
\s*<\/p>/i', function ($matches) { return $matches[1]; }, $hotspot_data['hotspot-hover'] ?? '' ); $on_hover_content = $this->sanitize_content_preserve_styles($on_hover_content ?? ''); $on_click_content = preg_replace_callback('/]*>/', "replace_callback", $hotspot_content ?? ''); $hotspot_shape = 'round'; if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') { $hotspot_shape = isset($hotspot_data["hotspot-shape"]) ? $hotspot_data["hotspot-shape"] : 'round'; } $hotspot_data_for_on_click=[]; if('info' === $hotspot_type && !empty($on_click_content)){ $hotspot_data_for_on_click = [ 'on_click_content' => $on_click_content, 'tour_id' => $id, 'scene_id' => $panoscenes['scene-id'], 'hotspot_id' => $hotspot_data['hotspot-title'], ]; } elseif('info' === $hotspot_type && !empty($hotspot_data["hotspot-url"])){ $hotspot_data_for_on_click = [ 'on_click_content' => '', 'tour_id' => $id, 'scene_id' => $panoscenes['scene-id'], 'hotspot_id' => $hotspot_data['hotspot-title'], ]; } $hotspot_info = array( "text" => $hotspot_data["hotspot-title"], "pitch" => $hotspot_data["hotspot-pitch"], "yaw" => $hotspot_data["hotspot-yaw"], "type" => $hotspot_type, "cssClass" => $hotspot_data["hotspot-customclass"], "URL" => $hotspot_data["hotspot-url"], "wpvr_url_open" => $wpvr_url_open, "clickHandlerArgs" => $hotspot_data_for_on_click, 'createTooltipArgs' => !empty(trim($on_hover_content)) ? trim($on_hover_content) : '', "sceneId" => $hotspot_data["hotspot-scene"], "targetPitch" => (float)$hotspot_scene_pitch, "targetYaw" => (float)$hotspot_scene_yaw, 'hotspot_type' => $hotspot_data['hotspot-type'], 'hotspot_target' => 'notBlank', 'hotspot_shape' => $hotspot_shape, ); $hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL']; if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') { unset($hotspot_info["cssClass"]); } if (empty($hotspot_data["hotspot-scene"])) { unset($hotspot_info['targetPitch']); unset($hotspot_info['targetYaw']); } array_push($hotspots, $hotspot_info); } $device_scene = $panoscenes['scene-attachment-url']; $mobile_media_resize = get_option('mobile_media_resize'); $file_accessible = ini_get('allow_url_fopen'); if ($mobile_media_resize == "true" && $device_scene ) { if ($file_accessible == "1") { $image_info = getimagesize($device_scene); if ($image_info[0] > 4096) { $src_to_id_for_mobile = ''; $src_to_id_for_desktop = ''; if (wpvr_isMobileDevice()) { $src_to_id_for_mobile = attachment_url_to_postid($panoscenes['scene-attachment-url']); if ($src_to_id_for_mobile) { $mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile'); if ($mobile_scene[3]) { $device_scene = $mobile_scene[0]; } } } else { $src_to_id_for_desktop = attachment_url_to_postid($panoscenes['scene-attachment-url']); if ($src_to_id_for_desktop) { $desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full'); if (isset($desktop_scene[0])) { $device_scene = $desktop_scene[0]; } } } } } } $scene_info = array(); if ($panoscenes["scene-type"] == 'cubemap') { $pano_attachment = array( $panoscenes["scene-attachment-url-face0"], $panoscenes["scene-attachment-url-face1"], $panoscenes["scene-attachment-url-face2"], $panoscenes["scene-attachment-url-face3"], $panoscenes["scene-attachment-url-face4"], $panoscenes["scene-attachment-url-face5"] ); $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); } else { $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); } if (isset($panoscenes["ptyscene"])) { if ($panoscenes["ptyscene"] == "off") { unset($scene_info['pitch']); unset($scene_info['yaw']); } } if (empty($panoscenes["scene-ititle"])) { unset($scene_info['title']); } if (empty($panoscenes["scene-author"])) { unset($scene_info['author']); } if (empty($panoscenes["scene-author-url"])) { unset($scene_info['authorURL']); } if (empty($scene_vaov)) { unset($scene_info['vaov']); } if (empty($scene_haov)) { unset($scene_info['haov']); } if (empty($scene_vertical_offset)) { unset($scene_info['vOffset']); } if (isset($panoscenes["cvgscene"])) { if ($panoscenes["cvgscene"] == "off") { unset($scene_info['maxPitch']); unset($scene_info['minPitch']); } } if (empty($panoscenes["scene-maxpitch"])) { unset($scene_info['maxPitch']); } if (empty($panoscenes["scene-minpitch"])) { unset($scene_info['minPitch']); } if (isset($panoscenes["chgscene"])) { if ($panoscenes["chgscene"] == "off") { unset($scene_info['maxYaw']); unset($scene_info['minYaw']); } } if (empty($panoscenes["scene-maxyaw"])) { unset($scene_info['maxYaw']); } if (empty($panoscenes["scene-minyaw"])) { unset($scene_info['minYaw']); } // if (isset($panoscenes["czscene"])) { // if ($panoscenes["czscene"] == "off") { // unset($scene_info['hfov']); // unset($scene_info['maxHfov']); // unset($scene_info['minHfov']); // } // } $scene_array = array(); $scene_array = array( $panoscenes["scene-id"] => $scene_info ); $scene_data[$panoscenes["scene-id"]] = $scene_info; } } $pano_id_array = array(); $pano_id_array = array("panoid" => $panoid); $pano_response = array(); $pano_response = array("autoLoad" => $autoload, "showControls" => $control, "orientationSupport" => 'false', "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); if (empty($autorotation)) { unset($pano_response['autoRotate']); unset($pano_response['autoRotateInactivityDelay']); unset($pano_response['autoRotateStopDelay']); } if (empty($autorotationinactivedelay)) { unset($pano_response['autoRotateInactivityDelay']); } if (empty($autorotationstopdelay)) { unset($pano_response['autoRotateStopDelay']); } $response = array(); $response = array($pano_id_array, $pano_response); if (!empty($response)) { $response = json_encode($response); } if (empty($width)) { $width = '600px'; } if (empty($height)) { $height = '400px'; } $foreground_color = '#fff'; $pulse_color = wpvr_hex2rgb($hotspoticoncolor); $rgb = wpvr_HTMLToRGB($hotspoticoncolor); $hsl = wpvr_RGBToHSL($rgb); if ($hsl->lightness > 200) { $foreground_color = '#000000'; } else { $foreground_color = '#fff'; } $html = ''; $html .= ''; $scene_animation = isset($postdata['sceneAnimation']) ? $postdata['sceneAnimation'] : 'off'; if( $scene_animation === 'on'){ $animation_type = isset($postdata['sceneAnimationName']) ? $postdata['sceneAnimationName'] : 'none'; $animationDuration = isset($postdata['sceneAnimationTransitionDuration']) ? $postdata['sceneAnimationTransitionDuration'] : '500ms'; $animationDelay = isset($postdata['sceneAnimationTransitionDelay']) ? $postdata['sceneAnimationTransitionDelay'] : '0ms'; $animation_css = apply_filters('wpvr_tour_scene_animation',$animation_type,$animationDuration,$animationDelay,$postdata,$id); $html .= $animation_css; } if ($width == 'fullwidth') { $width = "100%"; } if (wpvr_isMobileDevice()) { $html .= '

'; } else { $html .= '
'; } $is_pro = apply_filters('is_wpvr_pro_active',false); $status = get_option('wpvr_edd_license_status'); $is_cardboard = get_option('wpvr_cardboard_disable'); if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true' ) { $html .= ''; $embed_mode = ''; if($width == "embed"){ $embed_mode = "vr-embade-mode"; } $html .= ''; } if ($width == 'fullwidth') { if (wpvr_isMobileDevice()) { $html .= '
'; $html .= '
'; $html .= '
'; } else { $html .= '
'; if ($radius) { $html .= '
'; } else { $html .= '
'; } } } elseif ($width == 'embed') { $html .= '
'; $html .= '
'; $html .= '
'; } else { if (wpvr_isMobileDevice()) { $html .= '
'; if ($radius) { $html .= '
'; } else { $html .= '
'; } } else { $html .= '
'; if ($radius) { $html .= '
'; } else { $html .= '
'; } } } // Vr mode transction scene to scene if ($status !== false && 'valid' == $status && $is_pro) { $html .= ''; } $social_logo_top = ''; //===company logo===// if (isset($postdata['cpLogoSwitch'])) { $cpLogoImg = $postdata['cpLogoImg']; $cpLogoContent = $postdata['cpLogoContent']; if ($postdata['cpLogoSwitch'] == 'on') { $html .= '
'; $html .= ''; $html .= '
'; } } //===company logo ends===// //===Generic Form===// if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on') { // Process shortcode with fallback handling $shortcode_content = ''; if (isset($postdata["genericformshortcode"]) && !empty(trim($postdata["genericformshortcode"]))) { $shortcode_content = do_shortcode($postdata["genericformshortcode"]); } else { $shortcode_content = '

No shortcode found.

'; } // Generate the form trigger button $html .= '
'; $html .= '
'; $html .= '
'; // Generate the modal form container $html .= ''; } //===Generic Form ends===// //===Background Tour===// if (isset($postdata['bg_tour_enabler'])) { $bg_tour_enabler = $postdata['bg_tour_enabler']; if ($bg_tour_enabler == 'on') { $bg_tour_navmenu = $postdata['bg_tour_navmenu'] ?? 'off'; $bg_tour_title = $postdata['bg_tour_title'] ?? ''; $bg_tour_subtitle = $postdata['bg_tour_subtitle'] ?? ''; if ($bg_tour_navmenu == 'on') { $menuLocations = get_nav_menu_locations(); if (!empty($menuLocations['primary'])) { $menuID = $menuLocations['primary']; $primaryNav = wp_get_nav_menu_items($menuID); $html .= '
    '; foreach ($primaryNav as $primaryNav_key => $primaryNav_value) { if ($primaryNav_value->menu_item_parent == "0") { $html .= '
  • '; $html .= '' . $primaryNav_value->title . ''; $html .= '
      '; foreach ($primaryNav as $pm_key => $pm_value) { if ($pm_value->menu_item_parent == $primaryNav_value->ID) { $html .= '
    • '; $html .= '' . $pm_value->title . ''; $html .= '
    • '; } } $html .= '
    '; $html .= '
  • '; } } $html .= '
'; } } $html .= '
'; $html .= '
' . $bg_tour_title . '
'; $html .= '
' . $bg_tour_subtitle . '
'; $html .= '
'; } } //===Background Tour End===// //===Custom Control===// if (isset($custom_control)) { if ($custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $custom_control['gyroscopeSwitch'] == "on" || $custom_control['backToHomeSwitch'] == "on") { $html .= '
'; if ($custom_control['backToHomeSwitch'] == "on") { $html .= '
'; } if ($custom_control['panZoomInSwitch'] == "on") { $html .= '
'; } if ($custom_control['panZoomOutSwitch'] == "on") { $html .= '
'; } if ($custom_control['gyroscopeSwitch'] == "on") { $html .= '
'; } $html .= '
'; } //===zoom in out Control===// if ($custom_control['panupSwitch'] == "on" || $custom_control['panDownSwitch'] == "on" || $custom_control['panLeftSwitch'] == "on" || $custom_control['panRightSwitch'] == "on" || $custom_control['panFullscreenSwitch'] == "on") { //===Custom Control===// $html .= '
'; if ($custom_control['panupSwitch'] == "on") { $html .= '
'; } if ($custom_control['panDownSwitch'] == "on") { $html .= '
'; } if ($custom_control['panLeftSwitch'] == "on") { $html .= '
'; } if ($custom_control['panRightSwitch'] == "on") { $html .= '
'; } if ($custom_control['panFullscreenSwitch'] == "on") { $html .= '
'; } $html .= '
'; } //===explainer button===// $explainerControlSwitch = ''; if (isset($custom_control['explainerSwitch'])) { $explainerControlSwitch = $custom_control['explainerSwitch']; } if ($explainerControlSwitch == "on") { $explainer_style = empty($postdata['explainerContent']) || ( isset( $postdata['explainerSwitch'] ) && 'off' === $postdata['explainerSwitch'] )? 'pointer-events: none; opacity: 0.5;' : ''; $html .= '
'; $html .= '
'; $html .= '
'; } //===explainer button===// } //===Custom Control===// //===Floor map button===// $status = get_option('wpvr_edd_license_status'); if ($status !== false && 'valid' == $status && $is_pro){ if ($floor_plan_enable == "on" && !empty($floor_plan_image)) { $html .= '
'; $html .= '
'; $html .= '
'; } } //===floor map button===// if ($vrgallery) { //===Carousal setup===// $size = ''; if($vrgallery_icon_size){ $size = 'vrg-icon-size-large'; } $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= ''; $html .= '
'; //===Carousal setup end===// } //===Call TO action Button===// $bg_music = isset($postdata['bg_music']) ? $postdata['bg_music'] : 'off'; $bg_music_url = isset($postdata['bg_music_url']) ? $postdata['bg_music_url'] : ''; $autoplay_bg_music = isset($postdata['autoplay_bg_music']) ? $postdata['autoplay_bg_music'] : 'off'; $loop_bg_music = isset($postdata['loop_bg_music']) ? $postdata['loop_bg_music'] : 'off'; $bg_loop = ($loop_bg_music === 'on') ? 'loop' : ''; $autoplay_attr = ($autoplay_bg_music === 'on') ? 'autoplay' : ''; $audio_muted_attr = ($autoplay_bg_music === 'on') ? 'muted' : ''; $audio_icon_class = 'fa-volume-mute'; // Always start with mute icon if ($bg_music === 'on') { $html .= '
'; $html .= ''; $html .= ''; $html .= '
'; } //===Explainer video section===// $explainerContent = ""; if (isset($postdata['explainerContent'])) { $explainerContent = $postdata['explainerContent']; } $html .= ''; //===Explainer video section End===// //===Scene navigation Control===// if (isset($postdata['scene_navigation']) && $postdata['scene_navigation'] === 'on') { $html .= ''; $html .= '
    '; } //===Scene navigation Control===// if( 'embed' === $width){ if(WPVR_Helper::is_enable_social_share($postdata) === 'on'){ $html .= ''; } } //===Floor plan section===// $floor_map_image = ""; $floor_map_pointer = array(); $floor_map_scene_id = ''; $floor_plan_custom_color = '#cca92c'; if (isset($postdata['floor_plan_attachment_url'])) { $floor_map_image = $postdata['floor_plan_attachment_url']; $floor_map_pointer = $postdata['floor_plan_pointer_position']; $floor_map_scene_id = $postdata['floor_plan_data_list']; $floor_plan_custom_color = $postdata['floor_plan_custom_color']; } $html .= ''; //===Floor plan section===// $html .= ''; $html .= ''; $html .= '
    '; $html .= '
    '; if( "embed" == $width ){ $html .= '
    '; } if ($status !== false && 'valid' == $status && $is_pro) { $call_to_action = isset($postdata['calltoaction']) ? $postdata['calltoaction'] : 'off'; if( 'on' == $call_to_action){ $buttontext = isset($postdata['buttontext']) ? $postdata['buttontext'] : ''; $buttonurl = isset($postdata['buttonurl']) ? $postdata['buttonurl'] : ''; $cta_btn_style = isset($postdata['button_configuration']) ? $postdata['button_configuration'] : array(); $button_open_new_tab = isset($cta_btn_style['button_open_new_tab']) ? $cta_btn_style['button_open_new_tab'] : "off"; $target = '_self'; $button_position = isset($cta_btn_style['button_position']) ? $cta_btn_style['button_position'] : ""; $background_color = isset($cta_btn_style['button_background_color']) ? $cta_btn_style['button_background_color'] : ""; $color = isset($cta_btn_style['button_font_color']) ? $cta_btn_style['button_font_color'] : ""; $font_size = isset($cta_btn_style['button_font_size']) ? $cta_btn_style['button_font_size'] : ""; $font_weight = isset($cta_btn_style['button_font_weight']) ? $cta_btn_style['button_font_weight'] : ""; $text_align = isset($cta_btn_style['button_alignment']) ? $cta_btn_style['button_alignment'] : ""; $text_transform = isset($cta_btn_style['button_transform']) ? $cta_btn_style['button_transform'] : ""; $font_style = isset($cta_btn_style['button_text_style']) ? $cta_btn_style['button_text_style'] : ""; $text_decoration = isset($cta_btn_style['button_text_decoration']) ? $cta_btn_style['button_text_decoration'] : ""; $line_height = isset($cta_btn_style['button_line_height']) ? $cta_btn_style['button_line_height'] : ""; $letter_spacing = isset($cta_btn_style['button_letter_spacing']) ? $cta_btn_style['button_letter_spacing'] : ""; $word_spacing = isset($cta_btn_style['button_word_spacing']) ? $cta_btn_style['button_word_spacing'] : ""; $border_width = isset($cta_btn_style['button_border_width']) ? $cta_btn_style['button_border_width'] : ""; $border_style = isset($cta_btn_style['button_border_style']) ? $cta_btn_style['button_border_style'] : ""; $border_color = isset($cta_btn_style['button_border_color']) ? $cta_btn_style['button_border_color'] : ""; $border_radius = isset($cta_btn_style['button_border_radius']) ? $cta_btn_style['button_border_radius'] : ""; $button_pt = isset($cta_btn_style['button_pt']) ? $cta_btn_style['button_pt'] : ""; $button_pr = isset($cta_btn_style['button_pr']) ? $cta_btn_style['button_pr'] : ""; $button_pb = isset($cta_btn_style['button_pb']) ? $cta_btn_style['button_pb'] : ""; $button_pl = isset($cta_btn_style['button_pl']) ? $cta_btn_style['button_pl'] : ""; if($button_open_new_tab == 'on'){ $target = '_blank'; } $style = 'background-color: '.$background_color.'; color: '.$color.'; font-size: '.$font_size.'px; font-weight: '.$font_weight.'; text-align: center; display: inline-block; text-transform: '.$text_transform.'; font-style: '.$font_style.'; text-decoration: '.$text_decoration.'; line-height: '.$line_height.'; letter-spacing: '.$letter_spacing.'px; word-spacing: '.$word_spacing.'px; border: '.$border_width.'px '.$border_style.' '.$border_color.'; border-radius: '.$border_radius.'px; padding: '.$button_pt.'px '.$button_pr.'px '.$button_pb.'px '.$button_pl.'px; '; $html .= ''; } } //script started $html .= ''; $tour_data = []; if(defined("WPVR_PRO_VERSION")){ $tour_data = array( 'explainerControlSwitch' => $explainerControlSwitch ?? '', 'floor_plan_enable' => $floor_plan_enable ?? '', 'floor_plan_image' => $floor_plan_image ?? '', 'custom_control' => $custom_control ?? '', ); } ob_start(); echo $html; $output = ob_get_clean(); return apply_filters('wpvr_generate_tour_layout_html', $output ,$postdata ,$id, $tour_data); } function replace_callback($matches){ foreach ($matches as $match){ return str_replace(']*>.*?<\/script>/si', '', $content); $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*javascript:/i', '$1=""', $content); $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*vbscript:/i', '$1=""', $content); $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*data:/i', '$1=""', $content); $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*about:/i', '$1=""', $content); $content = preg_replace('/\s*on\w+\s*=\s*["\'][^"\']*["\']/i', '', $content); $content = preg_replace('/\s*on\w+\s*=\s*[^>\s]+/i', '', $content); $content = preg_replace('/<(object|embed|applet|iframe|frame|frameset|meta|link|base|form|input|button|textarea|select|option)\b[^>]*>/i', '', $content); $content = preg_replace('/<\/(object|embed|applet|iframe|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content); $content = preg_replace_callback('/style\s*=\s*["\']([^"\']*)["\']/', function($matches) { $style = $matches[1]; $style = preg_replace('/expression\s*\(/i', '', $style); $style = preg_replace('/javascript\s*:/i', '', $style); $style = preg_replace('/vbscript\s*:/i', '', $style); $style = preg_replace('/about\s*:/i', '', $style); $style = preg_replace('/url\s*\(\s*["\']?\s*javascript:/i', '', $style); $style = preg_replace('/url\s*\(\s*["\']?\s*vbscript:/i', '', $style); $style = preg_replace('/url\s*\(\s*["\']?\s*data:/i', '', $style); $style = preg_replace('/import\s*["\']?\s*javascript:/i', '', $style); $style = preg_replace('/behavior\s*:/i', '', $style); $style = preg_replace('/-moz-binding\s*:/i', '', $style); return 'style="' . $style . '"'; }, $content); $content = preg_replace_callback('/]*>(.*?)<\/style>/si', function($matches) { $css = $matches[1]; $css = preg_replace('/expression\s*\(/i', '', $css); $css = preg_replace('/javascript\s*:/i', '', $css); $css = preg_replace('/vbscript\s*:/i', '', $css); $css = preg_replace('/about\s*:/i', '', $css); $css = preg_replace('/url\s*\(\s*["\']?\s*javascript:/i', '', $css); $css = preg_replace('/url\s*\(\s*["\']?\s*vbscript:/i', '', $css); $css = preg_replace('/url\s*\(\s*["\']?\s*data:/i', '', $css); $css = preg_replace('/import\s*["\']?\s*javascript:/i', '', $css); $css = preg_replace('/behavior\s*:/i', '', $css); $css = preg_replace('/-moz-binding\s*:/i', '', $css); return ''; }, $content); $content = preg_replace('/\s*srcdoc\s*=\s*["\'][^"\']*["\']/i', '', $content); $content = preg_replace('/\s*formaction\s*=\s*["\'][^"\']*["\']/i', '', $content); $content = preg_replace('/\s*action\s*=\s*["\'][^"\']*["\']/i', '', $content); $content = preg_replace('/<[^>]*script[^>]*>/i', '', $content); $content = preg_replace('/<[^>]*\s+on\w+\s*=[^>]*>/i', '', $content); $content = preg_replace('//s', '', $content); $content = preg_replace('/\beval\s*\(/i', '', $content); $content = preg_replace('/\bsetTimeout\s*\(/i', '', $content); $content = preg_replace('/\bsetInterval\s*\(/i', '', $content); $content = preg_replace('/<\/(script|object|embed|applet|iframe|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content); $allowed_tags = wp_kses_allowed_html('post'); $allowed_tags['img'] = array( 'src' => true, 'alt' => true, 'title' => true, 'width' => true, 'height' => true, 'class' => true, 'id' => true, 'style' => true, 'loading' => true, 'srcset' => true, 'sizes' => true ); $result = wp_kses($content, $allowed_tags); return $result; } }