PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 All 204 releases
← All changes | core/wpbc-translation.php +24 -16 11.4.311.8.4 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -409,11 +409,11 @@
409 409
410 410 /**
411 411 * Translate content. Check for language sections -- [lang=xx_XX] shortcode. // FixIn: 10.0.0.46.
412 412 *
413 - * @param $content_orig
414 - *
415 - * @return string
413 + * @param mixed $content_orig Content containing optional language sections.
414 + *
415 + * @return string Translated content, or an empty string for unsupported values.
416 416 */
417 417 function wpbc_lang( $content_orig ) {
418 418 return wpdev_check_for_active_language( $content_orig );
419 419 }
@@ -421,24 +421,32 @@
421 421
422 422 /**
423 423 * Check plugin text for active language section -- [lang=xx_XX] shortcode
424 424 *
425 - * @param string $content_orig
426 - * @return string
425 + * @param mixed $content_orig Content containing optional language sections.
426 + * @return string Translated content, or an empty string for unsupported values.
427 427 * Usage:
428 428 * $text = wpbc_lang( $text );
429 429 */
430 -function wpdev_check_for_active_language( $content_orig ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
430 +function wpdev_check_for_active_language( $content_orig ) { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
431 +
432 + if ( is_string( $content_orig ) ) {
433 + $content = $content_orig;
434 + } elseif ( is_scalar( $content_orig ) ) {
435 + $content = (string) $content_orig;
436 + } elseif ( is_object( $content_orig ) && method_exists( $content_orig, '__toString' ) ) {
437 + $content = (string) $content_orig;
438 + } else {
439 + return '';
440 + }
441 +
442 + $languages = array();
443 + $content_ex = explode( '[lang', $content );
444 +
445 + foreach ( $content_ex as $value ) {
446 +
447 + if ( '=' === substr( $value, 0, 1 ) ) {
431 448
432 - $content = $content_orig;
433 -
434 - $languages = array();
435 - $content_ex = explode('[lang',$content);
436 -
437 - foreach ( $content_ex as $value ) {
438 -
439 - if ( '=' == substr( $value, 0, 1 ) ) {
440 -
441 449 $pos_s = strpos( $value, '=' );
442 450 $pos_f = strpos( $value, ']' );
443 451 $key = trim( substr( $value, ( $pos_s + 1 ), ( $pos_f - $pos_s - 1 ) ) );
444 452 $value_l = trim( substr( $value, $pos_f + 1 ) );
@@ -448,9 +456,9 @@
448 456 $languages['default'] = $value;
449 457 }
450 458 }
451 459
452 - $locale = wpbc_get_maybe_reloaded_booking_locale(); // $locale = 'fr_FR';
460 + $locale = wpbc_get_maybe_reloaded_booking_locale(); // $locale = 'fr_FR'.
453 461
454 462 if ( isset( $languages[ $locale ] ) ) {
455 463 $return_text = $languages[ $locale ];
456 464 } else {