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 | libraries/adapter/application/route.php +46 -1 1.6.4 → 1.8.16 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * @package VikWP - Libraries
4 4 * @subpackage adapter.application
5 5 * @author E4J s.r.l.
6 - * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
6 + * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
7 7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 8 * @link https://vikwp.com
9 9 */
10 10
@@ -190,8 +190,28 @@
190 190 {
191 191 // if the post ID is set, get the permalink directly
192 192 if ($post_id)
193 193 {
194 + /**
195 + * Added support to WPML, since it is unable to properly obtain the
196 + * correct permalink depending the requested language tag.
197 + *
198 + * @since 10.1.55
199 + */
200 + $wpml_post_lang = apply_filters('wpml_post_language_details', null, $post_id);
201 +
202 + /**
203 + * Make sure we haven't received an error object from WPML.
204 + *
205 + * @since 10.1.60
206 + */
207 + if ($wpml_post_lang && !is_wp_error($wpml_post_lang))
208 + {
209 + // WPML supported, go ahead
210 + return apply_filters('wpml_permalink', get_permalink($post_id), $wpml_post_lang['language_code']);
211 + }
212 +
213 + // WPML not supported, fallback to the default behavior
194 214 return get_permalink($post_id);
195 215 }
196 216
197 217 // otherwise get the current permalink
@@ -401,8 +421,33 @@
401 421 $difference = array();
402 422
403 423 foreach ($array1 as $key => $value)
404 424 {
425 + /**
426 + * Improved the comparison of the language tag, which might be
427 + * handled in different ways from different sections of WP.
428 + *
429 + * @since 10.1.49
430 + */
431 + if ($key === 'lang')
432 + {
433 + // check whether at least a language code doesn't mention the country code
434 + if (!preg_match("/[_\-]/", $value) || !preg_match("/[_\-]/", $array2[$key]))
435 + {
436 + // remove country code from locale assigned to the shortcode
437 + $array2[$key] = preg_split("/[_\-]/", $array2[$key]);
438 + $array2[$key] = array_shift($array2[$key]);
439 +
440 + // remove country code from URL locale
441 + $value = preg_split("/[_\-]/", $value);
442 + $value = array_shift($value);
443 + }
444 +
445 + // normalize locale separators
446 + $array2[$key] = str_replace('-', '_', $array2[$key]);
447 + $value = str_replace('-', '_', $value);
448 + }
449 +
405 450 if (is_array($value))
406 451 {
407 452 if (!isset($array2[$key]) || !is_array($array2[$key]))
408 453 {