WordPress.org

Making WordPress.org

Opened 2 years ago

Last modified 5 weeks ago

#1109 assigned enhancement

Site Cloner: Add support for importing menus

Reported by: iandunn Owned by:
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 (2)

1109.diff (2.9 KB) - added by chandrapatel 11 months ago.
Import menus and set to menu location
1109.1.diff (3.1 KB) - added by chandrapatel 11 months ago.

Download all attachments as: .zip

Change History (19)

#1 @iandunn
2 years ago

  • Keywords good-first-bug added

#2 @iandunn
21 months ago

  • Owner set to iandunn
  • Status changed from new to accepted

This ticket was mentioned in Slack in #outreach by neha03. View the logs.


21 months ago

#4 @neha03
21 months ago

  • Keywords changed from needs-patch, good-first-bug to needs-patch good-first-bug

I would like to work on this ticket

@chandrapatel
11 months ago

Import menus and set to menu location

#5 @chandrapatel
11 months ago

Hello @iandunn

I've uploaded patch file. I implemented following points.

  1. Import all menus with a menu item. Create default Home custom menu item and assign that to all menus.
  2. After that, set menu to menu locations.

I've tested locally. Please check and let me know if its fine.

#6 @iandunn
11 months 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 @chandrapatel
11 months ago

Hello @iandunn

Thanks for the suggestion. I've added separate function for creating the menu.

Please check 1109.1.diff

#8 @iandunn
11 months ago

Looks good :)

This ticket was mentioned in Slack in #meta-wordcamp by coreymckrill. View the logs.


3 months ago

#10 @coreymckrill
3 months 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 @iandunn
3 months 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.


3 months ago

#13 @coreymckrill
3 months 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?

#14 @chandrapatel
3 months ago

@coreymckrill Sure, I will update my patch over the weekend.

#15 @chandrapatel
3 months 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 @coreymckrill
2 months 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.

#17 @iandunn
5 weeks ago

  • Owner iandunn deleted
  • Status changed from accepted to assigned
Note: See TracTickets for help on using tickets.