Version Description
Added filter on capabilities to allow other roles to edit translations:'trp_translating_capability' Don't show php errors and notices when we are storing strings in the database Fixed issues with attributes that contain json content, for instance in woocommerce variations We no longer wrap gettext inside the wptexturize function We no longer wrap gettexts that appear in the bloginfo function
Download this release
Release Info
Developer | madalin.ungureanu |
Plugin | TranslatePress – Translate Multilingual sites |
Version | 1.0.6 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 1.0.6
- class-translate-press.php +4 -1
- includes/class-translation-manager.php +9 -8
- includes/class-translation-render.php +24 -0
- index.php +1 -1
- partials/addons-settings-page.php +1 -1
- readme.txt +9 -2
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();
|
@@ -176,6 +176,9 @@ class TRP_Translate_Press{
|
|
176 |
|
177 |
/* set up wp_mail hooks */
|
178 |
$this->loader->add_filter( 'wp_mail', $this->translation_render, 'wp_mail_filter', 200 );
|
|
|
|
|
|
|
179 |
}
|
180 |
|
181 |
/**
|
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.6' );
|
43 |
|
44 |
$this->load_dependencies();
|
45 |
$this->initialize_components();
|
176 |
|
177 |
/* set up wp_mail hooks */
|
178 |
$this->loader->add_filter( 'wp_mail', $this->translation_render, 'wp_mail_filter', 200 );
|
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 |
/**
|
includes/class-translation-manager.php
CHANGED
@@ -31,7 +31,7 @@ class TRP_Translation_Manager{
|
|
31 |
*/
|
32 |
protected function conditions_met( $mode = 'true' ){
|
33 |
if ( isset( $_REQUEST['trp-edit-translation'] ) && esc_attr( $_REQUEST['trp-edit-translation'] ) == $mode ) {
|
34 |
-
if ( current_user_can( 'manage_options' ) && ! is_admin() ) {
|
35 |
return true;
|
36 |
}else{
|
37 |
wp_die(
|
@@ -163,7 +163,7 @@ class TRP_Translation_Manager{
|
|
163 |
|
164 |
// necessary in order to obtain all the original strings
|
165 |
if ( $this->settings['default-language'] != $current_language ) {
|
166 |
-
if ( current_user_can ( 'manage_options' ) ) {
|
167 |
$this->translation_render->process_strings($original_array, $current_language);
|
168 |
}
|
169 |
$dictionaries[$current_language] = $this->trp_query->get_string_rows( $id_array, $original_array, $current_language );
|
@@ -192,7 +192,7 @@ class TRP_Translation_Manager{
|
|
192 |
if (empty($original_strings)) {
|
193 |
$original_strings = $this->extract_original_strings($dictionaries[$current_language], $original_array, $id_array);
|
194 |
}
|
195 |
-
if (current_user_can('manage_options')) {
|
196 |
$this->translation_render->process_strings($original_strings, $language);
|
197 |
}
|
198 |
$dictionaries[$language] = $this->trp_query->get_string_rows(array(), $original_strings, $language);
|
@@ -319,7 +319,7 @@ class TRP_Translation_Manager{
|
|
319 |
*/
|
320 |
public function save_translations(){
|
321 |
|
322 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && current_user_can( 'manage_options' ) ) {
|
323 |
if ( isset( $_POST['action'] ) && $_POST['action'] === 'trp_save_translations' && !empty( $_POST['strings'] ) ) {
|
324 |
$strings = json_decode(stripslashes($_POST['strings']));
|
325 |
$update_strings = array();
|
@@ -355,7 +355,7 @@ class TRP_Translation_Manager{
|
|
355 |
}
|
356 |
|
357 |
public function gettext_save_translations(){
|
358 |
-
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && current_user_can( 'manage_options' ) ) {
|
359 |
if (isset($_POST['action']) && $_POST['action'] === 'trp_gettext_save_translations' && !empty($_POST['gettext_strings'])) {
|
360 |
$strings = json_decode(stripslashes($_POST['gettext_strings']));
|
361 |
$update_strings = array();
|
@@ -397,8 +397,7 @@ class TRP_Translation_Manager{
|
|
397 |
* @param $wp_admin_bar
|
398 |
*/
|
399 |
public function add_shortcut_to_translation_editor( $wp_admin_bar ) {
|
400 |
-
|
401 |
-
if( ! current_user_can( 'manage_options' ) ) {
|
402 |
return;
|
403 |
}
|
404 |
|
@@ -653,7 +652,9 @@ class TRP_Translation_Manager{
|
|
653 |
$callstack_function['function'] == 'wp_register_script' ||
|
654 |
$callstack_function['function'] == 'wp_print_scripts'||
|
655 |
$callstack_function['function'] == 'wp_localize_script'||
|
656 |
-
$callstack_function['function'] == 'wp_print_media_templates'
|
|
|
|
|
657 |
) {
|
658 |
return $translation;
|
659 |
}
|
31 |
*/
|
32 |
protected function conditions_met( $mode = 'true' ){
|
33 |
if ( isset( $_REQUEST['trp-edit-translation'] ) && esc_attr( $_REQUEST['trp-edit-translation'] ) == $mode ) {
|
34 |
+
if ( current_user_can( apply_filters( 'trp_translating_capability', 'manage_options' ) ) && ! is_admin() ) {
|
35 |
return true;
|
36 |
}else{
|
37 |
wp_die(
|
163 |
|
164 |
// necessary in order to obtain all the original strings
|
165 |
if ( $this->settings['default-language'] != $current_language ) {
|
166 |
+
if ( current_user_can ( apply_filters( 'trp_translating_capability', 'manage_options' ) ) ) {
|
167 |
$this->translation_render->process_strings($original_array, $current_language);
|
168 |
}
|
169 |
$dictionaries[$current_language] = $this->trp_query->get_string_rows( $id_array, $original_array, $current_language );
|
192 |
if (empty($original_strings)) {
|
193 |
$original_strings = $this->extract_original_strings($dictionaries[$current_language], $original_array, $id_array);
|
194 |
}
|
195 |
+
if (current_user_can(apply_filters( 'trp_translating_capability', 'manage_options' ))) {
|
196 |
$this->translation_render->process_strings($original_strings, $language);
|
197 |
}
|
198 |
$dictionaries[$language] = $this->trp_query->get_string_rows(array(), $original_strings, $language);
|
319 |
*/
|
320 |
public function save_translations(){
|
321 |
|
322 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && current_user_can( apply_filters( 'trp_translating_capability', 'manage_options' ) ) ) {
|
323 |
if ( isset( $_POST['action'] ) && $_POST['action'] === 'trp_save_translations' && !empty( $_POST['strings'] ) ) {
|
324 |
$strings = json_decode(stripslashes($_POST['strings']));
|
325 |
$update_strings = array();
|
355 |
}
|
356 |
|
357 |
public function gettext_save_translations(){
|
358 |
+
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && current_user_can( apply_filters( 'trp_translating_capability', 'manage_options' ) ) ) {
|
359 |
if (isset($_POST['action']) && $_POST['action'] === 'trp_gettext_save_translations' && !empty($_POST['gettext_strings'])) {
|
360 |
$strings = json_decode(stripslashes($_POST['gettext_strings']));
|
361 |
$update_strings = array();
|
397 |
* @param $wp_admin_bar
|
398 |
*/
|
399 |
public function add_shortcut_to_translation_editor( $wp_admin_bar ) {
|
400 |
+
if( ! current_user_can( apply_filters( 'trp_translating_capability', 'manage_options' ) ) ) {
|
|
|
401 |
return;
|
402 |
}
|
403 |
|
652 |
$callstack_function['function'] == 'wp_register_script' ||
|
653 |
$callstack_function['function'] == 'wp_print_scripts'||
|
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'] == 'wptexturize'
|
658 |
) {
|
659 |
return $translation;
|
660 |
}
|
includes/class-translation-render.php
CHANGED
@@ -37,6 +37,25 @@ class TRP_Translation_Render{
|
|
37 |
ob_start(array($this, 'translate_page'));
|
38 |
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
/**
|
41 |
* Language to translate into.
|
42 |
*
|
@@ -292,6 +311,11 @@ class TRP_Translation_Render{
|
|
292 |
if( !empty( $all_attributes ) ) {
|
293 |
foreach ($all_attributes as $attr_name => $attr_value) {
|
294 |
if (strpos($attr_value, 'trp-gettext ') !== false) {
|
|
|
|
|
|
|
|
|
|
|
295 |
// convert to a node
|
296 |
$node_from_value = trp_str_get_html(html_entity_decode(htmlspecialchars_decode($attr_value, ENT_QUOTES)));
|
297 |
foreach ($node_from_value->find('trp-gettext') as $nfv_row) {
|
37 |
ob_start(array($this, 'translate_page'));
|
38 |
}
|
39 |
|
40 |
+
/**
|
41 |
+
* Function to hide php errors and notice and instead log them in debug.log so we don't store the notice strings inside the db if WP_DEBUG is on
|
42 |
+
*/
|
43 |
+
public function trp_debug_mode_off(){
|
44 |
+
if ( WP_DEBUG ) {
|
45 |
+
global $TRP_LANGUAGE;
|
46 |
+
if (is_admin() ||
|
47 |
+
($TRP_LANGUAGE == $this->settings['default-language'] && (!isset($_REQUEST['trp-edit-translation']) || (isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] != 'preview'))) ||
|
48 |
+
(isset($_REQUEST['trp-edit-translation']) && $_REQUEST['trp-edit-translation'] == 'true')
|
49 |
+
) {
|
50 |
+
return; //don't do nothing if we are not storing strings
|
51 |
+
}
|
52 |
+
|
53 |
+
ini_set('display_errors', 0);
|
54 |
+
ini_set('log_errors', 1);
|
55 |
+
ini_set('error_log', WP_CONTENT_DIR . '/debug.log');
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
/**
|
60 |
* Language to translate into.
|
61 |
*
|
311 |
if( !empty( $all_attributes ) ) {
|
312 |
foreach ($all_attributes as $attr_name => $attr_value) {
|
313 |
if (strpos($attr_value, 'trp-gettext ') !== false) {
|
314 |
+
//if we have json content in the value of the attribute, we don't do anything. The trp-wrap will be removed later in the code
|
315 |
+
if (is_array($json_array = json_decode( html_entity_decode( $attr_value, ENT_QUOTES ), true ) ) ) {
|
316 |
+
continue;
|
317 |
+
}
|
318 |
+
|
319 |
// convert to a node
|
320 |
$node_from_value = trp_str_get_html(html_entity_decode(htmlspecialchars_decode($attr_value, ENT_QUOTES)));
|
321 |
foreach ($node_from_value->find('trp-gettext') as $nfv_row) {
|
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.6
|
7 |
Author: Cozmoslabs, Razvan Mocanu, Madalin Ungureanu, Cristophor Hurduban
|
8 |
Author URI: https://cozmoslabs.com/
|
9 |
License: GPL2
|
partials/addons-settings-page.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
<div class="grid feat-header">
|
7 |
<div class="grid-cell">
|
8 |
<h2>Advanced Addons</h2>
|
9 |
-
<p>These addons extend your translation plugin and are available in the
|
10 |
</div>
|
11 |
</div>
|
12 |
|
6 |
<div class="grid feat-header">
|
7 |
<div class="grid-cell">
|
8 |
<h2>Advanced Addons</h2>
|
9 |
+
<p>These addons extend your translation plugin and are available in the Developer, Business and Personal plans.</p>
|
10 |
</div>
|
11 |
</div>
|
12 |
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: cozmoslabs, razvan.mo, madalin.ungureanu, cristophor
|
|
3 |
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.
|
7 |
-
Stable tag: 1.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -107,6 +107,13 @@ For more information please check out [TranslatePress documentation](https://tra
|
|
107 |
|
108 |
== Changelog ==
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
= 1.0.5 =
|
111 |
* Added possibility to edit gettext strings from themes and plugins from english to english, without adding another language. Basically, string-replace functionality.
|
112 |
* We now can translate text input placeholders
|
3 |
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.6
|
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.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.
|
119 |
* We now can translate text input placeholders
|