| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Plugin Name: Panorama |
| 5 |
* Description: A lite Weight Plugin that helps you, Easily display panoramic 360 degree images / videos into WordPress Website in Post, Page, Widget Area using shortCode. |
| 6 |
* Plugin URI: https://bplugins.com/products/panorama |
| 7 |
* Version: 1.6.0 |
| 8 |
* Author: bPlugins |
| 9 |
* Author URI: http://abuhayatpolash.com |
| 10 |
* License: GPLv3 |
| 11 |
* Text Domain: panorama-viewer |
| 12 |
* Domain Path: /languages |
| 13 |
*/ |
| 14 |
if ( !defined( 'ABSPATH' ) ) { |
| 15 |
exit; |
| 16 |
} |
| 17 |
if ( function_exists( 'panorama_fs' ) ) { |
| 18 |
panorama_fs()->set_basename( false, __FILE__ ); |
| 19 |
} else { |
| 20 |
if ( !function_exists( 'panorama_fs' ) ) { |
| 21 |
function panorama_fs() { |
| 22 |
global $panorama_fs; |
| 23 |
if ( !isset( $panorama_fs ) ) { |
| 24 |
if ( !defined( 'WP_FS__PRODUCT_8824_MULTISITE' ) ) { |
| 25 |
define( 'WP_FS__PRODUCT_8824_MULTISITE', true ); |
| 26 |
} |
| 27 |
// Include Freemius SDK. |
| 28 |
require_once dirname( __FILE__ ) . '/vendor/freemius/start.php'; |
| 29 |
$panorama_fs = fs_dynamic_init( array( |
| 30 |
'id' => '8824', |
| 31 |
'slug' => 'panorama', |
| 32 |
'type' => 'plugin', |
| 33 |
'public_key' => 'pk_a112d1d1d66d3b480dbea5690d3ff', |
| 34 |
'is_premium' => false, |
| 35 |
'premium_suffix' => 'Pro', |
| 36 |
'has_addons' => false, |
| 37 |
'has_paid_plans' => true, |
| 38 |
'trial' => array( |
| 39 |
'days' => 7, |
| 40 |
'is_require_payment' => false, |
| 41 |
), |
| 42 |
'menu' => array( |
| 43 |
'slug' => 'edit.php?post_type=bppiv-image-viewer', |
| 44 |
'first-path' => 'edit.php?post_type=bppiv-image-viewer&page=bppiv-support#welcome', |
| 45 |
), |
| 46 |
'is_live' => true, |
| 47 |
'is_org_compliant' => true, |
| 48 |
) ); |
| 49 |
} |
| 50 |
return $panorama_fs; |
| 51 |
} |
| 52 |
|
| 53 |
// Init Freemius. |
| 54 |
panorama_fs(); |
| 55 |
// Signal that SDK was initiated. |
| 56 |
do_action( 'panorama_fs_loaded' ); |
| 57 |
} |
| 58 |
// ... Your plugin's main file logic ... |
| 59 |
define( 'BPPIV_PLUGIN_DIR', plugin_dir_url( __FILE__ ) ); |
| 60 |
define( 'BPPIV_VERSION', ( isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] === 'localhost' ? time() : '1.6.0' ) ); |
| 61 |
defined( 'BPPIV_PATH' ) or define( 'BPPIV_PATH', plugin_dir_path( __FILE__ ) ); |
| 62 |
defined( 'BPPIV__FILE__' ) or define( 'BPPIV__FILE__', __FILE__ ); |
| 63 |
define( 'BPPIV_HAS_PRO', file_exists( dirname( __FILE__ ) . '/vendor/freemius/start.php' ) ); |
| 64 |
add_action( 'plugins_loaded', 'bppiv_textdomain' ); |
| 65 |
add_action( 'init', 'onInit' ); |
| 66 |
add_action( 'wp_ajax_panoramaPremiumChecker', 'panoramaPremiumChecker' ); |
| 67 |
add_action( 'wp_ajax_nopriv_panoramaPremiumChecker', 'panoramaPremiumChecker' ); |
| 68 |
add_action( 'admin_init', 'registerSettings' ); |
| 69 |
add_action( 'rest_api_init', 'registerSettings' ); |
| 70 |
add_filter( |
| 71 |
'plugin_row_meta', |
| 72 |
'mppiv_plugin_row_meta', |
| 73 |
10, |
| 74 |
2 |
| 75 |
); |
| 76 |
add_action( 'admin_enqueue_scripts', "bppiv_popup_modal" ); |
| 77 |
add_action( 'wp_ajax_bppivGetBlocks', 'bppivGetBlocks_callback' ); |
| 78 |
// panorama get blocks for our modern dashboard |
| 79 |
function bppivGetBlocks_callback() { |
| 80 |
$nonce = sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) ?? null; |
| 81 |
if ( !wp_verify_nonce( $nonce, 'bppiv_admin_nonce' ) ) { |
| 82 |
wp_send_json_error( 'Invalid Request' ); |
| 83 |
} |
| 84 |
$data = json_decode( stripslashes( $_POST['data'] ), true ); |
| 85 |
$db_data = get_option( 'bppivBlocks', [] ); |
| 86 |
if ( !isset( $data ) && $db_data ) { |
| 87 |
wp_send_json_success( $db_data ); |
| 88 |
} |
| 89 |
update_option( 'bppivBlocks', $data ); |
| 90 |
wp_send_json_success( $data ); |
| 91 |
} |
| 92 |
|
| 93 |
// panorama demo & help link |
| 94 |
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), function ( $links ) { |
| 95 |
$help_link = '<a href="' . admin_url( 'edit.php?post_type=bppiv-image-viewer&page=bppiv-support' ) . '" style="color:#FF7A00;font-weight:bold;">Help & Demos</a>'; |
| 96 |
$links[] = $help_link; |
| 97 |
return $links; |
| 98 |
} ); |
| 99 |
if ( BPPIV_HAS_PRO ) { |
| 100 |
require_once BPPIV_PATH . 'inc/LicenseActivation.php'; |
| 101 |
} |
| 102 |
// panorama google street help modal |
| 103 |
function bppiv_popup_modal() { |
| 104 |
wp_add_inline_script( 'jquery-core', "\r\n jQuery(document).ready(function(\$){\r\n \$('.pano-help-link').on('click', function(e){\r\n e.preventDefault();\r\n if (\$('#pano-help-modal').length === 0) {\r\n \$('body').append(`\r\n <div id='pano-help-modal' style='\r\n position:fixed; top:0; left:0; width:100%; height:100%;\r\n background:rgba(0,0,0,0.5); z-index:9999;\r\n display:flex; justify-content:center; align-items:center;'>\r\n <div style='\r\n background:#fff; padding:20px; max-width:500px; width:90%;\r\n border-radius:6px; box-shadow:0 5px 15px rgba(0,0,0,0.3);'>\r\n <h3>How to Find Google Street View Panorama ID</h3>\r\n <ol>\r\n <li>Open <b>Google Maps</b></li>\r\n <li>Search your location</li>\r\n <li>Drag the yellow Street View icon onto a road</li>\r\n <li>Copy the URL from your browser</li>\r\n <li>Find <b>panoid=</b> in the URL</li>\r\n <li>Copy the text after <b>panoid=</b></li>\r\n </ol>\r\n <p>Example: <code>https://www.google.com/maps/...panoid=JmSoPsBPhqWvaBmOqfFzgA</code></p>\r\n <p>Panorama ID: <code>JmSoPsBPhqWvaBmOqfFzgA</code></p>\r\n <button id='pano-help-close' style='margin-top:10px; cursor:pointer;'>Close</button>\r\n </div>\r\n </div>\r\n `);\r\n }\r\n \$('#pano-help-modal').fadeIn();\r\n \$('#pano-help-close').on('click', function(){ \$('#pano-help-modal').fadeOut(); });\r\n \$('#pano-help-modal').on('click', function(e){ if(e.target.id==='pano-help-modal'){ \$(this).fadeOut(); } });\r\n });\r\n });\r\n " ); |
| 105 |
} |
| 106 |
|
| 107 |
function bppiv_textdomain() { |
| 108 |
load_textdomain( 'panorama-viewer', BPPIV_PLUGIN_DIR . 'languages' ); |
| 109 |
} |
| 110 |
|
| 111 |
// register all blocks |
| 112 |
function onInit() { |
| 113 |
register_block_type( __DIR__ . '/build/blocks/parent' ); |
| 114 |
register_block_type( __DIR__ . '/build/blocks/image-360' ); |
| 115 |
register_block_type( __DIR__ . '/build/blocks/image-3d' ); |
| 116 |
register_block_type( __DIR__ . '/build/blocks/video' ); |
| 117 |
register_block_type( __DIR__ . '/build/blocks/video-360' ); |
| 118 |
register_block_type( __DIR__ . '/build/blocks/google-street' ); |
| 119 |
register_block_type( __DIR__ . '/build/blocks/gallery' ); |
| 120 |
register_block_type( __DIR__ . '/build/blocks/tour' ); |
| 121 |
register_block_type( __DIR__ . '/build/blocks/gutenberg-block' ); |
| 122 |
register_block_type( __DIR__ . '/build/blocks/virtual' ); |
| 123 |
register_block_type( __DIR__ . '/build/blocks/product-spot' ); |
| 124 |
} |
| 125 |
|
| 126 |
function panoramaIsPremium() { |
| 127 |
return panorama_fs()->can_use_premium_code(); |
| 128 |
} |
| 129 |
|
| 130 |
function panoramaPremiumChecker() { |
| 131 |
$nonce = sanitize_text_field( $_POST['_wpnonce'] ?? null ); |
| 132 |
if ( !wp_verify_nonce( $nonce, 'wp_rest' ) ) { |
| 133 |
wp_send_json_error( 'Invalid Request' ); |
| 134 |
} |
| 135 |
wp_send_json_success( [ |
| 136 |
'isPipe' => panoramaIsPremium(), |
| 137 |
] ); |
| 138 |
} |
| 139 |
|
| 140 |
function registerSettings() { |
| 141 |
register_setting( 'panoramaUtils', 'panoramaUtils', [ |
| 142 |
'show_in_rest' => [ |
| 143 |
'name' => 'panoramaUtils', |
| 144 |
'schema' => [ |
| 145 |
'type' => 'string', |
| 146 |
], |
| 147 |
], |
| 148 |
'type' => 'string', |
| 149 |
'default' => wp_json_encode( [ |
| 150 |
'nonce' => wp_create_nonce( 'wp_ajax' ), |
| 151 |
] ), |
| 152 |
'sanitize_callback' => 'sanitize_text_field', |
| 153 |
] ); |
| 154 |
} |
| 155 |
|
| 156 |
// black friday |
| 157 |
function mppiv_plugin_row_meta( $plugin_meta, $plugin_file ) { |
| 158 |
if ( strpos( $plugin_file, 'panorama/panorama.php' ) !== false && time() < strtotime( '2025-12-05' ) ) { |
| 159 |
$plugin_meta[] = "<a href='https://bplugins.com/coupons/?from=plugins.php&plugin=panorama' target='_blank' style='font-weight: 600; color: #146ef5;'>🎉 Black Friday Sale - Get up to 80% OFF Now!</a>"; |
| 160 |
} |
| 161 |
return $plugin_meta; |
| 162 |
} |
| 163 |
|
| 164 |
// FRAMEWORK + OTHER INCLUDES |
| 165 |
require_once 'vendor/csf/codestar-framework.php'; |
| 166 |
require_once 'admin/ads/submenu.php'; |
| 167 |
require_once 'product-spot.php'; |
| 168 |
$init_file = BPPIV_PATH . 'inc/Init.php'; |
| 169 |
if ( file_exists( $init_file ) ) { |
| 170 |
require_once $init_file; |
| 171 |
} |
| 172 |
if ( class_exists( 'BPPIV\\Init' ) ) { |
| 173 |
\BPPIV\Init::instance(); |
| 174 |
} |
| 175 |
function bppiv_get_woo_template( $template ) { |
| 176 |
$path = BPPIV_PATH . 'inc/Woocommerce/template/' . $template; |
| 177 |
if ( file_exists( $path ) ) { |
| 178 |
require $path; |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
// get values from csf |
| 183 |
function bppiv_isset( $array ) { |
| 184 |
return function ( |
| 185 |
$key1, |
| 186 |
$isBoolean = false, |
| 187 |
$default = false, |
| 188 |
$key2 = '' |
| 189 |
) use($array) { |
| 190 |
if ( isset( $array[$key1][$key2] ) ) { |
| 191 |
return ( $isBoolean ? (bool) $array[$key1][$key2] : $array[$key1][$key2] ); |
| 192 |
} |
| 193 |
if ( isset( $array[$key1] ) ) { |
| 194 |
return ( $isBoolean ? (bool) $array[$key1] : $array[$key1] ); |
| 195 |
} |
| 196 |
return $default; |
| 197 |
}; |
| 198 |
} |
| 199 |
|
| 200 |
require_once 'shortcode.php'; |
| 201 |
// codestar textdomain issues resolver |
| 202 |
add_action( 'init', function () { |
| 203 |
if ( panorama_fs()->is_free_plan() ) { |
| 204 |
require_once 'inc/metabox-options-free.php'; |
| 205 |
} |
| 206 |
}, 0 ); |
| 207 |
} |