带有序列化对象的WPML管理文本

时间:2016-07-21 作者:Paul

我一直在尝试使用一个插件来处理WPML—我就快到了,但我想知道是否有人知道是否有可能让WPML的管理文本(WPML config.xml)来读取存储在wp\\U选项中的序列化对象?

参考号:https://wpml.org/documentation/support/language-configuration-files/

它可以很好地处理数组,但我无法让它拾取对象。

下面是我试图让它阅读的示例:

s:13:"custom_fields";a:4:{i:0;O:8:"stdClass":7:{s:9:"field_key";s:10:"bama_multi";s:10:"field_name";s:5:"Multi";s:10:"field_type";s:11:"multiselect";s:13:"default_value";s:0:"";s:14:"show_on_signup";b:1;s:8:"required";b:1;s:7:"options";a:3:{i:0;O:8:"stdClass":2:{s:11:"option_name";s:3:"One";s:12:"option_value";s:3:"one";}i:1;O:8:"stdClass":2:{s:11:"option_name";s:3:"Two";s:12:"option_value";s:3:"two";}i:2;O:8:"stdClass":2:{s:11:"option_name";s:5:"Three";s:12:"option_value";s:5:"three";}}}i:1;O:8:"stdClass":7:{s:9:"field_key";s:13:"bama_dropdown";s:10:"field_name";s:8:"Dropdown";s:10:"field_type";s:8:"dropdown";s:13:"default_value";s:0:"";s:14:"show_on_signup";b:1;s:8:"required";b:1;s:7:"options";a:3:{i:0;O:8:"stdClass":2:{s:11:"option_name";s:3:"Uno";s:12:"option_value";s:3:"uno";}i:1;O:8:"stdClass":2:{s:11:"option_name";s:3:"Dos";s:12:"option_value";s:3:"dos";}i:2;O:8:"stdClass":2:{s:11:"option_name";s:4:"Tres";s:12:"option_value";s:4:"tres";}}}i:2;O:8:"stdClass":7:{s:9:"field_key";s:15:"bama_checkboxes";s:10:"field_name";s:10:"Checkboxes";s:10:"field_type";s:10:"checkboxes";s:13:"default_value";s:0:"";s:14:"show_on_signup";b:1;s:8:"required";b:1;s:7:"options";a:3:{i:0;O:8:"stdClass":2:{s:11:"option_name";s:1:"E";s:12:"option_value";s:1:"e";}i:1;O:8:"stdClass":2:{s:11:"option_name";s:1:"R";s:12:"option_value";s:1:"r";}i:2;O:8:"stdClass":2:{s:11:"option_name";s:3:"San";s:12:"option_value";s:3:"san";}}}i:3;O:8:"stdClass":7:{s:9:"field_key";s:11:"bama_radios";s:10:"field_name";s:6:"Radios";s:10:"field_type";s:6:"radios";s:13:"default_value";s:0:"";s:14:"show_on_signup";b:1;s:8:"required";b:1;s:7:"options";a:3:{i:0;O:8:"stdClass":2:{s:11:"option_name";s:1:"A";s:12:"option_value";s:1:"a";}i:1;O:8:"stdClass":2:{s:11:"option_name";s:1:"B";s:12:"option_value";s:1:"b";}i:2;O:8:"stdClass":2:{s:11:"option_name";s:1:"C";s:12:"option_value";s:1:"c";}}}}
这是一个标准对象数组,我想让field\\u name和option\\u name可以翻译。

我知道我可以将custom\\u字段更改为使用数组而不是对象,但如果可能的话,我希望避免这种情况。

有什么想法吗?或者这是WPML的严格限制?

1 个回复
SO网友:Paul

我最终不得不切换到数组而不是对象。即使这样,结果也没有我希望的那么好。