TranslatePress – Translate Multilingual sites - Version 2.0.0

Version Description

  • Improved compatibility with WPBakery Page Builder and Wpresidence
  • Improved compatibility with integrations by initializing machine translator earlier
  • License key in TP settings is hidden now
  • Added filter trp_apply_gettext_early
  • Fixed high loading time when WP_DEBUG was set to true
Download this release

Release Info

Developer razvan.mo
Plugin Icon 128x128 TranslatePress – Translate Multilingual sites
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.9.9 to 2.0.0

class-translate-press.php CHANGED
@@ -58,7 +58,7 @@ class TRP_Translate_Press{
58
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
59
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
60
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
61
- define( 'TRP_PLUGIN_VERSION', '1.9.9' );
62
 
63
  wp_cache_add_non_persistent_groups(array('trp'));
64
 
@@ -383,7 +383,7 @@ class TRP_Translate_Press{
383
  $this->loader->add_action( "init", $this, 'init_translation', 8 );
384
 
385
  // machine translation
386
- $this->loader->add_action( 'plugins_loaded', $this, 'init_machine_translation', 10 );
387
 
388
  //search
389
  $this->loader->add_filter( 'pre_get_posts', $this->search, 'trp_search_filter', 99999999 );
58
  define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
59
  define( 'TRP_PLUGIN_BASE', plugin_basename( __DIR__ . '/index.php' ) );
60
  define( 'TRP_PLUGIN_SLUG', 'translatepress-multilingual' );
61
+ define( 'TRP_PLUGIN_VERSION', '2.0.0' );
62
 
63
  wp_cache_add_non_persistent_groups(array('trp'));
64
 
383
  $this->loader->add_action( "init", $this, 'init_translation', 8 );
384
 
385
  // machine translation
386
+ $this->loader->add_action( 'plugins_loaded', $this, 'init_machine_translation', 2 );
387
 
388
  //search
389
  $this->loader->add_filter( 'pre_get_posts', $this->search, 'trp_search_filter', 99999999 );
includes/class-edd-sl-plugin-updater.php CHANGED
@@ -533,6 +533,8 @@ if( !class_exists('TRP_LICENSE_PAGE') ) {
533
  public function license_page()
534
  {
535
  $license = get_option('trp_license_key');
 
 
536
  $status = get_option('trp_license_status');
537
  $details = get_option('trp_license_details');
538
  $action = 'options.php';
@@ -661,10 +663,16 @@ class TRP_Plugin_Updater{
661
  if( ! check_admin_referer( 'trp_license_nonce', 'trp_license_nonce' ) )
662
  return; // get out if we didn't click the Activate button
663
 
664
- // save the license
665
- $license = $this->edd_sanitize_license( trim( $_POST['trp_license_key'] ) );
666
- $this->update_option( 'trp_license_key', $license );
667
 
 
 
 
 
 
 
 
 
 
668
  $message = array();//we will check the license for each addon and we will sotre the messages in an array
669
  $license_information_for_all_addons = array();
670
 
533
  public function license_page()
534
  {
535
  $license = get_option('trp_license_key');
536
+ // don't show the license in html
537
+ $license = str_repeat("*", strlen($license));
538
  $status = get_option('trp_license_status');
539
  $details = get_option('trp_license_details');
540
  $action = 'options.php';
663
  if( ! check_admin_referer( 'trp_license_nonce', 'trp_license_nonce' ) )
664
  return; // get out if we didn't click the Activate button
665
 
 
 
 
666
 
667
+ if (preg_match('/^[*]+$/', $_POST['trp_license_key']) && strlen( $_POST['trp_license_key'] ) > 5 ) {
668
+ // pressed submit without altering the existing license key (containing only * as outputted by default)
669
+ // useful for Deactivating/Activating valid license back
670
+ $license = get_option('trp_license_key', '');
671
+ }else{
672
+ // save the license
673
+ $license = $this->edd_sanitize_license( trim( $_POST['trp_license_key'] ) );
674
+ $this->update_option( 'trp_license_key', $license );
675
+ }
676
  $message = array();//we will check the license for each addon and we will sotre the messages in an array
677
  $license_information_for_all_addons = array();
678
 
includes/class-translation-manager.php CHANGED
@@ -554,14 +554,14 @@ class TRP_Translation_Manager
554
  $is_ajax_on_frontend = $this::is_ajax_on_frontend();
555
 
556
  /* on ajax hooks from frontend that have the init hook ( we found WooCommerce has it ) apply it earlier */
557
- if ($is_ajax_on_frontend) {
558
  add_action('wp_loaded', array($this, 'apply_gettext_filter'));
559
  } else {//otherwise start from the wp_head hook
560
  add_action('wp_head', array($this, 'apply_gettext_filter'), 100);
561
  }
562
 
563
  //if we have woocommerce installed and it is not an ajax request add a gettext hook starting from wp_loaded and remove it on wp_head
564
- if (class_exists('WooCommerce') && !$is_ajax_on_frontend) {
565
  // WooCommerce launches some ajax calls before wp_head, so we need to apply_gettext_filter earlier to catch them
566
  add_action('wp_loaded', array($this, 'apply_woocommerce_gettext_filter'), 19);
567
  }
554
  $is_ajax_on_frontend = $this::is_ajax_on_frontend();
555
 
556
  /* on ajax hooks from frontend that have the init hook ( we found WooCommerce has it ) apply it earlier */
557
+ if ($is_ajax_on_frontend || apply_filters( 'trp_apply_gettext_early', false ) ) {
558
  add_action('wp_loaded', array($this, 'apply_gettext_filter'));
559
  } else {//otherwise start from the wp_head hook
560
  add_action('wp_head', array($this, 'apply_gettext_filter'), 100);
561
  }
562
 
563
  //if we have woocommerce installed and it is not an ajax request add a gettext hook starting from wp_loaded and remove it on wp_head
564
+ if (class_exists('WooCommerce') && !$is_ajax_on_frontend && !apply_filters( 'trp_apply_gettext_early', false ) ) {
565
  // WooCommerce launches some ajax calls before wp_head, so we need to apply_gettext_filter earlier to catch them
566
  add_action('wp_loaded', array($this, 'apply_woocommerce_gettext_filter'), 19);
567
  }
includes/class-wp-bakery-language-for-blocks.php CHANGED
@@ -241,6 +241,8 @@ class TRP_WPBakery {
241
  *
242
  * Shortcodes with missing 'params' trigger notice, so don't add TP settings to them
243
  *
 
 
244
  * @return array of shortcodes to skip
245
  */
246
  public function get_skip_sc_array(){
@@ -248,7 +250,7 @@ class TRP_WPBakery {
248
  $sc = WPBMap::getAllShortCodes();
249
  if ( isset( $sc) && is_array($sc) ){
250
  foreach( $sc as $key => $value ){
251
- if ( isset($sc[$key] ) && !isset($sc[$key]['params'])){
252
  $skip_sc[] = $key;
253
  }
254
  }
241
  *
242
  * Shortcodes with missing 'params' trigger notice, so don't add TP settings to them
243
  *
244
+ * Also, shortcodes with 'params' set to empty string instead of array trigger fatal error.
245
+ *
246
  * @return array of shortcodes to skip
247
  */
248
  public function get_skip_sc_array(){
250
  $sc = WPBMap::getAllShortCodes();
251
  if ( isset( $sc) && is_array($sc) ){
252
  foreach( $sc as $key => $value ){
253
+ if ( isset($sc[$key] ) && (!isset($sc[$key]['params']) || !is_array($sc[$key]['params'])) ){
254
  $skip_sc[] = $key;
255
  }
256
  }
includes/functions.php CHANGED
@@ -565,7 +565,7 @@ function trp_get_languages($nodefault=null)
565
  }
566
 
567
  /**
568
- * Wrapper function for wp_cahce_get() that bypases cache if WP_DEBUG is on
569
  * @param int|string $key The key under which the cache contents are stored.
570
  * @param string $group Optional. Where the cache contents are grouped. Default empty.
571
  * @param bool $force Optional. Whether to force an update of the local cache
@@ -576,7 +576,7 @@ function trp_get_languages($nodefault=null)
576
  *
577
  */
578
  function trp_cache_get( $key, $group = '', $force = false, &$found = null ){
579
- if( defined( 'WP_DEBUG' ) && WP_DEBUG == true )
580
  return false;
581
 
582
  $cache = wp_cache_get( $key, $group, $force, $found );
565
  }
566
 
567
  /**
568
+ * Wrapper function for wp_cache_get() that bypasses cache if TRP_DEBUG is on
569
  * @param int|string $key The key under which the cache contents are stored.
570
  * @param string $group Optional. Where the cache contents are grouped. Default empty.
571
  * @param bool $force Optional. Whether to force an update of the local cache
576
  *
577
  */
578
  function trp_cache_get( $key, $group = '', $force = false, &$found = null ){
579
+ if( defined( 'TRP_DEBUG' ) && TRP_DEBUG == true )
580
  return false;
581
 
582
  $cache = wp_cache_get( $key, $group, $force, $found );
index.php CHANGED
@@ -3,7 +3,7 @@
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: 1.9.9
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
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.0.0
7
  Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
8
  Author URI: https://cozmoslabs.com/
9
  Text Domain: translatepress-multilingual
languages/translatepress-multilingual.pot CHANGED
@@ -145,35 +145,35 @@ msgstr ""
145
  msgid "Select..."
146
  msgstr ""
147
 
148
- #: includes/class-edd-sl-plugin-updater.php:700
149
  msgid "Your license key expired on %s."
150
  msgstr ""
151
 
152
- #: includes/class-edd-sl-plugin-updater.php:705
153
  msgid "Your license key has been disabled."
154
  msgstr ""
155
 
156
- #: includes/class-edd-sl-plugin-updater.php:708
157
  msgid "Invalid license."
158
  msgstr ""
159
 
160
- #: includes/class-edd-sl-plugin-updater.php:712
161
  msgid "Your license is not active for this URL."
162
  msgstr ""
163
 
164
- #: includes/class-edd-sl-plugin-updater.php:715
165
  msgid "This appears to be an invalid license key for %s."
166
  msgstr ""
167
 
168
- #: includes/class-edd-sl-plugin-updater.php:718
169
  msgid "Your license key has reached its activation limit."
170
  msgstr ""
171
 
172
- #: includes/class-edd-sl-plugin-updater.php:721, includes/class-edd-sl-plugin-updater.php:689, includes/class-edd-sl-plugin-updater.php:792
173
  msgid "An error occurred, please try again."
174
  msgstr ""
175
 
176
- #: includes/class-edd-sl-plugin-updater.php:752
177
  msgid "You have successfully activated your license"
178
  msgstr ""
179
 
145
  msgid "Select..."
146
  msgstr ""
147
 
148
+ #: includes/class-edd-sl-plugin-updater.php:708
149
  msgid "Your license key expired on %s."
150
  msgstr ""
151
 
152
+ #: includes/class-edd-sl-plugin-updater.php:713
153
  msgid "Your license key has been disabled."
154
  msgstr ""
155
 
156
+ #: includes/class-edd-sl-plugin-updater.php:716
157
  msgid "Invalid license."
158
  msgstr ""
159
 
160
+ #: includes/class-edd-sl-plugin-updater.php:720
161
  msgid "Your license is not active for this URL."
162
  msgstr ""
163
 
164
+ #: includes/class-edd-sl-plugin-updater.php:723
165
  msgid "This appears to be an invalid license key for %s."
166
  msgstr ""
167
 
168
+ #: includes/class-edd-sl-plugin-updater.php:726
169
  msgid "Your license key has reached its activation limit."
170
  msgstr ""
171
 
172
+ #: includes/class-edd-sl-plugin-updater.php:729, includes/class-edd-sl-plugin-updater.php:697, includes/class-edd-sl-plugin-updater.php:800
173
  msgid "An error occurred, please try again."
174
  msgstr ""
175
 
176
+ #: includes/class-edd-sl-plugin-updater.php:760
177
  msgid "You have successfully activated your license"
178
  msgstr ""
179
 
partials/license-settings-page.php CHANGED
@@ -15,7 +15,7 @@ if( !empty( $trp->active_pro_addons ) ){//if we have any Advanced or Pro addons
15
  </th>
16
  <td>
17
  <div>
18
- <input id="trp_license_key" name="trp_license_key" type="text" class="regular-text" value="<?php esc_attr_e( $license ); ?>" />
19
  <?php wp_nonce_field( 'trp_license_nonce', 'trp_license_nonce' ); ?>
20
  <?php if( $status !== false && $status == 'valid' ) {
21
  $button_name = 'trp_edd_license_deactivate';
15
  </th>
16
  <td>
17
  <div>
18
+ <input id="trp_license_key" name="trp_license_key" type="password" class="regular-text" value="<?php esc_attr_e( $license ); ?>" />
19
  <?php wp_nonce_field( 'trp_license_nonce', 'trp_license_nonce' ); ?>
20
  <?php if( $status !== false && $status == 'valid' ) {
21
  $button_name = 'trp_edd_license_deactivate';
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: translate, translation, multilingual, automatic translation, bilingual, fr
5
  Requires at least: 3.1.0
6
  Tested up to: 5.7.1
7
  Requires PHP: 5.6.20
8
- Stable tag: 1.9.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -139,6 +139,13 @@ For more information please check out our [documentation](https://translatepress
139
 
140
 
141
  == Changelog ==
 
 
 
 
 
 
 
142
  = 1.9.9 =
143
  * Forcing a slash at the end of home url is now an optional Advanced setting
144
  * Better handling of WPEngine long query limiting
5
  Requires at least: 3.1.0
6
  Tested up to: 5.7.1
7
  Requires PHP: 5.6.20
8
+ Stable tag: 2.0.0
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
139
 
140
 
141
  == Changelog ==
142
+ = 2.0.0 =
143
+ * Improved compatibility with WPBakery Page Builder and Wpresidence
144
+ * Improved compatibility with integrations by initializing machine translator earlier
145
+ * License key in TP settings is hidden now
146
+ * Added filter trp_apply_gettext_early
147
+ * Fixed high loading time when WP_DEBUG was set to true
148
+
149
  = 1.9.9 =
150
  * Forcing a slash at the end of home url is now an optional Advanced setting
151
  * Better handling of WPEngine long query limiting