Version Description
- Fixed issue in WP 5.9 causing Invalid Data SQL Error reports
- Improved page load time for WooCommerce websites on translated languages
- Improved admin notices regarding database optimization
Download this release
Release Info
| Developer | razvan.mo |
| Plugin | |
| Version | 2.2.2 |
| Comparing to | |
| See all releases | |
Code changes from version 2.2.1 to 2.2.2
- assets/js/trp-update-database.js +1 -0
- assets/lib/simplehtmldom/simple_html_dom.php +11 -1
- class-translate-press.php +5 -2
- includes/class-check-invalid-text.php +91 -0
- includes/class-query.php +33 -9
- includes/class-translation-render.php +3 -0
- includes/class-upgrade.php +9 -8
- includes/compatibility-functions.php +1 -2
- includes/functions.php +7 -3
- index.php +2 -2
- languages/translatepress-multilingual.pot +16 -16
- readme.txt +7 -2
assets/js/trp-update-database.js
CHANGED
|
@@ -19,5 +19,6 @@ jQuery( function() {
|
|
| 19 |
trigger_update_by_ajax( {
|
| 20 |
action: 'trp_update_database',
|
| 21 |
trp_updb_nonce: trp_updb_localized['nonce'],
|
|
|
|
| 22 |
} );
|
| 23 |
});
|
| 19 |
trigger_update_by_ajax( {
|
| 20 |
action: 'trp_update_database',
|
| 21 |
trp_updb_nonce: trp_updb_localized['nonce'],
|
| 22 |
+
initiate_update: true,
|
| 23 |
} );
|
| 24 |
});
|
assets/lib/simplehtmldom/simple_html_dom.php
CHANGED
|
@@ -36,6 +36,9 @@ namespace TranslatePress;
|
|
| 36 |
* (Reason for this change: tag <text> exists in HTML docs so we need a different reserved tag.)
|
| 37 |
* (In class-translation-render.php we use find('trptext') because of this. ).
|
| 38 |
*
|
|
|
|
|
|
|
|
|
|
| 39 |
*/
|
| 40 |
|
| 41 |
define('TRP_HDOM_TYPE_ELEMENT', 1);
|
|
@@ -506,7 +509,14 @@ class simple_html_dom_node
|
|
| 506 |
{
|
| 507 |
case TRP_HDOM_QUOTE_DOUBLE: $quote = '"'; break;
|
| 508 |
case TRP_HDOM_QUOTE_SINGLE: $quote = '\''; break;
|
| 509 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 510 |
}
|
| 511 |
|
| 512 |
$ret .= $key
|
| 36 |
* (Reason for this change: tag <text> exists in HTML docs so we need a different reserved tag.)
|
| 37 |
* (In class-translation-render.php we use find('trptext') because of this. ).
|
| 38 |
*
|
| 39 |
+
* In function makeup() the default $quote was changed from '' to double quotes, ' " ', because it was causing a JS security issue when onclick()
|
| 40 |
+
* function was used as translation for a link where title was set without double quotes.
|
| 41 |
+
*
|
| 42 |
*/
|
| 43 |
|
| 44 |
define('TRP_HDOM_TYPE_ELEMENT', 1);
|
| 509 |
{
|
| 510 |
case TRP_HDOM_QUOTE_DOUBLE: $quote = '"'; break;
|
| 511 |
case TRP_HDOM_QUOTE_SINGLE: $quote = '\''; break;
|
| 512 |
+
default: $quote = '';
|
| 513 |
+
/*
|
| 514 |
+
* TranslatePress modifications
|
| 515 |
+
* We changed the default $quote from '' to ' " ' to avoid JS security issue. There is a filter applied on this global, $TRP_HDOM_QUOTE_DEFAULT,
|
| 516 |
+
* so it can be changed in case there is a problem for some clients.
|
| 517 |
+
|
| 518 |
+
default: { global $TRP_HDOM_QUOTE_DEFAULT; $quote = $TRP_HDOM_QUOTE_DEFAULT; };
|
| 519 |
+
*/
|
| 520 |
}
|
| 521 |
|
| 522 |
$ret .= $key
|
class-translate-press.php
CHANGED
|
@@ -34,6 +34,7 @@ class TRP_Translate_Press{
|
|
| 34 |
protected $install_plugins;
|
| 35 |
protected $reviews;
|
| 36 |
protected $rewrite_rules;
|
|
|
|
| 37 |
|
| 38 |
public $active_pro_addons = array();
|
| 39 |
public static $translate_press = null;
|
|
@@ -59,7 +60,7 @@ class TRP_Translate_Press{
|
|
| 59 |
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
| 60 |
define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
|
| 61 |
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
|
| 62 |
-
define( 'TRP_PLUGIN_VERSION', '2.2.
|
| 63 |
|
| 64 |
wp_cache_add_non_persistent_groups(array('trp'));
|
| 65 |
|
|
@@ -118,6 +119,7 @@ class TRP_Translate_Press{
|
|
| 118 |
require_once TRP_PLUGIN_DIR . 'includes/class-install-plugins.php';
|
| 119 |
require_once TRP_PLUGIN_DIR . 'includes/class-reviews.php';
|
| 120 |
require_once TRP_PLUGIN_DIR . 'includes/class-rewrite-rules.php';
|
|
|
|
| 121 |
require_once TRP_PLUGIN_DIR . 'assets/lib/tp-add-ons-listing/tp-add-ons-listing.php';
|
| 122 |
if ( did_action( 'elementor/loaded' ) )
|
| 123 |
require_once TRP_PLUGIN_DIR . 'includes/class-elementor-language-for-blocks.php';
|
|
@@ -159,6 +161,7 @@ class TRP_Translate_Press{
|
|
| 159 |
$this->install_plugins = new TRP_Install_Plugins();
|
| 160 |
$this->reviews = new TRP_Reviews( $this->settings->get_settings() );
|
| 161 |
$this->rewrite_rules = new TRP_Rewrite_Rules( $this->settings->get_settings() );
|
|
|
|
| 162 |
}
|
| 163 |
|
| 164 |
/**
|
|
@@ -249,10 +252,10 @@ class TRP_Translate_Press{
|
|
| 249 |
|
| 250 |
|
| 251 |
$this->loader->add_action( 'admin_menu', $this->upgrade, 'register_menu_page' );
|
|
|
|
| 252 |
$this->loader->add_action( 'admin_init', $this->upgrade, 'show_admin_notice' );
|
| 253 |
$this->loader->add_action( 'admin_init', $this->upgrade, 'show_notification_about_add_ons_removal' );
|
| 254 |
$this->loader->add_action( 'admin_init', $this->upgrade, 'trp_prepare_options_for_database_optimization' );
|
| 255 |
-
$this->loader->add_action( 'admin_init', $this->upgrade, 'show_admin_error_message' );
|
| 256 |
$this->loader->add_action( 'admin_enqueue_scripts', $this->upgrade, 'enqueue_update_script', 10, 1 );
|
| 257 |
$this->loader->add_action( 'wp_ajax_trp_update_database', $this->upgrade, 'trp_update_database' );
|
| 258 |
|
| 34 |
protected $install_plugins;
|
| 35 |
protected $reviews;
|
| 36 |
protected $rewrite_rules;
|
| 37 |
+
protected $check_invalid_text;
|
| 38 |
|
| 39 |
public $active_pro_addons = array();
|
| 40 |
public static $translate_press = null;
|
| 60 |
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
| 61 |
define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
|
| 62 |
define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
|
| 63 |
+
define( 'TRP_PLUGIN_VERSION', '2.2.2' );
|
| 64 |
|
| 65 |
wp_cache_add_non_persistent_groups(array('trp'));
|
| 66 |
|
| 119 |
require_once TRP_PLUGIN_DIR . 'includes/class-install-plugins.php';
|
| 120 |
require_once TRP_PLUGIN_DIR . 'includes/class-reviews.php';
|
| 121 |
require_once TRP_PLUGIN_DIR . 'includes/class-rewrite-rules.php';
|
| 122 |
+
require_once TRP_PLUGIN_DIR . 'includes/class-check-invalid-text.php';
|
| 123 |
require_once TRP_PLUGIN_DIR . 'assets/lib/tp-add-ons-listing/tp-add-ons-listing.php';
|
| 124 |
if ( did_action( 'elementor/loaded' ) )
|
| 125 |
require_once TRP_PLUGIN_DIR . 'includes/class-elementor-language-for-blocks.php';
|
| 161 |
$this->install_plugins = new TRP_Install_Plugins();
|
| 162 |
$this->reviews = new TRP_Reviews( $this->settings->get_settings() );
|
| 163 |
$this->rewrite_rules = new TRP_Rewrite_Rules( $this->settings->get_settings() );
|
| 164 |
+
$this->check_invalid_text = new TRP_Check_Invalid_Text();
|
| 165 |
}
|
| 166 |
|
| 167 |
/**
|
| 252 |
|
| 253 |
|
| 254 |
$this->loader->add_action( 'admin_menu', $this->upgrade, 'register_menu_page' );
|
| 255 |
+
$this->loader->add_action( 'admin_init', $this->upgrade, 'show_admin_error_message' );
|
| 256 |
$this->loader->add_action( 'admin_init', $this->upgrade, 'show_admin_notice' );
|
| 257 |
$this->loader->add_action( 'admin_init', $this->upgrade, 'show_notification_about_add_ons_removal' );
|
| 258 |
$this->loader->add_action( 'admin_init', $this->upgrade, 'trp_prepare_options_for_database_optimization' );
|
|
|
|
| 259 |
$this->loader->add_action( 'admin_enqueue_scripts', $this->upgrade, 'enqueue_update_script', 10, 1 );
|
| 260 |
$this->loader->add_action( 'wp_ajax_trp_update_database', $this->upgrade, 'trp_update_database' );
|
| 261 |
|
includes/class-check-invalid-text.php
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Class TRP_Check_Invalid_Text
|
| 4 |
+
*
|
| 5 |
+
* Used to exclude problematic strings triggering 'WordPress database error: Could not perform query because it contains invalid data.' from TP query functions.
|
| 6 |
+
*
|
| 7 |
+
* Divide et impera method used to minimise number of queries needed to detect needle in haystack. Applied for key functions:
|
| 8 |
+
* get_existing_translations, insert_strings and update_strings.
|
| 9 |
+
*/
|
| 10 |
+
class TRP_Check_Invalid_Text{
|
| 11 |
+
protected $table_charset;
|
| 12 |
+
protected $check_current_query;
|
| 13 |
+
protected $col_meta;
|
| 14 |
+
|
| 15 |
+
public function get_existing_translations_without_invalid_text( $dictionary, $prepared_query, $strings_array, $language_code, $block_type ){
|
| 16 |
+
if ( $this->is_invalid_data_error() ){
|
| 17 |
+
$count = count($strings_array);
|
| 18 |
+
if ( $count <= 1 ){
|
| 19 |
+
// fake translated so it doesn't get auto translated or updated in DB later
|
| 20 |
+
$entry = new stdClass();
|
| 21 |
+
$entry->translated = $strings_array[0];
|
| 22 |
+
$entry->original = $strings_array[0];
|
| 23 |
+
$entry->status = "1";
|
| 24 |
+
$entry->invalid_data = true;
|
| 25 |
+
return array( $strings_array[0] => $entry);
|
| 26 |
+
}else{
|
| 27 |
+
$trp = TRP_Translate_Press::get_trp_instance();
|
| 28 |
+
$trp_query = $trp->get_component( 'query' );
|
| 29 |
+
|
| 30 |
+
$half = floor( $count / 2 );
|
| 31 |
+
|
| 32 |
+
$array1 = $trp_query->get_existing_translations( array_slice( $strings_array, 0, $half ), $language_code, $block_type );
|
| 33 |
+
$array2 = $trp_query->get_existing_translations( array_slice( $strings_array, $half ), $language_code, $block_type );
|
| 34 |
+
return array_merge( $array1, $array2 );
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
return $dictionary;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
public function insert_translations_without_invalid_text( $new_strings, $language_code, $block_type ){
|
| 41 |
+
if ( $this->is_invalid_data_error() ){
|
| 42 |
+
$count = count($new_strings);
|
| 43 |
+
if ( $count <= 1 ){
|
| 44 |
+
return;
|
| 45 |
+
}else{
|
| 46 |
+
$trp = TRP_Translate_Press::get_trp_instance();
|
| 47 |
+
$trp_query = $trp->get_component( 'query' );
|
| 48 |
+
|
| 49 |
+
$half = floor( $count / 2 );
|
| 50 |
+
|
| 51 |
+
$trp_query->insert_strings( array_slice( $new_strings, 0, $half ), $language_code, $block_type );
|
| 52 |
+
$trp_query->insert_strings( array_slice( $new_strings, $half ), $language_code, $block_type );
|
| 53 |
+
return;
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
public function update_translations_without_invalid_text( $update_strings, $language_code, $block_type ){
|
| 60 |
+
if ( $this->is_invalid_data_error() ){
|
| 61 |
+
$count = count($update_strings);
|
| 62 |
+
if ( $count <= 1 ){
|
| 63 |
+
return;
|
| 64 |
+
}else{
|
| 65 |
+
$trp = TRP_Translate_Press::get_trp_instance();
|
| 66 |
+
$trp_query = $trp->get_component( 'query' );
|
| 67 |
+
|
| 68 |
+
$half = floor( $count / 2 );
|
| 69 |
+
|
| 70 |
+
$trp_query->update_strings( array_slice( $update_strings, 0, $half ), $language_code, $block_type );
|
| 71 |
+
$trp_query->update_strings( array_slice( $update_strings, $half ), $language_code, $block_type );
|
| 72 |
+
return;
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function is_invalid_data_error(){
|
| 79 |
+
// Using $trp_disable_invalid_data_detection as a sort of apply_filters to turn off this feature.
|
| 80 |
+
// Not using proper WP filter to reduce page load time. This function is executed many times.
|
| 81 |
+
global $wpdb, $trp_disable_invalid_data_detection;
|
| 82 |
+
if ( !empty($wpdb->last_error) && !isset( $trp_disable_invalid_data_detection) ) {
|
| 83 |
+
$invalid_data_error = __( 'WordPress database error: Could not perform query because it contains invalid data.' ); /* phpcs:ignore */ /* $domain arg is purposely omitted because we want to identify the exact wpdb last_error message. Only used for comparison reasons, it's not actually displayed. */
|
| 84 |
+
if ( $wpdb->last_error == $invalid_data_error ) {
|
| 85 |
+
return true;
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
return false;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
}
|
includes/class-query.php
CHANGED
|
@@ -14,6 +14,7 @@ class TRP_Query{
|
|
| 14 |
protected $url_converter;
|
| 15 |
protected $translation_render;
|
| 16 |
protected $error_manager;
|
|
|
|
| 17 |
protected $tables_exist = array();
|
| 18 |
protected $db_sql_version = null;
|
| 19 |
|
|
@@ -80,15 +81,26 @@ class TRP_Query{
|
|
| 80 |
$prepared_query = $this->db->prepare( $query, $values );
|
| 81 |
$dictionary = $this->db->get_results( $prepared_query, OBJECT_K );
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running get_existing_translations()' ) );
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
// if table is missing then last_error is empty for the select query
|
| 86 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Missing table ' . $this->get_table_name( $language_code ) . ' . To regenerate tables, try going to Settings->TranslatePress->General tab and Save Settings.'), true );
|
| 87 |
}
|
| 88 |
-
if ($this->db->last_error !== '')
|
| 89 |
-
$dictionary = false;
|
| 90 |
|
| 91 |
-
return
|
| 92 |
}
|
| 93 |
|
| 94 |
/**
|
|
@@ -674,7 +686,11 @@ class TRP_Query{
|
|
| 674 |
|
| 675 |
$prepared_query = $this->db->prepare($query . ' ', $values);
|
| 676 |
$this->db->query( $prepared_query );
|
| 677 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 678 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running update_strings()' ) );
|
| 679 |
}
|
| 680 |
|
|
@@ -711,9 +727,12 @@ class TRP_Query{
|
|
| 711 |
// you cannot insert multiple rows at once using insert() method.
|
| 712 |
// but by using prepare you cannot insert NULL values.
|
| 713 |
$this->db->query( $this->db->prepare($query . ' ', $values) );
|
| 714 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 715 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running insert_strings()' ) );
|
| 716 |
-
|
| 717 |
}
|
| 718 |
|
| 719 |
public function insert_gettext_strings( $new_strings, $language_code ){
|
|
@@ -955,11 +974,11 @@ class TRP_Query{
|
|
| 955 |
|
| 956 |
public function get_all_gettext_strings( $language_code ){
|
| 957 |
$dictionary = $this->db->get_results( "SELECT id, original, translated, domain FROM `" . sanitize_text_field( $this->get_gettext_table_name( $language_code ) ) . "`", ARRAY_A );
|
|
|
|
| 958 |
if ( is_array( $dictionary ) && count( $dictionary ) === 0 && !$this->table_exists($this->get_gettext_table_name( $language_code )) ){
|
| 959 |
// if table is missing then last_error is empty
|
| 960 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Missing table ' . $this->get_gettext_table_name( $language_code ). ' . To regenerate tables, try going to Settings->TranslatePress->General tab and Save Settings.'), true );
|
| 961 |
}
|
| 962 |
-
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running get_all_gettext_strings()' ) );
|
| 963 |
return $dictionary;
|
| 964 |
}
|
| 965 |
|
|
@@ -1396,7 +1415,12 @@ class TRP_Query{
|
|
| 1396 |
}
|
| 1397 |
|
| 1398 |
public function maybe_record_automatic_translation_error($error_details = array(), $ignore_last_error = false ){
|
| 1399 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1400 |
$trp = TRP_Translate_Press::get_trp_instance();
|
| 1401 |
if( !$this->error_manager ){
|
| 1402 |
$this->error_manager = $trp->get_component( 'error_manager' );
|
| 14 |
protected $url_converter;
|
| 15 |
protected $translation_render;
|
| 16 |
protected $error_manager;
|
| 17 |
+
protected $check_invalid_text;
|
| 18 |
protected $tables_exist = array();
|
| 19 |
protected $db_sql_version = null;
|
| 20 |
|
| 81 |
$prepared_query = $this->db->prepare( $query, $values );
|
| 82 |
$dictionary = $this->db->get_results( $prepared_query, OBJECT_K );
|
| 83 |
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
if( !$this->check_invalid_text ){
|
| 87 |
+
$trp = TRP_Translate_Press::get_trp_instance();
|
| 88 |
+
$this->check_invalid_text = $trp->get_component( 'check_invalid_text' );
|
| 89 |
+
}
|
| 90 |
+
$dictionary = $this->check_invalid_text->get_existing_translations_without_invalid_text($dictionary, $prepared_query, $strings_array, $language_code, $block_type );
|
| 91 |
+
|
| 92 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running get_existing_translations()' ) );
|
| 93 |
+
|
| 94 |
+
if ($this->db->last_error !== '' && !$this->check_invalid_text->is_invalid_data_error())
|
| 95 |
+
$dictionary = false;
|
| 96 |
+
|
| 97 |
+
$dictionary = apply_filters( 'trp_get_existing_translations', $dictionary, $prepared_query, $strings_array, $language_code, $block_type );
|
| 98 |
+
if ( is_array( $dictionary ) && count( $dictionary ) === 0 && !$this->table_exists($this->get_table_name( $language_code )) && !$this->check_invalid_text->is_invalid_data_error()){
|
| 99 |
// if table is missing then last_error is empty for the select query
|
| 100 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Missing table ' . $this->get_table_name( $language_code ) . ' . To regenerate tables, try going to Settings->TranslatePress->General tab and Save Settings.'), true );
|
| 101 |
}
|
|
|
|
|
|
|
| 102 |
|
| 103 |
+
return $dictionary;
|
| 104 |
}
|
| 105 |
|
| 106 |
/**
|
| 686 |
|
| 687 |
$prepared_query = $this->db->prepare($query . ' ', $values);
|
| 688 |
$this->db->query( $prepared_query );
|
| 689 |
+
if( !$this->check_invalid_text ){
|
| 690 |
+
$trp = TRP_Translate_Press::get_trp_instance();
|
| 691 |
+
$this->check_invalid_text = $trp->get_component( 'check_invalid_text' );
|
| 692 |
+
}
|
| 693 |
+
$this->check_invalid_text->update_translations_without_invalid_text( $update_strings, $language_code, $columns_to_update );
|
| 694 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running update_strings()' ) );
|
| 695 |
}
|
| 696 |
|
| 727 |
// you cannot insert multiple rows at once using insert() method.
|
| 728 |
// but by using prepare you cannot insert NULL values.
|
| 729 |
$this->db->query( $this->db->prepare($query . ' ', $values) );
|
| 730 |
+
if( !$this->check_invalid_text ){
|
| 731 |
+
$trp = TRP_Translate_Press::get_trp_instance();
|
| 732 |
+
$this->check_invalid_text = $trp->get_component( 'check_invalid_text' );
|
| 733 |
+
}
|
| 734 |
+
$this->check_invalid_text->insert_translations_without_invalid_text($new_strings, $language_code, $block_type);
|
| 735 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running insert_strings()' ) );
|
|
|
|
| 736 |
}
|
| 737 |
|
| 738 |
public function insert_gettext_strings( $new_strings, $language_code ){
|
| 974 |
|
| 975 |
public function get_all_gettext_strings( $language_code ){
|
| 976 |
$dictionary = $this->db->get_results( "SELECT id, original, translated, domain FROM `" . sanitize_text_field( $this->get_gettext_table_name( $language_code ) ) . "`", ARRAY_A );
|
| 977 |
+
$this->maybe_record_automatic_translation_error(array( 'details' => 'Error running get_all_gettext_strings()' ) );
|
| 978 |
if ( is_array( $dictionary ) && count( $dictionary ) === 0 && !$this->table_exists($this->get_gettext_table_name( $language_code )) ){
|
| 979 |
// if table is missing then last_error is empty
|
| 980 |
$this->maybe_record_automatic_translation_error(array( 'details' => 'Missing table ' . $this->get_gettext_table_name( $language_code ). ' . To regenerate tables, try going to Settings->TranslatePress->General tab and Save Settings.'), true );
|
| 981 |
}
|
|
|
|
| 982 |
return $dictionary;
|
| 983 |
}
|
| 984 |
|
| 1415 |
}
|
| 1416 |
|
| 1417 |
public function maybe_record_automatic_translation_error($error_details = array(), $ignore_last_error = false ){
|
| 1418 |
+
if( !$this->check_invalid_text ){
|
| 1419 |
+
$trp = TRP_Translate_Press::get_trp_instance();
|
| 1420 |
+
$this->check_invalid_text = $trp->get_component( 'check_invalid_text' );
|
| 1421 |
+
}
|
| 1422 |
+
|
| 1423 |
+
if ( ( !empty( $this->db->last_error) && !$this->check_invalid_text->is_invalid_data_error() ) || $ignore_last_error ){
|
| 1424 |
$trp = TRP_Translate_Press::get_trp_instance();
|
| 1425 |
if( !$this->error_manager ){
|
| 1426 |
$this->error_manager = $trp->get_component( 'error_manager' );
|
includes/class-translation-render.php
CHANGED
|
@@ -381,6 +381,9 @@ class TRP_Translation_Render{
|
|
| 381 |
return $output;
|
| 382 |
}
|
| 383 |
|
|
|
|
|
|
|
|
|
|
| 384 |
global $trp_editor_notices;
|
| 385 |
|
| 386 |
/* replace our special tags so we have valid html */
|
| 381 |
return $output;
|
| 382 |
}
|
| 383 |
|
| 384 |
+
global $TRP_HDOM_QUOTE_DEFAULT;
|
| 385 |
+
$TRP_HDOM_QUOTE_DEFAULT = apply_filters('trp_hdom_quote_default_double_quotes', '"');
|
| 386 |
+
|
| 387 |
global $trp_editor_notices;
|
| 388 |
|
| 389 |
/* replace our special tags so we have valid html */
|
includes/class-upgrade.php
CHANGED
|
@@ -226,9 +226,10 @@ class TRP_Upgrade {
|
|
| 226 |
return;
|
| 227 |
}
|
| 228 |
$updates_needed = $this->get_updates_details();
|
|
|
|
| 229 |
foreach( $updates_needed as $update ){
|
| 230 |
$option = get_option( $update['option_name'], 'is not set' );
|
| 231 |
-
if ( $option === 'no' ){
|
| 232 |
add_action( 'admin_notices', array( $this, 'admin_notice_update_database' ) );
|
| 233 |
break;
|
| 234 |
}
|
|
@@ -264,13 +265,11 @@ class TRP_Upgrade {
|
|
| 264 |
return;
|
| 265 |
}
|
| 266 |
$updates_needed = $this->get_updates_details();
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
add_action( 'admin_notices', array( $this, 'trp_admin_notice_error_database' ) );
|
| 271 |
-
break;
|
| 272 |
-
}
|
| 273 |
}
|
|
|
|
| 274 |
}
|
| 275 |
|
| 276 |
public function trp_admin_notice_error_database(){
|
|
@@ -305,6 +304,9 @@ class TRP_Upgrade {
|
|
| 305 |
$request = array();
|
| 306 |
$request['progress_message'] = '';
|
| 307 |
$updates_needed = $this->get_updates_details();
|
|
|
|
|
|
|
|
|
|
| 308 |
if ( empty ( $_REQUEST['trp_updb_action'] ) ){
|
| 309 |
foreach( $updates_needed as $update_action_key => $update ) {
|
| 310 |
$option = get_option( $update['option_name'], 'is not set' );
|
|
@@ -586,7 +588,6 @@ class TRP_Upgrade {
|
|
| 586 |
}
|
| 587 |
|
| 588 |
if ( $redirect ) {
|
| 589 |
-
update_option('trp_show_error_db_message', 'no');
|
| 590 |
$url = add_query_arg( array( 'page' => 'trp_update_database' ), site_url( 'wp-admin/admin.php' ) );
|
| 591 |
wp_safe_redirect( $url );
|
| 592 |
exit;
|
| 226 |
return;
|
| 227 |
}
|
| 228 |
$updates_needed = $this->get_updates_details();
|
| 229 |
+
$option_db_error_message = get_option($updates_needed['show_error_db_message']['option_name']);
|
| 230 |
foreach( $updates_needed as $update ){
|
| 231 |
$option = get_option( $update['option_name'], 'is not set' );
|
| 232 |
+
if ( $option === 'no' && $option_db_error_message !== 'no'){
|
| 233 |
add_action( 'admin_notices', array( $this, 'admin_notice_update_database' ) );
|
| 234 |
break;
|
| 235 |
}
|
| 265 |
return;
|
| 266 |
}
|
| 267 |
$updates_needed = $this->get_updates_details();
|
| 268 |
+
$option_db_error_message = get_option($updates_needed['show_error_db_message']['option_name']);
|
| 269 |
+
if ( $option_db_error_message === 'no' ) {
|
| 270 |
+
add_action( 'admin_notices', array( $this, 'trp_admin_notice_error_database' ) );
|
|
|
|
|
|
|
|
|
|
| 271 |
}
|
| 272 |
+
|
| 273 |
}
|
| 274 |
|
| 275 |
public function trp_admin_notice_error_database(){
|
| 304 |
$request = array();
|
| 305 |
$request['progress_message'] = '';
|
| 306 |
$updates_needed = $this->get_updates_details();
|
| 307 |
+
if (isset($_REQUEST['initiate_update']) && $_REQUEST['initiate_update']=== "true" ){
|
| 308 |
+
update_option('trp_show_error_db_message', 'no');
|
| 309 |
+
}
|
| 310 |
if ( empty ( $_REQUEST['trp_updb_action'] ) ){
|
| 311 |
foreach( $updates_needed as $update_action_key => $update ) {
|
| 312 |
$option = get_option( $update['option_name'], 'is not set' );
|
| 588 |
}
|
| 589 |
|
| 590 |
if ( $redirect ) {
|
|
|
|
| 591 |
$url = add_query_arg( array( 'page' => 'trp_update_database' ), site_url( 'wp-admin/admin.php' ) );
|
| 592 |
wp_safe_redirect( $url );
|
| 593 |
exit;
|
includes/compatibility-functions.php
CHANGED
|
@@ -1623,5 +1623,4 @@ function trp_page_builders_compatibility_with_subdirectory_for_default_language(
|
|
| 1623 |
$needed_language = $settings['default-language'];
|
| 1624 |
}
|
| 1625 |
return $needed_language;
|
| 1626 |
-
}
|
| 1627 |
-
|
| 1623 |
$needed_language = $settings['default-language'];
|
| 1624 |
}
|
| 1625 |
return $needed_language;
|
| 1626 |
+
}
|
|
|
includes/functions.php
CHANGED
|
@@ -94,7 +94,11 @@ function trp_x( $text, $context, $domain, $language ){
|
|
| 94 |
* @return string the path of the mo file if it is found else an empty string
|
| 95 |
*/
|
| 96 |
function trp_find_translation_location_for_domain( $domain, $language ){
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
$path = '';
|
| 99 |
|
| 100 |
if( file_exists( WP_LANG_DIR . '/plugins/'. $domain .'-' . $language . '.mo') ) {
|
|
@@ -107,8 +111,8 @@ function trp_find_translation_location_for_domain( $domain, $language ){
|
|
| 107 |
} else {
|
| 108 |
$possible_translation_folders = array( '', 'languages/', 'language/', 'translations/', 'translation/', 'lang/' );
|
| 109 |
foreach( $possible_translation_folders as $possible_translation_folder ){
|
| 110 |
-
if (file_exists(
|
| 111 |
-
$path =
|
| 112 |
} elseif ( file_exists(WP_PLUGIN_DIR . '/' . $domain . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo') ) {
|
| 113 |
$path = WP_PLUGIN_DIR . '/' . $domain . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo';
|
| 114 |
}
|
| 94 |
* @return string the path of the mo file if it is found else an empty string
|
| 95 |
*/
|
| 96 |
function trp_find_translation_location_for_domain( $domain, $language ){
|
| 97 |
+
global $trp_template_directory;
|
| 98 |
+
if ( !isset($trp_template_directory)){
|
| 99 |
+
// "caching" this because it sometimes leads to increased page load time due to many calls
|
| 100 |
+
$trp_template_directory = get_template_directory();
|
| 101 |
+
}
|
| 102 |
$path = '';
|
| 103 |
|
| 104 |
if( file_exists( WP_LANG_DIR . '/plugins/'. $domain .'-' . $language . '.mo') ) {
|
| 111 |
} else {
|
| 112 |
$possible_translation_folders = array( '', 'languages/', 'language/', 'translations/', 'translation/', 'lang/' );
|
| 113 |
foreach( $possible_translation_folders as $possible_translation_folder ){
|
| 114 |
+
if (file_exists($trp_template_directory . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo')) {
|
| 115 |
+
$path = $trp_template_directory . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo';
|
| 116 |
} elseif ( file_exists(WP_PLUGIN_DIR . '/' . $domain . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo') ) {
|
| 117 |
$path = WP_PLUGIN_DIR . '/' . $domain . '/' . $possible_translation_folder . $domain . '-' . $language . '.mo';
|
| 118 |
}
|
index.php
CHANGED
|
@@ -3,14 +3,14 @@
|
|
| 3 |
Plugin Name: TranslatePress - Multilingual
|
| 4 |
Plugin URI: https://translatepress.com/
|
| 5 |
Description: Experience a better way of translating your WordPress site using a visual front-end translation editor, with full support for WooCommerce and site builders.
|
| 6 |
-
Version: 2.2.
|
| 7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
| 8 |
Author URI: https://cozmoslabs.com/
|
| 9 |
Text Domain: translatepress-multilingual
|
| 10 |
Domain Path: /languages
|
| 11 |
License: GPL2
|
| 12 |
WC requires at least: 2.5.0
|
| 13 |
-
WC tested up to: 6.2
|
| 14 |
|
| 15 |
== Copyright ==
|
| 16 |
Copyright 2017 Cozmoslabs (www.cozmoslabs.com)
|
| 3 |
Plugin Name: TranslatePress - Multilingual
|
| 4 |
Plugin URI: https://translatepress.com/
|
| 5 |
Description: Experience a better way of translating your WordPress site using a visual front-end translation editor, with full support for WooCommerce and site builders.
|
| 6 |
+
Version: 2.2.2
|
| 7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
| 8 |
Author URI: https://cozmoslabs.com/
|
| 9 |
Text Domain: translatepress-multilingual
|
| 10 |
Domain Path: /languages
|
| 11 |
License: GPL2
|
| 12 |
WC requires at least: 2.5.0
|
| 13 |
+
WC tested up to: 6.2.1
|
| 14 |
|
| 15 |
== Copyright ==
|
| 16 |
Copyright 2017 Cozmoslabs (www.cozmoslabs.com)
|
languages/translatepress-multilingual.pot
CHANGED
|
@@ -185,7 +185,7 @@ msgstr ""
|
|
| 185 |
msgid "Automatic translation has been disabled."
|
| 186 |
msgstr ""
|
| 187 |
|
| 188 |
-
#: includes/class-error-manager.php:146, includes/class-plugin-notices.php:341, includes/class-plugin-notices.php:392, includes/class-plugin-notices.php:373, includes/class-plugin-notices.php:406, includes/class-plugin-notices.php:431, includes/class-plugin-notices.php:455, includes/class-reviews.php:119, includes/class-reviews.php:122, includes/class-upgrade.php:
|
| 189 |
msgid "Dismiss this notice."
|
| 190 |
msgstr ""
|
| 191 |
|
|
@@ -837,63 +837,63 @@ msgstr ""
|
|
| 837 |
msgid "Finishing up..."
|
| 838 |
msgstr ""
|
| 839 |
|
| 840 |
-
#: includes/class-upgrade.php:
|
| 841 |
msgid "TranslatePress data update"
|
| 842 |
msgstr ""
|
| 843 |
|
| 844 |
-
#: includes/class-upgrade.php:
|
| 845 |
msgid "We need to update your translations database to the latest version."
|
| 846 |
msgstr ""
|
| 847 |
|
| 848 |
-
#: includes/class-upgrade.php:
|
| 849 |
msgid "IMPORTANT: It is strongly recommended to first backup the database!\nAre you sure you want to continue?"
|
| 850 |
msgstr ""
|
| 851 |
|
| 852 |
-
#: includes/class-upgrade.php:
|
| 853 |
msgid "Run the updater"
|
| 854 |
msgstr ""
|
| 855 |
|
| 856 |
-
#: includes/class-upgrade.php:
|
| 857 |
msgid "Database optimization did not complete successfully. We recommend restoring the original database or <a href=\"%s\" >trying again.</a>"
|
| 858 |
msgstr ""
|
| 859 |
|
| 860 |
-
#: includes/class-upgrade.php:
|
| 861 |
msgid "Update aborted! Your user account doesn't have the capability to perform database updates."
|
| 862 |
msgstr ""
|
| 863 |
|
| 864 |
-
#: includes/class-upgrade.php:
|
| 865 |
msgid "Update aborted! Invalid nonce."
|
| 866 |
msgstr ""
|
| 867 |
|
| 868 |
-
#: includes/class-upgrade.php:
|
| 869 |
msgid "Update aborted! Incorrect action."
|
| 870 |
msgstr ""
|
| 871 |
|
| 872 |
-
#: includes/class-upgrade.php:
|
| 873 |
msgid "Update aborted! Incorrect language code."
|
| 874 |
msgstr ""
|
| 875 |
|
| 876 |
-
#: includes/class-upgrade.php:
|
| 877 |
msgid "Updating database to version %s+"
|
| 878 |
msgstr ""
|
| 879 |
|
| 880 |
-
#: includes/class-upgrade.php:
|
| 881 |
msgid "Processing table for language %s..."
|
| 882 |
msgstr ""
|
| 883 |
|
| 884 |
-
#: includes/class-upgrade.php:
|
| 885 |
msgid "Back to TranslatePress Settings"
|
| 886 |
msgstr ""
|
| 887 |
|
| 888 |
-
#: includes/class-upgrade.php:
|
| 889 |
msgid "Successfully updated database!"
|
| 890 |
msgstr ""
|
| 891 |
|
| 892 |
-
#: includes/class-upgrade.php:
|
| 893 |
msgid " done."
|
| 894 |
msgstr ""
|
| 895 |
|
| 896 |
-
#: includes/class-upgrade.php:
|
| 897 |
msgid "All individual TranslatePress add-on plugins <a href=\"%1$s\" target=\"_blank\">have been discontinued</a> and are now included in the premium Personal, Business and Developer versions of TranslatePress. Please log into your <a href=\"%2$s\" target=\"_blank\">account page</a>, download the new premium version and install it. Your individual addons settings will be ported over."
|
| 898 |
msgstr ""
|
| 899 |
|
| 185 |
msgid "Automatic translation has been disabled."
|
| 186 |
msgstr ""
|
| 187 |
|
| 188 |
+
#: includes/class-error-manager.php:146, includes/class-plugin-notices.php:341, includes/class-plugin-notices.php:392, includes/class-plugin-notices.php:373, includes/class-plugin-notices.php:406, includes/class-plugin-notices.php:431, includes/class-plugin-notices.php:455, includes/class-reviews.php:119, includes/class-reviews.php:122, includes/class-upgrade.php:817
|
| 189 |
msgid "Dismiss this notice."
|
| 190 |
msgstr ""
|
| 191 |
|
| 837 |
msgid "Finishing up..."
|
| 838 |
msgstr ""
|
| 839 |
|
| 840 |
+
#: includes/class-upgrade.php:250
|
| 841 |
msgid "TranslatePress data update"
|
| 842 |
msgstr ""
|
| 843 |
|
| 844 |
+
#: includes/class-upgrade.php:250
|
| 845 |
msgid "We need to update your translations database to the latest version."
|
| 846 |
msgstr ""
|
| 847 |
|
| 848 |
+
#: includes/class-upgrade.php:251
|
| 849 |
msgid "IMPORTANT: It is strongly recommended to first backup the database!\nAre you sure you want to continue?"
|
| 850 |
msgstr ""
|
| 851 |
|
| 852 |
+
#: includes/class-upgrade.php:251
|
| 853 |
msgid "Run the updater"
|
| 854 |
msgstr ""
|
| 855 |
|
| 856 |
+
#: includes/class-upgrade.php:278
|
| 857 |
msgid "Database optimization did not complete successfully. We recommend restoring the original database or <a href=\"%s\" >trying again.</a>"
|
| 858 |
msgstr ""
|
| 859 |
|
| 860 |
+
#: includes/class-upgrade.php:296
|
| 861 |
msgid "Update aborted! Your user account doesn't have the capability to perform database updates."
|
| 862 |
msgstr ""
|
| 863 |
|
| 864 |
+
#: includes/class-upgrade.php:301
|
| 865 |
msgid "Update aborted! Invalid nonce."
|
| 866 |
msgstr ""
|
| 867 |
|
| 868 |
+
#: includes/class-upgrade.php:345
|
| 869 |
msgid "Update aborted! Incorrect action."
|
| 870 |
msgstr ""
|
| 871 |
|
| 872 |
+
#: includes/class-upgrade.php:348
|
| 873 |
msgid "Update aborted! Incorrect language code."
|
| 874 |
msgstr ""
|
| 875 |
|
| 876 |
+
#: includes/class-upgrade.php:332
|
| 877 |
msgid "Updating database to version %s+"
|
| 878 |
msgstr ""
|
| 879 |
|
| 880 |
+
#: includes/class-upgrade.php:336, includes/class-upgrade.php:399
|
| 881 |
msgid "Processing table for language %s..."
|
| 882 |
msgstr ""
|
| 883 |
|
| 884 |
+
#: includes/class-upgrade.php:319, includes/class-upgrade.php:429
|
| 885 |
msgid "Back to TranslatePress Settings"
|
| 886 |
msgstr ""
|
| 887 |
|
| 888 |
+
#: includes/class-upgrade.php:323
|
| 889 |
msgid "Successfully updated database!"
|
| 890 |
msgstr ""
|
| 891 |
|
| 892 |
+
#: includes/class-upgrade.php:404, includes/class-upgrade.php:396
|
| 893 |
msgid " done."
|
| 894 |
msgstr ""
|
| 895 |
|
| 896 |
+
#: includes/class-upgrade.php:815
|
| 897 |
msgid "All individual TranslatePress add-on plugins <a href=\"%1$s\" target=\"_blank\">have been discontinued</a> and are now included in the premium Personal, Business and Developer versions of TranslatePress. Please log into your <a href=\"%2$s\" target=\"_blank\">account page</a>, download the new premium version and install it. Your individual addons settings will be ported over."
|
| 898 |
msgstr ""
|
| 899 |
|
readme.txt
CHANGED
|
@@ -3,9 +3,9 @@ Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, sareiodata, cristophor
|
|
| 3 |
Donate link: https://www.translatepress.com/
|
| 4 |
Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
|
| 5 |
Requires at least: 3.1.0
|
| 6 |
-
Tested up to: 5.9
|
| 7 |
Requires PHP: 5.6.20
|
| 8 |
-
Stable tag: 2.2.
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
|
@@ -140,6 +140,11 @@ For more information please check out our [documentation](https://translatepress
|
|
| 140 |
|
| 141 |
|
| 142 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
= 2.2.1 =
|
| 144 |
* Added Advanced option to adjust hreflang to hide region independent language tags or country locale tags
|
| 145 |
* Added missing flags for Tamil (Sri Lanka), Spanish (Ecuador), Spanish (Dominican Republic), Amharic
|
| 3 |
Donate link: https://www.translatepress.com/
|
| 4 |
Tags: translate, translation, multilingual, automatic translation, bilingual, front-end translation, google translate, language
|
| 5 |
Requires at least: 3.1.0
|
| 6 |
+
Tested up to: 5.9.1
|
| 7 |
Requires PHP: 5.6.20
|
| 8 |
+
Stable tag: 2.2.2
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
| 140 |
|
| 141 |
|
| 142 |
== Changelog ==
|
| 143 |
+
= 2.2.2 =
|
| 144 |
+
* Fixed issue in WP 5.9 causing Invalid Data SQL Error reports
|
| 145 |
+
* Improved page load time for WooCommerce websites on translated languages
|
| 146 |
+
* Improved admin notices regarding database optimization
|
| 147 |
+
|
| 148 |
= 2.2.1 =
|
| 149 |
* Added Advanced option to adjust hreflang to hide region independent language tags or country locale tags
|
| 150 |
* Added missing flags for Tamil (Sri Lanka), Spanish (Ecuador), Spanish (Dominican Republic), Amharic
|
