WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#14750 closed feature request (fixed)

Add menus, menu items to import and export

Reported by: nacin Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version:
Component: Import Keywords: dev-feedback
Focuses: Cc:

Description (last modified by nacin)

Export

Menus and their menu items should be included in the WXR. Switching can_export to true should mostly rectify this.

However, that introduces some issues. Including them in the post type and taxonomy dropdowns is not intuitive. You either need to export everything, or just export the menu tax and item PT (and you need to know to select both). Not every post type is going to be "content" that belongs in the dropdown, but that doesn't mean it shouldn't be somehow portable. (Same with taxonomies.)

Thus to me it makes sense that can_export might need to be split into A) showing it in the export UI, and B) can it be included in the WXR file. We can then handle our own UI, perhaps with a checkbox, "Export menus." Or something.

That of course brings up another concern, which is that menu items have associated posts, which means they need to also be exported. So really you should not be able to export just menus and menu items, unless of course all of your menu items are custom links (but how can we know that?). Ironically, a simplified export.php from 2.9 would have served us well here, as we'd always just export everything.

Import

Offering a patch for import is particularly challenging, because we'll not only need to map the post-taxonomy relationships (which the importer should handle for menus out of the box) but also the relationships between a menu item and the associated post or term. That introduces new problems. What happens when the associated post or term is not included in the WXR file? Does the menu item convert to a custom link? (Is there any indication that it became broken on import?) Or do we decline to import the menu item? (What about children menu items?)

Clearly a lot of questions here. I think it is pretty safe to say that we do want menus exportable (they are much more like content than basic settings), but the implementation will not be easy.

Suggestions and patches strongly welcome.

Change History (6)

comment:1 @nacin4 years ago

  • Description modified (diff)

comment:2 @nacin4 years ago

  • Description modified (diff)

comment:3 @mikeschinkel4 years ago

  • Cc mikeschinkel@… added

comment:4 @shawnparker4 years ago

  • Cc shawnparker added

comment:5 @blepoxp4 years ago

I did some digging around and found the following:

  • The 'nav_menu' taxonomy is included at the top of the export file in the main channel along with any other core / custom terms.
  • Posts with post type of 'nav_menu_item' already get included in the export file if all content types are selected. This is because can_export is true by default (it doesn't appear in the select box for content types on the export page because is_public is set to false).
  • Posts with post type of 'nav_menu_item' fail to have their associated 'nav_menu' term taxonomy id associated with them in the export file.

The above results in the following when imported via the core WordPress Importer plugin

  • New taxonomy and terms are created for the 'nav_menu' taxonomy if they do not exist already (ie the Menus themselves get imported.
  • New menu items are imported correctly.
  • New menu items are not correctly associated with their correct menu (no object_to_term_taxonomy relationship is established in the term_relationships table

This means that all we have to do to get nav menus exporting / importing correctly when all content types are selected during export process is to a) Tweak export script to add the nav_menu to the nav_menu_items and b) tweak the import plugin to set those relationships correctly.

Seems like this should be corrected before tackling user specified options. Thoughts?

comment:6 @nacin4 years ago

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

(In [15961]) Importer and exporter overhaul, mega props duck.

Exporter overhaul:

  • Add author information to export
  • Greater usage of slug identifiers
  • Don't export auto-drafts, spam comments, or edit lock/last meta keys
  • Inline documentation improvements
  • Remove filtering for now (@todo)
  • Bump WXR version to 1.1, but remain back compat in the importer

Importer overhaul (http://plugins.trac.wordpress.org/changeset/304249):

  • Use an XML parser where available (SimpleXML, XML Parser)
  • Proper import support for navigation menus
  • Many bug fixes, specifically improvements to category and custom taxonomy handling
  • Better author/user mapping

Fixes #5447 #5460 #7400 #7973 #8471 #9237 #10319 #11118 #11144 #11354 #11574 #12685 #13364 #13394 #13453 #13454 #13627 #14306 #14442 #14524 #14750 #15055 #15091 #15108.

See #15197.

Note: See TracTickets for help on using tickets.