PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | modules/sync/sync.php +7 -9 2.7.22.6.2 View file →
@@ -82,8 +82,9 @@
82 82 */
83 83 public function can_sync_post_parent( $post_parent, $post_id, $postarr ) {
84 84 if ( ! empty( $postarr['ID'] ) && ! $this->model->post->current_user_can_synchronize( $postarr['ID'] ) ) {
85 85 $tr_ids = $this->model->post->get_translations( $postarr['ID'] );
86 + $orig_lang = array_search( $postarr['ID'], $tr_ids );
86 87 foreach ( $tr_ids as $tr_id ) {
87 88 if ( $tr_id !== $postarr['ID'] && $post = get_post( $tr_id ) ) {
88 89 $post_parent = $post->post_parent;
89 90 break;
@@ -138,9 +139,9 @@
138 139
139 140 $tr_arr = $postarr;
140 141 unset( $tr_arr['post_parent'] );
141 142
142 - // Do not udpate the translation parent if the user set a parent with no translation.
143 + // Do not udpate the translation parent if the user set a parent with no translation
143 144 if ( isset( $postarr['post_parent'] ) ) {
144 145 $post_parent = $postarr['post_parent'] ? $this->model->post->get_translation( $postarr['post_parent'], $lang ) : 0;
145 146 if ( ! ( $postarr['post_parent'] && ! $post_parent ) ) {
146 147 $tr_arr['post_parent'] = $post_parent;
@@ -146,14 +147,12 @@
146 147 $tr_arr['post_parent'] = $post_parent;
147 148 }
148 149 }
149 150
150 - // Update all the rows at once.
151 - if ( ! empty( $tr_arr ) ) {
152 - // Don't use wp_update_post to avoid infinite loop.
153 - $wpdb->update( $wpdb->posts, $tr_arr, array( 'ID' => $tr_id ) );
154 - clean_post_cache( $tr_id );
155 - }
151 + // Update all the row at once
152 + // Don't use wp_update_post to avoid infinite loop
153 + $wpdb->update( $wpdb->posts, $tr_arr, array( 'ID' => $tr_id ) );
154 + clean_post_cache( $tr_id );
156 155 }
157 156 }
158 157 }
159 158 }
@@ -175,10 +174,9 @@
175 174 $term = get_term( $term_id );
176 175 $translations = $this->model->term->get_translations( $term_id );
177 176
178 177 foreach ( $translations as $lang => $tr_id ) {
179 - if ( ! empty( $tr_id ) && $tr_id !== $term_id ) {
180 - $tr_parent = $this->model->term->get_translation( $term->parent, $lang );
178 + if ( ! empty( $tr_id ) && $tr_id !== $term_id && $tr_parent = $this->model->term->get_translation( $term->parent, $lang ) ) {
181 179 $wpdb->update(
182 180 $wpdb->term_taxonomy,
183 181 array( 'parent' => isset( $tr_parent ) ? $tr_parent : 0 ),
184 182 array( 'term_taxonomy_id' => get_term( (int) $tr_id, $taxonomy )->term_taxonomy_id )