= 1 && $options['limit'] <= 12 ) { $profile['query']['limit'] = (int) $options['limit']; } $language = $options['language'] ?? ''; if ( ! in_array( $language, AKLA_Admin::LANGUAGES, true ) ) { $language = $profile['query']['language'] ?? 'en'; if ( 'page' === ( $profile['language_mode'] ?? 'fixed' ) ) { $locale = function_exists( 'pll_current_language' ) ? pll_current_language( 'locale' ) : apply_filters( 'wpml_current_language', null ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WPML public integration hook must keep its documented name. $locale = is_string( $locale ) && '' !== $locale ? $locale : get_locale(); $code = strtolower( str_replace( '_', '-', $locale ) ); $language = str_starts_with( $code, 'zh-tw' ) || str_starts_with( $code, 'zh-hk' ) || 'zh-hant' === $code ? 'zh-TW' : ( str_starts_with( $code, 'zh' ) ? 'zh' : ( str_starts_with( $code, 'fr' ) ? 'fr' : ( str_starts_with( $code, 'en' ) ? 'en' : $language ) ) ); } } $profile['query']['language'] = in_array( $language, AKLA_Admin::LANGUAGES, true ) ? $language : 'en'; $widget = wp_is_uuid( $widget ) ? $widget : ( $profile['widget_id'] ?? '' ); if ( ! empty( $options['instance'] ) && wp_is_uuid( $widget ) ) { $hash = hash( 'sha256', $widget . '|' . $options['instance'] ); $widget = substr( $hash, 0, 8 ) . '-' . substr( $hash, 8, 4 ) . '-4' . substr( $hash, 13, 3 ) . '-a' . substr( $hash, 17, 3 ) . '-' . substr( $hash, 20, 12 ); } return array( 'profile' => $profile, 'widget' => $widget, 'language' => $profile['query']['language'], ); } }