中的摘要tags widget 在Post Edit page, 我需要知道filter 通过:
在tags suggestions
tag terms update 什么时候saving or updating the post至少我认为这是我需要的。我的箱子正在使用qTranslate (v.2.5.32)创建多语言前端以及backend. 我关心的是showing the translated taxonomy terms in the backend, 明确地the post tags in the Post Edit page.
qTranslate通过使用custom fields (metaboxes) 在taxonomy edit page, 每种语言一个,保存到options table 数据库
该插件在前端很好地翻译了分类术语,但是in the backend they don\'t translate. 仅适用于default language 无论查看的是当前语言,都会显示。
到目前为止,我的黑客技术hack 以便使用以下代码以正确的语言显示术语:
if (is_admin()) {
/**
* Fix translation for:
* - Taxonomy & custom taxonomy names in Post Manage page
* - List of tags already added to the post in Post
* Edit page (but have issues when saving)
*/
function mod_wp_get_object_terms_qtranslate($terms, $obj_id, $taxonomy, $args) {
// $taxonomy output seems to be wrapped
// in single quotes, thus remove them to
// make the output valid
$tax = str_replace("\'", "", $taxonomy);
if ( !is_taxonomy_hierarchical($tax) ) {
$meta = get_option(\'qtranslate_term_name\');
$lang = qtrans_getLanguage();
if ( !empty( $terms ) ) {
foreach ($terms as $term) {
$term->name = $meta[$term->name][$lang];
};
};
}
return $terms;
}
add_filter( \'wp_get_object_terms\', \'mod_wp_get_object_terms_qtranslate\', 0, 4 );
/**
* Fix translation for:
* - Taxonomy names in Taxonomy Manage page
* - \'Popular Tags\' in Taxonomy (Tags) Manage page
* - Category filter dropdown menu in Post Manage page
* - Category list in Post Edit page
* - \'Most Used\' tags list in Post Edit page
* (but have issues when saving)
*/
function mod_get_terms_qtranslate($terms, $taxonomy) {
$meta = get_option(\'qtranslate_term_name\');
$lang = qtrans_getLanguage();
if ( !empty( $terms ) ) {
foreach ($terms as $term) {
if ($meta[$term->name][$lang]) {
$term->name = $meta[$term->name][$lang];
}
};
};
return $terms;
}
add_filter( \'get_terms\', \'mod_get_terms_qtranslate\', 0, 3 );
}
问题现在在tags widget 在Post Edit page. 虽然我设法翻译了已经added to the post 以及\'Most Used\' list, 我遇到了以下问题:无法获取tags suggestions 显示translated version of the terms. 目前,只有当我使用默认语言输入术语时,它才会提示术语当帖子saved/updated, 从added tags list (新增或现有)和\'Most Used\' list 被视为new tags 通过Wordpress。如果我添加了默认语言的术语,那么它们将正常保存
How do I fix the above issues?
我在上面的hack中的第一个函数中尝试了什么(即。mod_wp_get_object_terms_qtranslate
) 我补充道wp_update_term
内部foreach
循环,以便term data 它本身会更新以反映当前正在查看的语言。我假设这将导致在tag suggestion 列表和中updating the post.
foreach ($terms as $term) {
$term->name = $meta[$term->name][$lang];
wp_update_term($term->term_id, $taxonomy, array(
\'name\' => $meta[$term->name][$lang]
));
};
这似乎不起作用
term data was not updated.