PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.2
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.2
9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 8.5.4 All 221 releases
wpvr / legacy / includes / class-wpvr.php

class-wpvr.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 9.1.2, at legacy/includes/class-wpvr.php

527 lines 15.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link http://rextheme.com/
10 * @since 8.0.0
11 *
12 * @package Wpvr
13 * @subpackage Wpvr/includes
14 */
15
16 use WPVR\Builder\DIVI\WPVR_Divi_modules;
17
18 /**
19 * The core plugin class.
20 *
21 * This is used to define internationalization, admin-specific hooks, and
22 * public-facing site hooks.
23 *
24 * Also maintains the unique identifier of this plugin as well as the current
25 * version of the plugin.
26 *
27 * @since 8.0.0
28 * @package Wpvr
29 * @subpackage Wpvr/includes
30 * @author Rextheme <support@rextheme.com>
31 */
32 class Wpvr
33 {
34
35 /**
36 * The loader that's responsible for maintaining and registering all hooks that power
37 * the plugin.
38 *
39 * @since 8.0.0
40 * @access protected
41 * @var Wpvr_Loader $loader Maintains and registers all hooks for the plugin.
42 */
43 protected $loader;
44
45 /**
46 * The unique identifier of this plugin.
47 *
48 * @since 8.0.0
49 * @access protected
50 * @var string $plugin_name The string used to uniquely identify this plugin.
51 */
52 protected $plugin_name;
53
54 /**
55 * The current version of the plugin.
56 *
57 * @since 8.0.0
58 * @access protected
59 * @var string $version The current version of the plugin.
60 */
61 protected $version;
62
63 /**
64 * The post type for the plugin
65 *
66 * @since 8.0.0
67 * @var string $version The current version of the plugin.
68 */
69 protected $post_type;
70
71 /**
72 * Instacne of WPVR_Post_Type
73 *
74 * @var object
75 * @since 8.0.0
76 */
77 protected $wpvr_post_type;
78
79 /**
80 * Instance of Wpvr_Admin class
81 *
82 * @var object
83 * @since 8.0.0
84 */
85 protected $plugin_admin;
86
87 /**
88 * Holds instances or information about the DIVI modules used in the builder.
89 *
90 * This property may store an array of module instances or configurations, depending
91 * on how it's utilized within the class. It's used to manage and reference DIVI modules
92 * effectively within custom builder implementations.
93 *
94 * @var array
95 */
96 protected $divi_modules;
97
98 /**
99 * Define the core functionality of the plugin.
100 *
101 * Set the plugin name and the plugin version that can be used throughout the plugin.
102 * Load the dependencies, define the locale, and set the hooks for the admin area and
103 * the public-facing side of the site.
104 *
105 * Define the core functionality of the plugin.
106 *
107 * Set the plugin name and the plugin version that can be used throughout the plugin.
108 * Load the dependencies, define the locale, and set the hooks for the admin area and
109 * the public-facing side of the site.
110 *
111 * @since 8.0.0
112 */
113 public function __construct()
114 {
115 if (defined('WPVR_VERSION')) {
116 $this->version = WPVR_VERSION;
117 } else {
118 $this->version = '8.0.0';
119 }
120 $this->plugin_name = 'wpvr';
121 $this->post_type = 'wpvr_item';
122
123 $this->load_dependencies();
124 $this->set_locale();
125 $this->define_admin_hooks();
126 $this->define_public_hooks();
127 add_action('plugins_loaded', array($this, 'load_plugin'), 99);
128 add_action('init', array($this, 'register_wpvr_setup_wizard'));
129 add_action('admin_init', array($this, 'admin_redirects'));
130 add_filter('wpvr_tracking_enabled', array($this, 'wpvr_tracking_enabled'));
131 }
132
133 /**
134 * Initializes and loads the DIVI modules into the class property.
135 *
136 * This method sets up the DIVI modules by fetching an instance of the WPVR_Divi_modules class
137 * and storing it in the divi_modules property. It ensures that the modules are ready to be
138 * used within the plugin.
139 *
140 * @since 8.4.8 This method was introduced in version 8.4.8 to streamline the initialization of DIVI modules.
141 */
142 public function load_plugin()
143 {
144 $this->divi_modules = WPVR_Divi_modules::instance();
145 }
146
147
148 /**
149 * Load the required dependencies for this plugin.
150 *
151 * Include the following files that make up the plugin:
152 *
153 * - Wpvr_Loader. Orchestrates the hooks of the plugin.
154 * - Wpvr_i18n. Defines internationalization functionality.
155 * - Wpvr_Admin. Defines all hooks for the admin area.
156 * - Wpvr_Public. Defines all hooks for the public side of the site.
157 *
158 * Create an instance of the loader which will be used to register the hooks
159 * with WordPress.
160 *
161 * @since 8.0.0
162 * @access private
163 */
164 private function load_dependencies()
165 {
166
167 /**
168 * The class responsible for auto loading all files of the core plugin.
169 */
170 if ( file_exists( dirname( plugin_dir_path( __DIR__ ) ) . '/vendor/autoload.php' ) ) {
171 require_once dirname( plugin_dir_path( __DIR__ ) ) . '/vendor/autoload.php';
172 } else {
173 require_once plugin_dir_path( __DIR__ ) . 'vendor/autoload.php';
174 }
175
176 /**
177 * The class responsible for orchestrating the actions and filters of the core plugin.
178 */
179 require_once plugin_dir_path(__DIR__) . 'includes/class-wpvr-loader.php';
180
181 /**
182 * The class responsible for defining internationalization functionality of the plugin.
183 */
184 require_once plugin_dir_path(__DIR__) . 'includes/class-wpvr-i18n.php';
185
186 $this->loader = new Wpvr_Loader();
187 }
188
189
190 /**
191 * Define the locale for this plugin for internationalization.
192 *
193 * Uses the Wpvr_i18n class in order to set the domain and to register the hook
194 * with WordPress.
195 *
196 * @since 8.0.0
197 * @access private
198 */
199 private function set_locale()
200 {
201 $plugin_i18n = new Wpvr_i18n();
202 $this->loader->add_action('init', $plugin_i18n, 'load_plugin_textdomain');
203 }
204
205
206 /**
207 * Register all of the hooks related to the admin area functionality
208 * of the plugin.
209 *
210 * @since 8.0.0
211 * @access private
212 */
213 private function define_admin_hooks()
214 {
215 if ( ! function_exists( 'is_plugin_active' ) ) {
216 require_once ABSPATH . 'wp-admin/includes/plugin.php';
217 }
218 $this->plugin_admin = new Wpvr_Admin($this->get_plugin_name(), $this->get_version(), $this->get_post_type());
219
220 $this->loader->add_filter('plugin_action_links_' . WPVR_BASE, $this->plugin_admin, 'plugin_action_links_wpvr', 10, 4);
221 $this->loader->add_action('admin_enqueue_scripts', $this->plugin_admin, 'enqueue_styles');
222 $this->loader->add_action('admin_enqueue_scripts', $this->plugin_admin, 'enqueue_scripts');
223 $this->loader->add_action('publish_wpvr_item', $this->plugin_admin, 'show_review_request_markups', 99999);
224 $this->loader->add_action('admin_init', $this->plugin_admin, 'wpvr_trigger_based_review_helper', 99999);
225 $high_res_image = get_option('high_res_image');
226
227 if ($high_res_image == 'true') { //phpcs:ignore
228 add_filter('big_image_size_threshold', '__return_false');
229 }
230
231 $this->loader->add_action('admin_init', $this->plugin_admin, 'trigger_rollback');
232 if (!is_plugin_active('wpvr-pro/wpvr-pro.php')) {
233 $this->loader->add_action('include_floor_plan_meta_content', $this, 'include_floor_plan_meta_content', 10, 1);
234 $this->loader->add_action('include_background_tour_meta_content', $this, 'include_background_tour_meta_content', 10, 1);
235 $this->loader->add_action('include_street_view_meta_content', $this, 'include_street_view_meta_content', 10, 1);
236 $this->loader->add_action('include_export_meta_content', $this, 'include_export_meta_content', 10, 2);
237 }
238
239 }
240
241 public function include_floor_plan_meta_content($post_data)
242 {
243 ?>
244
245 <div class="rex-pano-tab floor-plan" id="floorPlan">
246 <h6 class="title"> <?php echo esc_html__('Floor Plan Settings : ', 'wpvr');?> </h6>
247
248 <div class="content-wrapper">
249
250 <div class="floor-plan-left">
251 <!-- bg tour on/off -->
252 <div class="single-settings inline-style">
253 <span> <?php echo esc_html__('Enable Floor Plan: ', 'wpvr') ?> </span>
254 <span class="wpvr-switcher">
255 <input id="wpvr_floor_plan_enabler" class="vr-switcher-check wpvr_floor_plan_enabler" name="wpvr_floor_plan_enabler" disabled type="checkbox"/>
256 <label for="wpvr_floor_plan_enabler"></label>
257 </span>
258
259
260 <div class="field-tooltip">
261 <img loading="lazy" src="<?php echo esc_url( WPVR_PLUGIN_DIR_URL . 'admin/icon/tooltip-icon.svg' ); ?>" alt="icon" />
262
263 <span>
264 <?php
265 echo wp_kses(
266 sprintf(
267 /* translators: %s: documentation url */
268 __('Activate the floor plan view for your virtual tour. <a href="%s" target="_blank" rel="noopener noreferrer">View Doc</a>', 'wpvr'),
269 esc_url('https://rextheme.com/docs/virtual-floor-plans-inside-tours/#0-toc-title')
270 ),
271 array(
272 'a' => array('href' => array(), 'target' => array(), 'rel' => array())
273 )
274 );
275 ?>
276 </span>
277 </div>
278
279
280 </div>
281
282 </div>
283
284 </div>
285
286 </div>
287
288 <?php
289 }
290
291 public function include_background_tour_meta_content($post_data)
292 {
293 ?>
294
295 <div class="rex-pano-tab background-tour" id="backgroundTour">
296 <h6 class="title"> <?php echo esc_html__('Background Tour Settings : ', 'wpvr');?> </h6>
297
298 <div class="content-wrapper">
299 <div class="background-tour-left">
300 <!-- bg tour on/off -->
301 <div class="single-settings inline-style">
302 <span> <?php echo esc_html__('Enable Background Tour: ', 'wpvr') ?> </span>
303
304 <span class="wpvr-switcher">
305 <input id="wpvr_bg_tour_enabler" class="vr-switcher-check wpvr_bg_tour_enabler" name="wpvr_bg_tour_enabler" type="checkbox" disabled />
306 <label for="wpvr_bg_tour_enabler"></label>
307 </span>
308
309 <div class="field-tooltip">
310 <img loading="lazy" src="<?php echo esc_url( WPVR_PLUGIN_DIR_URL . 'admin/icon/tooltip-icon.svg' ); ?>" alt="icon" />
311
312 <span>
313 <?php
314 echo wp_kses(
315 sprintf(
316 /* translators: %s: documentation url */
317 __('When enabled, a title and subtitle will appear at the top of the tour. <a href="%s" target="_blank" rel="noopener noreferrer">View Doc</a>', 'wpvr'),
318 esc_url('https://rextheme.com/docs/360-panorama-background-virtual-tour/')
319 ),
320 array(
321 'a' => array('href' => array(), 'target' => array(), 'rel' => array())
322 )
323 );
324 ?>
325 </span>
326 </div>
327
328 </div>
329 </div>
330 </div>
331
332 </div>
333
334 <?php
335 }
336
337 public function include_street_view_meta_content($post_data)
338 {
339 ?>
340
341 <div class="rex-pano-tab streetview" id="streetview">
342
343 <h6 class="title"> <?php echo esc_html__('Embed Google Street View : ', 'wpvr'); ?> </h6>
344
345 <div class="single-settings">
346 <div class="wpvr-global-tooltip-area">
347 <span> <?php echo esc_html__('Enable Street View:','wpvr') ?> </span>
348
349 <div class="field-tooltip">
350 <img loading="lazy" src="<?php echo esc_url( WPVR_PLUGIN_DIR_URL . 'admin/icon/tooltip-icon.svg' ); ?>" alt="icon" />
351 <span>
352 <?php echo esc_html__('Insert a Street View iframe link.', 'wpvr'); ?>
353 <a href="https://rextheme.com/docs/wp-vr-embed-google-street-view-tour/"
354 target="_blank"
355 rel="noopener noreferrer">
356 <?php echo esc_html__('View Doc', 'wpvr'); ?>
357 </a>
358 </span>
359 </div>
360
361 </div>
362
363
364 <ul>
365 <li class="radio-btn">
366 <input class="styled-radio wpvrStreetView_off" id="styled-radio-sv-off" type="radio" name="wpvrStreetView" value="off" >
367 <label for="styled-radio-sv-off">Off</label>
368 </li>
369
370 <li class="radio-btn">
371 <input class="styled-radio wpvrStreetView_on" id="styled-radio-sv-on" type="radio" name="wpvrStreetView" value="on">
372 <label for="styled-radio-sv-on">On</label>
373 </li>
374 </ul>
375
376 </div>
377
378 </div>
379 <?php
380
381 }
382
383 public function include_export_meta_content($post_data ,$post)
384 {
385 ?>
386
387 <div class="rex-pano-tab export" id="import">
388 <h6 class="title"> <?php echo esc_html__('Export Tour : ', 'wpvr') ?></h6>
389 <a class="vr-export"><?php echo esc_html__('Download', 'wpvr') ?></a>
390 </div>
391 <?php
392
393 }
394
395
396 /**
397 * Register all of the hooks related to the public-facing functionality
398 * of the plugin.
399 *
400 * @since 8.0.0
401 * @access private
402 */
403 private function define_public_hooks()
404 {
405 if (apply_filters('is_wpvr_pro_active', false)) {
406 if (class_exists('Wpvrpropublic')) {
407 $plugin_public = new Wpvrpropublic($this->get_plugin_name(), $this->get_version());
408 } else {
409 $plugin_public = new Wpvr_Public($this->get_plugin_name(), $this->get_version());
410 }
411 } else {
412 $plugin_public = new Wpvr_Public($this->get_plugin_name(), $this->get_version());
413 }
414
415 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles');
416 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts');
417 if (method_exists($plugin_public, 'fix_script_deps')) {
418 $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'fix_script_deps', 20);
419 }
420
421 $plugin_public->public_init();
422 }
423
424
425 /**
426 * Run the loader to execute all of the hooks with WordPress.
427 *
428 * @since 8.0.0
429 */
430 public function run()
431 {
432 $this->loader->run();
433 }
434
435
436 /**
437 * The name of the plugin used to uniquely identify it within the context of
438 * WordPress and to define internationalization functionality.
439 *
440 * @since 8.0.0
441 * @return string The name of the plugin.
442 */
443 public function get_plugin_name()
444 {
445 return $this->plugin_name;
446 }
447
448
449 /**
450 * The reference to the class that orchestrates the hooks with the plugin.
451 *
452 * @since 8.0.0
453 * @return Wpvr_Loader Orchestrates the hooks of the plugin.
454 */
455 public function get_loader()
456 {
457 return $this->loader;
458 }
459
460
461 /**
462 * Retrieve the version number of the plugin.
463 *
464 * @since 8.0.0
465 * @return string The version number of the plugin.
466 */
467 public function get_version()
468 {
469 return $this->version;
470 }
471
472
473 /**
474 * Retrieve the post type of the plugin.
475 *
476 * @since 8.0.0
477 */
478 public function get_post_type()
479 {
480 return $this->post_type;
481 }
482
483 public function register_wpvr_setup_wizard()
484 {
485 if (!empty($_GET['page']) && 'rex-wpvr-setup-wizard' == sanitize_text_field($_GET['page'])) {
486 add_action('admin_menu', function () {
487 add_dashboard_page('WPVR Setup', 'WPVR Setup', 'manage_options', 'rex-wpvr-setup-wizard', function () {
488 return '';
489 });
490 });
491 add_action('current_screen', function () {
492 (new WPVR_Setup_Wizard())->setup_wizard();
493 }, 999);
494 }
495 }
496
497 /**
498 * Handle redirects to setup/welcome page after install and updates.
499 *
500 * For setup wizard, transient must be present, the user must have access rights, and we must ignore the network/bulk plugin updaters.
501 */
502 public function admin_redirects()
503 {
504 // Setup wizard redirect.
505 if (get_transient('_wpvr_activation_redirect')) {
506 $do_redirect = true;
507 // On these pages, or during these events, postpone the redirect.
508 if (wp_doing_ajax() || is_network_admin() || !current_user_can('manage_options')) {
509 $do_redirect = false;
510 }
511
512 if ( $do_redirect ) {
513 delete_transient('_wpvr_activation_redirect');
514 $url = admin_url('admin.php?page=rex-wpvr-setup-wizard');
515 wp_safe_redirect( wp_sanitize_redirect( esc_url_raw( $url ) ) );
516 exit;
517 }
518 }
519 }
520
521 public function wpvr_tracking_enabled(){
522 // Check if the tracking option is enabled
523 $tracking_enabled = get_option( 'wpvr_posthog_access_enabled', 'yes' );
524 return $tracking_enabled === 'yes';
525 }
526 }
527