PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.39
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.39
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.39, at admin/class-wpvr-admin.php

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