| @@ -202,8 +202,20 @@ | ||
| 202 | 202 | } else { |
| 203 | 203 | $args_clear['texts_unknow'] = $args['texts_unknow']; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | + /** | |
| 207 | + * Ckeck "save_translations" | |
| 208 | + */ | |
| 209 | + | |
| 210 | + $args_clear['save_translations'] = true; | |
| 211 | + | |
| 212 | + if ( isset( $args['save_translations'] ) | |
| 213 | + && is_bool( $args['save_translations'] ) | |
| 214 | + ) { | |
| 215 | + $args_clear['save_translations'] = $args['save_translations']; | |
| 216 | + } | |
| 217 | + | |
| 206 | 218 | $args = $args_clear; |
| 207 | 219 | } |
| 208 | 220 | |
| 209 | 221 | |
| @@ -260,13 +272,13 @@ | ||
| 260 | 272 | */ |
| 261 | 273 | |
| 262 | 274 | $texts_unknow = array(); |
| 263 | 275 | $translations_in_page = array(); |
| 276 | + $detection = wplng_api_feature_is_allow( 'detection' ); | |
| 264 | 277 | |
| 265 | 278 | foreach ( $texts as $text ) { |
| 266 | 279 | |
| 267 | - $is_in = false; | |
| 268 | - $detection = wplng_api_feature_is_allow( 'detection' ); | |
| 280 | + $is_in = false; | |
| 269 | 281 | |
| 270 | 282 | $array_index = (string) mb_substr( $text, 0, 1 ); |
| 271 | 283 | $array_index .= (string) strlen( $text ); |
| 272 | 284 | |
| @@ -272,10 +284,8 @@ | ||
| 272 | 284 | |
| 273 | 285 | if ( ! empty( $translations_all_languages[ $array_index ] ) ) { |
| 274 | 286 | foreach ( $translations_all_languages[ $array_index ] as $translation ) { |
| 275 | 287 | |
| 276 | - // $source = $translation['source']; | |
| 277 | - | |
| 278 | 288 | if ( $text === $translation['source'] |
| 279 | 289 | && isset( $translation['translations'][ $args['language_target'] ] ) |
| 280 | 290 | && is_string( $translation['translations'][ $args['language_target'] ] ) |
| 281 | 291 | && isset( $translation['review'] ) |
| @@ -341,10 +351,15 @@ | ||
| 341 | 351 | /** |
| 342 | 352 | * Check if the current page is overloaded |
| 343 | 353 | */ |
| 344 | 354 | |
| 345 | - $args['overloaded'] = wplng_get_api_overloaded() && ! empty( $args['count_texts_unknow'] ); | |
| 355 | + $api_data = wplng_get_api_data(); | |
| 346 | 356 | |
| 357 | + $args['overloaded'] = ( | |
| 358 | + wplng_get_api_overloaded() | |
| 359 | + && ! empty( $args['count_texts_unknow'] ) | |
| 360 | + ) || ! empty( $api_data['expired'] ); | |
| 361 | + | |
| 347 | 362 | /** |
| 348 | 363 | * Define $max_translations |
| 349 | 364 | */ |
| 350 | 365 | |
| @@ -362,9 +377,9 @@ | ||
| 362 | 377 | |
| 363 | 378 | } elseif ( $args['load'] === 'enabled' |
| 364 | 379 | && $args['count_texts_unknow'] > 10 |
| 365 | 380 | && ! $args['overloaded'] |
| 366 | - && wplng_api_feature_is_allow( 'detection' ) | |
| 381 | + && $detection | |
| 367 | 382 | && current_user_can( 'edit_posts' ) |
| 368 | 383 | ) { |
| 369 | 384 | |
| 370 | 385 | /** |
| @@ -412,12 +427,14 @@ | ||
| 412 | 427 | ); |
| 413 | 428 | } |
| 414 | 429 | } |
| 415 | 430 | |
| 416 | - $translations_new = wplng_save_translations( | |
| 417 | - $translations_new, | |
| 418 | - $args['language_target'] | |
| 419 | - ); | |
| 431 | + if ( $args['save_translations'] === true ) { | |
| 432 | + $translations_new = wplng_save_translations( | |
| 433 | + $translations_new, | |
| 434 | + $args['language_target'] | |
| 435 | + ); | |
| 436 | + } | |
| 420 | 437 | |
| 421 | 438 | /** |
| 422 | 439 | * Merge know and new translations |
| 423 | 440 | */ |