exists() && 'bricks' === get_template()) {
require_once plugin_dir_path(__FILE__) . 'bricks/bricks.php';
}
/**
* Currently plugin version.
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define('WPVR_VERSION', '8.5.36');
define('WPVR_FILE', __FILE__);
define("WPVR_PLUGIN_DIR_URL", plugin_dir_url(__FILE__));
define("WPVR_PLUGIN_DIR_PATH", plugin_dir_path(__FILE__));
define("WPVR_PLUGIN_PUBLIC_DIR_URL", plugin_dir_url(__FILE__) . 'public/');
define('WPVR_BASE', plugin_basename(WPVR_FILE));
define('WPVR_DEV_MODE', false);
define('WPVR_JS_PATH', plugin_dir_url(__FILE__) . 'admin/js/');
define('WPVR_ASSET_PATH', plugin_dir_url(__FILE__) . 'admin/');
define( 'WPVR_WEBHOOK_URL', sanitize_url( 'https://rextheme.com/?mailmint=1&route=webhook&topic=contact&hash=bbd19901-6d42-4ae5-a7a8-01eb1013c553' ) );
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-wpvr-activator.php
*/
function activate_wpvr()
{
require_once plugin_dir_path(__FILE__) . 'includes/class-wpvr-activator.php';
Wpvr_Activator::activate();
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-wpvr-deactivator.php
*/
function deactivate_wpvr()
{
require_once plugin_dir_path(__FILE__) . 'includes/class-wpvr-deactivator.php';
Wpvr_Deactivator::deactivate();
}
register_activation_hook(__FILE__, 'activate_wpvr');
register_deactivation_hook(__FILE__, 'deactivate_wpvr');
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
require plugin_dir_path(__FILE__) . 'includes/class-wpvr.php';
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 7.3.6
*/
function run_wpvr()
{
$plugin = new Wpvr();
$plugin->run();
// black friday banner class initialization
new WPVR_Special_Occasion_Banner(
'4th_of_july_deal_2025',
'2025-07-02 00:00:01',
'2025-07-14 23:59:59'
);
// if (!defined('WPVR_PRO_VERSION') && 'no' === get_option('wpvr_sell_notification_bar', 'no')) {
// new WPVR_Notification_Bar();
// }
}
run_wpvr();
/**
* Array information checker
*
* @param mixed $needle
* @param mixed $haystack
* @param bool $strict
*
* @return bool
* @since 7.3.6
*/
function wpvr_in_array_r($needle, $haystack, $strict = false)
{
foreach ($haystack as $item) {
if ((($strict ? $item === $needle : $item == $needle)) || is_array($item) && wpvr_in_array_r($needle, $item, $strict)) {
return true;
}
}
return false;
}
/**
* Initialize the plugin tracker
*
* @return void
* @since 7.3.6
*/
function appsero_init_tracker_wpvr()
{
if (!class_exists('Appsero\Client')) {
require_once __DIR__ . '/appsero/src/Client.php';
}
$client = new Appsero\Client('cab9761e-b067-4824-9c71-042df5d58598', 'WP VR', __FILE__);
// Active insights
$client->insights()->init();
}
appsero_init_tracker_wpvr();
function wpvr_block()
{
wp_register_script(
'wpvr-block',
plugins_url('build/index.build.js', __FILE__),
array('wp-blocks', 'wp-element', 'wp-components', 'wp-editor')
);
if (is_admin()) {
wp_enqueue_style(
'gutyblocks/guty-block',
plugins_url('src/view.css', __FILE__),
array()
);
}
if (function_exists('register_block_type')) {
register_block_type('wpvr/wpvr-block', array(
'attributes' => array(
'id' => array(
'type' => 'string',
'default' => '0',
),
'width' => array(
'type' => 'string',
'default' => '600',
),
'width_unit' => array(
'type' => 'string',
'default' => 'px',
),
'height' => array(
'type' => 'string',
'default' => '400',
),
'height_unit' => array(
'type' => 'string',
'default' => 'px',
),
'mobile_height' => array(
'type' => 'string',
'default' => '300',
),
'mobile_height_unit' => array(
'type' => 'string',
'default' => 'px',
),
'radius' => array(
'type' => 'string',
'default' => '0',
),
'border_width' => array(
'type' => 'string',
'default' => '0px',
),
'border_style' => array(
'type' => 'string',
'default' => 'none',
),
'border_color' => array(
'type' => 'string',
'default' => 'none',
),
'radius_unit' => array(
'type' => 'string',
'default' => 'px',
),
'content' => array(
'type' => 'string',
'source' => 'html',
'default' => ''
),
),
'editor_script' => 'wpvr-block',
'render_callback' => 'wpvr_block_render',
));
}
}
add_action('init', 'wpvr_block');
function wpvr_block_render($attributes)
{
if (isset($attributes['id'])) {
$id = $attributes['id'];
} else {
$id = 0;
}
$memberpress_active = defined('MEPR_VERSION');
$rcp_active = is_plugin_active( 'restrict-content-pro/restrict-content-pro.php' );
if (($memberpress_active || $rcp_active ) && apply_filters('is_wpvr_pro_active', false)) {
if (!is_user_logged_in()) {
return esc_html__('You need to log in to access this content.', 'wpvr');
}
$user_id = get_current_user_id();
$allowed_access = false;
// Get saved membership levels from post meta
$allowed_membership_levels = get_post_meta($id, '_wpvr_allowed_roles_levels', true);
if ( isset($allowed_membership_levels) && 'none' !== $allowed_membership_levels ) {
if (!is_array($allowed_membership_levels)) {
$allowed_membership_levels = array($allowed_membership_levels);
}
// Check MemberPress Access
if ($memberpress_active) {
$user = new MeprUser($user_id);
$active_memberships = $user->active_product_subscriptions();
if (array_intersect($allowed_membership_levels, $active_memberships) ) {
$allowed_access = true;
}
}
// Check Restrict Content Pro Access
if ($rcp_active) {
$user_rcp_memberships = rcp_get_customer_memberships($user_id);
foreach ($user_rcp_memberships as $membership) {
$rcp_access_level = array(
$membership->get_object_id()
);
if (array_intersect($allowed_membership_levels, $rcp_access_level) ) {
$allowed_access = true;
break;
}
}
}
} else {
// If no membership restriction is set, allow access by default
$allowed_access = true;
}
if (!$allowed_access) {
return esc_html__('You do not have access to this content.', 'wpvr');
}
}
if (isset($attributes['width'])) {
$width = $attributes['width'];
}
if (isset($attributes['width_unit'])) {
$width_unit = $attributes['width_unit'];
}
if (isset($attributes['height'])) {
$height = $attributes['height'];
}
if (isset($attributes['height_unit'])) {
$height_unit = $attributes['height_unit'];
}
if (isset($attributes['mobile_height'])) {
$mobile_height = $attributes['mobile_height'];
}
if (isset($attributes['mobile_height_unit'])) {
$mobile_height_unit = $attributes['mobile_height_unit'];
}
if (isset($attributes['radius']) && isset($attributes['radius_unit'])) {
$radius = $attributes['radius'] . $attributes['radius_unit'];
}
$border_style = '';
if (isset($attributes['border_width'], $attributes['border_style'], $attributes['border_color'])) {
$border_style = $attributes['border_width'] . 'px ' . $attributes['border_style'] . ' ' . $attributes['border_color'];
}
if (isset($attributes['className'])) {
$className = $attributes['className'];
} else {
$className = '';
}
$get_post = get_post_status($id);
if ($get_post !== 'publish') {
return esc_html__('Oops! It seems like this post isn\'t published yet. Stay tuned for updates!', 'wpvr');
}
if (post_password_required($id)) {
return get_the_password_form();
}
$postdata = get_post_meta($id, 'panodata', true);
$panoid = 'pano' . $id;
$panoid2 = 'pano2' . $id;
if (!isset($postdata) || empty($postdata)) {
return wp_kses(
__('Oops! It seems that you have not selected any tour yet. Please select a tour from the dropdown of WPVR block.
', 'wpvr'),
['br' => []]
);
}
if (isset($postdata['streetviewdata'])) {
if (empty($width)) {
$width = '600px';
}
if (empty($height)) {
$height = '400px';
}
$streetviewurl = $postdata['streetviewurl'];
$html = '';
$html .= '
\s*(]*>)\s*
\s*<\/p>/i',
function ($matches) {
return $matches[1];
},
$hotspot_data['hotspot-hover'] ?? ''
);
$on_hover_content = 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_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 && $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 ($desktop_scene && $desktop_scene[0]) {
$device_scene = $desktop_scene[0];
}
}
}
}
}
}
$scene_info = array();
if ($panoscenes["scene-type"] == 'cubemap') {
$pano_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, '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, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}
if (empty($width)) {
$width = '600';
}
if (empty($height)) {
$height = '400';
}
if ('fullwidth' == $width) {
$width = "100%";
}
$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';
}
$class = 'myclass';
$html = 'test';
$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 (wpvr_isMobileDevice()) {
$html .= '