PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | vikbooking.php +189 -14 1.6.9 → 1.8.16 View file →
@@ -2,9 +2,9 @@
2 2 /*
3 3 Plugin Name: VikBooking
4 4 Plugin URI: https://vikwp.com/plugin/vikbooking
5 5 Description: Certified Booking Engine for Hotels and Accommodations.
6 -Version: 1.6.9
6 +Version: 1.8.16
7 7 Author: E4J s.r.l.
8 8 Author URI: https://vikwp.com
9 9 License: GPL2
10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -77,8 +77,9 @@
77 77 add_action('plugins_loaded', array('VikBookingBuilder', 'setupOverridesManager'));
78 78
79 79 // setup lite system
80 80 add_action('plugins_loaded', array('VikBookingLiteManager', 'setup'));
81 +add_action('plugins_loaded', array('VikChannelManagerLiteManager', 'setup'));
81 82
82 83 /**
83 84 * Added support for screen options.
84 85 * Parameters such as the list limit can be changed from there.
@@ -105,21 +106,8 @@
105 106 {
106 107 // installer class will check the update status
107 108 VikBookingInstaller::update();
108 109
109 - /**
110 - *
111 - * Fires once the plugins have loaded.
112 - *
113 - * Language is loaded through the filter 'plugins_loaded' in order to avoid to load language
114 - * before the correct one has been set by WordPress or by another third-party plugin.
115 - *
116 - * @link https://developer.wordpress.org/reference/hooks/plugins_loaded/
117 - *
118 - * @since 1.4.2
119 - */
120 - VikBookingBuilder::loadLanguage();
121 -
122 110 global $pagenow;
123 111
124 112 $app = JFactory::getApplication();
125 113 $input = $app->input;
@@ -161,8 +149,15 @@
161 149
162 150 // process the request and obtain the response
163 151 add_action('init', function()
164 152 {
153 + /**
154 + * Language files should no longer be loaded during 'plugins_loaded'.
155 + *
156 + * @since 1.7.6
157 + */
158 + VikBookingBuilder::loadLanguage();
159 +
165 160 $app = JFactory::getApplication();
166 161 $input = $app->input;
167 162
168 163 // if we are in the front-end, try to parse the URL to inject
@@ -220,8 +215,16 @@
220 215
221 216 // register widgets
222 217 add_action('widgets_init', array('VikBookingBuilder', 'setupWidgets'));
223 218
219 +/**
220 + * Load plugin language when registering the widgets as well.
221 + * Since translations are now loaded at "init", they might not be available yet.
222 + *
223 + * @since 1.8.4
224 + */
225 +add_action('widgets_init', ['VikBookingBuilder', 'loadLanguage'], 1);
226 +
224 227 // handle shortcodes (SITE controller dispatcher)
225 228 add_shortcode('vikbooking', function($atts, $content = null)
226 229 {
227 230 $app = JFactory::getApplication();
@@ -269,8 +272,31 @@
269 272 {
270 273 $input->def($k, $args->get($k));
271 274 }
272 275
276 + /**
277 + * When saving a shortcode block through Gutenberg,
278 + * WordPress tries to reach the page to check what happens.
279 + * Some views of VikBooking may immediately redirect the users to
280 + * another page URI.
281 + * This redirect breaks the request made by WordPress for the
282 + * validation of the page, which follows the new location.
283 + * The code below prevents the execution of the controller
284 + * in case the URI matches the REST API end-point.
285 + *
286 + * @since 1.7
287 + */
288 + $rest_prefix = trailingslashit(rest_get_url_prefix());
289 + $is_rest_api = strpos($input->server->getString('REQUEST_URI', ''), $rest_prefix) !== false
290 + || JUri::getInstance($input->server->getString('REQUEST_URI', ''))->hasVar('rest_route')
291 + || strpos($input->server->getString('REQUEST_URI', ''), '/wp-admin/') !== false;
292 +
293 + if ($is_rest_api && in_array($input->get('view'), ['tinyurl']))
294 + {
295 + // return an empty string to prevent any redirects
296 + return '';
297 + }
298 +
273 299 // dispatch the controller
274 300 return VikBookingBody::getHtml(true);
275 301 });
276 302
@@ -320,8 +346,18 @@
320 346 VikBooking::getTracker();
321 347 VikBooking::loadPreferredColorStyles();
322 348 }
323 349
350 + /**
351 + * Prevent some pages from performing an auto-redirect when running
352 + * the Bricks plugin preview.
353 + *
354 + * @since 1.7.7
355 + */
356 + if ($app->input->get('bricks') === 'run' && in_array($app->input->get('view'), ['tinyurl']))
357 + {
358 + $app->input->set('view', '');
359 + }
324 360 });
325 361
326 362 // instead using the default server timezone, try to use the one
327 363 // specified within the WordPress configuration
@@ -564,8 +600,99 @@
564 600 */
565 601 add_action('plugins_loaded', array('VikBookingCron', 'setup'), (PHP_INT_MAX - 1));
566 602
567 603 /**
604 + * Action used to register a periodic check of the automatic payments scheduled.
605 + * This hook will be called by a scheduled event in WP-Cron.
606 + *
607 + * @since 1.6.10
608 + */
609 +add_action('vikbooking_cron_payments_scheduled', function()
610 +{
611 + // watch the automatic payments scheduled, if any
612 + VBOModelPayschedules::getInstance()->watch();
613 +});
614 +
615 +/**
616 + * Action used to register a periodic performance cleaning check.
617 + * This hook will be called by a scheduled event in WP-Cron.
618 + *
619 + * @since 1.7.2
620 + * @since 1.8.7 scheduled DAC expired passcodes cleaning.
621 + */
622 +add_action('vikbooking_cron_performance_cleaner', function()
623 +{
624 + // performance cleaning check
625 + VBOPerformanceCleaner::runCheck();
626 + // clean up expired passcodes from smart locks
627 + VBOFactory::getDoorAccessControl()->cleanExpiredPasscodes();
628 +});
629 +
630 +/**
631 + * Action used to register a periodic check of door-access-control framework.
632 + * This hook will be called by a scheduled event in WP-Cron.
633 + *
634 + * @since 1.8.4
635 + * @since 1.8.6 added support to watch the devices first access.
636 + */
637 +add_action('vikbooking_cron_door_access_control', function()
638 +{
639 + // watch if any booking is approaching the check-in date
640 + VBOFactory::getDoorAccessControl()->handleUpcomingArrivals();
641 + // watch if passcodes get used for the first time
642 + VBOFactory::getDoorAccessControl()->watchFirstAccess();
643 +});
644 +
645 +/**
646 + * Action used to register a periodic database cleaning check.
647 + * This hook will be called by a scheduled event in WP-Cron.
648 + *
649 + * @since 1.8.5
650 + */
651 +add_action('vikbooking_cron_db_optimization', ['VBOPerformanceCleaner', 'optimizeDatabase']);
652 +
653 +/**
654 + * Install the scheduling of the hook within WP-Cron needed
655 + * to watch and process the automatic payments scheduled.
656 + *
657 + * @since 1.6.10
658 + * @since 1.7.2 registered "vikbooking_cron_performance_cleaner".
659 + * @since 1.8.4 registered "vikbooking_cron_door_access_control".
660 + * @since 1.8.5 registered "vikbooking_cron_db_optimization".
661 + */
662 +add_action('plugins_loaded', function()
663 +{
664 + // make sure the cron event hasn't been yet scheduled.
665 + if (!wp_next_scheduled('vikbooking_cron_payments_scheduled'))
666 + {
667 + // schedule event starting from the current time for "every half hour"
668 + // such interval will be installed by VikBookingCron::setup()
669 + wp_schedule_event(time(), 'half_hour', 'vikbooking_cron_payments_scheduled');
670 + }
671 +
672 + // make sure the cron event hasn't been yet scheduled.
673 + if (!wp_next_scheduled('vikbooking_cron_performance_cleaner'))
674 + {
675 + // schedule event starting from the current time for "every week"
676 + wp_schedule_event(time(), 'weekly', 'vikbooking_cron_performance_cleaner');
677 + }
678 +
679 + // make sure the cron event hasn't been yet scheduled.
680 + if (!wp_next_scheduled('vikbooking_cron_door_access_control'))
681 + {
682 + // schedule event starting from the current time for "every hour"
683 + wp_schedule_event(time(), 'hourly', 'vikbooking_cron_door_access_control');
684 + }
685 +
686 + // make sure the cron event hasn't been yet scheduled.
687 + if (!wp_next_scheduled('vikbooking_cron_db_optimization'))
688 + {
689 + // schedule event starting from the current time for "every hour"
690 + wp_schedule_event(time(), 'hourly', 'vikbooking_cron_db_optimization');
691 + }
692 +}, (PHP_INT_MAX - 1));
693 +
694 +/**
568 695 * Filters the action links displayed for each plugin in the Plugins list table.
569 696 * Hook used to filter the "deactivation" link and ask a feedback every time that
570 697 * button is clicked.
571 698 *
@@ -744,8 +871,46 @@
744 871 <?php
745 872 });
746 873
747 874 /**
875 + * Detect outdated VCM versions.
876 + *
877 + * @since 1.8.13
878 + */
879 +add_action('admin_notices', function()
880 +{
881 + global $pagenow;
882 +
883 + if (wp_doing_ajax())
884 + {
885 + // nothing to check
886 + return;
887 + }
888 +
889 + $option = JFactory::getApplication()->input->get('option');
890 + $inPlugins = in_array($option, ['com_vikbooking', 'com_vikchannelmanager']);
891 +
892 + if (!$inPlugins && $pagenow != 'plugins.php')
893 + {
894 + // nothing to check
895 + return;
896 + }
897 +
898 + if (!defined('VIKCHANNELMANAGER_SOFTWARE_VERSION') || version_compare(VIKCHANNELMANAGER_SOFTWARE_VERSION, VIKCHANNELMANAGER_MINIMUM_VERSION, '>='))
899 + {
900 + // check passed
901 + return;
902 + }
903 +
904 + echo JLayoutHelper::render(
905 + 'html.vcm.version',
906 + ['page' => $inPlugins ? preg_replace('/^com_/', '', $option) : $pagenow],
907 + null,
908 + ['component' => 'com_vikbooking']
909 + );
910 +});
911 +
912 +/**
748 913 * Downloads the RSS feeds after loading the dashboard of VikBooking.
749 914 *
750 915 * @since 1.3.9
751 916 */
@@ -817,8 +982,18 @@
817 982 $input = $app->input;
818 983
819 984 // make sure we are not inside Vik Booking
820 985 if ($input->get('option') == 'com_vikbooking' || $input->get('page') == 'vikbooking' || $input->get('action') == 'vikbooking')
986 + {
987 + return;
988 + }
989 +
990 + /**
991 + * Avoid conflicts with third-party page-builder plugins that may simulate the front-end.
992 + *
993 + * @since 1.8.1
994 + */
995 + if (!$app->isClient('administrator'))
821 996 {
822 997 return;
823 998 }
824 999