Version Description
- Fixed a small bug in js regarding the translation editor sidebar with
- Fixed Language Switcher for Woocommerce product categories and product tags going to 404 pages
- Fixed issues with Woocommerce and permalinks when the default language was not english
- Excluded more functions from getting gettext wraps
Download this release
Release Info
| Developer | madalin.ungureanu |
| Plugin | |
| Version | 1.0.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.6 to 1.0.7
- assets/images/translator-accounts-addon.png +0 -0
- assets/js/trp-editor-script.js +1 -1
- class-translate-press.php +8 -1
- includes/class-translation-manager.php +9 -1
- includes/class-url-converter.php +52 -0
- includes/functions.php +18 -0
- index.php +1 -1
- partials/addons-settings-page.php +7 -0
- partials/translation-manager.php +4 -4
- readme.txt +12 -6
assets/images/translator-accounts-addon.png
ADDED
|
Binary file
|
assets/js/trp-editor-script.js
CHANGED
|
@@ -355,7 +355,7 @@ function TRP_Editor(){
|
|
| 355 |
}
|
| 356 |
|
| 357 |
preview_container.css('right', width );
|
| 358 |
-
preview_container.css('left', ( width -
|
| 359 |
preview_container.css('width', (total_width - width));
|
| 360 |
}
|
| 361 |
|
| 355 |
}
|
| 356 |
|
| 357 |
preview_container.css('right', width );
|
| 358 |
+
preview_container.css('left', ( width - 348 ) );
|
| 359 |
preview_container.css('width', (total_width - width));
|
| 360 |
}
|
| 361 |
|
class-translate-press.php
CHANGED
|
@@ -39,7 +39,7 @@ class TRP_Translate_Press{
|
|
| 39 |
define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
| 40 |
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
| 41 |
define( 'TRP_PLUGIN_SLUG', 'translatepress' );
|
| 42 |
-
define( 'TRP_PLUGIN_VERSION', '1.0.
|
| 43 |
|
| 44 |
$this->load_dependencies();
|
| 45 |
$this->initialize_components();
|
|
@@ -179,6 +179,13 @@ class TRP_Translate_Press{
|
|
| 179 |
|
| 180 |
/* hide php errors and notice when we are storing strings in db */
|
| 181 |
$this->loader->add_action( 'wp', $this->translation_render, 'trp_debug_mode_off' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
}
|
| 183 |
|
| 184 |
/**
|
| 39 |
define( 'TRP_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
|
| 40 |
define( 'TRP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
|
| 41 |
define( 'TRP_PLUGIN_SLUG', 'translatepress' );
|
| 42 |
+
define( 'TRP_PLUGIN_VERSION', '1.0.7' );
|
| 43 |
|
| 44 |
$this->load_dependencies();
|
| 45 |
$this->initialize_components();
|
| 179 |
|
| 180 |
/* hide php errors and notice when we are storing strings in db */
|
| 181 |
$this->loader->add_action( 'wp', $this->translation_render, 'trp_debug_mode_off' );
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* we need to modify the permalinks structure for woocommerce when we switch languages
|
| 185 |
+
* when woo registers post_types and taxonomies in the rewrite parameter of the function they change the slugs of the items (they are localized with _x )
|
| 186 |
+
* we can't flush the permalinks on every page load so we filter the rewrite_rules option
|
| 187 |
+
*/
|
| 188 |
+
$this->loader->add_filter( "option_rewrite_rules", $this->url_converter, 'woocommerce_filter_permalinks_on_other_languages' );
|
| 189 |
}
|
| 190 |
|
| 191 |
/**
|
includes/class-translation-manager.php
CHANGED
|
@@ -654,10 +654,18 @@ class TRP_Translation_Manager{
|
|
| 654 |
$callstack_function['function'] == 'wp_localize_script'||
|
| 655 |
$callstack_function['function'] == 'wp_print_media_templates' ||
|
| 656 |
$callstack_function['function'] == 'get_bloginfo' ||
|
| 657 |
-
$callstack_function['function'] == '
|
|
|
|
|
|
|
| 658 |
) {
|
| 659 |
return $translation;
|
| 660 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 661 |
}
|
| 662 |
}
|
| 663 |
|
| 654 |
$callstack_function['function'] == 'wp_localize_script'||
|
| 655 |
$callstack_function['function'] == 'wp_print_media_templates' ||
|
| 656 |
$callstack_function['function'] == 'get_bloginfo' ||
|
| 657 |
+
$callstack_function['function'] == 'wp_get_document_title' ||
|
| 658 |
+
$callstack_function['function'] == 'wp_title' ||
|
| 659 |
+
$callstack_function['function'] == 'wptexturize'
|
| 660 |
) {
|
| 661 |
return $translation;
|
| 662 |
}
|
| 663 |
+
|
| 664 |
+
/* make sure we don't touch the woocommerce permalink rewrite slugs that are translated */
|
| 665 |
+
if( $callstack_function['function'] == 'wc_get_permalink_structure' ){
|
| 666 |
+
return $translation;
|
| 667 |
+
}
|
| 668 |
+
|
| 669 |
}
|
| 670 |
}
|
| 671 |
|
includes/class-url-converter.php
CHANGED
|
@@ -136,6 +136,19 @@ class TRP_Url_Converter {
|
|
| 136 |
}
|
| 137 |
}
|
| 138 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
if ( empty( $new_url ) ) {
|
| 141 |
$new_url = $url;
|
|
@@ -281,4 +294,43 @@ class TRP_Url_Converter {
|
|
| 281 |
return $pageURL;
|
| 282 |
}
|
| 283 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
}
|
| 136 |
}
|
| 137 |
}
|
| 138 |
}
|
| 139 |
+
|
| 140 |
+
/* fix links for woocommerce on language switcher for product categories and product tags */
|
| 141 |
+
if( class_exists( 'WooCommerce' ) ){
|
| 142 |
+
if ( is_product_category() ) {
|
| 143 |
+
$current_cat_slug = trp_x( 'product-category', 'slug', 'woocommerce', $TRP_LANGUAGE );
|
| 144 |
+
$translated_cat_slug = trp_x( 'product-category', 'slug', 'woocommerce', $language );
|
| 145 |
+
$new_url = str_replace( '/'.$current_cat_slug.'/', '/'.$translated_cat_slug.'/', $new_url );
|
| 146 |
+
}elseif( is_product_tag() ){
|
| 147 |
+
$current_tag_slug = trp_x( 'product-tag', 'slug', 'woocommerce', $TRP_LANGUAGE );
|
| 148 |
+
$translated_tag_slug = trp_x( 'product-tag', 'slug', 'woocommerce', $language );
|
| 149 |
+
$new_url = str_replace( '/'.$current_tag_slug.'/', '/'.$translated_tag_slug.'/', $new_url );
|
| 150 |
+
}
|
| 151 |
+
}
|
| 152 |
|
| 153 |
if ( empty( $new_url ) ) {
|
| 154 |
$new_url = $url;
|
| 294 |
return $pageURL;
|
| 295 |
}
|
| 296 |
|
| 297 |
+
/**
|
| 298 |
+
* we need to modify the permalinks structure for woocommerce when we switch languages
|
| 299 |
+
* when woo registers post_types and taxonomies in the rewrite parameter of the function they change the slugs of the items (they are localized with _x )
|
| 300 |
+
* we can't flush the permalinks on every page load so we filter the rewrite_rules option
|
| 301 |
+
*/
|
| 302 |
+
public function woocommerce_filter_permalinks_on_other_languages( $rewrite_rules ){
|
| 303 |
+
if( class_exists( 'WooCommerce' ) ){
|
| 304 |
+
global $TRP_LANGUAGE;
|
| 305 |
+
if( $TRP_LANGUAGE != $this->settings['default-language'] ){
|
| 306 |
+
global $default_language_wc_permalink_structure; //we use a global because apparently you can't do switch to locale and restore multiple times. I should keep an eye on this
|
| 307 |
+
/* get rewrite rules from original language */
|
| 308 |
+
if( empty($default_language_wc_permalink_structure) ) {
|
| 309 |
+
switch_to_locale($this->settings['default-language']);
|
| 310 |
+
$default_language_wc_permalink_structure = wc_get_permalink_structure();
|
| 311 |
+
restore_previous_locale();
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
$current_language_permalink_structure = wc_get_permalink_structure();
|
| 315 |
+
|
| 316 |
+
$new_rewrite_rules = array();
|
| 317 |
+
|
| 318 |
+
$search = array( '/^'.$default_language_wc_permalink_structure['product_rewrite_slug'].'\//', '/^'.$default_language_wc_permalink_structure['category_rewrite_slug'].'\//', '/^'.$default_language_wc_permalink_structure['tag_rewrite_slug'].'\//' );
|
| 319 |
+
$replace = array( $current_language_permalink_structure['product_rewrite_slug'].'/', $current_language_permalink_structure['category_rewrite_slug'].'/', $current_language_permalink_structure['tag_rewrite_slug'].'/' );
|
| 320 |
+
|
| 321 |
+
foreach( $rewrite_rules as $rewrite_key => $rewrite_values ){
|
| 322 |
+
$new_rewrite_rules[preg_replace( $search, $replace, $rewrite_key )] = preg_replace( $search, $replace, $rewrite_values );
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
}
|
| 326 |
+
}
|
| 327 |
+
|
| 328 |
+
if( !empty($new_rewrite_rules) ) {
|
| 329 |
+
return $new_rewrite_rules;
|
| 330 |
+
}
|
| 331 |
+
else
|
| 332 |
+
return $rewrite_rules;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
|
| 336 |
}
|
includes/functions.php
CHANGED
|
@@ -56,4 +56,22 @@ function trp_utf8ize($mixed) {
|
|
| 56 |
return utf8_encode($mixed);
|
| 57 |
}
|
| 58 |
return $mixed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
}
|
| 56 |
return utf8_encode($mixed);
|
| 57 |
}
|
| 58 |
return $mixed;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* function that gets the translation for a string with context directly from a .mo file
|
| 63 |
+
* @TODO this was developped firstly for woocommerce so it needs further development. It only works for plugins at the moment
|
| 64 |
+
*/
|
| 65 |
+
function trp_x( $text, $context, $domain, $language ){
|
| 66 |
+
$mo_file = new MO();
|
| 67 |
+
|
| 68 |
+
if( file_exists( WP_LANG_DIR . '/plugins/'. $domain .'-' . $language . '.mo') ) {
|
| 69 |
+
if (!$mo_file->import_from_file(WP_LANG_DIR . '/plugins/' . $domain . '-' . $language . '.mo')) return $text;
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
if (!empty($mo_file->entries[$context . '' . $text]))
|
| 73 |
+
$text = $mo_file->entries[$context . '' . $text]->translations[0];
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
return $text;
|
| 77 |
}
|
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, with full support for WooCommerce and site builders.
|
| 6 |
-
Version: 1.0.
|
| 7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
| 8 |
Author URI: https://cozmoslabs.com/
|
| 9 |
License: GPL2
|
| 3 |
Plugin Name: TranslatePress - Multilingual
|
| 4 |
Plugin URI: https://translatepress.com/
|
| 5 |
Description: Experience a better way of translating your WordPress site, with full support for WooCommerce and site builders.
|
| 6 |
+
Version: 1.0.7
|
| 7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
| 8 |
Author URI: https://cozmoslabs.com/
|
| 9 |
License: GPL2
|
partials/addons-settings-page.php
CHANGED
|
@@ -27,4 +27,11 @@
|
|
| 27 |
</div>
|
| 28 |
</div>
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
</div>
|
| 27 |
</div>
|
| 28 |
</div>
|
| 29 |
|
| 30 |
+
<div class="grid">
|
| 31 |
+
<div class="grid-cell" style="overflow:hidden;">
|
| 32 |
+
<a href="https://translatepress.com/pricing/" target="_blank"><img src="<?php echo plugins_url('../assets/images/translator-accounts-addon.png', __FILE__) ?>" alt="Translator Account" style="float: left; margin: 0 1.5rem 1.5rem 0;"></a>
|
| 33 |
+
<h3><a href="https://translatepress.com/pricing/" target="_blank">Translator Accounts</a></h3>
|
| 34 |
+
<p>Create translator accounts for new users or allow existing users <br/>that are not administrators to translate your website.</p>
|
| 35 |
+
</div>
|
| 36 |
+
</div>
|
| 37 |
</div>
|
partials/translation-manager.php
CHANGED
|
@@ -126,17 +126,17 @@
|
|
| 126 |
<?php
|
| 127 |
// upsell to PRO from Translation Editor.
|
| 128 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
| 129 |
-
if ( !( is_plugin_active('tp-add-on-extra-languages/
|
| 130 |
?>
|
| 131 |
<div class="trp-controls-section wp-core-ui">
|
| 132 |
<div id="trp-upsell-section" class="trp-controls-section-content">
|
| 133 |
<h3><?php _e('Your Website <br/> Multiple Languages', TRP_PLUGIN_SLUG ); ?></h3>
|
| 134 |
<ul>
|
| 135 |
<li><?php _e('Support for 221 Languages', TRP_PLUGIN_SLUG ); ?></li>
|
| 136 |
-
<li><?php _e('
|
| 137 |
-
<li><?php _e('Translate SEO Title and Description', TRP_PLUGIN_SLUG ); ?></li>
|
| 138 |
-
<li><?php _e('Translate SEO Slug', TRP_PLUGIN_SLUG ); ?></li>
|
| 139 |
<li><?php _e('Translate Facebook Tags', TRP_PLUGIN_SLUG ); ?></li>
|
|
|
|
|
|
|
| 140 |
</ul>
|
| 141 |
<p><span style="background: #f5fb9d;"><?php _e('Supported By Real People', TRP_PLUGIN_SLUG ); ?></span></p>
|
| 142 |
<p><a class="button-primary" target="_blank" href="https://translatepress.com/pricing/?utm_source=wpbackend&utm_medium=clientsite&utm_content=tpeditor&utm_campaign=tpfree"><?php _e('Learn More', TRP_PLUGIN_SLUG ); ?></a></p>
|
| 126 |
<?php
|
| 127 |
// upsell to PRO from Translation Editor.
|
| 128 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
| 129 |
+
if ( !( is_plugin_active('tp-add-on-extra-languages/tp-extra-languages.php') || is_plugin_active('tp-add-on-seo-pack/tp-seo-pack.php') || is_plugin_active('tp-add-on-translator-accounts/index.php') ) ) :
|
| 130 |
?>
|
| 131 |
<div class="trp-controls-section wp-core-ui">
|
| 132 |
<div id="trp-upsell-section" class="trp-controls-section-content">
|
| 133 |
<h3><?php _e('Your Website <br/> Multiple Languages', TRP_PLUGIN_SLUG ); ?></h3>
|
| 134 |
<ul>
|
| 135 |
<li><?php _e('Support for 221 Languages', TRP_PLUGIN_SLUG ); ?></li>
|
| 136 |
+
<li><?php _e('Translate SEO Title, Description, Slug', TRP_PLUGIN_SLUG ); ?></li>
|
|
|
|
|
|
|
| 137 |
<li><?php _e('Translate Facebook Tags', TRP_PLUGIN_SLUG ); ?></li>
|
| 138 |
+
<li><?php _e('Create Translator Accounts', TRP_PLUGIN_SLUG ); ?></li>
|
| 139 |
+
<li><?php _e('Publish when the translation is done', TRP_PLUGIN_SLUG ); ?></li>
|
| 140 |
</ul>
|
| 141 |
<p><span style="background: #f5fb9d;"><?php _e('Supported By Real People', TRP_PLUGIN_SLUG ); ?></span></p>
|
| 142 |
<p><a class="button-primary" target="_blank" href="https://translatepress.com/pricing/?utm_source=wpbackend&utm_medium=clientsite&utm_content=tpeditor&utm_campaign=tpfree"><?php _e('Learn More', TRP_PLUGIN_SLUG ); ?></a></p>
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: https://www.cozmoslabs.com/
|
|
| 4 |
Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate, bilingual
|
| 5 |
Requires at least: 3.1.0
|
| 6 |
Tested up to: 4.8.3
|
| 7 |
-
Stable tag: 1.0.
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
|
@@ -107,12 +107,18 @@ For more information please check out [TranslatePress documentation](https://tra
|
|
| 107 |
|
| 108 |
== Changelog ==
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
= 1.0.6 =
|
| 111 |
-
Added filter on capabilities to allow other roles to edit translations:'trp_translating_capability'
|
| 112 |
-
Don't show php errors and notices when we are storing strings in the database
|
| 113 |
-
Fixed issues with attributes that contain json content, for instance in woocommerce variations
|
| 114 |
-
We no longer wrap gettext inside the wptexturize function
|
| 115 |
-
We no longer wrap gettexts that appear in the bloginfo function
|
| 116 |
|
| 117 |
= 1.0.5 =
|
| 118 |
* Added possibility to edit gettext strings from themes and plugins from english to english, without adding another language. Basically, string-replace functionality.
|
| 4 |
Tags: translate, translation, multilingual, automatic translation, front-end translation, google translate, bilingual
|
| 5 |
Requires at least: 3.1.0
|
| 6 |
Tested up to: 4.8.3
|
| 7 |
+
Stable tag: 1.0.7
|
| 8 |
License: GPLv2 or later
|
| 9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 10 |
|
| 107 |
|
| 108 |
== Changelog ==
|
| 109 |
|
| 110 |
+
= 1.0.7 =
|
| 111 |
+
* Fixed a small bug in js regarding the translation editor sidebar with
|
| 112 |
+
* Fixed Language Switcher for Woocommerce product categories and product tags going to 404 pages
|
| 113 |
+
* Fixed issues with Woocommerce and permalinks when the default language was not english
|
| 114 |
+
* Excluded more functions from getting gettext wraps
|
| 115 |
+
|
| 116 |
= 1.0.6 =
|
| 117 |
+
* Added filter on capabilities to allow other roles to edit translations:'trp_translating_capability'
|
| 118 |
+
* Don't show php errors and notices when we are storing strings in the database
|
| 119 |
+
* Fixed issues with attributes that contain json content, for instance in woocommerce variations
|
| 120 |
+
* We no longer wrap gettext inside the wptexturize function
|
| 121 |
+
* We no longer wrap gettexts that appear in the bloginfo function
|
| 122 |
|
| 123 |
= 1.0.5 =
|
| 124 |
* Added possibility to edit gettext strings from themes and plugins from english to english, without adding another language. Basically, string-replace functionality.
|
