[wp-trac] [WordPress Trac] #55051: WP_Customize_Nav_Menu_Item_Setting class needs hooks/filters parity for preview and update
WordPress Trac
noreply at wordpress.org
Wed Feb 2 18:46:59 UTC 2022
#55051: WP_Customize_Nav_Menu_Item_Setting class needs hooks/filters parity for
preview and update
----------------------------+-----------------------------
Reporter: helgatheviking | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
----------------------------+-----------------------------
the `WP_Customize_Nav_Menu_Item_Setting` class needs parity with the
`WP_Customize_Setting` class.
The following actions exist in the `WP_Customize_Setting` class:
`do_action( "customize_preview_{$this->id}", $this );`
`do_action( "customize_preview_{$this->type}", $this );`
[see
source](https://github.com/WordPress/WordPress/blob/234877c9c3d81b6341bef5539ef52b0745b2a660
/wp-includes/class-wp-customize-setting.php#L389-L411)
and
`do_action( "customize_update_{$this->type}", $value, $this );`
[see
source](https://github.com/WordPress/WordPress/blob/234877c9c3d81b6341bef5539ef52b0745b2a660
/wp-includes/class-wp-customize-setting.php#L692-L703)
The `preview()` and `update()` methods are overriden in
`WP_Customize_Nav_Menu_Item_Setting` and ''don't'' have those `do_action`
hooks, so there's no straightforward way to filter nav menu meta values on
preview/update.
For example, the Nav Menu Roles plugin adds meta fields to the Nav Menu
Items in the customizer and am currently using a workaround to attach the
preview/save routines since there's no direct way to do this with these
hooks missing.
Potentially related, the `WP_Customize_Nav_Menu_Item_Setting` class has an
unimplemented `@todo` in the `preview()` method: see
[source](https://github.com/WordPress/WordPress/blob/071c322bf2211db37cb38b4ddf4d2ed660e745d6
/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php#L461)
I'm not 100% certain what is meant there and if it can be ignored if those
hooks are implemented. (a quick test suggests that I can filter the
metadata in a callback on `customize_preview_nav_menu_item` once it
exists.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55051>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list