| @@ -40,9 +40,9 @@ | ||
| 40 | 40 | * Constructor |
| 41 | 41 | * |
| 42 | 42 | * @since 1.2 |
| 43 | 43 | * |
| 44 | - * @param object $polylang | |
| 44 | + * @param object $polylang The Polylang object. | |
| 45 | 45 | */ |
| 46 | 46 | public function __construct( &$polylang ) { |
| 47 | 47 | $this->model = &$polylang->model; |
| 48 | 48 | $this->options = &$polylang->options; |
| @@ -167,9 +167,9 @@ | ||
| 167 | 167 | |
| 168 | 168 | $tr_arr = $postarr; |
| 169 | 169 | unset( $tr_arr['post_parent'] ); |
| 170 | 170 | |
| 171 | - // Do not udpate the translation parent if the user set a parent with no translation. | |
| 171 | + // Do not update the translation parent if the user set a parent with no translation. | |
| 172 | 172 | if ( isset( $postarr['post_parent'] ) ) { |
| 173 | 173 | $post_parent = $postarr['post_parent'] ? $this->model->post->get_translation( $postarr['post_parent'], $lang ) : 0; |
| 174 | 174 | if ( ! ( $postarr['post_parent'] && ! $post_parent ) ) { |
| 175 | 175 | $tr_arr['post_parent'] = $post_parent; |
| @@ -207,16 +207,16 @@ | ||
| 207 | 207 | if ( $term instanceof WP_Term ) { |
| 208 | 208 | $translations = $this->model->term->get_translations( $term_id ); |
| 209 | 209 | |
| 210 | 210 | foreach ( $translations as $lang => $tr_id ) { |
| 211 | - if ( ! empty( $tr_id ) && $tr_id !== $term_id ) { | |
| 211 | + if ( $tr_id !== $term_id ) { | |
| 212 | 212 | $tr_parent = $this->model->term->get_translation( $term->parent, $lang ); |
| 213 | 213 | $tr_term = get_term( (int) $tr_id, $taxonomy ); |
| 214 | 214 | |
| 215 | - if ( $tr_term instanceof WP_Term ) { | |
| 215 | + if ( $tr_term instanceof WP_Term && ! ( $term->parent && empty( $tr_parent ) ) ) { | |
| 216 | 216 | $wpdb->update( |
| 217 | 217 | $wpdb->term_taxonomy, |
| 218 | - array( 'parent' => $tr_parent ? $tr_parent : 0 ), | |
| 218 | + array( 'parent' => $tr_parent ?: 0 ), | |
| 219 | 219 | array( 'term_taxonomy_id' => $tr_term->term_taxonomy_id ) |
| 220 | 220 | ); |
| 221 | 221 | |
| 222 | 222 | clean_term_cache( $tr_id, $taxonomy ); // OK since WP 3.9. |