mattrabe / Widgets-In-Menu-for-WordPress

Allows you to add Widgets in WordPress Navigation Menus
1 stars 0 forks source link

Mega Menu Link widget in menu title saved to DB instead of querying to get title #2

Open mikehatfield opened 6 years ago

mikehatfield commented 6 years ago

If the title in a Mega Menu Link widget is updated and the widget has already been added to a menu under Appearance > Menus, the original name is still displayed.

For example:

In Widgets admin panel: Drag "Mega Menu Link" into >> "Widgets In Menu" Enter title and save: Fire Alarm Systems

In Menus admin panel: Drag "Link: Fire Alarm Systems" into menu and save

Return to Widgets admin panel and update the same widget link title to "thisiscray", save. Return to Menu admin panel, old title is still displayed.
Rendered on the front end, the correct title and URL are shown.

Looking at the database

In the wp_options table, where widget data is stored, the given "widget_custom_widget_mega_menu_link" has all correct, updated serialized data.

In the posts table, where the menu item appears to be stored, the post still has the old "Link: Fire Alarm Systems" title and post-name "link-fire-alarm-systems". If the widget menu link item was added multiple times to the menu, multiple post items will exist and none are updated. We'll have to take this into consideration.

I've been looking into the DB field structure and haven't figured out yet what the connecting attribute is that makes the relationship from menu item to the widget data in the options table. But it is obviously all hooked up. I'm guessing we'll have to add some logic to the process when saving a widget item also scan the post table for menu items and update the post_title and post_name fields. May be tricky.

mattrabe commented 6 years ago

Committed to bayalarm repo, created PR: https://bitbucket.org/campcreative/bayalarm2016/pull-requests/27/re-https-githubcom-mattrabe-widgets-in