| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 3 |
/** |
| 4 |
* Responsible for managing WPVR data formation |
| 5 |
* |
| 6 |
* @link http://rextheme.com/ |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package Wpvr |
| 10 |
* @subpackage Wpvr/admin/views |
| 11 |
*/ |
| 12 |
|
| 13 |
class WPVR_Format |
| 14 |
{ |
| 15 |
|
| 16 |
/** |
| 17 |
* Setup checkboxes values for meta fields |
| 18 |
* @param string $arg |
| 19 |
* |
| 20 |
* @return bool |
| 21 |
* @since 8.0.0 |
| 22 |
*/ |
| 23 |
public function set_checkbox_value($arg) |
| 24 |
{ |
| 25 |
$data = sanitize_text_field($arg); |
| 26 |
if ($data == 'off') { |
| 27 |
return $data = false; |
| 28 |
} else { |
| 29 |
return $data = true; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
/** |
| 35 |
* Setup checkboxes values for meta fields while default value is on |
| 36 |
* @param string $arg |
| 37 |
* |
| 38 |
* @return bool |
| 39 |
* @since 8.0.0 |
| 40 |
*/ |
| 41 |
public function set_checkbox_on_value($arg) |
| 42 |
{ |
| 43 |
$data = sanitize_text_field($arg); |
| 44 |
if ($data == 'on') { |
| 45 |
return $data = true; |
| 46 |
} else { |
| 47 |
return $data = false; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
/** |
| 53 |
* Setup checkboxes values for pro version meta fields |
| 54 |
* @param string $arg |
| 55 |
* |
| 56 |
* @return bool |
| 57 |
* @since 8.0.0 |
| 58 |
*/ |
| 59 |
public function set_pro_checkbox_value($arg) |
| 60 |
{ |
| 61 |
$data = sanitize_text_field($arg); |
| 62 |
if ($data == 'on') { |
| 63 |
return $data = 'on'; |
| 64 |
} else { |
| 65 |
return $data = 'off'; |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
/** |
| 71 |
* Preapre default scene ID for Tour |
| 72 |
* @param array $panodata |
| 73 |
* |
| 74 |
* @return string |
| 75 |
* @since 8.0.0 |
| 76 |
*/ |
| 77 |
public function prepare_default_scene($panodata) |
| 78 |
{ |
| 79 |
$allsceneids = array(); |
| 80 |
|
| 81 |
foreach ($panodata["scene-list"] as $panoscenes) { |
| 82 |
if (!empty($panoscenes['scene-id'])) { |
| 83 |
array_push($allsceneids, $panoscenes['scene-id']); |
| 84 |
} |
| 85 |
if ($panoscenes['dscene'] == 'on') { |
| 86 |
return $default_scene = $panoscenes['scene-id']; |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
if (empty($default_scene)) { |
| 91 |
if ($allsceneids) { |
| 92 |
return $default_scene = $allsceneids[0]; |
| 93 |
} |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
|
| 98 |
/** |
| 99 |
* Prepare panaromic data for Tour |
| 100 |
* |
| 101 |
* @param string $panodata |
| 102 |
* |
| 103 |
* @return array |
| 104 |
* @since 8.0.0 |
| 105 |
*/ |
| 106 |
public function prepare_panodata($panodata) |
| 107 |
{ |
| 108 |
$panolist = stripslashes($panodata); |
| 109 |
$panodata = (array)json_decode($panolist); |
| 110 |
$panolist = array(); |
| 111 |
if (is_array($panodata["scene-list"])) { |
| 112 |
foreach ($panodata["scene-list"] as $scenes_data) { |
| 113 |
$temp_array = array(); |
| 114 |
$temp_array = (array)$scenes_data; |
| 115 |
|
| 116 |
if ($temp_array['hotspot-list']) { |
| 117 |
$_hotspot_array = array(); |
| 118 |
foreach ($temp_array['hotspot-list'] as $temp_hotspot) { |
| 119 |
|
| 120 |
$temp_hotspot = (array)$temp_hotspot; |
| 121 |
$_hotspot_array[] = $temp_hotspot; |
| 122 |
} |
| 123 |
} |
| 124 |
|
| 125 |
$temp_array['hotspot-list'] = $_hotspot_array; |
| 126 |
$panolist['scene-list'][] = $temp_array; |
| 127 |
} |
| 128 |
} |
| 129 |
$panodata = $panolist; |
| 130 |
return $panodata; |
| 131 |
} |
| 132 |
|
| 133 |
|
| 134 |
/** |
| 135 |
* Remove empty scene and hotspot from panaromic data list |
| 136 |
* |
| 137 |
* @param array $panodata |
| 138 |
* |
| 139 |
* @return array |
| 140 |
* @since 8.0.0 |
| 141 |
*/ |
| 142 |
public function remove_empty_scene_and_hotspot($panodata) |
| 143 |
{ |
| 144 |
$panolength = count($panodata["scene-list"]); |
| 145 |
for ($i = 0; $i < $panolength; $i++) { |
| 146 |
if (empty($panodata["scene-list"][$i]['scene-id'])) { |
| 147 |
unset($panodata["scene-list"][$i]); |
| 148 |
} else { |
| 149 |
$panohotspotlength = count($panodata["scene-list"][$i]['hotspot-list']); |
| 150 |
for ($j = 0; $j < $panohotspotlength; $j++) { |
| 151 |
if (empty($panodata["scene-list"][$i]['hotspot-list'][$j]['hotspot-title'])) { |
| 152 |
unset($panodata["scene-list"][$i]['hotspot-list'][$j]); |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
} |
| 157 |
return $panodata; |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
/** |
| 162 |
* Prepare tour rotation wrapper data |
| 163 |
* |
| 164 |
* @param array $pano_array |
| 165 |
* @param string $rotation |
| 166 |
* |
| 167 |
* @return array |
| 168 |
* @since 8.0.0 |
| 169 |
*/ |
| 170 |
public function prepare_rotation_wrapper_data($pano_array, $rotation) |
| 171 |
{ |
| 172 |
if ($rotation == 'off') { |
| 173 |
unset($pano_array['autoRotate']); |
| 174 |
unset($pano_array['autoRotateInactivityDelay']); |
| 175 |
unset($pano_array['autoRotateStopDelay']); |
| 176 |
} |
| 177 |
if (empty($pano_array['autoRotate'])) { |
| 178 |
unset($pano_array['autoRotate']); |
| 179 |
unset($pano_array['autoRotateInactivityDelay']); |
| 180 |
unset($pano_array['autoRotateStopDelay']); |
| 181 |
} |
| 182 |
if (empty($pano_array['autoRotateInactivityDelay'])) { |
| 183 |
unset($pano_array['autoRotateInactivityDelay']); |
| 184 |
} |
| 185 |
if (empty($pano_array['autoRotateStopDelay'])) { |
| 186 |
unset($pano_array['autoRotateStopDelay']); |
| 187 |
} |
| 188 |
return $pano_array; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
public function prepare_video_settings_data() |
| 193 |
{ |
| 194 |
$autoplay = ''; |
| 195 |
if (isset($_POST['autoplay'])) { |
| 196 |
$autoplay = sanitize_text_field($_POST['autoplay']); |
| 197 |
} |
| 198 |
|
| 199 |
$loop = ''; |
| 200 |
if (isset($_POST['loop'])) { |
| 201 |
$loop = sanitize_text_field($_POST['loop']); |
| 202 |
} |
| 203 |
|
| 204 |
return array( |
| 205 |
'autoplay' => $autoplay, |
| 206 |
'loop' => $loop |
| 207 |
); |
| 208 |
} |
| 209 |
|
| 210 |
|
| 211 |
/** |
| 212 |
* Prepare meta data when video url has youtube |
| 213 |
* |
| 214 |
* @param string $videourl |
| 215 |
* |
| 216 |
* @return string |
| 217 |
* @since 8.0.0 |
| 218 |
*/ |
| 219 |
public function prepare_youtube_video_meta_data($videourl, $videodata) |
| 220 |
{ |
| 221 |
$explodeid = ''; |
| 222 |
$explodeid = explode("=", $videourl); |
| 223 |
|
| 224 |
if ($videodata['autoplay'] == 'on') { |
| 225 |
$autoplay = '&autoplay=1'; |
| 226 |
} else { |
| 227 |
$autoplay = ''; |
| 228 |
} |
| 229 |
|
| 230 |
if ($videodata['loop'] == 'on') { |
| 231 |
$loop = '&loop=1'; |
| 232 |
} else { |
| 233 |
$loop = ''; |
| 234 |
} |
| 235 |
|
| 236 |
$foundid = ''; |
| 237 |
$foundid = $explodeid[1] . '?' . $autoplay . $loop; |
| 238 |
$html = ''; |
| 239 |
$html .= '<iframe width="600" height="400" src="https://www.youtube.com/embed/' . $foundid . '" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'; |
| 240 |
return $html; |
| 241 |
} |
| 242 |
|
| 243 |
/** |
| 244 |
* Prepare meta data when video url has youtu.be |
| 245 |
* |
| 246 |
* @param string $videourl |
| 247 |
* |
| 248 |
* @return string |
| 249 |
* @since 8.0.0 |
| 250 |
*/ |
| 251 |
public function prepare_youtu_be_video_meta_data($videourl, $videodata) |
| 252 |
{ |
| 253 |
$explodeid = ''; |
| 254 |
$explodeid = explode("/", $videourl); |
| 255 |
|
| 256 |
if ($videodata['autoplay'] == 'on') { |
| 257 |
$autoplay = '&autoplay=1'; |
| 258 |
} else { |
| 259 |
$autoplay = ''; |
| 260 |
} |
| 261 |
|
| 262 |
if ($videodata['loop'] == 'on') { |
| 263 |
$loop = '&loop=1'; |
| 264 |
} else { |
| 265 |
$loop = ''; |
| 266 |
} |
| 267 |
|
| 268 |
$foundid = ''; |
| 269 |
$foundid = $explodeid[3] . '?' . $autoplay . $loop; |
| 270 |
$html = ''; |
| 271 |
$html .= '<iframe width="600" height="400" src="https://www.youtube.com/embed/' . $foundid . '" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'; |
| 272 |
return $html; |
| 273 |
} |
| 274 |
|
| 275 |
/** |
| 276 |
* Prepare meta data when video url has vimeo |
| 277 |
* |
| 278 |
* @param string $videourl |
| 279 |
* |
| 280 |
* @return string |
| 281 |
* @since 8.0.0 |
| 282 |
*/ |
| 283 |
public function prepare_vimeo_video_meta_data($videourl, $videodata) |
| 284 |
{ |
| 285 |
$explodeid = ''; |
| 286 |
$explodeid = explode("/", $videourl); |
| 287 |
|
| 288 |
if ($videodata['autoplay'] == 'on') { |
| 289 |
$autoplay = '&autoplay=1&muted=1'; |
| 290 |
} else { |
| 291 |
$autoplay = ''; |
| 292 |
} |
| 293 |
|
| 294 |
if ($videodata['loop'] == 'on') { |
| 295 |
$loop = '&loop=1'; |
| 296 |
} else { |
| 297 |
$loop = ''; |
| 298 |
} |
| 299 |
|
| 300 |
$foundid = ''; |
| 301 |
$foundid = $explodeid[3] . '?' . $autoplay . $loop; |
| 302 |
$html = ''; |
| 303 |
$html .= '<iframe src="https://player.vimeo.com/video/' . $foundid . '" width="600" height="400" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; |
| 304 |
return $html; |
| 305 |
} |
| 306 |
|
| 307 |
/** |
| 308 |
* Prepare meta data when video is selfhosted |
| 309 |
* |
| 310 |
* @param string $videourl |
| 311 |
* |
| 312 |
* @return string |
| 313 |
* @since 8.0.0 |
| 314 |
*/ |
| 315 |
public function prepare_selfhost_video_meta_data($videourl, $vidid, $videodata) |
| 316 |
{ |
| 317 |
if ($videodata['autoplay'] == 'on') { |
| 318 |
$autoplay = 'autoplay muted'; |
| 319 |
} else { |
| 320 |
$autoplay = ''; |
| 321 |
} |
| 322 |
|
| 323 |
if ($videodata['loop'] == 'on') { |
| 324 |
$loop = 'loop'; |
| 325 |
} else { |
| 326 |
$loop = ''; |
| 327 |
} |
| 328 |
|
| 329 |
$html = ''; |
| 330 |
$html .= '<video id="' . $vidid . '" class="video-js vjs-default-skin vjs-big-play-centered" ' . $autoplay . ' ' . $loop . ' controls preload="auto" style="width:100%; height: 100%;" poster="" >'; |
| 331 |
$html .= '<source src="' . $videourl . '" type="video/mp4"/>'; |
| 332 |
$html .= '<p class="vjs-no-js">'; |
| 333 |
$html .= 'To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com html5-video-support/" target="_blank">supports HTML5 video</a>'; |
| 334 |
$html .= '</p>'; |
| 335 |
$html .= '</video>'; |
| 336 |
return $html; |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
/** |
| 341 |
* Prepare scene data for Tour preview |
| 342 |
* |
| 343 |
* @param array $panodata |
| 344 |
* |
| 345 |
* @return array |
| 346 |
* @since 8.0.0 |
| 347 |
*/ |
| 348 |
public function prepare_scene_data_for_preview($panodata) |
| 349 |
{ |
| 350 |
$scene_data = array(); |
| 351 |
foreach ($panodata["scene-list"] as $panoscenes) { |
| 352 |
if (!empty($panoscenes['scene-id'])) { |
| 353 |
$scene_ititle = sanitize_text_field(@$panoscenes["scene-ititle"]); |
| 354 |
$scene_author = sanitize_text_field(@$panoscenes["scene-author"]); |
| 355 |
|
| 356 |
$scene_vaov = isset($panoscenes["scene-vaov"]) ? (float)$panoscenes["scene-vaov"] : 180; |
| 357 |
$scene_haov = isset($panoscenes["scene-vaov"]) ? (float)$panoscenes["scene-haov"] : 360; |
| 358 |
$scene_vertical_offset = isset($panoscenes["scene-vertical-offset"]) ? (float)$panoscenes["scene-vertical-offset"] : 0; |
| 359 |
|
| 360 |
$default_scene_pitch = isset($panoscenes["scene-pitch"]) ? (float)$panoscenes["scene-pitch"] : null; |
| 361 |
$default_scene_yaw = isset($panoscenes["scene-yaw"]) ? (float)$panoscenes["scene-yaw"] : null; |
| 362 |
$scene_max_pitch = isset($panoscenes["scene-maxpitch"]) ? (float)$panoscenes["scene-maxpitch"] : ''; |
| 363 |
$scene_min_pitch = isset($panoscenes["scene-minpitch"]) ? (float)$panoscenes["scene-minpitch"] : ''; |
| 364 |
$scene_max_yaw = isset($panoscenes["scene-maxyaw"]) ? (float)$panoscenes["scene-maxyaw"] : ''; |
| 365 |
$scene_min_yaw = isset($panoscenes["scene-minyaw"]) ? (float)$panoscenes["scene-minyaw"] : ''; |
| 366 |
|
| 367 |
$default_zoom = isset($panoscenes["scene-zoom"]) ? $panoscenes["scene-zoom"] : 100; |
| 368 |
if (!empty($default_zoom)) { |
| 369 |
$default_zoom = isset($panoscenes["scene-zoom"]) ? (int)$panoscenes["scene-zoom"] : (int)$default_zoom; |
| 370 |
} else { |
| 371 |
$default_zoom = 100; |
| 372 |
} |
| 373 |
|
| 374 |
$max_zoom = isset($panoscenes["scene-maxzoom"]) ? $panoscenes["scene-maxzoom"] : 120; |
| 375 |
if (!empty($max_zoom)) { |
| 376 |
$max_zoom = isset($panoscenes["scene-maxzoom"]) ? (int)$panoscenes["scene-maxzoom"] : (int)$max_zoom; |
| 377 |
} else { |
| 378 |
$max_zoom = 120; |
| 379 |
} |
| 380 |
|
| 381 |
$min_zoom = isset($panoscenes["scene-minzoom"]) ? $panoscenes["scene-minzoom"] : 50; |
| 382 |
if (!empty($min_zoom)) { |
| 383 |
$min_zoom = isset($panoscenes["scene-minzoom"]) ? (int)$panoscenes["scene-minzoom"] : (int)$min_zoom; |
| 384 |
} else { |
| 385 |
$min_zoom = 50; |
| 386 |
} |
| 387 |
|
| 388 |
$hotspot_datas = $panoscenes["hotspot-list"]; |
| 389 |
|
| 390 |
$hotspots = $this->prepare_hotspot_data_for_preview($hotspot_datas); |
| 391 |
|
| 392 |
$scene_info = array(); |
| 393 |
if ($panoscenes["scene-type"] == 'cubemap') { |
| 394 |
$pano_type = 'cubemap'; |
| 395 |
$pano_attachment = array( |
| 396 |
$panoscenes["scene-attachment-url-face0"], |
| 397 |
$panoscenes["scene-attachment-url-face1"], |
| 398 |
$panoscenes["scene-attachment-url-face2"], |
| 399 |
$panoscenes["scene-attachment-url-face3"], |
| 400 |
$panoscenes["scene-attachment-url-face4"], |
| 401 |
$panoscenes["scene-attachment-url-face5"] |
| 402 |
); |
| 403 |
|
| 404 |
$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, "vaov" => $scene_vaov, "haov" => $scene_haov, "vOffset" => $scene_vertical_offset, "hotSpots" => $hotspots); |
| 405 |
} else { |
| 406 |
$scene_info = array("type" => $panoscenes["scene-type"], "panorama" => $panoscenes["scene-attachment-url"], "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, "vaov" => $scene_vaov, "haov" => $scene_haov, "vOffset" => $scene_vertical_offset, "hotSpots" => $hotspots); |
| 407 |
} |
| 408 |
|
| 409 |
if (empty($panoscenes["scene-ititle"])) { |
| 410 |
unset($scene_info['title']); |
| 411 |
} |
| 412 |
if (empty($panoscenes["scene-author"])) { |
| 413 |
unset($scene_info['author']); |
| 414 |
} |
| 415 |
|
| 416 |
if (empty($scene_vaov)) { |
| 417 |
unset($scene_info['vaov']); |
| 418 |
} |
| 419 |
|
| 420 |
if (empty($scene_haov)) { |
| 421 |
unset($scene_info['haov']); |
| 422 |
} |
| 423 |
|
| 424 |
if (empty($scene_vertical_offset)) { |
| 425 |
unset($scene_info['vOffset']); |
| 426 |
} |
| 427 |
|
| 428 |
if (isset($panoscenes["cvgscene"])) { |
| 429 |
if ($panoscenes["cvgscene"] == "off") { |
| 430 |
unset($scene_info['maxPitch']); |
| 431 |
unset($scene_info['minPitch']); |
| 432 |
} |
| 433 |
} |
| 434 |
|
| 435 |
if (empty($panoscenes["scene-maxpitch"])) { |
| 436 |
unset($scene_info['maxPitch']); |
| 437 |
} |
| 438 |
|
| 439 |
if (empty($panoscenes["scene-minpitch"])) { |
| 440 |
unset($scene_info['minPitch']); |
| 441 |
} |
| 442 |
|
| 443 |
if (isset($panoscenes["chgscene"])) { |
| 444 |
if ($panoscenes["chgscene"] == "off") { |
| 445 |
unset($scene_info['maxYaw']); |
| 446 |
unset($scene_info['minYaw']); |
| 447 |
} |
| 448 |
} |
| 449 |
if (empty($panoscenes["scene-maxyaw"])) { |
| 450 |
unset($scene_info['maxYaw']); |
| 451 |
} |
| 452 |
|
| 453 |
if (empty($panoscenes["scene-minyaw"])) { |
| 454 |
unset($scene_info['minYaw']); |
| 455 |
} |
| 456 |
|
| 457 |
$scene_array = array(); |
| 458 |
$scene_array = array( |
| 459 |
$panoscenes["scene-id"] => $scene_info |
| 460 |
); |
| 461 |
$scene_data[$panoscenes["scene-id"]] = $scene_info; |
| 462 |
} |
| 463 |
} |
| 464 |
return $scene_data; |
| 465 |
} |
| 466 |
|
| 467 |
|
| 468 |
/** |
| 469 |
* Preapre hotspot data for Tour preview |
| 470 |
* |
| 471 |
* @param array $hotspot_datas |
| 472 |
* |
| 473 |
* @return array |
| 474 |
* @since 8.0.0 |
| 475 |
*/ |
| 476 |
private function prepare_hotspot_data_for_preview($hotspot_datas) |
| 477 |
{ |
| 478 |
$hotspots = array(); |
| 479 |
foreach ($hotspot_datas as $hotspot_data) { |
| 480 |
|
| 481 |
if (!empty($hotspot_data["hotspot-title"])) { |
| 482 |
|
| 483 |
$hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"]; |
| 484 |
$hotspot_content = ''; |
| 485 |
|
| 486 |
ob_start(); |
| 487 |
do_action('wpvr_hotspot_content_admin', $hotspot_data); |
| 488 |
$hotspot_content = ob_get_clean(); |
| 489 |
|
| 490 |
|
| 491 |
if (!$hotspot_content) $hotspot_content = $hotspot_data["hotspot-content"]; |
| 492 |
|
| 493 |
|
| 494 |
$hotspot_info = array( |
| 495 |
"text" => $hotspot_data["hotspot-title"], |
| 496 |
"pitch" => $hotspot_data["hotspot-pitch"], |
| 497 |
"yaw" => $hotspot_data["hotspot-yaw"], |
| 498 |
"type" => $hotspot_type, |
| 499 |
"URL" => $hotspot_data["hotspot-url"], |
| 500 |
"clickHandlerArgs" => $hotspot_content, |
| 501 |
"createTooltipArgs" => $hotspot_data["hotspot-hover"], |
| 502 |
"sceneId" => $hotspot_data["hotspot-scene"], |
| 503 |
'hotspot_type' => $hotspot_data['hotspot-type'] |
| 504 |
); |
| 505 |
|
| 506 |
array_push($hotspots, $hotspot_info); |
| 507 |
if (empty($hotspot_data["hotspot-scene"])) { |
| 508 |
unset($hotspot_info['targetPitch']); |
| 509 |
unset($hotspot_info['targetYaw']); |
| 510 |
} |
| 511 |
} |
| 512 |
} |
| 513 |
return $hotspots; |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
/** |
| 518 |
* Prepare youtube video for preview |
| 519 |
* |
| 520 |
* @param string $videourl |
| 521 |
* |
| 522 |
* @return string |
| 523 |
* @since 8.0.0 |
| 524 |
*/ |
| 525 |
public function prepare_youtube_video_preview($videourl, $videodata) |
| 526 |
{ |
| 527 |
$explodeid = ''; |
| 528 |
$explodeid = explode("=", $videourl); |
| 529 |
|
| 530 |
if ($videodata['autoplay'] == 'on') { |
| 531 |
$autoplay = '&autoplay=1'; |
| 532 |
$muted = '&mute=1'; |
| 533 |
} else { |
| 534 |
$autoplay = ''; |
| 535 |
$muted = ''; |
| 536 |
} |
| 537 |
|
| 538 |
if ($videodata['loop'] == 'on') { |
| 539 |
$loop = '&loop=1'; |
| 540 |
} else { |
| 541 |
$loop = ''; |
| 542 |
} |
| 543 |
|
| 544 |
$html = ''; |
| 545 |
|
| 546 |
$html .= ' |
| 547 |
<iframe src="https://www.youtube.com/embed/' . $explodeid[1] . '?rel=0&modestbranding=1' . $loop . '&autohide=1' . $muted . '&showinfo=0&controls=1' . $autoplay . '" width="600" height="400" frameborder="0" allowfullscreen></iframe> |
| 548 |
'; |
| 549 |
return $html; |
| 550 |
} |
| 551 |
|
| 552 |
|
| 553 |
/** |
| 554 |
* Prepare shortcode data for youtube video url |
| 555 |
* |
| 556 |
* @param array $postdata |
| 557 |
* @param mixed $width |
| 558 |
* @param mixed $height |
| 559 |
* |
| 560 |
* @return string |
| 561 |
* @since 8.0.0 |
| 562 |
*/ |
| 563 |
public function preapre_youtube_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius) |
| 564 |
{ |
| 565 |
$explodeid = ''; |
| 566 |
$explodeid = explode("=", $postdata['vidurl']); |
| 567 |
|
| 568 |
$foundid = ''; |
| 569 |
|
| 570 |
$muted = '&mute=1'; |
| 571 |
|
| 572 |
$autoplay = ($autoplay == 'on') ? '&autoplay=1' : ''; |
| 573 |
$loop = ($loop == 'on') ? '&loop=1' : ''; |
| 574 |
|
| 575 |
if (strpos($postdata['vidurl'], 'youtu') > 0) { |
| 576 |
$explodeid = explode("/", $postdata['vidurl']); |
| 577 |
$foundid = $explodeid[3] . '?' . $autoplay . $loop; |
| 578 |
$expdata = $explodeid[3]; |
| 579 |
} else { |
| 580 |
$foundid = $explodeid[1] . '?' . $autoplay . $loop; |
| 581 |
$expdata = $explodeid[1]; |
| 582 |
} |
| 583 |
|
| 584 |
$playlist = '&playlist='. $expdata; |
| 585 |
$playlist = str_replace("?feature=shared","",$playlist); |
| 586 |
|
| 587 |
$html = ''; |
| 588 |
$html .= '<div style="text-align:center; max-width:100%; width:' . $width . '; height:' . $height . '; border-radius: ' . $radius . '; margin: 0 auto;">'; |
| 589 |
$html .= '<iframe src="https://www.youtube.com/embed/' . $expdata . '?rel=0&modestbranding=1' . $loop . '&autohide=1' . $muted . '&showinfo=0&controls=1' . $autoplay . ''.$playlist.'" width="100%" height="100%" style="border-radius: ' . $radius . ';" frameborder="0" allowfullscreen></iframe>'; |
| 590 |
$html .= '</div>'; |
| 591 |
return $html; |
| 592 |
} |
| 593 |
|
| 594 |
|
| 595 |
/** |
| 596 |
* Prepare shortcode data for Vimeo url |
| 597 |
* |
| 598 |
* @param array $postdata |
| 599 |
* @param mixed $width |
| 600 |
* @param mixed $height |
| 601 |
* |
| 602 |
* @return string |
| 603 |
* @since 8.0.0 |
| 604 |
*/ |
| 605 |
public function prepare_vimeo_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius) |
| 606 |
{ |
| 607 |
$explodeid = ''; |
| 608 |
$explodeid = explode("/", $postdata['autoplay']); |
| 609 |
$foundid = ''; |
| 610 |
|
| 611 |
$autoplay = ($autoplay == 'on') ? '&autoplay=1&muted=1' : ''; |
| 612 |
$loop = ($loop == 'on') ? '&loop=1' : ''; |
| 613 |
if(!isset($explodeid[3])){ |
| 614 |
$vidurl = explode('/',$postdata['vidurl']); |
| 615 |
$foundid = end($vidurl); |
| 616 |
}else{ |
| 617 |
$foundid = $explodeid[3] . '?' . $autoplay . $loop; |
| 618 |
} |
| 619 |
$html = ''; |
| 620 |
$html .= '<div style="text-align: center; max-width:100%; width:' . $width . '; height:' . $height . '; margin: 0 auto;">'; |
| 621 |
$html .= '<iframe src="https://player.vimeo.com/video/' . $foundid . '" width="' . trim($width, 'px') . '" height="' . trim($height, 'px') . '" style="border-radius: ' . $radius . ';" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; |
| 622 |
$html .= '</div>'; |
| 623 |
return $html; |
| 624 |
} |
| 625 |
|
| 626 |
|
| 627 |
/** |
| 628 |
* Prepare shortcode data from regular postdata |
| 629 |
* |
| 630 |
* @param integer $id |
| 631 |
* @param array $postdata |
| 632 |
* @param string $width |
| 633 |
* @param string $height |
| 634 |
* |
| 635 |
* @return string |
| 636 |
* @since 8.0.0 |
| 637 |
*/ |
| 638 |
public function prepare_regular_video_shortcode_data($id, $postdata, $width, $height, $radius) |
| 639 |
{ |
| 640 |
$html = ''; |
| 641 |
$html .= '<div id="pano' . $id . '" class="pano-wrap" style="max-width:100%; width: ' . $width . '; height: ' . $height . '; border-radius: ' . $radius . '; margin: 0 auto;">'; |
| 642 |
$html .= '<div style="width:100%; height:100%; ">' . $postdata['panoviddata'] . '</div>'; |
| 643 |
|
| 644 |
$html .= ' |
| 645 |
<style> |
| 646 |
.video-js { |
| 647 |
border-radius:' . $radius . '; |
| 648 |
} |
| 649 |
.video-js canvas{ |
| 650 |
border-radius:' . $radius . '; |
| 651 |
} |
| 652 |
#pano' . $id . ' .vjs-poster { |
| 653 |
border-radius: ' . $radius . '; |
| 654 |
} |
| 655 |
</style> |
| 656 |
|
| 657 |
'; |
| 658 |
|
| 659 |
$html .= '</div>'; |
| 660 |
|
| 661 |
//video js vr setup // |
| 662 |
$html .= '<script>'; |
| 663 |
$html .= ' |
| 664 |
(function (window, videojs) { |
| 665 |
var player = window.player = videojs("' . $postdata['vidid'] . '"); |
| 666 |
player.mediainfo = player.mediainfo || {}; |
| 667 |
player.mediainfo.projection = "equirectangular"; |
| 668 |
|
| 669 |
// AUTO is the default and looks at mediainfo |
| 670 |
var vr = window.vr = player.vr({ projection: "AUTO", debug: true, forceCardboard: false, antialias: false }); |
| 671 |
}(window, window.videojs)); |
| 672 |
|
| 673 |
'; |
| 674 |
$html .= '</script>'; |
| 675 |
//video js vr end // |
| 676 |
return $html; |
| 677 |
} |
| 678 |
|
| 679 |
|
| 680 |
/** |
| 681 |
* Prepare scene data for shortcode |
| 682 |
* |
| 683 |
* @param array $panodata |
| 684 |
* |
| 685 |
* @return array |
| 686 |
* @since 8.0.0 |
| 687 |
*/ |
| 688 |
public function prepare_shortcode_scene_data($panodata) |
| 689 |
{ |
| 690 |
$scene_data = array(); |
| 691 |
|
| 692 |
if (!empty($panodata["scene-list"])) { |
| 693 |
$scene_data = $this->prepare_shortcode_scene_list($panodata); |
| 694 |
} |
| 695 |
|
| 696 |
return $scene_data; |
| 697 |
} |
| 698 |
|
| 699 |
|
| 700 |
/** |
| 701 |
* Prepare scene lists data for shortcode |
| 702 |
* |
| 703 |
* @param array $panodata |
| 704 |
* |
| 705 |
* @return array |
| 706 |
* @since 8.0.0 |
| 707 |
*/ |
| 708 |
private function prepare_shortcode_scene_list($panodata) |
| 709 |
{ |
| 710 |
$scene_data = array(); |
| 711 |
foreach ($panodata["scene-list"] as $panoscenes) { |
| 712 |
$hotspot_datas = array(); |
| 713 |
if (isset($panoscenes["hotspot-list"])) { |
| 714 |
$hotspot_datas = $panoscenes["hotspot-list"]; |
| 715 |
} |
| 716 |
$hotspots = $this->prepare_shortcode_hotspots_list($hotspot_datas); |
| 717 |
$device_scene = $this->get_shortcode_device_scene($panoscenes['scene-attachment-url']); |
| 718 |
$scene_info = $this->get_shortcode_scene_info($panoscenes, $hotspots, $device_scene); |
| 719 |
$scene_data[$panoscenes["scene-id"]] = $scene_info; |
| 720 |
} |
| 721 |
return $scene_data; |
| 722 |
} |
| 723 |
|
| 724 |
|
| 725 |
/** |
| 726 |
* Prepare hotspots list for shortcode |
| 727 |
* |
| 728 |
* @param array $hotspot_datas |
| 729 |
* |
| 730 |
* @return array |
| 731 |
* @since 8.0.0 |
| 732 |
*/ |
| 733 |
private function prepare_shortcode_hotspots_list($hotspot_datas) |
| 734 |
{ |
| 735 |
$hotspots = array(); |
| 736 |
foreach ($hotspot_datas as $hotspot_data) { |
| 737 |
$hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"]; |
| 738 |
$hotspot_content = $hotspot_data["hotspot-content"]; |
| 739 |
$hotspot_info = $this->get_shortcode_hotspot_info($hotspot_data, $hotspot_type, $hotspot_content); |
| 740 |
array_push($hotspots, $hotspot_info); |
| 741 |
} |
| 742 |
return $hotspots; |
| 743 |
} |
| 744 |
|
| 745 |
|
| 746 |
/** |
| 747 |
* Return hotspot info array to hotspot list |
| 748 |
* |
| 749 |
* @param array $hotspot_data |
| 750 |
* @param string $hotspot_type |
| 751 |
* @param string $hotspot_content |
| 752 |
* |
| 753 |
* @return array |
| 754 |
* @since 8.0.0 |
| 755 |
*/ |
| 756 |
private function get_shortcode_hotspot_info($hotspot_data, $hotspot_type, $hotspot_content) |
| 757 |
{ |
| 758 |
$hotspot_info = array( |
| 759 |
"text" => $hotspot_data["hotspot-title"], |
| 760 |
"pitch" => $hotspot_data["hotspot-pitch"], |
| 761 |
"yaw" => $hotspot_data["hotspot-yaw"], |
| 762 |
"type" => $hotspot_type, |
| 763 |
"cssClass" => $hotspot_data["hotspot-customclass"], |
| 764 |
"URL" => $hotspot_data["hotspot-url"], |
| 765 |
"wpvr_url_open" => isset($hotspot_data["wpvr_url_open"][0]) ? $hotspot_data["wpvr_url_open"][0] : 'off', |
| 766 |
"clickHandlerArgs" => $hotspot_content, |
| 767 |
"createTooltipArgs" => $hotspot_data["hotspot-hover"], |
| 768 |
"sceneId" => $hotspot_data["hotspot-scene"], |
| 769 |
'hotspot_type' => $hotspot_data['hotspot-type'] |
| 770 |
); |
| 771 |
|
| 772 |
$hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL']; |
| 773 |
|
| 774 |
if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') { |
| 775 |
unset($hotspot_info["cssClass"]); |
| 776 |
} |
| 777 |
if (empty($hotspot_data["hotspot-scene"])) { |
| 778 |
unset($hotspot_info['targetPitch']); |
| 779 |
unset($hotspot_info['targetYaw']); |
| 780 |
} |
| 781 |
return $hotspot_info; |
| 782 |
} |
| 783 |
|
| 784 |
|
| 785 |
/** |
| 786 |
* Return scene info array for scene list |
| 787 |
* |
| 788 |
* @param array $panoscenes |
| 789 |
* @param array $hotspots |
| 790 |
* @param string $device_scene |
| 791 |
* |
| 792 |
* @return array |
| 793 |
* @since 8.0.0 |
| 794 |
*/ |
| 795 |
private function get_shortcode_scene_info($panoscenes, $hotspots, $device_scene) |
| 796 |
{ |
| 797 |
$scene_info = array(); |
| 798 |
if ($panoscenes["scene-type"] == 'cubemap') { |
| 799 |
$pano_attachment = array( |
| 800 |
$panoscenes["scene-attachment-url-face0"], |
| 801 |
$panoscenes["scene-attachment-url-face1"], |
| 802 |
$panoscenes["scene-attachment-url-face2"], |
| 803 |
$panoscenes["scene-attachment-url-face3"], |
| 804 |
$panoscenes["scene-attachment-url-face4"], |
| 805 |
$panoscenes["scene-attachment-url-face5"] |
| 806 |
); |
| 807 |
$scene_info = array("type" => $panoscenes["scene-type"], "cubeMap" => $pano_attachment, "hotSpots" => $hotspots); |
| 808 |
} else { |
| 809 |
$scene_info = array("type" => $panoscenes["scene-type"], "panorama" => $device_scene, "hotSpots" => $hotspots); |
| 810 |
} |
| 811 |
return $scene_info; |
| 812 |
} |
| 813 |
|
| 814 |
|
| 815 |
/** |
| 816 |
* Return device scene for shortcode |
| 817 |
* |
| 818 |
* @param string $device_scene |
| 819 |
* |
| 820 |
* @return string |
| 821 |
* @since 8.0.0 |
| 822 |
*/ |
| 823 |
private function get_shortcode_device_scene($device_scene) |
| 824 |
{ |
| 825 |
$mobile_media_resize = get_option('mobile_media_resize'); |
| 826 |
$file_accessible = ini_get('allow_url_fopen'); |
| 827 |
|
| 828 |
if ($mobile_media_resize == "true" && $device_scene) { |
| 829 |
if ($file_accessible == "1") { |
| 830 |
$image_info = getimagesize($device_scene); |
| 831 |
if ($image_info[0] > 4096) { |
| 832 |
$src_to_id_for_mobile = ''; |
| 833 |
$src_to_id_for_desktop = ''; |
| 834 |
if (wpvr_isMobileDevice()) { |
| 835 |
$src_to_id_for_mobile = attachment_url_to_postid($device_scene); |
| 836 |
if ($src_to_id_for_mobile) { |
| 837 |
$mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile'); |
| 838 |
if ($mobile_scene[3]) { |
| 839 |
$device_scene = $mobile_scene[0]; |
| 840 |
} |
| 841 |
} |
| 842 |
} else { |
| 843 |
$src_to_id_for_desktop = attachment_url_to_postid($device_scene); |
| 844 |
if ($src_to_id_for_desktop) { |
| 845 |
$desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full'); |
| 846 |
if ($desktop_scene[0]) { |
| 847 |
$device_scene = $desktop_scene[0]; |
| 848 |
} |
| 849 |
} |
| 850 |
} |
| 851 |
} |
| 852 |
} |
| 853 |
} |
| 854 |
return $device_scene; |
| 855 |
} |
| 856 |
|
| 857 |
|
| 858 |
/** |
| 859 |
* Prepare json response for shortcode |
| 860 |
* |
| 861 |
* @param string $autorotation |
| 862 |
* @param array $pano_response |
| 863 |
* @param string $panoid |
| 864 |
* @param integer $autorotationinactivedelay |
| 865 |
* @param integer $autorotationstopdelay |
| 866 |
* |
| 867 |
* @return array |
| 868 |
* @since 8.0.0 |
| 869 |
*/ |
| 870 |
public function prepare_shortcode_response($autorotation, $pano_response, $panoid, $autorotationinactivedelay, $autorotationstopdelay) |
| 871 |
{ |
| 872 |
$pano_id_array = array("panoid" => $panoid); |
| 873 |
if (empty($autorotation)) { |
| 874 |
unset($pano_response['autoRotate']); |
| 875 |
unset($pano_response['autoRotateInactivityDelay']); |
| 876 |
unset($pano_response['autoRotateStopDelay']); |
| 877 |
} |
| 878 |
if (empty($autorotationinactivedelay)) { |
| 879 |
unset($pano_response['autoRotateInactivityDelay']); |
| 880 |
} |
| 881 |
if (empty($autorotationstopdelay)) { |
| 882 |
unset($pano_response['autoRotateStopDelay']); |
| 883 |
} |
| 884 |
$response = array(); |
| 885 |
$response = array($pano_id_array, $pano_response); |
| 886 |
if (!empty($response)) { |
| 887 |
$response = json_encode($response); |
| 888 |
} |
| 889 |
return $response; |
| 890 |
} |
| 891 |
|
| 892 |
|
| 893 |
/** |
| 894 |
* Prepare HTML and script contents for scene shortcode |
| 895 |
* |
| 896 |
* @param mixed $width |
| 897 |
* @param mixed $panoid |
| 898 |
* @param mixed $hotspoticoncolor |
| 899 |
* @param mixed $foreground_color |
| 900 |
* @param mixed $hotspotblink |
| 901 |
* @param mixed $pulse_color |
| 902 |
* @param mixed $radius |
| 903 |
* @param mixed $id |
| 904 |
* @param mixed $height |
| 905 |
* @param mixed $scene_data |
| 906 |
* @param mixed $response |
| 907 |
* @param mixed $autoload |
| 908 |
* @param mixed $default_scene |
| 909 |
* @param mixed $postdata |
| 910 |
* |
| 911 |
* @return string |
| 912 |
* @since 8.0.0 |
| 913 |
*/ |
| 914 |
public function prepare_scene_shortcode_html_content($width, $panoid, $hotspoticoncolor, $foreground_color, $hotspotblink, $pulse_color, $radius, $id, $height, $scene_data, $response, $autoload, $default_scene, $postdata, $mobile_height, $gyro) |
| 915 |
{ |
| 916 |
$html = ''; |
| 917 |
$html .= '<style>'; |
| 918 |
|
| 919 |
if ($width == 'embed') { |
| 920 |
$html .= 'body{overflow: hidden;}'; |
| 921 |
} |
| 922 |
// Return ID and Classes for CSS styling // |
| 923 |
$html = $this->get_shortcode_content_classes($html, $panoid, $hotspoticoncolor, $foreground_color); |
| 924 |
// Return webkit keyframes CSS styling // |
| 925 |
if ($hotspotblink == 'on') { |
| 926 |
$html = $this->get_shortcode_webkit_keyframes($html, $panoid, $pulse_color); |
| 927 |
} |
| 928 |
$status = get_option('wpvr_edd_license_status'); |
| 929 |
if ($status !== false && $status == 'valid') { |
| 930 |
if (!$gyro) { |
| 931 |
$html .= '#' . $panoid . ' div.pnlm-orientation-button { |
| 932 |
display: none; |
| 933 |
}'; |
| 934 |
} |
| 935 |
} else { |
| 936 |
$html .= '#' . $panoid . ' div.pnlm-orientation-button { |
| 937 |
display: none; |
| 938 |
}'; |
| 939 |
} |
| 940 |
$html .= '</style>'; |
| 941 |
|
| 942 |
// Render pano wrapper contents // |
| 943 |
$html = $this->get_shortcode_pano_wrap_content($width, $radius, $html, $id, $height, $mobile_height); |
| 944 |
// Render hotspots contents // |
| 945 |
$html = $this->render_shortcode_hotspot_content($html, $id, $scene_data); |
| 946 |
// Render custom iframe content // |
| 947 |
$html = $this->render_shortcode_custom_iframe_wrapper($html, $id); |
| 948 |
|
| 949 |
$html .= '</div>'; |
| 950 |
|
| 951 |
//script started |
| 952 |
$html = $this->get_shortcode_script_content($html, $response, $id, $autoload, $default_scene, $postdata); |
| 953 |
//script end |
| 954 |
return $html; |
| 955 |
} |
| 956 |
|
| 957 |
|
| 958 |
/** |
| 959 |
* Return ID and Classes for CSS styling |
| 960 |
* |
| 961 |
* @param mixed $html |
| 962 |
* @param mixed $panoid |
| 963 |
* @param mixed $hotspoticoncolor |
| 964 |
* @param mixed $foreground_color |
| 965 |
* |
| 966 |
* @return string |
| 967 |
* @since 8.0.0 |
| 968 |
*/ |
| 969 |
private function get_shortcode_content_classes($html, $panoid, $hotspoticoncolor, $foreground_color) |
| 970 |
{ |
| 971 |
$html .= '#' . $panoid . ' div.pnlm-hotspot-base.fas, |
| 972 |
#' . $panoid . ' div.pnlm-hotspot-base.fab, |
| 973 |
#' . $panoid . ' div.pnlm-hotspot-base.fa, |
| 974 |
#' . $panoid . ' div.pnlm-hotspot-base.fa-solid, |
| 975 |
#' . $panoid . ' div.pnlm-hotspot-base.far { |
| 976 |
display: block !important; |
| 977 |
background-color: ' . $hotspoticoncolor . '; |
| 978 |
color: ' . $foreground_color . '; |
| 979 |
border-radius: 100%; |
| 980 |
width: 30px; |
| 981 |
height: 30px; |
| 982 |
animation: icon-pulse' . $panoid . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1); |
| 983 |
}'; |
| 984 |
return $html; |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
/** |
| 989 |
* Resturn webkit keyframes CSS styling |
| 990 |
* |
| 991 |
* @param mixed $html |
| 992 |
* @param mixed $panoid |
| 993 |
* @param mixed $pulse_color |
| 994 |
* |
| 995 |
* @return string |
| 996 |
* @since 8.0.0 |
| 997 |
*/ |
| 998 |
private function get_shortcode_webkit_keyframes($html, $panoid, $pulse_color) |
| 999 |
{ |
| 1000 |
$html .= '@-webkit-keyframes icon-pulse' . $panoid . ' { |
| 1001 |
0% { |
| 1002 |
box-shadow: 0 0 0 0px rgba(' . $pulse_color[0] . ', 1); |
| 1003 |
} |
| 1004 |
100% { |
| 1005 |
box-shadow: 0 0 0 10px rgba(' . $pulse_color[0] . ', 0); |
| 1006 |
} |
| 1007 |
} |
| 1008 |
@keyframes icon-pulse' . $panoid . ' { |
| 1009 |
0% { |
| 1010 |
box-shadow: 0 0 0 0px rgba(' . $pulse_color[0] . ', 1); |
| 1011 |
} |
| 1012 |
100% { |
| 1013 |
box-shadow: 0 0 0 10px rgba(' . $pulse_color[0] . ', 0); |
| 1014 |
} |
| 1015 |
}'; |
| 1016 |
return $html; |
| 1017 |
} |
| 1018 |
|
| 1019 |
|
| 1020 |
/** |
| 1021 |
* Render pano wrapper content depending on Tour Width, Height and radius |
| 1022 |
* |
| 1023 |
* @param mixed $width |
| 1024 |
* @param mixed $radius |
| 1025 |
* @param mixed $html |
| 1026 |
* @param mixed $id |
| 1027 |
* @param mixed $height |
| 1028 |
* |
| 1029 |
* @return string |
| 1030 |
* @since 8.0.0 |
| 1031 |
*/ |
| 1032 |
private function get_shortcode_pano_wrap_content($width, $radius, $html, $id, $height, $mobile_height) |
| 1033 |
{ |
| 1034 |
if ($width == 'fullwidth') { |
| 1035 |
|
| 1036 |
if (wpvr_isMobileDevice()) { |
| 1037 |
if ($radius) { |
| 1038 |
$html .= '<div id="pano' . $id . '" class="pano-wrap" style="text-align:center; border-radius:' . $radius . '; direction:ltr;">'; |
| 1039 |
} else { |
| 1040 |
$html .= '<div id="pano' . $id . '" class="pano-wrap" style="text-align:center;">'; |
| 1041 |
} |
| 1042 |
} else { |
| 1043 |
if ($radius) { |
| 1044 |
$html .= '<div id="pano' . $id . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . $height . '; border-radius:' . $radius . '; direction:ltr;" >'; |
| 1045 |
} else { |
| 1046 |
$html .= '<div id="pano' . $id . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . $height . '; direction:ltr;" >'; |
| 1047 |
} |
| 1048 |
} |
| 1049 |
} elseif ($width == 'embed') { |
| 1050 |
$html .= '<div id="pano' . $id . '" class="pano-wrap vrembed" style=" text-align:center; direction:ltr;" >'; |
| 1051 |
} else { |
| 1052 |
if (wpvr_isMobileDevice()) { |
| 1053 |
if ($radius) { |
| 1054 |
$html .= '<div id="pano' . $id . '" class="pano-wrap" style=" text-align:center; max-width:100%; width: ' . $width . '; height: ' . $mobile_height . '!important; margin: 0 auto; border-radius:' . $radius . '; direction:ltr;">'; |
| 1055 |
} else { |
| 1056 |
$html .= '<div id="pano' . $id . '" class="pano-wrap" style=" text-align:center; max-width:100%; width: ' . $width . '; height: ' . $mobile_height . '!important; margin: 0 auto; direction:ltr;">'; |
| 1057 |
} |
| 1058 |
} else { |
| 1059 |
if ($radius) { |
| 1060 |
$html .= '<div id="pano' . $id . '" class="pano-wrap" style=" text-align:center; max-width:100%; width: ' . $width . '; height: ' . $height . '; margin: 0 auto; border-radius:' . $radius . '; direction:ltr;">'; |
| 1061 |
} else { |
| 1062 |
$html .= '<div id="pano' . $id . '" class="pano-wrap" style=" text-align:center; max-width:100%; width: ' . $width . '; height: ' . $height . '; margin: 0 auto; direction:ltr;">'; |
| 1063 |
} |
| 1064 |
} |
| 1065 |
} |
| 1066 |
return $html; |
| 1067 |
} |
| 1068 |
|
| 1069 |
|
| 1070 |
/** |
| 1071 |
* Render hotspot contents inside pano wrapper |
| 1072 |
* |
| 1073 |
* @param string $html |
| 1074 |
* @param mixed $id |
| 1075 |
* @param array $scene_data |
| 1076 |
* |
| 1077 |
* @return string |
| 1078 |
* @since 8.0.0 |
| 1079 |
*/ |
| 1080 |
private function render_shortcode_hotspot_content($html, $id, $scene_data) |
| 1081 |
{ |
| 1082 |
$html .= '<div class="wpvr-hotspot-tweak-contents-wrapper" style="display: none">'; |
| 1083 |
$html .= '<i class="fa fa-times cross" data-id="' . $id . '"></i>'; |
| 1084 |
$html .= '<div class="wpvr-hotspot-tweak-contents-flex">'; |
| 1085 |
$html .= '<div class="wpvr-hotspot-tweak-contents">'; |
| 1086 |
ob_start(); |
| 1087 |
do_action('wpvr_hotspot_tweak_contents', $scene_data); |
| 1088 |
$hotspot_content = ob_get_clean(); |
| 1089 |
$html .= $hotspot_content; |
| 1090 |
$html .= '</div>'; |
| 1091 |
$html .= '</div>'; |
| 1092 |
$html .= '</div>'; |
| 1093 |
return $html; |
| 1094 |
} |
| 1095 |
|
| 1096 |
|
| 1097 |
/** |
| 1098 |
* Render custom iframe wrapper inside pano wrapper |
| 1099 |
* |
| 1100 |
* @param string $html |
| 1101 |
* @param mixed $id |
| 1102 |
* |
| 1103 |
* @return string |
| 1104 |
* @since 8.0.0 |
| 1105 |
*/ |
| 1106 |
private function render_shortcode_custom_iframe_wrapper($html, $id) |
| 1107 |
{ |
| 1108 |
$html .= '<div class="custom-ifram-wrapper" style="display: none;">'; |
| 1109 |
$html .= '<i class="fa fa-times cross" data-id="' . $id . '"></i>'; |
| 1110 |
|
| 1111 |
$html .= '<div class="custom-ifram-flex">'; |
| 1112 |
$html .= '<div class="custom-ifram">'; |
| 1113 |
$html .= '</div>'; |
| 1114 |
$html .= '</div>'; |
| 1115 |
$html .= '</div>'; |
| 1116 |
return $html; |
| 1117 |
} |
| 1118 |
|
| 1119 |
|
| 1120 |
/** |
| 1121 |
* Return scripts contents for shortcode |
| 1122 |
* |
| 1123 |
* @param string $html |
| 1124 |
* @param mixed $response |
| 1125 |
* @param mixed $id |
| 1126 |
* @param mixed $autoload |
| 1127 |
* @param mixed $default_scene |
| 1128 |
* @param mixed $postdata |
| 1129 |
* |
| 1130 |
* @return string |
| 1131 |
* @since 8.0.0 |
| 1132 |
*/ |
| 1133 |
private function get_shortcode_script_content($html, $response, $id, $autoload, $default_scene, $postdata) |
| 1134 |
{ |
| 1135 |
$html .= '<script>'; |
| 1136 |
$html .= 'jQuery(document).ready(function() {'; |
| 1137 |
$html .= 'var response = ' . $response . ';'; |
| 1138 |
$html .= 'var scenes = response[1];'; |
| 1139 |
// Hotspot scripts content // |
| 1140 |
$html = $this->get_shortcode_hotspot_script_content($html); |
| 1141 |
|
| 1142 |
$html .= 'var panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);'; |
| 1143 |
|
| 1144 |
// Panaromic show scripts content // |
| 1145 |
$html = $this->render_shortcode_panoshow_script_content($html, $id); |
| 1146 |
// Auto rotation scripts content // |
| 1147 |
$html = $this->render_shortcode_autoRotate_content($html, $id); |
| 1148 |
|
| 1149 |
$html .= 'var touchtime = 0;'; |
| 1150 |
|
| 1151 |
// Return autoload scripts content // |
| 1152 |
if (!$autoload) { |
| 1153 |
$html = $this->render_shortcode_autoload_content($html, $id); |
| 1154 |
} |
| 1155 |
|
| 1156 |
// JQuery scripts for on-click content for elementor tab // |
| 1157 |
$previeword = "Click to Load Panorama"; |
| 1158 |
if (isset($postdata['previewtext']) && $postdata['previewtext'] != '') { |
| 1159 |
$previeword = $postdata['previewtext']; |
| 1160 |
} |
| 1161 |
$html = $this->render_elementor_tab_title_click_content($html, $id, $default_scene, $previeword); |
| 1162 |
// JQuery scripts for on-click content for vr tour tab // |
| 1163 |
$html = $this->render_vr_tour_tab_click_content($html, $id, $default_scene); |
| 1164 |
|
| 1165 |
if (isset($postdata['previewtext']) && $postdata['previewtext'] != '') { |
| 1166 |
$html .= 'jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $postdata['previewtext'] . '")'; |
| 1167 |
} |
| 1168 |
|
| 1169 |
$html .= '});'; |
| 1170 |
$html .= '</script>'; |
| 1171 |
return $html; |
| 1172 |
} |
| 1173 |
|
| 1174 |
|
| 1175 |
/** |
| 1176 |
* Return scripts content for hotspot data on shortcode |
| 1177 |
* |
| 1178 |
* @param mixed $html |
| 1179 |
* |
| 1180 |
* @return string |
| 1181 |
* @since 8.0.0 |
| 1182 |
*/ |
| 1183 |
private function get_shortcode_hotspot_script_content($html) |
| 1184 |
{ |
| 1185 |
$html .= 'if(scenes) {'; |
| 1186 |
$html .= 'var scenedata = scenes.scenes;'; |
| 1187 |
$html .= 'for(var i in scenedata) {'; |
| 1188 |
$html .= 'var scenehotspot = scenedata[i].hotSpots;'; |
| 1189 |
$html .= 'for(var i = 0; i < scenehotspot.length; i++) {'; |
| 1190 |
$html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {'; |
| 1191 |
$html .= 'scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;'; |
| 1192 |
$html .= '}'; |
| 1193 |
if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") { |
| 1194 |
} else { |
| 1195 |
$html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {'; |
| 1196 |
$html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;'; |
| 1197 |
$html .= '}'; |
| 1198 |
} |
| 1199 |
$html .= '}'; |
| 1200 |
$html .= '}'; |
| 1201 |
$html .= '}'; |
| 1202 |
return $html; |
| 1203 |
} |
| 1204 |
|
| 1205 |
|
| 1206 |
/** |
| 1207 |
* Render scripts content for panaromic show on shortcode |
| 1208 |
* |
| 1209 |
* @param mixed $html |
| 1210 |
* @param mixed $id |
| 1211 |
* |
| 1212 |
* @return string |
| 1213 |
* @since 8.0.0 |
| 1214 |
*/ |
| 1215 |
private function render_shortcode_panoshow_script_content($html, $id) |
| 1216 |
{ |
| 1217 |
$html .= 'panoshow' . $id . '.on("load", function (){ |
| 1218 |
setTimeout(() => { |
| 1219 |
window.dispatchEvent(new Event("resize")); |
| 1220 |
}, 200); |
| 1221 |
if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) { |
| 1222 |
jQuery("#controls' . $id . '").css("bottom", "55px"); |
| 1223 |
} |
| 1224 |
else { |
| 1225 |
jQuery("#controls' . $id . '").css("bottom", "5px"); |
| 1226 |
} |
| 1227 |
});'; |
| 1228 |
$html .= 'panoshow' . $id . '.on("render", function (){ |
| 1229 |
window.dispatchEvent(new Event("resize")); |
| 1230 |
});'; |
| 1231 |
return $html; |
| 1232 |
} |
| 1233 |
|
| 1234 |
|
| 1235 |
/** |
| 1236 |
* Return auto rotation scripts content on shortcode |
| 1237 |
* |
| 1238 |
* @param mixed $html |
| 1239 |
* @param mixed $id |
| 1240 |
* |
| 1241 |
* @return string |
| 1242 |
* @since 8.0.0 |
| 1243 |
*/ |
| 1244 |
private function render_shortcode_autoRotate_content($html, $id) |
| 1245 |
{ |
| 1246 |
$html .= 'if (scenes.autoRotate) { |
| 1247 |
panoshow' . $id . '.on("load", function (){ |
| 1248 |
setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000); |
| 1249 |
}); |
| 1250 |
panoshow' . $id . '.on("scenechange", function (){ |
| 1251 |
setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000); |
| 1252 |
}); |
| 1253 |
}'; |
| 1254 |
return $html; |
| 1255 |
} |
| 1256 |
|
| 1257 |
|
| 1258 |
/** |
| 1259 |
* Return autoload scripts content on shortcode |
| 1260 |
* |
| 1261 |
* @param mixed $html |
| 1262 |
* @param mixed $id |
| 1263 |
* |
| 1264 |
* @return string |
| 1265 |
* @since 8.0.0 |
| 1266 |
*/ |
| 1267 |
private function render_shortcode_autoload_content($html, $id) |
| 1268 |
{ |
| 1269 |
$html .= 'jQuery(document).ready(function(){ |
| 1270 |
jQuery("#controls' . $id . '").hide(); |
| 1271 |
jQuery("#zoom-in-out-controls' . $id . '").hide(); |
| 1272 |
jQuery("#adcontrol' . $id . '").hide(); |
| 1273 |
jQuery("#pano' . $id . '").find(".pnlm-panorama-info").hide(); |
| 1274 |
});'; |
| 1275 |
|
| 1276 |
$html .= 'panoshow' . $id . '.on("load", function (){ |
| 1277 |
jQuery("#controls' . $id . '").show(); |
| 1278 |
jQuery("#zoom-in-out-controls' . $id . '").show(); |
| 1279 |
jQuery("#adcontrol' . $id . '").show(); |
| 1280 |
jQuery("#pano' . $id . '").find(".pnlm-panorama-info").show(); |
| 1281 |
});'; |
| 1282 |
return $html; |
| 1283 |
} |
| 1284 |
|
| 1285 |
|
| 1286 |
/** |
| 1287 |
* JQuery scripts for on-click content for elementor tab |
| 1288 |
* |
| 1289 |
* @param mixed $html |
| 1290 |
* @param mixed $id |
| 1291 |
* @param mixed $default_scene |
| 1292 |
* |
| 1293 |
* @return string |
| 1294 |
* @since 8.0.0 |
| 1295 |
*/ |
| 1296 |
private function render_elementor_tab_title_click_content($html, $id, $default_scene, $previeword) |
| 1297 |
{ |
| 1298 |
$html .= 'jQuery(".elementor-tab-title").click(function(){ |
| 1299 |
var element_id; |
| 1300 |
var pano_id; |
| 1301 |
var element_id = this.id; |
| 1302 |
element_id = element_id.split("-"); |
| 1303 |
element_id = element_id[3]; |
| 1304 |
jQuery("#elementor-tab-content-"+element_id).children("div").addClass("awwww"); |
| 1305 |
var pano_id = jQuery(".awwww").attr("id"); |
| 1306 |
jQuery("#elementor-tab-content-"+element_id).children("div").removeClass("awwww"); |
| 1307 |
if (pano_id != undefined) { |
| 1308 |
pano_id = pano_id.split("o"); |
| 1309 |
pano_id = pano_id[1]; |
| 1310 |
if (pano_id == "' . $id . '") { |
| 1311 |
jQuery("#pano' . $id . '").children(".pnlm-render-container").remove(); |
| 1312 |
jQuery("#pano' . $id . '").children(".pnlm-ui").remove(); |
| 1313 |
panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes); |
| 1314 |
jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previeword . '") |
| 1315 |
setTimeout(function() { |
| 1316 |
// panoshow' . $id . '.loadScene("' . $default_scene . '"); |
| 1317 |
window.dispatchEvent(new Event("resize")); |
| 1318 |
if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) { |
| 1319 |
jQuery("#controls' . $id . '").css("bottom", "55px"); |
| 1320 |
} |
| 1321 |
else { |
| 1322 |
jQuery("#controls' . $id . '").css("bottom", "5px"); |
| 1323 |
} |
| 1324 |
}, 200); |
| 1325 |
} |
| 1326 |
} |
| 1327 |
});'; |
| 1328 |
return $html; |
| 1329 |
} |
| 1330 |
|
| 1331 |
|
| 1332 |
/** |
| 1333 |
* JQuery scripts for on-click content for vr tour tab |
| 1334 |
* |
| 1335 |
* @param mixed $html |
| 1336 |
* @param mixed $id |
| 1337 |
* @param mixed $default_scene |
| 1338 |
* |
| 1339 |
* @return string |
| 1340 |
* @since 8.0.0 |
| 1341 |
*/ |
| 1342 |
private function render_vr_tour_tab_click_content($html, $id, $default_scene) |
| 1343 |
{ |
| 1344 |
$html .= 'jQuery(".geodir-tab-head dd, #vr-tour-tab").click(function(){ |
| 1345 |
jQuery("#pano' . $id . '").children(".pnlm-render-container").remove(); |
| 1346 |
jQuery("#pano' . $id . '").children(".pnlm-ui").remove(); |
| 1347 |
panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes); |
| 1348 |
setTimeout(function() { |
| 1349 |
panoshow' . $id . '.loadScene("' . $default_scene . '"); |
| 1350 |
window.dispatchEvent(new Event("resize")); |
| 1351 |
if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) { |
| 1352 |
jQuery("#controls' . $id . '").css("bottom", "55px"); |
| 1353 |
} |
| 1354 |
else { |
| 1355 |
jQuery("#controls' . $id . '").css("bottom", "5px"); |
| 1356 |
} |
| 1357 |
}, 200); |
| 1358 |
});'; |
| 1359 |
return $html; |
| 1360 |
} |
| 1361 |
} |
| 1362 |
|