From ad28ac487f2ec7a35f45c83dd2f4fc4d8d3b8179 Mon Sep 17 00:00:00 2001 From: John Clause Date: Sat, 7 May 2016 15:09:54 -0700 Subject: [PATCH] proper tag editing on `post.php --- admin/qtx_admin.php | 27 ++++++++++++++++++++++++-- admin/qtx_admin_utils.php | 40 +++++++++++++++++++++++++++++++++++++++ readme.txt | 1 + 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/admin/qtx_admin.php b/admin/qtx_admin.php index fc0038c..fa6ee49 100644 --- a/admin/qtx_admin.php +++ b/admin/qtx_admin.php @@ -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){ @@ -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 ); /** diff --git a/admin/qtx_admin_utils.php b/admin/qtx_admin_utils.php index d32bafc..3021517 100644 --- a/admin/qtx_admin_utils.php +++ b/admin/qtx_admin_utils.php @@ -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)){ diff --git a/readme.txt b/readme.txt index 9c492ea..0b96a07 100644 --- a/readme.txt +++ b/readme.txt @@ -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).