Title: Widget Compatibility/Problem with saving data
Last modified: January 16, 2018

---

# Widget Compatibility/Problem with saving data

 *  Resolved [doubleyoustew](https://wordpress.org/support/users/doubleyoustew/)
 * (@doubleyoustew)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/)
 * Hi,
 * first off thank you for this great plugin! I can translate Posts fine and the
   language switcher works, all great!
 * I just have a problem with Widgets. Now there seems to be a Problem when saving
   Data. You can reproduce it easily when installing WP-Multilang and Social Icons
   By WPZOOM. Now add the widget to an area and try adding/deleting social links.
   On save it will always revert back to it’s [initial state](https://imgur.com/a/8HhL9).
 * Now I’d be fine disabling the translation functionality for all widgets but I
   can’t figure out how to do that either. I added the “wpm-config.json” in my child
   theme and added the following:
 *     ```
       {
           "admin_pages": [
               "upload",
               "nav-menus",
               "options-general",
               "settings-network",
               "site-settings-network"
           ],
           "widgets": {}
       }
       ```
   
 * I also tried setting “widgets” to none and placing the file into my parent themes
   directory.
 * Can you help?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [VaLeXaR](https://wordpress.org/support/users/valexar/)
 * (@valexar)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/#post-9868095)
 * Hi [@doubleyoustew](https://wordpress.org/support/users/doubleyoustew/)
    In “
   admin_pages” section You need to add IDs of current admin screen. All this screen
   IDs, what You added already exist in configuration.
 * In “widget” section, You need to add widget IDs and its fields.
    As example from
   core config:
 *     ```
       "widgets": {
           "media_image": {
             "caption": {},
             "alt": {},
             "image_title": {}
           },
           "custom_html": {
             "content": {}
           }
       }
       ```
   
 *  Thread Starter [doubleyoustew](https://wordpress.org/support/users/doubleyoustew/)
 * (@doubleyoustew)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/#post-9868397)
 * Hey [@valexar](https://wordpress.org/support/users/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, 3 months ago by [doubleyoustew](https://wordpress.org/support/users/doubleyoustew/).
 *  [VaLeXaR](https://wordpress.org/support/users/valexar/)
 * (@valexar)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/#post-9868957)
 * [@doubleyoustew](https://wordpress.org/support/users/doubleyoustew/)
    The title
   of widget is translating by default. You need translate another fields. Use “
   wpm_each” tag for set in translate each element in a array.
 *     ```
       {
           "widgets": {
               "hestia-child-map-widget": {
                   "locations": {                
                       "wpm_each": {
                         "latlong": {},
                         "name": {},
                         "url": {}
                        }
                   }
               }
           }
       }
       ```
   
 *  Thread Starter [doubleyoustew](https://wordpress.org/support/users/doubleyoustew/)
 * (@doubleyoustew)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/#post-9871204)
 * [@valexar](https://wordpress.org/support/users/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 😉
 * [https://pastebin.com/S41RpyAZ](https://pastebin.com/S41RpyAZ)
 * 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](https://pastebin.com/YfkV6phV) 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, 3 months ago by [doubleyoustew](https://wordpress.org/support/users/doubleyoustew/).
    -  This reply was modified 8 years, 3 months ago by [doubleyoustew](https://wordpress.org/support/users/doubleyoustew/).
 *  Thread Starter [doubleyoustew](https://wordpress.org/support/users/doubleyoustew/)
 * (@doubleyoustew)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/#post-9883609)
 * Hey [@valexar](https://wordpress.org/support/users/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](https://wordpress.org/support/users/valexar/)
 * (@valexar)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/#post-9887173)
 * Ok.
    The latest way is set config by filter. Try to use these filters: ‘wpm_widgets_config’‘
   wpm_widget_{$widget_id}_config’ This must definitely help.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Widget Compatibility/Problem with saving data’ is closed to new replies.

 * ![](https://ps.w.org/wp-multilang/assets/icon-256x256.png?rev=1760406)
 * [WP Multilang - Translation and Multilingual Plugin](https://wordpress.org/plugins/wp-multilang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-multilang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-multilang/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-multilang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-multilang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-multilang/reviews/)

## Tags

 * [config](https://wordpress.org/support/topic-tag/config/)
 * [widgets](https://wordpress.org/support/topic-tag/widgets/)

 * 6 replies
 * 2 participants
 * Last reply from: [VaLeXaR](https://wordpress.org/support/users/valexar/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/widget-compatibility-problem-with-saving-data/#post-9887173)
 * Status: resolved