Created
July 6, 2012 11:16
-
-
Save benhuson/3059610 to your computer and use it in GitHub Desktop.
WPML Serialised Custom Fields Patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sitepress.class.php b/sitepress.class.php | |
index d5b2802be9a9de8b64244e889328b3e2ad776c9b..ecd861877107f00a7b111c3477bd65df12e86e6f 100644 | |
--- a/sitepress.class.php | |
+++ b/sitepress.class.php | |
@@ -2775,7 +2775,7 @@ class SitePress{ | |
// if the list of values has 1 element run update | |
// this will either ADD or UPDATE the value on the translated document | |
if(count($meta_values) == 1){ | |
- update_post_meta($post_id, $meta_key, $meta_values[0]);; | |
+ update_post_meta( $post_id, $meta_key, maybe_unserialize( $meta_values[0] ) ); | |
// determine the list of added elements | |
}else{ | |
@@ -2790,7 +2790,7 @@ class SitePress{ | |
// run ADD on each element added | |
foreach($added_fields as $v){ | |
- add_post_meta($post_id, $meta_key, $v, true); | |
+ add_post_meta($post_id, $meta_key, maybe_unserialize( $v ), true); | |
} | |
} | |
diff --git a/inc/translation-management/translation-management.class.php b/inc/translation-management/translation-management.class.php | |
index 83e399fbd832e3231e11e92e9fa610d393cdcff6..87b5b8d140cd778f8216750e0d85ac7f6dbc04ae 100644 | |
--- a/inc/translation-management/translation-management.class.php | |
+++ b/inc/translation-management/translation-management.class.php | |
@@ -2269,13 +2269,11 @@ class TranslationManagement{ | |
default: | |
if(in_array($field->field_type, $sitepress->get_translatable_taxonomies(false, $job->original_post_type))){ | |
$taxs = $this->decode_field_data($field->field_data_translated, $field->field_format); | |
- | |
$original_taxs = $this->decode_field_data($field->field_data, $field->field_format); | |
$taxonomy = $field->field_type; | |
$alltaxs = $tax_ids = array(); | |
foreach($taxs as $k=>$c){ | |
$thetax = $sitepress->get_term_by_name_and_lang($c, $taxonomy, $job->language_code); | |
- | |
$taxs[$k] = $c; // Save $c as we may have added @.lang to it | |
if(empty($thetax)){ | |
$the_original_tax = $sitepress->get_term_by_name_and_lang($original_taxs[$k], $taxonomy, $job->source_language_code); | |
@@ -2283,7 +2281,6 @@ class TranslationManagement{ | |
if($the_original_tax_parent){ | |
$op_tr = icl_object_id($the_original_tax_parent, $taxonomy, false, $job->language_code); | |
}else{$op_tr = 0;} | |
- | |
$tmp = wp_insert_term($c, $taxonomy, array('parent'=>$op_tr)); | |
if(isset($tmp['term_taxonomy_id'])){ | |
$sitepress->set_term_translation($the_original_tax, | |
@@ -3354,7 +3351,7 @@ class TranslationManagement{ | |
delete_post_meta($id, $key); | |
foreach($values as $value){ | |
- add_post_meta($id, $key, $value); | |
+ add_post_meta( $id, $key, maybe_unserialize( $value ) ); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using get_post_custom() values should always use maybe_unserialize()