Skip to content

Commit

Permalink
2.9.8.3 alpha pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
johnclause committed Feb 3, 2015
1 parent a70c029 commit 87efb63
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 33 deletions.
14 changes: 14 additions & 0 deletions admin/admin_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@ function qtranxf_admin_the_title($title) {
}
add_filter('the_title', 'qtranxf_admin_the_title', 0);//WP: fires for display purposes only

//filter added in qtranslate_hooks.php
function qtranxf_trim_words( $text, $num_words, $more, $original_text ) {
global $q_config;
$blocks = qtranxf_get_language_blocks($original_text);
if ( count($blocks) <= 1 )
return $text;
$lang = $q_config['language'];
$texts = qtranxf_split_blocks($blocks);
foreach($texts as $key => $txt){
$texts[$key] = wp_trim_words($txt, $num_words, $more);
}
return qtranxf_join_c($texts);
}

function qtranxf_the_editor($editor_div)
{
// remove wpautop, which causes unmatched <p> on combined language strings
Expand Down
4 changes: 2 additions & 2 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.2
Version: 2.9.8.3
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.2');
define('QTX_VERSION','2.9.8.3');

/* DEFAULT CONFIGURATION PART BEGINS HERE */

Expand Down
58 changes: 56 additions & 2 deletions qtranslate_configuration.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
.qtranxs_title_input {
border:0pt none;
font-size:1.7em;
Expand All @@ -13,7 +14,7 @@
border-width:1px;
padding:2px 3px;
}
#qtranxf_textarea_content {
#qtranxs_textarea_content {
padding:6px;
border:0 none;
line-height:150%;
Expand All @@ -35,10 +36,11 @@
border-top-right-radius: 6px;
border-top-left-radius: 6px;
}
.hide-if-no-js.wp-switch-editor.switch-tmce { margin-left:6px !important; }
#qtranxs_debug { width:100%; height:200px }
#qtranxs_custom_fields { width:100%; }
#postexcerpt textarea { height:4em; margin:0; width:98% }
.qtranxs_lang_div {
float:right;
height:12px;
Expand All @@ -52,3 +54,55 @@
border-right: 1px solid #F7F7F7;
padding:6px 4px 8px 4px;
}
*/

#qtranxs_custom_fields { width:100%; }

/*
//Language Switching Buttons as tabs
.qtranxs-lang-switch-wrap {
margin: 15px 0 10px;
position: relative;
}
.qtranxs-lang-switch-wrap:before{
position: absolute;
content: ' ';
bottom:0;
left:0;
right:0;
z-index: 1;
border-bottom: 1px solid #ccc;
}
.qtranxs-lang-switch-wrap li.qtranxs-lang-switch{
position: relative;
border-color: #ccc;
padding: 10px 15px;
cursor: pointer;
position: relative;
z-index: 2;
background: none;
margin-right: 2px;
line-height: 1.42857143;
border: 1px solid transparent;
border-radius: 4px 4px 0 0;
opacity: 0.8;
}
.qtranxs-lang-switch-wrap li.qtranxs-lang-switch:hover{
background: #e0e0e0;
opacity: 1;
}
.qtranxs-lang-switch-wrap li.qtranxs-lang-switch.active, .qtranxs-lang-switch-wrap li.qtranxs-lang-switch.active:focus,
.qtranxs-lang-switch-wrap li.qtranxs-lang-switch.active:hover {
color: #555;
cursor: default;
background-color: #f1f1f1;
border: 1px solid #ccc;
border-bottom-color: transparent;
opacity: 1;
}
*/
14 changes: 7 additions & 7 deletions qtranslate_configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function qtranxf_select_admin_js ($enqueue_script=false) {

function qtranxf_add_admin_footer_js ( $enqueue_script=false ) {
global $q_config;
//wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.js', __FILE__ ) );
//wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.js', __FILE__ ), array(), QTX_VERSION );
//wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.min.js', __FILE__ ), array(), QTX_VERSION );
//wp_enqueue_script( 'qtranslate-script' );
$script_file=qtranxf_select_admin_js($enqueue_script);
Expand Down Expand Up @@ -349,14 +349,14 @@ function qtranxf_add_admin_lang_icons ()
}

function qtranxf_add_admin_css () {
wp_register_style( 'qtranslate-admin-style', plugins_url('qtranslate_configuration.css', __FILE__) );
wp_register_style( 'qtranslate-admin-style', plugins_url('qtranslate_configuration.css', __FILE__), array(), QTX_VERSION );
wp_enqueue_style( 'qtranslate-admin-style' );
qtranxf_add_admin_lang_icons();
echo '<style type="text/css" media="screen">'.PHP_EOL;
/*
echo ".qtranxs_title_input { border:0pt none; font-size:1.7em; outline-color:invert; outline-style:none; outline-width:medium; padding:0pt; width:100%; }\n";
echo ".qtranxs_title_wrap { border-color:#CCCCCC; border-style:solid; border-width:1px; padding:2px 3px; }\n";
echo "#qtranxf_textarea_content { padding:6px; border:0 none; line-height:150%; outline: none; margin:0pt; width:100%; -moz-box-sizing: border-box;";
echo "#qtranxs_textarea_content { padding:6px; border:0 none; line-height:150%; outline: none; margin:0pt; width:100%; -moz-box-sizing: border-box;";
echo "-webkit-box-sizing: border-box; -khtml-box-sizing: border-box; box-sizing: border-box; }\n";
echo ".qtranxs_title { -moz-border-radius: 6px 6px 0 0;";
echo "-webkit-border-top-right-radius: 6px; -webkit-border-top-left-radius: 6px; -khtml-border-top-right-radius: 6px; -khtml-border-top-left-radius: 6px;";
Expand Down Expand Up @@ -904,7 +904,7 @@ function qtranxf_conf() {
<label for="hide_untranslated"><input type="checkbox" name="hide_untranslated" id="hide_untranslated" value="1"<?php checked($q_config['hide_untranslated']); ?>/> <?php _e('Hide Content which is not available for the selected language.', 'qtranslate'); ?></label>
<br/>
<small><?php _e('When checked, posts will be hidden if the content is not available for the selected language. If unchecked, a message will appear showing all the languages the content is available in.', 'qtranslate'); ?>
<?php _e('This function will not work correctly if you installed qTranslate on a blog with existing entries. In this case you will need to take a look at "Convert Database" under "Advanced Settings".', 'qtranslate'); ?></small>
<?php printf(__('This function will not work correctly if you installed %s on a blog with existing entries. In this case you will need to take a look at option "%s" under "%s" section.', 'qtranslate'),'qTranslate',__('Convert Database','qtranslate'),__('Import','qtranslate').'/'.__('Export','qtranslate')); ?></small>
<br/><br/>
<label for="show_displayed_language_prefix"><input type="checkbox" name="show_displayed_language_prefix" id="show_displayed_language_prefix" value="1"<?php checked($q_config['show_displayed_language_prefix']); ?>/> <?php _e('Show displayed language prefix when content is not available for the selected language.', 'qtranslate'); ?></label>
</td>
Expand Down Expand Up @@ -1031,7 +1031,7 @@ function qtranxf_conf() {
<th scope="row"><?php _e('Editor Raw Mode', 'qtranslate');?></th>
<td>
<label for="qtranxs_editor_mode"><input type="checkbox" name="editor_mode" id="qtranxs_editor_mode" value="1"<?php checked($q_config['editor_mode']); ?>/>&nbsp;<?php _e('Do not use Language Switching Buttons to edit multi-language text entries.', 'qtranslate'); ?></label><br/>
<small><?php _e('Some people prefer to edit the raw entries containing all languages together separated by language defining tags, as they are stored in database.'); ?></small>
<small><?php _e('Some people prefer to edit the raw entries containing all languages together separated by language defining tags, as they are stored in database.', 'qtranslate'); ?></small>
</td>
</tr>
<?php /*
Expand Down Expand Up @@ -1166,8 +1166,8 @@ class qtranxcLangSwItems {
</div>
<span class="list-controls hide-if-no-js">
<a href="javascript:void(0);" class="help" onclick="jQuery( '#help-login-links' ).toggle();"><?php _e( 'Help' ); ?></a>
<span class="hide-if-js" id="help-login-links"><br/><a name="help-login-links"></a>
Menu item added is replaced with a sub-menu of available languages when menu is rendered. Depending on how your theme renders menu you may need to override and customize css entries .qtranxs-lang-menu and .qtranxs-lang-menu-item, originally defined in qtranslate.css. The field "URL" of inserted menu item allows additional configuration described in <a href="https://wordpress.org/plugins/qtranslate-x/faq" target="blank">FAQ</a>.<br>
<span class="hide-if-js" id="help-login-links"><p><a name="help-login-links"></a>
<?php printf(__('Menu item added is replaced with a sub-menu of available languages when menu is rendered. Depending on how your theme renders menu you may need to override and customize css entries %s and %s, originally defined in %s. The field "URL" of inserted menu item allows additional configuration described in %sFAQ%s.', 'qtranslate' ), '.qtranxs-lang-menu', '.qtranxs-lang-menu-item', 'qtranslate.css', '<a href="https://wordpress.org/plugins/qtranslate-x/faq" target="blank">','</a>');?></p>
</span>
</span>
<p class="button-controls">
Expand Down
24 changes: 17 additions & 7 deletions qtranslate_core.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ function qtranxf_init() {
if(!defined('WP_ADMIN')){
// don't filter untranslated posts in admin
if($q_config['hide_untranslated']){
add_filter('posts_where_request', 'qtranxf_excludeUntranslatedPosts');
add_filter('posts_where_request', 'qtranxf_excludeUntranslatedPosts',10,2);
add_filter('comments_clauses','qtranxf_excludeUntranslatedPostComments',10,2);
}
foreach($q_config['text_field_filters'] as $nm){
Expand Down Expand Up @@ -1219,7 +1219,7 @@ function qtranxf_enableLanguage($lang) {

if (!function_exists('qtranxf_use')){
function qtranxf_use($lang, $text, $show_available=false, $show_empty=false) {
global $q_config;
//global $q_config;
// return full string if language is not enabled
//if(!qtranxf_isEnabled($lang)) return $text;//why?
if(is_array($text)) {
Expand All @@ -1241,13 +1241,23 @@ function qtranxf_use($lang, $text, $show_available=false, $show_empty=false) {
if(!is_string($text) || empty($text))//|| $text) == ''
return $text;

// get content
return qtranxf_use_language($lang, $text, $show_available, $show_empty);
}
}

if (!function_exists('qtranxf_use_language')){
/** when $text is already known to be string */
function qtranxf_use_language($lang, $text, $show_available=false, $show_empty=false) {
$blocks = qtranxf_get_language_blocks($text);
//if($text==='[:ru][:en]EN'){
//qtranxf_dbg_echo('qtranxf_use:blocks:',$blocks,true);
//}
if(count($blocks)<=1)//no language is encoded in the $text, the most frequent case
return $text;
return qtranxf_use_block($lang, $blocks, $show_available, $show_empty);
}
}

if (!function_exists('qtranxf_use_block')){
function qtranxf_use_block($lang, $blocks, $show_available=false, $show_empty=false) {
global $q_config;
$content = qtranxf_split_blocks($blocks);
//$content = qtranxf_split($text);

Expand Down Expand Up @@ -1334,7 +1344,7 @@ function qtranxf_showAllSeperated($text) {

function qtranxf_add_css ()
{
wp_register_style( 'qtranslate-style', plugins_url('qtranslate.css', __FILE__) );
wp_register_style( 'qtranslate-style', plugins_url('qtranslate.css', __FILE__), array(), QTX_VERSION );
wp_enqueue_style( 'qtranslate-style' );
}

Expand Down
Loading

0 comments on commit 87efb63

Please sign in to comment.