Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#42357 closed defect (bug) (fixed)

NewMenuControl class has been removed from trunk

Reported by: herregroen's profile herregroen Owned by: bpayton's profile bpayton
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
Component: Customize Keywords: has-patch
Focuses: Cc:

Description (last modified by westonruter)

In the recent changes to src/wp-admin/js/customize-nav-menus.js the NewMenuControl seems to have been removed.

This seems to be the revision in which it was removed: https://core.trac.wordpress.org/browser/trunk/src/wp-admin/js/customize-nav-menus.js?rev=41768.

Considering the revision message mentions nothing about removing said class and there are no deprecation notices in the previous revision ( https://core.trac.wordpress.org/browser/trunk/src/wp-admin/js/customize-nav-menus.js?rev=41726 ) this is probably a mistake I would guess?

I felt it probably best to open a ticket since it seems weird for a class to be removed without any deprecation warnings or clear notice.

Introduced in #40104.

Change History (14)

#1 follow-up: @adamsilverstein
7 years ago

@herregroen Thanks for the ticket - perhaps @westonruter has a better understanding of why this was removed (or is it renamed?). Curious how you realized this, did it break something you built that uses it?

#2 @herregroen
7 years ago

I'm almost certain this is a mistake considering the following stack overflow message by @westonruter of said revision:

https://wordpress.stackexchange.com/questions/282671/location-of-customizer-menu-panel-core-code

Version 1, edited 7 years ago by herregroen (previous) (next) (diff)

#3 in reply to: ↑ 1 @herregroen
7 years ago

Replying to adamsilverstein:

@herregroen Thanks for the ticket - perhaps @westonruter has a better understanding of why this was removed (or is it renamed?). Curious how you realized this, did it break something you built that uses it?

I'm working on namespacing all documentation in the admin directory and was almost done and trying to merge in the recent changes.

I got a merge conflict on this change it didn't seem right for that class to be removed.

#5 @westonruter
7 years ago

  • Description modified (diff)
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.9
  • Owner set to bpayton
  • Status changed from new to assigned

@bpayton We need to find a way to not remove the class to add back-compat.

#6 @westonruter
7 years ago

  • Priority changed from normal to high

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


7 years ago

This ticket was mentioned in Slack in #core-customize by bpayton. View the logs.


7 years ago

#9 @westonruter
7 years ago

  • Keywords needs-dev-note added

There are 3 references to the NewMenuControl JS class on GitHub, but 1 is a match from core and 2 are from the feature original feature plugin so now obsolete: https://github.com/search?q=NewMenuControl+-filename%3Acustomize-nav-menus.js+language%3Ajavascript&type=Code

There are 10 possible references to the WP_Customize_New_Menu_Section PHP class on GitHub, but all of them seem to be related to either autoloading or malware scanning: https://github.com/search?utf8=%E2%9C%93&q=WP_Customize_New_Menu_Section+-filename%3Aclass-wp-customize-nav-menus.php+-filename%3Aclass-wp-customize-new-menu-section.php+-filename%3Aclass-wp-customize-section.php+language%3Aphp&type=Code

Similarly, there are 9 possible references to WP_Customize_New_Menu_Control but they are also either for autoloading or malware scanning: https://github.com/search?utf8=%E2%9C%93&q=WP_Customize_New_Menu_Control+-filename%3Aclass-wp-customize-control.php+-filename%3Aclass-wp-customize-new-menu-control.php+-filename%3Aclass-wp-customize-nav-menus.php+language%3Aphp&type=Code

I'm still running the ack on the plugin and theme directories for these classes.

#10 @bpayton
7 years ago

I have a fix in progress here and have been discussing the proper course of action with @westonruter .
https://github.com/xwp/wordpress-develop/pull/295

I'll upload a patch once we've settled on what is needed.

#11 @westonruter
7 years ago

  • Keywords has-patch added; needs-patch removed
  • Priority changed from high to normal

I finished grepping the theme and plugin directories and there are no results outside of the original Menu Customizer plugin where these were first introduced:

WordPress-Plugin-Directory-Slurper/plugins/menu-customizer/class-wp-customize-menus.php:505:WP_Customize_New_Menu_Section
WordPress-Plugin-Directory-Slurper/plugins/menu-customizer/class-wp-customize-new-menu-section.php:14:WP_Customize_New_Menu_Section
WordPress-Plugin-Directory-Slurper/plugins/menu-customizer/menu-customizer.js:809:WP_Customize_New_Menu_Section
WordPress-Plugin-Directory-Slurper/plugins/menu-customizer/menu-customizer.js:2134:NewMenuControl
WordPress-Plugin-Directory-Slurper/plugins/menu-customizer/menu-customizer.js:2142:NewMenuControl
WordPress-Plugin-Directory-Slurper/plugins/menu-customizer/menu-customizer.js:2234:NewMenuControl

So clearly there little to none in terms of plugins that directly interface with these APIs. The reference to wp.customize.Menus.NewMenuControl.prototype.submit in the WPSE answer was just advising to refer to the source for a plugin to copy/adapt for their own needs, not to actually call it themselves.

So what we'll do is this:

  1. Restore the class in JS but mark it as deprecated, also adding a console.warn().
  2. Introduce a new wp.customize.Menus.createNavMenu() API for core and plugins to use; this separates UI code from model code.
  3. Restore the require_once()'ing of class-wp-customize-new-menu-control.php but add a _deprecated_file() call to its constructor.
  4. Also mark class-wp-customize-new-menu-section.php as being deprecated.
  5. In 5.0 we will move the _deprecated_file() call to the file header itself, and remove the require_once().
  6. A dev note will be published by @bpayton to document the new nav menu UX as well as the API canges.
  7. Unit tests for the nav menu JS classes will be added by @bpayton next week.

See https://github.com/xwp/wordpress-develop/pull/295

#12 @celloexpressions
7 years ago

I'm not sure if it's necessary to maintain back-compat for this given the lack of use; however, deprecating and fully removing in 5.0 seems appropriate. The full removal plan should be mentioned in the dev note.

The PR looks good, with a couple possible inline doc tweaks noted there.

#13 @westonruter
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 42034:

Customize: Deprecate nav menu classes that are no longer used, instead of removing them immediately.

  • Deprecate PHP classes WP_Customize_New_Menu_Section and WP_Customize_New_Menu_Control.
  • Deprecate JS class wp.customize.Menus.NewMenuControl.
  • Also introduce wp.customize.Menus.createNavMenu() for logic to create nav menus separately from the logic for handling UI interactions.

Amends [41768].
See #40104, #42364.
Fixes #42357.

#14 @westonruter
7 years ago

  • Keywords needs-dev-note removed

@bpayton I'll commit any subsequent unit test patches you add to this ticket.

Dev note work can be done specifically in relation to #40104.

Note: See TracTickets for help on using tickets.