Skip to content

Commit

Permalink
3.2.9.5 pre-release issue #99
Browse files Browse the repository at this point in the history
  • Loading branch information
johnclause committed Mar 28, 2015
1 parent b3e82cd commit d02b5ff
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 12 deletions.
25 changes: 22 additions & 3 deletions admin/qtx_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ function qtranxf_admin_section_end($nm) {

function qtranxf_conf() {
global $qtranslate_options, $q_config, $wpdb;
//qtranxf_dbg_echo('qtranxf_conf: POST: ',$_POST);
//qtranxf_dbg_log('qtranxf_conf: POST: ',$_POST);

// do redirection for dashboard
if(isset($_GET['godashboard'])) {
Expand Down Expand Up @@ -911,10 +911,29 @@ function qtranxf_conf() {
}
}
}
if(get_magic_quotes_gpc()) {

/**
@since 3.2.9.5
In earlier versions the 'if' below used to work correctly, but magic_quotes has been removed from PHP for a while, and 'if(get_magic_quotes_gpc())' is now always 'false'.
However, WP adds magic quotes anyway via call to add_magic_quotes() in
./wp-includes/load.php:function wp_magic_quotes()
called from
./wp-settings.php: wp_magic_quotes()
Then it looks like we have to always 'stripslashes' now, although it is dangerous, since applying 'stripslashes' twice messes it up.
This problem reveals when, for example, '\a' format is in use.
Possible test for '\' character, instead of 'get_magic_quotes_gpc()' can be 'strpos($_POST['language_date_format'],'\\\\')' for this particular case.
If Wordpress ever decides to remove calls to wp_magic_quotes, then this place will be in trouble again.
Discussions:
http://wordpress.stackexchange.com/questions/21693/wordpress-and-magic-quotes
*/
//if(get_magic_quotes_gpc()) {
//qtranxf_dbg_log('get_magic_quotes_gpc: before language_date_format=',$_POST['language_date_format']);
//qtranxf_dbg_log('pos=',strpos($_POST['language_date_format'],'\\\\'));//shows a number
if(isset($_POST['language_date_format'])) $_POST['language_date_format'] = stripslashes($_POST['language_date_format']);
if(isset($_POST['language_time_format'])) $_POST['language_time_format'] = stripslashes($_POST['language_time_format']);
}
//qtranxf_dbg_log('pos=',strpos($_POST['language_date_format'],'\\\\'));//shows false
//qtranxf_dbg_log('get_magic_quotes_gpc: after language_date_format=',$_POST['language_date_format']);
//}
if($error=='') {
// everything is fine, insert language
$q_config['language_name'][$lang] = sanitize_text_field($_POST['language_name']);
Expand Down
1 change: 1 addition & 0 deletions qtranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
require_once(dirname(__FILE__).'/qtranslate_options.php');
require_once(dirname(__FILE__).'/qtranslate_utils.php');
require_once(dirname(__FILE__).'/qtranslate_core.php');

require_once(dirname(__FILE__).'/qtranslate_widget.php');

if(is_admin()){
Expand Down
18 changes: 9 additions & 9 deletions qtranslate_hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

function qtranxf_localeForCurrentLanguage($locale){
global $q_config;
if( !isset($q_config['language']) ) return $locale;
//if( !isset($q_config['language']) ) return $locale;
// try to figure out the correct locale
$windows_locale = qtranxf_default_windows_locale(); //$q_config['windows_locale'];
$lang = $q_config['language'];
Expand Down Expand Up @@ -88,21 +88,21 @@ function qtranxf_fixSearchForm($form) {
function qtranxf_gettext($translated_text) {
//same as qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage
global $q_config;
if(!isset($q_config['language'])){
//qtranxf_dbg_log('$q_config[language] is not set:',debug_backtrace());
return $translated_text;
}
//if(!isset($q_config['language'])){
// //qtranxf_dbg_log('$q_config[language] is not set:',debug_backtrace());
// return $translated_text;
//}
return qtranxf_use($q_config['language'], $translated_text, false);
}

//function qtranxf_gettext_with_context($translated_text, $text, $context, $domain) {
function qtranxf_gettext_with_context($translated_text) {
//same as qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage
global $q_config;
if(!isset($q_config['language'])){
//qtranxf_dbg_log('$q_config[language] is not set:',debug_backtrace());
return $translated_text;
}
//if(!isset($q_config['language'])){
// //qtranxf_dbg_log('$q_config[language] is not set:',debug_backtrace());
// return $translated_text;
//}
return qtranxf_use($q_config['language'], $translated_text, false);
}

Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ One can find the original qTranslate FAQ [here](https://wordpress.org/plugins/qt

### 3.2.9.5 ###
* Improvement: 'Code' column in the list of languages. Thanks to Pedro Mendonça for the [discussion](https://github.com/qTranslate-Team/qtranslate-x/issues/102).
* Fix: date/time formats containing backslashes: [Issue #99](https://github.com/qTranslate-Team/qtranslate-x/issues/99).

### 3.2.9.4 ###
* Translation: po files updated. Thanks to Pedro Mendonça for a [discussion](https://github.com/qTranslate-Team/qtranslate-x/pull/100).
Expand Down

0 comments on commit d02b5ff

Please sign in to comment.