Skip to content

Commit

Permalink
proper tag editing on `post.php
Browse files Browse the repository at this point in the history
  • Loading branch information
johnclause committed May 7, 2016
1 parent 34d947c commit ad28ac4
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
27 changes: 25 additions & 2 deletions admin/qtx_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ function qtranxf_admin_notices_config() {
* A term name containing '&' is stored in database with '&' instead of '&',
* but search in get_terms is done on raw '&' coming from $_POST variable.
*/
function qtranxf_get_terms_args($args) {
function qtranxf_get_terms_args($args, $taxonomies=null) {
if(!empty($args['name'])){
$p = 0;
while(($p = strpos($args['name'],'&',$p)) !== false){
Expand All @@ -789,10 +789,33 @@ function qtranxf_get_terms_args($args) {
$p += 4;
}
}
global $q_config;
$lang = $q_config['language'];
if($lang != $q_config['default_language']){
$args['name'] = qtranxf_find_term($lang, $args['name']);
}
}
if(!empty($args['name__like'])){
global $q_config;
$lang = $q_config['language'];
if($lang != $q_config['default_language']){
$s = $args['name__like'];
foreach($q_config['term_name'] as $nm => $ts){
if(empty($ts[$lang])) continue;
$t = $ts[$lang];
if(function_exists('mb_stripos'))
$p = mb_stripos($t,$s);
else
$p = stripos($t,$s);
if($p === false) continue;
$args['name__like'] = $nm;
break;
}
}
}
return $args;
}
add_filter('get_terms_args', 'qtranxf_get_terms_args');
add_filter('get_terms_args', 'qtranxf_get_terms_args', 5, 2);
//apply_filters( 'get_terms_args', $args, $taxonomies );

/**
Expand Down
40 changes: 40 additions & 0 deletions admin/qtx_admin_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,46 @@ function qtranxf_get_term_joined($obj,$taxonomy=null) {
return $obj;
}

/**
* @since 3.4.6.8
* @return string default language name of term $nm in langulage $lang
* @param string $lang two-letter language code to search for $nm
* @param string $nm name of term in language $lang
* @param string $taxonomy
*/
function qtranxf_find_term($lang, $term, $taxonomy=null) {
global $q_config;
if($lang != $q_config['default_language']){
foreach($q_config['term_name'] as $nm => $ts){
if(empty($ts[$lang])) continue;
if( $ts[$lang] == $term ) return $nm;
}
}
return $term;
}

/*
* @since 3.4.6.8
* @return string default language name of term $nm in langulage $lang
* @param string $lang two-letter language code to search for $nm
* @param string $nm name of term in language $lang
* @param string $taxonomy
*
function qtranxf_find_term_like($lang, $s, $taxonomy=null) {
global $q_config;
if($lang != $q_config['default_language']){
foreach($q_config['term_name'] as $nm => $ts){
if(empty($ts[$lang])) continue;
if(function_exists('mb_stripos'))
$p = stripos($ts[$lang],$s);
else
$p = stripos($ts[$lang],$s);
if( $p !== false) return $nm;
}
}
return $s;
} */

function qtranxf_get_terms_joined($terms, $taxonomy=null, $args=null) {
global $q_config;
if(is_array($terms)){
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ This version recovers translation of parent of a category on category edit page.

### 3.4.6.8 ###
* Imrovement: translation of taxonomies on page `/wp-admin/edit.php`.
* Fix: proper tag editing on page `post.php` [Issue #366](https://github.com/qTranslate-Team/qtranslate-x/issues/366).

### 3.4.6.7 ###
* Fix: for `/wp-login/` and `/login/`. Thanks to [extremecarver](http://qtranslate-x.com/support/index.php?action=profile;u=373).
Expand Down

0 comments on commit ad28ac4

Please sign in to comment.