PluginProbe
Polylang / 2.6.3
Polylang v2.6.3
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-metas.php +9 -10 2.92.6.3 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Abstract class to manage the copy and synchronization of metas
8 5 *
@@ -180,9 +177,9 @@
180 177 if ( $tr_id != $id ) {
181 178 $to_copy = $this->get_metas_to_copy( $id, $tr_id, $lang, true );
182 179 if ( in_array( $meta_key, $to_copy ) ) {
183 180 $meta_value = $this->maybe_translate_value( $meta_value, $meta_key, $id, $tr_id, $lang );
184 - add_metadata( $this->meta_type, $tr_id, wp_slash( $meta_key ), is_object( $meta_value ) ? $meta_value : wp_slash( $meta_value ) );
181 + add_metadata( $this->meta_type, $tr_id, $meta_key, wp_slash( $meta_value ) );
185 182 }
186 183 }
187 184 }
188 185
@@ -237,9 +234,9 @@
237 234 if ( $tr_id != $id && in_array( $meta_key, $this->get_metas_to_copy( $id, $tr_id, $lang, true ) ) ) {
238 235 if ( empty( $this->prev_value[ $hash ] ) || $this->prev_value[ $hash ] === $prev_meta->meta_value ) {
239 236 $prev_value = $this->maybe_translate_value( $prev_meta->meta_value, $meta_key, $id, $tr_id, $lang );
240 237 $meta_value = $this->maybe_translate_value( $meta_value, $meta_key, $id, $tr_id, $lang );
241 - update_metadata( $this->meta_type, $tr_id, wp_slash( $meta_key ), is_object( $meta_value ) ? $meta_value : wp_slash( $meta_value ), $prev_value );
238 + update_metadata( $this->meta_type, $tr_id, $meta_key, wp_slash( $meta_value ), $prev_value );
242 239 }
243 240 }
244 241 }
245 242 $this->restore_add_meta_action();
@@ -289,9 +286,9 @@
289 286 if ( in_array( $key, $this->to_copy[ $id ][ $tr_id ] ) ) {
290 287 if ( '' !== $value && null !== $value && false !== $value ) { // Same test as WP
291 288 $value = $this->maybe_translate_value( $value, $key, $id, $tr_id, $lang );
292 289 }
293 - delete_metadata( $this->meta_type, $tr_id, wp_slash( $key ), is_object( $value ) ? $value : wp_slash( $value ) );
290 + delete_metadata( $this->meta_type, $tr_id, $key, wp_slash( $value ) );
294 291 }
295 292 }
296 293 }
297 294 }
@@ -322,9 +319,9 @@
322 319 foreach ( $to_copy as $key ) {
323 320 if ( empty( $metas[ $key ] ) ) {
324 321 if ( ! empty( $tr_metas[ $key ] ) ) {
325 322 // If the meta key is not present in the source object, delete all values
326 - delete_metadata( $this->meta_type, $to, wp_slash( $key ) );
323 + delete_metadata( $this->meta_type, $to, $key );
327 324 }
328 325 } else {
329 326 if ( ! empty( $tr_metas[ $key ] ) && 1 === count( $metas[ $key ] ) && 1 === count( $tr_metas[ $key ] ) ) {
330 327 // One custom field to update
@@ -330,20 +327,20 @@
330 327 // One custom field to update
331 328 $value = reset( $metas[ $key ] );
332 329 $value = maybe_unserialize( $value );
333 330 $to_value = $this->maybe_translate_value( $value, $key, $from, $to, $lang );
334 - update_metadata( $this->meta_type, $to, wp_slash( $key ), is_object( $to_value ) ? $to_value : wp_slash( $to_value ) );
331 + update_metadata( $this->meta_type, $to, $key, wp_slash( $to_value ) );
335 332 } else {
336 333 // Multiple custom fields, either in the source or the target
337 334 if ( ! empty( $tr_metas[ $key ] ) ) {
338 335 // The synchronization of multiple values custom fields is easier if we delete all metas first
339 - delete_metadata( $this->meta_type, $to, wp_slash( $key ) );
336 + delete_metadata( $this->meta_type, $to, $key );
340 337 }
341 338
342 339 foreach ( $metas[ $key ] as $value ) {
343 340 $value = maybe_unserialize( $value );
344 341 $to_value = $this->maybe_translate_value( $value, $key, $from, $to, $lang );
345 - add_metadata( $this->meta_type, $to, wp_slash( $key ), is_object( $to_value ) ? $to_value : wp_slash( $to_value ) );
342 + add_metadata( $this->meta_type, $to, $key, wp_slash( $to_value ) );
346 343 }
347 344 }
348 345 }
349 346 }
@@ -361,8 +358,10 @@
361 358 * @param object $obj Not used
362 359 * @param array $translations The list of translations object ids
363 360 */
364 361 public function save_object( $object_id, $obj, $translations ) {
362 + $src_lang = array_search( $object_id, $translations );
363 +
365 364 foreach ( $translations as $tr_lang => $tr_id ) {
366 365 if ( $tr_id != $object_id ) {
367 366 $this->copy( $object_id, $tr_id, $tr_lang, true );
368 367 }