Skip to content

Commit

Permalink
2.9.8.6 pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
johnclause committed Feb 7, 2015
1 parent 30fe67c commit a460832
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 21 deletions.
12 changes: 9 additions & 3 deletions qtranslate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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");
Expand All @@ -521,6 +526,7 @@
}else{
require_once(dirname(__FILE__)."/qtranslate_frontend.php");
}
*/

// set hooks at the end
require_once(dirname(__FILE__)."/qtranslate_hooks.php");
Expand Down
5 changes: 5 additions & 0 deletions qtranslate_compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions qtranslate_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -1023,7 +1022,7 @@ function qtranxf_conf() {
<tr valign="top">
<th scope="row"><?php _e('Compatibility Functions', 'qtranslate');?></th>
<td>
<label for="qtranxs_qtrans_compatibility"><input type="checkbox" name="qtrans_compatibility" id="qtranxs_qtrans_compatibility" value="1"<?php checked($q_config['qtrans_compatibility']); ?>/>&nbsp;<?php printf(__('Enable function name compatibility (%s).', 'qtranslate'), 'qtrans_getLanguage, qtrans_convertURL, qtrans_use, qtrans_useCurrentLanguageIfNotFoundShowAvailable, qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage, qtrans_useTermLib, qtrans_getSortedLanguages, qtrans_generateLanguageSelectCode'); ?></label><br/>
<label for="qtranxs_qtrans_compatibility"><input type="checkbox" name="qtrans_compatibility" id="qtranxs_qtrans_compatibility" value="1"<?php checked($q_config['qtrans_compatibility']); ?>/>&nbsp;<?php printf(__('Enable function name compatibility (%s).', 'qtranslate'), 'qtrans_getLanguage, qtrans_convertURL, qtrans_use, qtranxf_useDefaultLanguage, qtrans_useCurrentLanguageIfNotFoundShowAvailable, qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage, qtrans_useTermLib, qtrans_getSortedLanguages, qtrans_generateLanguageSelectCode'); ?></label><br/>
<small><?php printf(__('Some plugins and themes use direct calls to the functions listed, which are defined in former %s plugin and some of its forks. Turning this flag on will enable those function to exists, which will make the dependent plugins and themes to work. WordPress policy prohibits to define functions with the same names as in other plugins, since it generates user-unfriendly fatal errors, when two conflicting plugins are activated simultaneously. Before turning this option on, you have to make sure that there are no other plugins active, which define those functions.', 'qtranslate'), '<a href="https://wordpress.org/plugins/qtranslate/" target="_blank">qTranslate</a>'); ?></small>
</td>
</tr>
Expand Down Expand Up @@ -1172,7 +1171,7 @@ class qtranxcLangSwItems {
</span>
<p class="button-controls">
<span class="add-to-menu">
<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu', 'qtranslate'); ?>" name="add-qtranxs-langsw-menu-item" id="submit-qtranxs-langsw" />
<input type="submit"<?php disabled( $nav_menu_selected_id, 0 ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-qtranxs-langsw-menu-item" id="submit-qtranxs-langsw" />
<span class="spinner"></span>
</span>
</p>
Expand Down
26 changes: 21 additions & 5 deletions qtranslate_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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']){
Expand All @@ -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
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion qtranslate_services.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -792,6 +793,7 @@ function qts_service() {
</ul>
<script type="text/javascript">
function chooseservice(id) {
if(id<=0) return;
jQuery('#qts_service_'+id).attr('checked','checked');
jQuery('#submitdiv .request').html('<?php _e('<p><img src="images/wpspin_light.gif"> Getting Quote...</p>', 'qtranslate'); ?>');
jQuery.post(ajaxurl, {
Expand Down
6 changes: 6 additions & 0 deletions qtranslate_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,16 @@ function qtranxf_dbg_echo($msg,$var='novar',$bt=false){
}
}
}
if(!function_exists('qtranxf_dbg_log_if')){
function qtranxf_dbg_log_if($condition,$msg,$var='novar',$bt=false){
if($condition) qtranxf_dbg_log($msg,$var,$bt);
}
}
assert_options(ASSERT_BAIL,true);
}else{
if(!function_exists('qtranxf_dbg_log')){ function qtranxf_dbg_log($msg,$var=null,$bt=false){} }
if(!function_exists('qtranxf_dbg_echo')){ function qtranxf_dbg_echo($msg,$var=null,$bt=false){} }
if(!function_exists('qtranxf_dbg_log_if')){ function qtranxf_dbg_log_if($condition,$msg,$var=null,$bt=false){} }
//assert_options(ASSERT_ACTIVE,false);
//assert_options(ASSERT_WARNING,false);
//assert_options(ASSERT_QUIET_EVAL,true);
Expand Down
22 changes: 13 additions & 9 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ qTranslate-X makes creation of multilingual content as easy as working with a si
- Use [Google XML Sitemaps v3 for qTranslate](https://wordpress.org/plugins/google-xml-sitemaps-v3-for-qtranslate/) plugin to rebuild your XML sitemap for better SEO support.
- Use plugin [Qtranslate Slug](https://wordpress.org/plugins/qtranslate-slug/) if you need to translate slugs.

Below is the list of plugins made compatible, as reported by users:
Below is the list of plugins recently made compatible, as reported by users:

- [ALO EasyMail Newsletter](https://wordpress.org/support/plugin/alo-easymail)
- [BuddyPress](https://wordpress.org/plugins/buddypress/) and its satellites.
- [Google XML Sitemaps v3 for qTranslate](https://wordpress.org/plugins/google-xml-sitemaps-v3-for-qtranslate/)
Expand All @@ -46,7 +47,7 @@ If you encounter a conflicting a plugin, please let us know, and meanwhile try t

You may still find a lot of useful information through reading [qTranslate](https://wordpress.org/plugins/qtranslate/ "Original qTranslate plugin")'s original documentation, which is not duplicated here in full. There are also other plugins, which offer multilingual support, but it seems that Qian Qin has very good original back-end design, and many people have been pleasantly using his plugin ever since. It stores all translations in the same single post, which makes it easy to maintain and to use it with other plugins. However, the user interface of former qTranslate got out of sync with the recent versions of Wordpress, especially after WP went to TinyMCE 4. There is a number of forks of qTranslate, see for example, [mqTranslate](https://wordpress.org/plugins/mqtranslate/ "mqTranslate plugin"), [qTranslate Plus](https://wordpress.org/plugins/qtranslate-xp/ "qTranslate Plus plugin") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate plugin"). They all try to fix qTranslate's user interface preserving its original back-end, which is what this plugin does too. This plugin is a hybrid of all of them and fixes a few bugs in each of them. It also has many new features too, like theme custom translatable fields, for example. We hope that this plugin is the most complete working version which combines the best features of [qTranslate](https://wordpress.org/plugins/qtranslate/ "Original qTranslate plugin"), [mqTranslate](https://wordpress.org/plugins/mqtranslate/ "mqTranslate fork"), [qTranslate Plus](https://wordpress.org/plugins/qtranslate-xp/ "qTranslate Plus fork") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate fork").

We suggest all mentioned authors to get together and to continue supporting one single qTranslate-ish plugin in a joint effort.
We organized an anonymous entity [qTranslate Team](https://github.com/qTranslate-Team) to maintain a joint authority of all qTranslate-ish plugins. Anyone is welcome to join with a contribution. Participating plugin authors should share the support efforts for each other.

GitHub repository is available: https://github.com/qTranslate-Team/qtranslate-x.git

Expand Down Expand Up @@ -204,12 +205,15 @@ One can find the original qTranslate FAQ [here](https://wordpress.org/plugins/qt

1. Editing screen showing the buttons to switch the languages. Pressing a button does not make a call to the server, the editing happens locally, until "Update" button is pressed, the same way as it is for one language.
2. Language Management Interface
3. qTranslate translation services

== Changelog ==

= 2.9.8.6 alpha =
* more on proper detection of front-end vs back-end on AJAX calls.

= 2.9.8.5 alpha =
* more on option "Hide Content which is not available for the selected language"
* thanks to Marius Siroen for Dutch translation

= 2.9.8.4 alpha =
* .pot/.po files in order. Thanks to [Pedro Mendonça](https://github.com/pedro-mendonca) for an extensive discussion on the best way to proceed with translations.
Expand Down Expand Up @@ -342,14 +346,14 @@ One can find the original qTranslate FAQ [here](https://wordpress.org/plugins/qt

== Known Issues ==

* [WooCommerce](https://wordpress.org/plugins/woocommerce/) framework plugins: turn on option "Compatibility Functions".
* Incompatibility with plugin [WP Editor](https://wordpress.org/support/plugin/wp-editor). Language switching buttons do not change the content of main editor in pages and posts. For now, you would need to deactivate "WP Editor".
* Message "The backup of this post in your browser is different from the version below" appears sometimes in the post editor. Clicking on "Restore the backup" may produce unexpected result, since backup has one language only,
the one which was active at the time of the last pressing of button "Update". The code which causes this is in /wp-includes/js/autosave.js.
* Sometimes after a new plugin update is released, the language switching buttons disappear on the first editor page load. Refresh the page to bring them back. Apparently, it has something to do with browse caching mechanism.
* Turn on option "Compatibility Functions", if you use [WooCommerce](https://wordpress.org/plugins/woocommerce/) framework plugins, like [IM8 qTranslate WooCommerce](https://wordpress.org/plugins/im8-qtranslate-woocommerce/), [qTranslate support for WooCommerce](https://wordpress.org/plugins/qtranslate-support-for-woocommerce/), [WooCommerce-qTML](https://wordpress.org/plugins/woocommerce-qtml/), for example. Also it is needed for any theme, which claims its compatibility with former qTranslate.
* If other plugin installs a custom TinyMCE editor on a translatable field served by qTranslate-X, then all kind of problems start to happen. Examples of 'offending' plugins are: [Fusion Page Builder](http://www.theme-fusion.com/), [Page Builder by SiteOrigin](https://wordpress.org/plugins/siteorigin-panels/), [Rich Text Tags](https://wordpress.org/plugins/rich-text-tags/), [WP Editor](https://wordpress.org/plugins/wp-editor/). We are looking into possibilities to enable integration with those plugins.
* When [Jetpack by WordPress.com](https://wordpress.org/plugins/jetpack/) is enabled, pressing 'Save Changes' at Settings/General (/wp-admin/options-general.php) page, causes fields "Site Title" and "Tagline" to be emptied, if they had multilingual values. It only happens when Jetpack is connected to WordPress. For now, when you need to edit those values, deactivate Jetpack, make your edits, then re-activate JetPack again. Fortunately, that general setting page need not to be changed frequently. [WP topic](https://wordpress.org/support/topic/site-titletagline-disappear-on-general-settings-update)
* Message "The backup of this post in your browser is different from the version below" appears sometimes in the post editor. Clicking on "Restore the backup" may produce unexpected result, since backup has one language only, the one which was active at the time of the last pressing of button "Update". The code which causes this is in /wp-includes/js/autosave.js. Autosave script is currently turned off to avoid this confusion.
* Search in Category/Tags editor works in default language only.
* If default language name of new category/tag is empty, nothing gets added.
* If field "Alternative Text" on page "Edit Media" is left empty, then caption or title will be used untranslated in 'alt' attribute of image display. There is no WP hook provided to enable translation in such a case (see code of 'function wp_get_attachment_image'). However, if "Alternative Text" is filled with non-empty value, then it is shown translated and correctly. We could only re-implement the WP algorithm to be run for the second time under filter 'wp_get_attachment_image_attributes' with translation, which would hurt performance a little bit. If this is a real problem for you, let us know, we can put it in as an option, or submit pull request with your version of implementation. [WP topic](https://wordpress.org/support/topic/odd-behavior-with-photos-and-photo-galleries)
* Page `/wp-admin/edit-tags.php?taxonomy=category`: if default language name of new category/tag is empty, nothing gets added.
* [resolved] Sometimes after a new plugin update is released, the language switching buttons disappear on the first editor page load. Refresh the page to bring them back. Apparently, it has something to do with browse caching mechanism.

== Credentials ==

Expand Down
Binary file removed screenshot-3.png
Binary file not shown.

0 comments on commit a460832

Please sign in to comment.