PluginProbe
Translate and Go multilingual – Automatic AI translation – wpLingua / 2.16.7
Translate and Go multilingual – Automatic AI translation – wpLingua v2.16.7
2.16.7 2.16.6 2.16.5 2.16.4 2.16.3 2.16.2 2.16.1 2.16.0 2.15.2 2.15.1 2.15.0 2.14.3 2.14.2 2.14.1 2.14.0 2.13.1 2.13.0 2.12.3 2.12.2 2.12.1 trunk 1.0.3 1.0.4 1.0.5 1.1.0 All 112 releases
← All changes | inc/url.php +18 -11 2.12.22.16.7 View file →
@@ -117,16 +117,21 @@
117 117 return $url;
118 118 }
119 119
120 120 $languages_target = wplng_get_languages_target();
121 - $preg_domain = '';
122 - $parsed_url_home = wp_parse_url( home_url() );
123 121 $home_base_path = wplng_get_home_base_path();
124 122
125 - if ( isset( $parsed_url_home['host'] )
126 - && is_string( $parsed_url_home['host'] )
127 - ) {
128 - $preg_domain = preg_quote( $parsed_url_home['host'] );
123 + static $preg_domain = null;
124 + static $parsed_url_home = null;
125 +
126 + if ( null === $parsed_url_home ) {
127 + $parsed_url_home = wp_parse_url( home_url() );
128 + $preg_domain = '';
129 + if ( isset( $parsed_url_home['host'] )
130 + && is_string( $parsed_url_home['host'] )
131 + ) {
132 + $preg_domain = preg_quote( $parsed_url_home['host'] );
133 + }
129 134 }
130 135
131 136 if ( ! empty( $preg_domain )
132 137 && preg_match( '#^(http:\/\/|https:\/\/)?' . $preg_domain . '(.*)$#', $url )
@@ -202,10 +207,10 @@
202 207 */
203 208
204 209 // Check if URL is already translated
205 210 foreach ( $languages_target as $language_target ) {
206 - if ( substr( $url, 0, 4 ) === ( '/' . $language_target['id'] . '/' )
207 - || substr( $url, 0, 3 ) === ( $language_target['id'] . '/' )
211 + if ( wplng_str_starts_with( $url, '/' . $language_target['id'] . '/' )
212 + || wplng_str_starts_with( $url, $language_target['id'] . '/' )
208 213 ) {
209 214 return $url;
210 215 }
211 216 }
@@ -283,8 +288,10 @@
283 288 if ( wplng_str_contains( $url, 'wp-login.php' )
284 289 || wplng_str_contains( $url, 'wp-register.php' )
285 290 || wplng_str_contains( $url, 'wp-comments-post.php' )
286 291 || wplng_str_contains( $url, 'wp-cron.php' )
292 + || wplng_str_contains( $url, '?doing_wp_cron=' )
293 + || wplng_str_contains( $url, '&doing_wp_cron=' )
287 294 || wplng_str_contains( $url, 'xmlrpc.php' )
288 295 || wplng_str_ends_with( $url, '/feed/' )
289 296 || wplng_str_contains( $url, '/wp-json/' )
290 297 || wplng_str_contains( $url, '/wp-includes/' )
@@ -315,9 +322,9 @@
315 322 return false;
316 323 }
317 324
318 325 // Exclude files URL
319 - $regex_is_file = '#\.(avi|css|js|map|docx?|exe|gif|html?|jfif|jpe?g|webp|bmp|midi?|mp3|mpe?g|avif|mov|qt|pdf|png|ra?m|rar|tiff?|txt|wav|zip|ico|xml|rss|xls[x]?|ttf|otf|woff2?|eot|svg)?\/$#i';
326 + $regex_is_file = '#\.(avi|css|js|map|docx?|exe|gif|html?|jfif|jpe?g|webp|bmp|midi?|mp3|mpe?g|avif|mov|qt|pdf|png|ra?m|rar|tiff?|txt|wav|zip|ico|xml|rss|xls[x]?|ttf|otf|woff2?|eot|svg)\/$#i';
320 327
321 328 if ( preg_match( $regex_is_file, $url ) ) {
322 329 return false;
323 330 }
@@ -364,9 +371,9 @@
364 371
365 372 // Check each URL REGEX
366 373 foreach ( $option as $regex ) {
367 374 $regex = trim( $regex );
368 - if ( '' !== $regex ) {
375 + if ( '' !== $regex && false !== @preg_match( '#' . $regex . '#', '' ) ) {
369 376 $url_exclude[] = '#' . $regex . '#';
370 377 }
371 378 }
372 379
@@ -504,9 +511,9 @@
504 511 $parsed_url = wp_parse_url( $url );
505 512 $url_path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
506 513
507 514 // Check if the URL matches common sitemap patterns
508 - $is_sitemap = str_contains( $url_path, 'sitemap' ) && str_contains( $url_path, '.xml' );
515 + $is_sitemap = wplng_str_contains( $url_path, 'sitemap' ) && wplng_str_contains( $url_path, '.xml' );
509 516
510 517 /**
511 518 * Filter to allow customization of the sitemap detection logic
512 519 *