PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.72
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.72
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 / admin / class-wpvr-admin.php

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

784 lines 30.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-specific functionality of the plugin.
5 *
6 * @link http://rextheme.com/
7 * @since 8.0.0
8 *
9 * @package Wpvr
10 * @subpackage Wpvr/admin
11 */
12
13 /**
14 * The admin-specific functionality of the plugin.
15 *
16 * Defines the plugin name, version, and two examples hooks for how to
17 * enqueue the admin-specific stylesheet and JavaScript.
18 *
19 * @package Wpvr
20 * @subpackage Wpvr/admin
21 * @author Rextheme <support@rextheme.com>
22 */
23 class Wpvr_Admin {
24
25 /**
26 * The ID of this plugin.
27 *
28 * @since 8.0.0
29 * @access private
30 * @var string $plugin_name The ID of this plugin.
31 */
32 private $plugin_name;
33
34 /**
35 * The version of this plugin.
36 *
37 * @since 8.0.0
38 * @access private
39 * @var string $version The current version of this plugin.
40 */
41 private $version;
42
43 /**
44 * The post type of this plugin.
45 *
46 * @since 8.0.0
47 */
48 private $post_type;
49
50 /**
51 * Instance of WPVR_Admin_Page class
52 *
53 * @var object
54 * @since 8.0.0
55 */
56 private $plugin_admin_page;
57
58 /**
59 * Instance of WPVR_Setup_Meta_Box class
60 *
61 * @var object
62 * @since 8.0.0
63 */
64 private $setup_metabox;
65
66 /**
67 * Instacne of WPVR_Tour_Preview class
68 *
69 * @var object
70 * @since 8.0.0
71 */
72 private $preview_metabox;
73
74 /**
75 * Instance of Wpvr_Ajax class
76 *
77 * @var object
78 * @since 8.0.0
79 */
80 private $plugin_admin_ajax;
81
82 /**
83 * Instance of WPVR_Post_Type class
84 *
85 * @var object
86 * @since 8.0.0
87 */
88 private $wpvr_post_type;
89
90 /**
91 * Instacne of WPVR_Tour_Preview class
92 *
93 * @var object
94 * @since 8.5.24
95 */
96 private $checklist_metabox;
97
98
99 /**
100 * Initialize the class and set its properties.
101 *
102 * @since 8.0.0
103 * @param string $plugin_name The name of this plugin.
104 * @param string $version The version of this plugin.
105 * @param string $post_type Post type of this plugin
106 */
107 public function __construct($plugin_name, $version, $post_type) {
108
109 $this->plugin_name = $plugin_name;
110 $this->version = $version;
111 $this->post_type = $post_type;
112
113 $this->wpvr_post_type = new WPVR_Post_Type($this->plugin_name, $this->version, $this->post_type);
114 $this->plugin_admin_page = WPVR_Admin_Page::getInstance();
115
116 add_action('admin_init', array($this, 'set_custom_meta_box'));
117
118 // // Add the import button to the All Tours page
119 add_action('admin_footer', array($this, 'add_import_button'));
120 add_action('admin_footer', array($this, 'enqueue_deactivation_scripts'), 99);
121
122 $this->plugin_admin_ajax = new Wpvr_Ajax();
123 }
124
125 /**
126 * Register the stylesheets for the admin area.
127 *
128 * @since 8.0.0
129 */
130 public function enqueue_styles() {
131
132 /**
133 * This function is provided for demonstration purposes only.
134 *
135 * An instance of this class should be passed to the run() function
136 * defined in Wpvr_Loader as all of the hooks are defined
137 * in that particular class.
138 *
139 * The Wpvr_Loader will then create the relationship
140 * between the defined hooks and the functions defined in this
141 * class.
142 */
143 $screen = get_current_screen();
144
145
146 if ($screen->id == "toplevel_page_wpvr" || $screen->id == "wp-vr_page_wpvr-setting") {
147 wp_enqueue_style('materialize-css', plugin_dir_url(__FILE__) . 'css/materialize.min.css', array(), $this->version, 'all');
148 wp_enqueue_style('materialize-icons', plugin_dir_url(__FILE__) . 'lib/materializeicon.css', array(), $this->version, 'all');
149 wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all');
150 wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-admin.css', array(), $this->version, 'all');
151 wp_enqueue_style('wpvr-rtl', plugin_dir_url(__FILE__) . 'css/wpvr-admin-rtl.css', array(), $this->version, 'all');
152 }
153
154 if ($screen->id == "edit-wpvr_item") {
155 wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-admin-post-type.css', array(), $this->version, 'all');
156 }
157
158 if ($screen->id == "wpvr_item") {
159 wp_enqueue_style($this->plugin_name . 'fontawesome', plugin_dir_url(__FILE__) . 'lib/fontawesome/css/all.css', array(), $this->version, 'all');
160 wp_enqueue_style('icon-picker-css', plugin_dir_url(__FILE__) . 'css/jquery.fonticonpicker.min.css', array(), $this->version, 'all');
161 wp_enqueue_style('icon-picker-css-theme', plugin_dir_url(__FILE__) . 'css/jquery.fonticonpicker.grey.min.css', array(), $this->version, 'all');
162 wp_enqueue_style('owl-css', plugin_dir_url(__FILE__) . 'css/owl.carousel.css', array(), $this->version, 'all');
163 wp_enqueue_style('panellium-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/pannellum.css', array(), true);
164 wp_enqueue_style('videojs-css', plugin_dir_url(__FILE__) . 'lib/pannellum/src/css/video-js.css', array(), true);
165 wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-admin.css', array(), $this->version, 'all');
166 wp_enqueue_style('wpvr-rtl', plugin_dir_url(__FILE__) . 'css/wpvr-admin-rtl.css', array(), $this->version, 'all');
167 wp_enqueue_style('summernote', plugin_dir_url(__FILE__) . 'lib/summernote/summernote-lite.min.css', array(), $this->version, 'all');
168
169 if (isset($_REQUEST['wpvr-guide-tour']) && $_REQUEST['wpvr-guide-tour'] == 1) {
170 wp_enqueue_style($this->plugin_name . '-shepherd-css', plugin_dir_url(__FILE__) . 'lib/shepherd/css/shepherd-theme-arrows-plain-buttons.css', false, $this->version);
171 wp_enqueue_style($this->plugin_name . '-tour-css', plugin_dir_url(__FILE__) . 'lib/shepherd/css/wpvr-tour-guide.min.css', false, $this->version);
172 }
173 }
174
175 if ($screen->id == "wp-vr_page_wpvr-setup-wizard") {
176 wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpvr-admin2.css', array(), $this->version, 'all');
177 wp_enqueue_style('wpvr-admin2-rtl', plugin_dir_url(__FILE__) . 'css/wpvr-admin2-rtl.css', array(), $this->version, 'all');
178 }
179
180 if ($screen->id == "dashboard_page_rex-wpvr-setup-wizard") {
181 wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/style.css', array(), $this->version, 'all');
182 }
183 }
184
185
186 /**
187 * Register the JavaScript for the admin area.
188 *
189 * @since 8.0.0
190 */
191 public function enqueue_scripts() {
192
193 /**
194 * This function is provided for demonstration purposes only.
195 *
196 * An instance of this class should be passed to the run() function
197 * defined in Wpvr_Loader as all of the hooks are defined
198 * in that particular class.
199 *
200 * The Wpvr_Loader will then create the relationship
201 * between the defined hooks and the functions defined in this
202 * class.
203 */
204
205 $wpvr_list = array();
206 $wpvr_list[] = array('value' => 0, 'label' => 'None');
207 $args = array(
208 'numberposts' => -1,
209 'post_type' => 'wpvr_item'
210 );
211
212 $wpvr_posts = get_posts($args);
213 foreach ($wpvr_posts as $wpvr_post) {
214 $title = $wpvr_post->ID . ' : ' . $wpvr_post->post_title;
215 $wpvr_list[] = array( 'value'=>$wpvr_post->ID,'label'=> $title);
216 }
217
218 wp_enqueue_script('wp-api');
219 wp_enqueue_media();
220
221 $asset_url = apply_filters('change_asset_url', plugin_dir_url(__FILE__));
222
223 wp_enqueue_script('wp-api');
224 $adscreen = get_current_screen();
225 wp_enqueue_media();
226 if ($adscreen->id == "wpvr_item" || $adscreen->id == "toplevel_page_wpvr" || $adscreen->id == "wp-vr_page_wpvr-setting" || $adscreen->id == "edit-wpvr_item") {
227 wp_enqueue_script('summernote', $asset_url . 'lib/summernote/summernote-lite.min.js', array('jquery'), true);
228 wp_enqueue_script('wpvr-icon-picker', $asset_url . 'lib/jquery.fonticonpicker.min.js', array(), true);
229 wp_enqueue_script('panellium-js', $asset_url . 'lib/pannellum/src/js/pannellum.js', array(), true);
230 wp_enqueue_script('panelliumlib-js', $asset_url . 'lib/pannellum/src/js/libpannellum.js', array(), true);
231 wp_enqueue_script('videojs-js', $asset_url . 'js/video.js', array('jquery'), true);
232 wp_enqueue_script('panelliumvid-js', $asset_url . 'lib/pannellum/src/js/videojs-pannellum-plugin.js', array(), true);
233 wp_enqueue_script('jquery-repeater', $asset_url . 'js/jquery.repeater.min.js', array('jquery'), true);
234 wp_enqueue_script('icon-picker', $asset_url . 'lib/jquery.fonticonpicker.min.js', array(), true);
235 wp_enqueue_script('owl', $asset_url . 'js/owl.carousel.js', array('jquery'), false);
236 wp_enqueue_script($this->plugin_name, $asset_url . 'js/wpvr-admin.js', array('jquery'), $this->version, true);
237 wp_localize_script($this->plugin_name, 'wpvr_localize', array(
238 'WriteYourCssHere' => __('Write your css here', 'wpvr'),
239 'VideoTourNotice' => __('Turning On The Video Option Will Erase Your Virtual Tour Data. Are You Sure?', 'wpvr'),
240 'StreetViewNotice' => __('Turning On The StreetView Option Will Erase Your Virtual Tour Data. Are You Sure?', 'wpvr'),
241 'AddingHotspotsOnScene' => __('Adding Hotspots on Scene', 'wpvr'),
242 'WPVR_ASSET_PATH' => WPVR_ASSET_PATH,
243 ));
244 if (isset($_REQUEST['wpvr-guide-tour']) && $_REQUEST['wpvr-guide-tour'] == 1) {
245 wp_enqueue_script($this->plugin_name . '-tether-js', plugin_dir_url(__FILE__) . 'lib/shepherd/tether/tether.js', $this->version, true);
246 wp_enqueue_script($this->plugin_name . '-shepherd-js', plugin_dir_url(__FILE__) . 'lib/shepherd/tether-shepherd/shepherd.js', array($this->plugin_name . '-tether-js'), $this->version, true);
247 wp_enqueue_script($this->plugin_name . '-tour-guide', plugin_dir_url(__FILE__) . 'js/wpvr-tour-guide.js', array('jquery', $this->plugin_name . '-tether-js'), $this->version, true);
248 $tour_guide_translation = new Tour_Guide_Translation();
249
250 wp_localize_script($this->plugin_name . '-tour-guide', 'wpvr_tour_guide_obj', array(
251 'Tour_Guide_Translation' => $tour_guide_translation->get_translatable_string(),
252 'step1_bg_image' => plugins_url('admin/icon/first-step-bg.png', WPVR_FILE),
253 'next_button_arrow' => plugins_url('admin/icon/next-button-arrow.png', WPVR_FILE),
254 ));
255 }
256
257 wp_localize_script($this->plugin_name, 'wpvr_obj', array(
258 'ajaxurl' => admin_url('admin-ajax.php'),
259 'ajax_nonce' => wp_create_nonce('wpvr'),
260 'translated_languages' => $this->get_translated_languages(),
261 'site_language' => get_locale(),
262 'successfully_updated' => __('Successfully Updated', 'wpvr'),
263 'importing_text' => __('Importing...', 'wpvr'),
264 'import_text' => __('Import Now', 'wpvr'),
265 'admin_url' => admin_url(),
266 'is_wpvr_pro_active' => apply_filters('is_wpvr_pro_active', false),
267 'is_wpvr_license_valid' => get_option('wpvr_edd_license_status', '') === 'valid',
268 'published_text' => __('Published', 'wpvr'),
269 'dis_on_hover' => get_option('dis_on_hover') === 'true' ? true : false,
270 'mobile_hotspot_tip' => get_option('wpvr_mobile_hotspot_tip') === 'true' ? true : false,
271 ));
272 }
273
274 if ($adscreen->id == "toplevel_page_wpvr" || $adscreen->id == "wp-vr_page_wpvr-setting") {
275 wp_enqueue_script('materialize-js', $asset_url . 'js/materialize.min.js', array('jquery'), $this->version, false);
276 }
277
278 if ($adscreen->id == "wpvr_item") {
279 wp_enqueue_script($this->plugin_name . '-shortcode', plugin_dir_url(__FILE__) . 'js/wpvr-shortcode.js', array('jquery'), $this->version, true);
280 }
281
282 wp_enqueue_script('owl-js', plugin_dir_url(__FILE__) . 'js/owl.carousel.js', array('jquery'), false);
283 wp_enqueue_script('wpvr-global', $asset_url . 'js/wpvr-global.js', array('jquery'), $this->version, false);
284
285 $admin_user = wp_get_current_user();
286 $admin_name = $admin_user->display_name ?? '';
287
288 wp_localize_script('wpvr-global', 'wpvr_global_obj', array(
289 'ajaxurl' => admin_url('admin-ajax.php'),
290 'site_url' => site_url() . '/wp-json/',
291 'ajax_nonce' => wp_create_nonce('wpvr'),
292 'user_information' => $this->get_logged_in_user_information(),
293 'is_wpvr_active' => is_plugin_active('wpvr-pro/wpvr-pro.php'),
294 'admin_name' => $admin_name,
295 'url_info' => array(
296 'admin_url' => admin_url(),
297 'screen' => $adscreen->action,
298 'url' => $_SERVER['PHP_SELF'],
299 'param' => $_GET,
300 ),
301 'active_tab_url' => admin_url('post-new.php?post_type=wpvr_item&active_tab=scene'),
302 'hotspot_warning_text' => __('Please upload a scene before proceeding to set hotspot!', 'wpvr'),
303 'negative_number_warning_text' =>__('Negative numbers are not allowed!', 'wpvr'),
304 ));
305
306 wp_localize_script('wpvr-global', 'wpvr_id_options', $wpvr_list);
307 }
308
309 /**
310 * Retrieve the currently logged-in user's email and name.
311 *
312 * @since 8.4.10
313 *
314 * @return array An associative array containing the logged-in user's email and name.
315 */
316 public function get_logged_in_user_information(): array
317 {
318 $admin_user = wp_get_current_user();
319 return array(
320 'email' => !empty( $admin_user->user_email ) ? $admin_user->user_email : '',
321 'name' => !empty( $admin_user->display_name ) ? $admin_user->display_name : '',
322 );
323 }
324
325
326 /**
327 * Set Preview and Setup custom metabox of this plugin
328 *
329 * @since 8.0.0
330 */
331 public function set_custom_meta_box() {
332 $this->setup_metabox = new WPVR_Setup_Meta_Box('setup', __('Setup', 'wpvr'), 'wpvr_item', 'normal', 'high');
333
334 $this->preview_metabox = new WPVR_Tour_Preview($this->post_type . '_builder__box', __('Tour Preview', 'wpvr'), $this->post_type, 'side', 'high');
335
336 $this->checklist_metabox = new WPVR_Tour_Checklist_Meta_Box($this->post_type . '_tour_checklist__box', __('Checklist', 'wpvr'), $this->post_type, 'side', 'high');
337
338 }
339
340
341 /**
342 * Plugin action links
343 *
344 * @param $actions || $links
345 * @return array
346 * @since 8.0.0
347 */
348 public function plugin_action_links_wpvr($actions)
349 {
350 $actions['get_started'] = sprintf(
351 '<a href="%s">%s</a>',
352 esc_url(admin_url('admin.php?page=wpvr')),
353 esc_html__('Get Started', 'wpvr')
354 );
355 $actions['documentation'] = sprintf(
356 '<a href="%s" target="_blank">%s</a>',
357 esc_url('https://rextheme.com/docs-category/wp-vr/'),
358 esc_html__('Documentation', 'wpvr')
359 );
360
361 if (!apply_filters('is_wpvr_pro_active', false)) {
362 $actions['go-pro'] = sprintf(
363 '<a href="%s" target="_blank" style="color: #201cfe; font-weight: bold;">%s</a>',
364 esc_url('https://rextheme.com/wpvr/wpvr-pricing/'),
365 esc_html__('Go Pro', 'wpvr')
366 );
367 }
368
369 return $actions;
370 }
371
372 /**
373 * Rollback execution
374 */
375 public function trigger_rollback()
376 {
377 if (!current_user_can('update_plugins') && !current_user_can('install_plugins')) {
378 return false;
379 }
380 $version = isset($_GET['wpvr_version']) ? sanitize_text_field(wp_unslash($_GET['wpvr_version'])) : '';
381 if ($version) {
382 check_admin_referer('wpvr_rollback', 'wpvr_rollback');
383 $plugin_slug = 'wpvr';
384 $rollback = new WPVR_Rollback(
385 [
386 'version' => $version,
387 'plugin_name' => 'wpvr',
388 'plugin_slug' => $plugin_slug,
389 'package_url' => sprintf('https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $version),
390 ]
391 );
392
393 $rollback->run();
394 }
395 }
396
397 /**
398 * Floor plan image Display
399 * Display Pro feature demo in free user
400 * @return void
401 */
402
403 public function floor_plan_image_show_for_free_user() {
404 if (!is_plugin_active('wpvr-pro/wpvr-pro.php')) {
405
406 ?>
407 <div class="rex-pano-tab floor-plan" id="floorPlan">
408
409 <img loading="lazy" src="<?= WPVR_PLUGIN_DIR_URL . 'images/floor-plan-demo.png' ?>" alt="icon" />
410 </div>
411 <?php
412 }
413 }
414
415 /**
416 * Background Tour image Display
417 * Display Pro feature demo in free user
418 * @return void
419 */
420 public function background_tour_image_show_for_free_user() {
421 if (!is_plugin_active('wpvr-pro/wpvr-pro.php')) {
422
423 ?>
424 <div class="rex-pano-tab background-tour" id="backgroundTour">
425
426 <!-- <img src="--><? //= WPVR_PLUGIN_DIR_URL . 'images/floor-plan-demo.png'
427 ?><!--" alt="icon" />-->
428 </div>
429 <?php
430 }
431 }
432 /**
433 * Street View image Display
434 * Display Pro feature demo in free user
435 * @return void
436 */
437
438 public function street_view_image_show_for_free_user() {
439 if (!is_plugin_active('wpvr-pro/wpvr-pro.php')) {
440
441 ?>
442 <div class="rex-pano-tab streetview" id="streetview">
443 <!-- <img src="--><? //= WPVR_PLUGIN_DIR_URL . 'images/floor-plan-demo.png'
444 ?><!--" alt="icon" />-->
445 </div>
446 <?php
447 }
448 }
449
450 public function scene_pro_image_show_for_free_user($pano_scene) {
451 if (!is_plugin_active('wpvr-pro/wpvr-pro.php')) {
452
453 ?>
454 <img loading="lazy" src="<?= WPVR_PLUGIN_DIR_URL . 'images/scene-pro-feature.png' ?>" alt="icon" />
455 <?php
456 }
457 }
458
459
460 public function empty_scene_pro_image_show_for_free_user() {
461 if (!is_plugin_active('wpvr-pro/wpvr-pro.php')) {
462 echo '<img loading="lazy" src="' . esc_url(WPVR_PLUGIN_DIR_URL . 'images/scene-pro-feature.png') . '" alt="WPVR Pro Feature" />';
463 }
464 }
465
466 public function show_review_request_markups() {
467 $show_review_request = get_option('wpvr_feed_review_request');
468 if (empty($show_review_request)) {
469 $data = array(
470 'show' => true,
471 'time' => '',
472 'frequency' => 'immediate',
473 );
474 update_option('wpvr_feed_review_request', $data);
475 }
476 }
477
478 public function wpvr_trigger_based_review_helper() {
479 $show_review_request = get_option('wpvr_feed_review_request');
480 $number_of_published_tours = $this->wpvr_get_total_published_tours();
481 if (!empty($show_review_request) && isset($show_review_request['show']) && $show_review_request['show']) {
482
483 if (isset($show_review_request['frequency']) && $number_of_published_tours > 1) {
484 if ($show_review_request['frequency'] == 'immediate') {
485 add_action('admin_notices', array($this, 'wpvr_generate_review_request_section'));
486 } elseif ($show_review_request['frequency'] == 'one_week') {
487 $last_shown_date = $show_review_request['time'];
488 $current_date = time();
489 $current_date = new DateTime(date('Y-m-d', $current_date));
490 $last_shown_date = new DateTime(date('Y-m-d', $last_shown_date));
491 $date_diff = $last_shown_date->diff($current_date);
492
493 if ($date_diff->d > 7) {
494 add_action('admin_notices', array($this, 'wpvr_generate_review_request_section'));
495 }
496 }
497 }
498 }
499 }
500
501 public function wpvr_generate_review_request_section() {
502 $screen = get_current_screen();
503
504 $promotional_notice_pages = [
505 'dashboard',
506 'plugins',
507 'wpvr_item',
508 'edit-wpvr_item',
509 'toplevel_page_wpvr',
510 'wp-vr_page_wpvr-setup-wizard'
511 ];
512
513 // Only proceed if the current screen ID matches the allowed pages.
514 if (!in_array($screen->id, $promotional_notice_pages)) {
515 return;
516 }
517
518 require_once plugin_dir_path(__FILE__) . 'partials/wpvr-review-request-body-content.php';
519 }
520
521 /**
522 * Get translated languages
523 *
524 * @return array
525 * @since 8.5.21
526 */
527 public function get_translated_languages(){
528 $language_mapping = [
529 'ar' => [ // Arabic
530 'Publish' => 'نشر', // nashr
531 'Update' => 'تحديث' // tahdith
532 ],
533 'pt_PT' => [ // Portuguese (Portugal)
534 'Publish' => 'Publicar',
535 'Update' => 'Atualizar'
536 ],
537 'es_ES' => [ // Spanish (Spain)
538 'Publish' => 'Publicar',
539 'Update' => 'Actualizar'
540 ],
541 'he_IL' => [ // Hebrew (Israel)
542 'Publish' => 'לפרסם', // lefarsem
543 'Update' => 'לעדכן' // le'adken
544 ],
545 'af' => [ // Afrikaans
546 'Publish' => 'Publiseer',
547 'Update' => 'Opdateer'
548 ],
549 'cs_CZ' => [ // Czech (Czech Republic)
550 'Publish' => 'Publikovat',
551 'Update' => 'Aktualizovat'
552 ],
553 'da_DK' => [ // Danish (Denmark)
554 'Publish' => 'Udgiv',
555 'Update' => 'Opdater'
556 ],
557 'de_DE' => [ // German (Germany)
558 'Publish' => 'Veröffentlichen',
559 'Update' => 'Aktualisieren'
560 ],
561 'fi' => [ // Finnish
562 'Publish' => 'Julkaise',
563 'Update' => 'Päivitä'
564 ],
565 'hr' => [ // Croatian
566 'Publish' => 'Objavi',
567 'Update' => 'Ažuriraj'
568 ],
569 'it_IT' => [ // Italian (Italy)
570 'Publish' => 'Pubblica',
571 'Update' => 'Aggiorna'
572 ],
573 'ja' => [ // Japanese
574 'Publish' => '�
575 �開',
576 'Update' => '更新'
577 ],
578 'nl_NL' => [ // Dutch (Netherlands)
579 'Publish' => 'Publiceren',
580 'Update' => 'Updaten'
581 ],
582 'pl_PL' => [ // Polish (Poland)
583 'Publish' => 'Opublikuj',
584 'Update' => 'Aktualizuj'
585 ],
586 'ru_RU' => [ // Russian (Russia)
587 'Publish' => 'Опубликовать',
588 'Update' => 'Обновить'
589 ],
590 'sv_SE' => [ // Swedish (Sweden)
591 'Publish' => 'Publicera',
592 'Update' => 'Uppdatera'
593 ],
594 'fr_FR' => [ // French (France)
595 'Publish' => 'Publier',
596 'Update' => 'Mettre à jour'
597 ],
598 'fr_CA' => [ // French (Canada)
599 'Publish' => 'Publier',
600 'Update' => 'Mettre à jour',
601 ],
602 'fr_BE' => [ // French (Belgium)
603 'Publish' => 'Publier',
604 'Update' => 'Mettre à jour',
605 ],
606 'fr_CH' => [ // Switzerland
607 'Publish' => 'Publier',
608 'Update' => 'Mettre à jour',
609 ],
610 'fr_LU' => [ // Luxembourg
611 'Publish' => 'Publier',
612 'Update' => 'Mettre à jour',
613 ],
614 'fr_MC' => [ // Monaco
615 'Publish' => 'Publier',
616 'Update' => 'Mettre à jour',
617 ],
618 'fr_CM' => [ // Cameroon
619 'Publish' => 'Publier',
620 'Update' => 'Mettre à jour',
621 ],
622 'fr_DZ' => [ // Algeria
623 'Publish' => 'Publier',
624 'Update' => 'Mettre à jour',
625 ],
626 'fr_MA' => [ // Morocco
627 'Publish' => 'Publier',
628 'Update' => 'Mettre à jour',
629 ],
630 'fr_TN' => [ // Tunisia
631 'Publish' => 'Publier',
632 'Update' => 'Mettre à jour',
633 ],
634 'fr_SN' => [ // Senegal
635 'Publish' => 'Publier',
636 'Update' => 'Mettre à jour',
637 ],
638 'fr_HT' => [ // Haiti
639 'Publish' => 'Publier',
640 'Update' => 'Mettre à jour',
641 ],
642 'fr_RW' => [ // Rwanda
643 'Publish' => 'Publier',
644 'Update' => 'Mettre à jour',
645 ],
646 'fr_CD' => [ // DR Congo
647 'Publish' => 'Publier',
648 'Update' => 'Mettre à jour',
649 ],
650 'fr_CI' => [ // Côte d’Ivoire
651 'Publish' => 'Publier',
652 'Update' => 'Mettre à jour',
653 ],
654 ];
655
656 return $language_mapping;
657 }
658
659
660 /**
661 * Add import button to the WPVR All Tours page
662 *
663 * @since 8.5.22
664 */
665 public function add_import_button() {
666 $screen = get_current_screen();
667 $status = get_option('wpvr_edd_license_status');
668
669 // Only add button on the WPVR Tours admin page
670 if ($screen && property_exists($screen, 'id') && ($screen->id === 'edit-wpvr_item')) {
671 ?>
672 <script type="text/javascript">
673 jQuery(document).ready(function($) {
674
675 // Check if user has WPVR Pro
676 var isProUser = <?php echo json_encode(defined('WPVR_PRO_VERSION')); ?>;
677
678 // Add the Import WPVR Tour button
679 var importButton = $('<a href="#" class="page-title-action wpvr-import-button"><?php _e("Import Tour", "wpvr"); ?></a>');
680 $('.wrap .page-title-action').after(importButton);
681
682 // If Free Version, add 'Pro' label
683 if (!isProUser || <?php echo json_encode($status !== 'valid'); ?>) {
684 importButton.append(" <span class='is-pro'>Pro</span>");
685 }
686
687 // If button wasn't added, try alternative placement
688 if ($('.wpvr-import-button').length === 0) {
689 $('.wrap h1.wp-heading-inline').after(importButton);
690 }
691
692 // Add the WPVR Import Form (hidden by default)
693 var importForm = `
694 <div id="wpvr-import-template-area">
695 <div id="wpvr-import-template-title">Choose a .zip archive of a WPVR tour and add it to your website.</div>
696 <form id="wpvr-import-template-form" method="post" action="<?php echo esc_url(admin_url('admin-ajax.php')); ?>" enctype="multipart/form-data">
697 <input type="hidden" name="action" value="wpvr_import_tour">
698 <fieldset id="wpvr-import-template-form-inputs">
699 <input type="file" name="wpvr_import_tour_file" accept=".zip" required>
700 <input id="wpvr-import-template-action" type="button" class="button button-primary" value="${wpvr_obj?.import_text}">
701 </fieldset>
702 </form>
703 </div>
704 `;
705
706 // Append the form after the Import button
707 $('.wpvr-import-button').after(importForm);
708
709 // Toggle form visibility on button click
710 $(document).on('click', '.wpvr-import-button', function(e) {
711 e.preventDefault();
712 if (!isProUser || <?php echo json_encode($status !== 'valid'); ?>) {
713 // Open CRO Modal (Pro Upgrade)
714 $("#wpvr_premium_feature_popup").show();
715 } else {
716 // Open WPVR Import Form
717 $('#wpvr-import-template-area').toggle();
718 }
719 });
720
721 // Close CRO Modal
722 $(document).on("click", "#wpvr_premium_feature_close", function () {
723 $("#wpvr_premium_feature_popup").hide();
724 });
725
726 var $importButton = $('#wpvr-import-template-action');
727 var $fileInput = $('input[name="wpvr_import_tour_file"]');
728
729 // Initially disable the import button
730 $importButton.prop('disabled', true);
731
732 // Enable button when a file is selected
733 $fileInput.on('change', function() {
734 if ($(this).val()) {
735 $importButton.prop('disabled', false);
736 } else {
737 $importButton.prop('disabled', true);
738 }
739 });
740 });
741 </script>
742 <?php
743 }
744 }
745
746 /**
747 * Enqueue deactivation sub-reason JS on plugins.php only, after SDK modal (priority 99).
748 *
749 * @return void
750 */
751 public function enqueue_deactivation_scripts() {
752 global $pagenow;
753 if ( 'plugins.php' !== $pagenow ) {
754 return;
755 }
756 wp_enqueue_script(
757 'wpvr-deactivation',
758 plugin_dir_url( __FILE__ ) . 'js/wpvr-deactivation.js',
759 array( 'jquery' ),
760 $this->version,
761 true
762 );
763 }
764
765 /**
766 * Get total published tours
767 *
768 * @return int
769 * @since 8.5.43
770 */
771 public function wpvr_get_total_published_tours(){
772 $args = array(
773 'post_type' => 'wpvr_item',
774 'post_status' => 'publish',
775 'posts_per_page' => -1,
776 'fields' => 'ids',
777 );
778
779 $query = new WP_Query( $args );
780 return $query->found_posts;
781 }
782
783 }
784