Opened 9 years ago
Closed 4 years ago
#1109 closed enhancement (reported-upstream)
Site Cloner: Add support for importing menus
Reported by: | iandunn | Owned by: | vedjain |
---|---|---|---|
Milestone: | Priority: | normal | |
Component: | WordCamp Site & Plugins | Keywords: | good-first-bug has-patch 2nd-opinion |
Cc: |
Description
Currently the Site Cloner only imports the theme and custom CSS, but that's not enough to make the user's site match the source site.
We should also set the user's existing menus to the new theme's menu locations.
Attachments (3)
Change History (24)
This ticket was mentioned in Slack in #outreach by neha03. View the logs.
9 years ago
#5
@
8 years ago
Hello @iandunn
I've uploaded patch file. I implemented following points.
- Import all menus with a menu item. Create default
Home
custom menu item and assign that to all menus. - After that, set menu to menu locations.
I've tested locally. Please check and let me know if its fine.
#6
@
8 years ago
- Keywords has-patch added; needs-patch removed
This looks pretty good to me at first glance, thanks!
I think the only thing I'd suggest improving would be to modularize import_menus()
, since right now it's doing 2-3 different things. At the very least, there should be a separate function for creating the new menus
There's a backlog of contributions right now, so it might be awhile before I have time to do a full review, but I've added this to my list.
#7
@
8 years ago
Hello @iandunn
Thanks for the suggestion. I've added separate function for creating the menu.
Please check 1109.1.diff
This ticket was mentioned in Slack in #meta-wordcamp by coreymckrill. View the logs.
7 years ago
#10
@
7 years ago
- Keywords 2nd-opinion added
This ticket came up in a WordCamp bug scrub this week.
It looks like the current patch from @chandrapatel creates empty menus with the same names as the ones on the source site, then adds a default "Home" item to each menu, and finally assigns these menus to the same menu locations as on the source site. Is that right?
@iandunn is that what you had in mind for this? It seems like having all the menus on the site just show a "Home" link would be confusing. On the other hand, it also might be confusing if all the source site's menu items were copied over, but the new site didn't have corresponding pages for the menu items.
I'm trying to clarify the purpose here, because I'm not sure if it's really something we should do...
#11
@
7 years ago
That's what I intended, yeah. If we don't create menus at all, then the layout often breaks because the custom CSS assumes that they're there. It wouldn't make sense to add links to missing pages, though, and there aren't any pages on the destination site yet, so it seemed like creating menus with just a Home link was the best we could do.
That did just give me a new idea, though. I wonder if we could copy over the menu items for links that do exist on the destination site? A lot of pages like Location, Contact, etc are pre-populated, so they'll exist. We could just skip the pages that don't exist.
That could be a future iteration, though, in order to get this shipped soon rather than waiting until someone has time to update the patch.
This ticket was mentioned in Slack in #meta-wordcamp by coreymckrill. View the logs.
7 years ago
#13
@
7 years ago
@iandunn Thanks for the clarification. We chatted about this in the WordCamp.org ticket scrub this week. Re this comment:
I wonder if we could copy over the menu items for links that do exist on the destination site? A lot of pages like Location, Contact, etc are pre-populated, so they'll exist. We could just skip the pages that don't exist.
We agreed that it would be better to do this before committing because having multiple menus in a new site that just have a "Home" link in them could be pretty baffling.
@chandrapatel do you want to take a shot at updating your patch to include pre-populated page links in the menus?
#15
@
7 years ago
Hi @coreymckrill, @iandunn
I wonder if we could copy over the menu items for links that do exist on the destination site? A lot of pages like Location, Contact, etc are pre-populated, so they'll exist. We could just skip the pages that don't exist.
Here, my concern is how we map pages from a source site to destination site? One possible solution is I will get pages from source site menu and then try to find those pages in destination site and if it exists then I'll add it in destination site menu else not. Also, pages slugs should same in both sites.
Please let me know if above solution sounds good or you've any other suggestion.
Thanks,
#16
@
7 years ago
@chandrapatel
One possible solution is I will get pages from source site menu and then try to find those pages in destination site and if it exists then I'll add it in destination site menu else not. Also, pages slugs should same in both sites.
I think this sounds reasonable. There are many pages that are automatically created when a new site is generated, so the likelihood that those pages will exist on both the source and the destination, with the same page slug, is fairly high.
#18
@
6 years ago
Hello @iandunn @coreymckrill
Sorry for late working on this.
I've updated patch 1109.2.diff to copy the menu items for pages that do exist on the destination site. I haven't consider menu items order and hierarchy when we copied menu items.
add_action( 'customize_register', __NAMESPACE__ . '\register_customizer_components', 12 );
I've changed the priority to 12
becasue nav_menu_locations
theme mod which I set after copied over menus from source site are overriden by customizer nav_menu_locations
setting. Customizer also update nav_menu_locations
theme mod when we change theme.
So I debug the issue and found that our import menu code executed first and then customizer's nav_menu_locations
setting updated. I found that customizer register function on customize_register
action at 11
priority to register nav_menu_locations
setting. So I've updated our hook at 12
priority to execute our code at last and prevent overriden of nav_menu_locations
theme mod.
Please check the updated patch and let me know if it's fine or if I miss any use cases.
This ticket was mentioned in Slack in #meta-wordcamp by coreymckrill. View the logs.
5 years ago
#21
@
4 years ago
- Resolution set to reported-upstream
- Status changed from reviewing to closed
This ticket has been moved to GitHub https://github.com/WordPress/wordcamp.org/issues/578
I would like to work on this ticket