sc0ttkclark/wordpress-fields-api

Implementation: Nav Menu Item edit

sc0ttkclark opened this issue · 11 comments

Not sure if this is possible given current hooks.

  • Display fields for nav menu item
  • Save fields on menu save

per discussion on slack, I think code from my simple plugin might be helpful - I'm going to have a look to see if I can figure out an implementation for pulling into this fields-api plugin: #34

Hi @sc0ttkclark I don't know if it can be usefull but in my theme I develope this code for adding custom field in nav menu item but I'm refactoring all code because I like the way CMB2 makes fields with less code.

Keep in mind that due to scaling problems (core ticket #14134), we can't allow support for adding custom fields to nav menu items in the admin (we still don't even have an action there). However, it would be very interesting to see whether this could be leveraged in terms of nav menu item controls in the customizer. While that would require using the fields api within the customizer api, it would be an interesting exploration and something that would definitely make sense to have in core long-term, along with fields api support within widget controls.

Yeah this is definitely something I know is a main concern and is an obvious blocker -- can't tell you how many sites I've hit this issue with in the past with people running Pods, it's countless!

We'll have to keep an eye on #25, as we may be able to put some of this implementation into the nav menu class over there, to provide Fields API support for nav menu items. Otherwise, until https://core.trac.wordpress.org/ticket/14134 moves forward with a solution (likely JSON encode then POST then JSON decode, just like we use for the pod editor in Pods) -- we really can't do much here.

Also, don't get me wrong, it's not that I don't want to have Nav Menu Items inside the Fields API properly, it's that we can't actively support and open things for all those custom fields showing in the admin screen until 14134 is solved.

Since the scaling issues are solved in the Customizer (and may only ever be solved there), I would definitely suggest trying to develop an implementation for nav menu item fields there first. That would be a fabulous use case for fields API and one that would be able to be adopted in core without other blockers.

Sounds great to me :) I love it when someone says "adopted in core without other blockers"

I've pushed some bits into 42abdf4 for customizer-specifics. Currently it doesn't have the fields from my other branch added, so it'll not actually output any fields at all right now.

@diddledan is your latest stuff up in PR form yet? Also, can you merge latest from our master into yours?

I've rebased both my branches against the latest master (up-to commit 033d25f).
my customizer work isn't in a PR yet, but it is currently residing in a branch: customizer-nav-menu-items

Core may have solved the issue of large menus with lots of fields, unblocking this for Nav Menus https://core.trac.wordpress.org/changeset/36510