Linklocalizer - Source Excerpt 02
Summary
This source excerpt preserves a bounded section of Antichrist.net/wp-content/plugins/uaix-locale-router/src/LinkLocalizer.php so readers can inspect the evidence without opening the full source file.
**Source path:** Antichrist.net/wp-content/plugins/uaix-locale-router/src/LinkLocalizer.php
if ( '' === $canonical_target || ! is_string( $canonical_target ) ) {
return $url;
}
if ( ! empty( $query ) ) {
$canonical_target = add_query_arg( $query, $canonical_target );
}
$fragment = (string) wp_parse_url( $url, PHP_URL_FRAGMENT );
if ( '' !== $fragment ) {
$canonical_target .= '#' . ltrim( $fragment, '#' );
}
return $canonical_target;
}
/**
* Determine whether a URL should not be localized.
*
* @param string $url URL input.
* @return bool
*/
private static function is_excluded_url( $url ) {
if ( preg_match( '#^(mailto:|tel:|javascript:)#i', $url ) ) {
return true;
}
if ( '#' === substr( $url, 0, 1 ) ) {
return true;
}
return false;
}
/**
* Determine whether the current runtime context should bypass URL localization.
*
* @return bool
*/
private static function should_bypass_localization_context() {
$settings = Plugin::settings();
if ( empty( $settings['enabled'] ) ) {
return true;
}
if ( is_admin() || wp_doing_ajax() || wp_doing_cron() ) {
return true;
}
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
return true;
}
return false;
}
}