@@ -49,7 +49,7 @@ class WPM_Taxonomies extends \WPM_Object {
49
49
public function __construct () {
50
50
parent ::__construct ();
51
51
$ this ->term_config = $ this ->config ['taxonomies ' ];
52
- add_filter ( 'get_term ' , array ( $ this , ' translate_term ' ) , 0 );
52
+ add_filter ( 'get_term ' , ' wpm_translate_term ' , 0 , 2 );
53
53
add_filter ( 'get_terms ' , array ( $ this , 'translate_terms ' ), 0 );
54
54
add_filter ( 'get_terms_args ' , array ( $ this , 'filter_terms_by_language ' ), 10 , 2 );
55
55
add_filter ( "get_ {$ this ->object_type }_metadata " , array ( $ this , 'get_meta_field ' ), 0 , 3 );
@@ -64,22 +64,6 @@ public function __construct() {
64
64
}
65
65
66
66
67
- /**
68
- * Translate term
69
- *
70
- * @param $term
71
- *
72
- * @return object
73
- */
74
- public function translate_term ( $ term ) {
75
- if ( ! is_object ( $ term ) || ! isset ( $ this ->term_config [ $ term ->taxonomy ] ) || is_null ( $ this ->term_config [ $ term ->taxonomy ] ) ) {
76
- return $ term ;
77
- }
78
-
79
- return wpm_translate_object ( $ term );
80
- }
81
-
82
-
83
67
/**
84
68
* Translate all terms
85
69
*
@@ -88,7 +72,20 @@ public function translate_term( $term ) {
88
72
* @return array
89
73
*/
90
74
public function translate_terms ( $ terms ) {
91
- return array_map ( array ( $ this , 'translate_term ' ), $ terms );
75
+
76
+ if ( is_array ( $ terms ) ) {
77
+ $ _terms = array ();
78
+ foreach ( $ terms as $ term ) {
79
+ if ( is_object ( $ term ) ) {
80
+ $ _terms [] = $ term ;
81
+ } else {
82
+ $ _terms [] = wpm_translate_value ( $ term );
83
+ }
84
+ }
85
+ $ terms = $ _terms ;
86
+ }
87
+
88
+ return $ terms ;
92
89
}
93
90
94
91
@@ -253,10 +250,10 @@ public function update_term( $data, $term_id, $taxonomy, $args ) {
253
250
return $ data ;
254
251
}
255
252
256
- remove_filter ( 'get_term ' , 'wpm_translate_object ' , 0 );
253
+ remove_filter ( 'get_term ' , 'wpm_translate_term ' , 0 );
257
254
$ old_name = get_term_field ( 'name ' , $ term_id , $ taxonomy , 'edit ' );
258
255
$ old_description = get_term_field ( 'description ' , $ term_id , $ taxonomy , 'edit ' );
259
- add_filter ( 'get_term ' , 'wpm_translate_object ' , 0 );
256
+ add_filter ( 'get_term ' , 'wpm_translate_term ' , 0 , 2 );
260
257
261
258
if ( ! wpm_is_ml_value ( $ data ['name ' ] ) ) {
262
259
$ strings = wpm_value_to_ml_array ( $ old_name );
0 commit comments