doubleyoustew
Forum Replies Created
-
Hey @valexar,
I still have that same problem. I tried to disable the translation but it doesn’t work either:
{ "widgets": { "hestia-child-map-widget": { "locations": { "wpm_each": { "latlong": null, "name": null, "url": null } } } } }@valexar Thanks, I can translate the fields now. However I still have the same bug. If I unset array keys the deleted items are not being deleted.
So what I’m guessing is happening is that on widget update() I’m getting the $instance of only one language. If I unset the empty fields they are still there in the other language and thus are not being deleted. So if I get the “en” instance and delete the keys, they are still there in the “de” instance and are being merged and are still there in the end. My guess is that behind the scenes the Widgets for each language are really the same dataset but with the [:en] tags etc.
I’m attaching the code of my widget so you can see what I’m trying to do. I don’t know if this is a bug with your plugin or my implementation is just sucks 😉
The same thing happens with the “Social Icons by WPZOOM” widget as well. Widgets not being translatable by default is fine, but IMHO your plugin shouldn’t break the functionality, especially if the proper json structure of the widget is added.
Cheers! 🙂
Edit: Just to confirm, I added this JSON for the Social Icons widget and you can’t even save the Icons (try altering the default domains for the facebook link for example). So either I’m still doing it wrong or there is a bug with your plugin :/
Edit2: Btw I’d still be fine with just disabling the translations for the widget area. I don’t really need my widgets to be translatable. I just need it to save data correctly 😀
- This reply was modified 8 years, 4 months ago by doubleyoustew.
- This reply was modified 8 years, 4 months ago by doubleyoustew.
Hey @valexar,
thanks for the quick reply! I’m having problems setting this up unfortunately. My widget is laid out like this (this is a dump of $new_instance when updating the widget data):
array(2) { ["title"]=> string(4) "test" ["locations"]=> array(1) { [0]=> array(3) { ["latlong"]=> string(7) "123/123" ["name"]=> string(8) "testname" ["url"]=> string(5) "/test" } } }And this is what I’ve added to the wpm-config.json:
{ "widgets": { "hestia-child-map-widget": { "title": {}, "locations": [ "latlong", "name", "url" ] } } }I’ve also tried it like this:
{ "widgets": { "hestia-child-map-widget": { "title": {}, "locations": { "latlong": {}, "name": {}, "url": {} } } } }But it’s not working. The exact problem I’m having is that since “locations” is an array, I need to be able to unset certain keys to be removed. But if I enable your plugin it doesn’t save the retuned instance properly. I can change values but I can’t delete basically.
So I unset all the array keys where name and latlong is empty but the data it will be saving looks more like this:
array(2) { ["title"]=> string(12) "[:de]Test[:]" ["locations"]=> array(3) { [0]=> array(3) { ["latlong"]=> string(7) "123/123" ["name"]=> string(8) "TestName" ["url"]=> string(6) "/test2" } [1]=> array(3) { ["latlong"]=> string(0) "" ["name"]=> string(0) "" ["url"]=> string(0) "" } [2]=> array(3) { ["latlong"]=> string(0) "" ["name"]=> string(0) "" ["url"]=> string(0) "" } } }Sorry for the wall of text, I’m very lost here..
- This reply was modified 8 years, 4 months ago by doubleyoustew.