From a460832f8c4bc50db74b4899f57ed1913d6b75c6 Mon Sep 17 00:00:00 2001 From: John Clause Date: Fri, 6 Feb 2015 17:35:43 -0700 Subject: [PATCH] 2.9.8.6 pre-release --- qtranslate.php | 12 +++++++++--- qtranslate_compatibility.php | 5 +++++ qtranslate_configuration.php | 5 ++--- qtranslate_core.php | 26 +++++++++++++++++++++----- qtranslate_services.php | 4 +++- qtranslate_utils.php | 6 ++++++ readme.txt | 22 +++++++++++++--------- screenshot-3.png | Bin 171349 -> 0 bytes 8 files changed, 59 insertions(+), 21 deletions(-) delete mode 100644 screenshot-3.png diff --git a/qtranslate.php b/qtranslate.php index 93fa591..5b834ed 100644 --- a/qtranslate.php +++ b/qtranslate.php @@ -3,7 +3,7 @@ Plugin Name: qTranslate-X Plugin URI: http://wordpress.org/plugins/qtranslate-x/ Description: Adds user-friendly and database-friendly multilingual content support into WordPress. -Version: 2.9.8.5 +Version: 2.9.8.6 Author: John Clause based on original code by Qian Qin Author URI: http://qtranslatexteam.wordpress.com/about Tags: multilingual, multi, language, admin, tinymce, Polyglot, bilingual, widget, switcher, professional, human, translation, service, qTranslate, zTranslate, mqTranslate, qTranslate Plus, WPML @@ -101,7 +101,7 @@ define( 'QTRANSLATE_FILE', __FILE__ ); } -define('QTX_VERSION','2.9.8.5'); +define('QTX_VERSION','2.9.8.6'); /* DEFAULT CONFIGURATION PART BEGINS HERE */ @@ -130,6 +130,7 @@ define('QTX_IGNORE_FILE_TYPES','gif,jpg,jpeg,png,pdf,swf,tif,rar,zip,7z,mpg,divx,mpeg,avi,css,js'); + $q_config = array(); // enable the use of following languages (order=>language) @@ -503,12 +504,16 @@ // Load qTranslate-X -register_activation_hook(__FILE__, 'qtranxf_activation_hook');//does not work if inside qtranslate_configuration.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() && !defined('DOING_AJAX')){ + require_once(dirname(__FILE__).'/admin/activation_hook.php'); + register_activation_hook(__FILE__, 'qtranxf_activation_hook');//does not work if inside qtranslate_configuration.php +} +/* if(is_admin()){ require_once(dirname(__FILE__)."/qtranslate_configuration.php"); @@ -521,6 +526,7 @@ }else{ require_once(dirname(__FILE__)."/qtranslate_frontend.php"); } +*/ // set hooks at the end require_once(dirname(__FILE__)."/qtranslate_hooks.php"); diff --git a/qtranslate_compatibility.php b/qtranslate_compatibility.php index 7712715..2958916 100644 --- a/qtranslate_compatibility.php +++ b/qtranslate_compatibility.php @@ -14,6 +14,11 @@ function qtrans_use($lang, $text, $show_available=false){ return qtranxf_use($lang, $text, $show_available); } } +if (!function_exists('qtrans_useDefaultLanguage')){ + function qtrans_useDefaultLanguage($content){ + return qtranxf_useDefaultLanguage($content); + } +} if (!function_exists('qtrans_useCurrentLanguageIfNotFoundShowAvailable')){ function qtrans_useCurrentLanguageIfNotFoundShowAvailable($content){ return qtranxf_useCurrentLanguageIfNotFoundShowAvailable($content); diff --git a/qtranslate_configuration.php b/qtranslate_configuration.php index 3589f77..26d12f3 100644 --- a/qtranslate_configuration.php +++ b/qtranslate_configuration.php @@ -21,7 +21,6 @@ if ( !defined( 'WP_ADMIN' ) ) exit; require_once(dirname(__FILE__).'/admin/import_export.php'); -require_once(dirname(__FILE__).'/admin/activation_hook.php'); function qtranxf_reset_config() { @@ -1023,7 +1022,7 @@ function qtranxf_conf() { -
+
qTranslate'); ?> @@ -1172,7 +1171,7 @@ class qtranxcLangSwItems {

- class="button-secondary submit-add-to-menu right" value="" name="add-qtranxs-langsw-menu-item" id="submit-qtranxs-langsw" /> + class="button-secondary submit-add-to-menu right" value="" name="add-qtranxs-langsw-menu-item" id="submit-qtranxs-langsw" />

diff --git a/qtranslate_core.php b/qtranslate_core.php index 3eeef56..28b7ba3 100644 --- a/qtranslate_core.php +++ b/qtranslate_core.php @@ -57,7 +57,7 @@ function qtranxf_init_language() { $url_info['language'] = qtranxf_detect_language($url_info); //qtranxf_dbg_log('qtranxf_init_language: url_info: ',$url_info); - $q_config['url_info'] = apply_filters('qtranslate_url_info', $url_info);//slug redirection etc. + $q_config['url_info'] = apply_filters('qtranslate_url_info', $url_info);//slug redirection etc.? $url_info = $q_config['url_info']; //qtranxf_dbg_log('qtranxf_init_language: url_info: ',$url_info); @@ -83,11 +83,19 @@ function qtranxf_init_language() { $q_config['url_info']['url'] = qtranxf_convertURL(add_query_arg('lang',$q_config['default_language'],$q_config['url_info']['url'])); // Filter all options for language tags - if(!defined('WP_ADMIN')) { + if($q_config['doing_front_end']) { $alloptions = wp_load_alloptions(); foreach($alloptions as $option => $value) { add_filter('option_'.$option, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0); } + require_once(dirname(__FILE__)."/qtranslate_frontend.php"); + }else{ + require_once(dirname(__FILE__).'/qtranslate_configuration.php'); + require_once(dirname(__FILE__).'/admin/admin_utils.php'); + + // load qTranslate Services if available + if(file_exists(dirname(__FILE__).'/qtranslate_services.php')) + require_once(dirname(__FILE__).'/qtranslate_services.php'); } if(isset($q_config['qtrans_compatibility']) && $q_config['qtrans_compatibility']){ @@ -113,6 +121,8 @@ function qtranxf_detect_language(&$url_info) { $lang = qtranxf_parse_language_info($url_info); + $q_config['doing_front_end'] = !defined('WP_ADMIN'); + //$q_config['doing_front_end'] defines if we are at front- or back-end. Why WP do not have that, or do they? while(!$lang) { if( defined('DOING_AJAX') && isset($_SERVER['HTTP_REFERER']) ){ //try to get language from HTTP_REFERER @@ -130,10 +140,16 @@ function qtranxf_detect_language(&$url_info) { //qtranxf_dbg_log('qtranxf_detect_language: referer_info: ',$referer); $lang = qtranxf_parse_language_info($referer,true); //qtranxf_dbg_log('qtranxf_detect_language: http_referer: lang=',$lang); - $url_info['referer_language'] = $lang ? $lang : $q_config['default_language']; + if($lang){ + $url_info['referer_language'] = $lang; + $q_config['doing_front_end'] = true; + }else{ + $url_info['referer_language'] = $q_config['default_language']; + } } - if(!$lang && !qtranxf_language_neutral_path($referer['url'])){ + if(!$lang && !qtranxf_language_neutral_path($referer['path'])){ $lang = $q_config['default_language']; + $q_config['doing_front_end'] = true; } //qtranxf_dbg_log('qtranxf_detect_language: DOING_AJAX: lang=',$lang); } @@ -538,7 +554,7 @@ function qtranxf_init() { // load plugin translations load_plugin_textdomain('qtranslate', false, dirname(plugin_basename( __FILE__ )).'/lang'); - if(!defined('WP_ADMIN')){ + if($q_config['doing_front_end']){ // don't filter untranslated posts in admin if($q_config['hide_untranslated']){ add_filter('posts_where_request', 'qtranxf_excludeUntranslatedPosts',10,2); diff --git a/qtranslate_services.php b/qtranslate_services.php index a0b42d9..428b88d 100644 --- a/qtranslate_services.php +++ b/qtranslate_services.php @@ -551,7 +551,7 @@ function qts_service() { printf(__('Post with id "%s" not found!','qtranslate'), $post_id); return; } - $default_service = intval(get_option('qts_default_service')); + $default_service = intval(get_option('qts_default_service'),0); $service_settings = get_option('qts_service_settings'); // Detect available Languages and possible target languages $available_languages = qtranxf_getAvailableLanguages($post->post_content); @@ -770,6 +770,7 @@ function qts_service() { if($services = qts_queryQS(QTS_GET_SERVICES)) { foreach($services as $service_id => $service) { // check if we have data for all required fields + //if($service_id==1) continue;//qTranslate Services Test $requirements_matched = true; foreach($service['service_required_fields'] as $field) { if(!isset($service_settings[$service_id][$field['name']]) || $service_settings[$service_id][$field['name']] == '') $requirements_matched = false; @@ -792,6 +793,7 @@ function qts_service() {