sensei icon indicating copy to clipboard operation
sensei copied to clipboard

Automatically inject My Courses and Courses pages into menu on plugin activation

Open merkushin opened this issue 1 year ago • 7 comments

Is your feature request related to a problem? Please describe

When we use a block theme, the pages are not added to the main menu automatically. So when the user completed all the tasks that we suggested in the onboarding flow and went to the frontend, they might be surprised and frustrated.

Describe the solution you'd like

~I propose to add a task to add Sensei pages to the main menu in the onboarding checklist.~ See https://github.com/Automattic/sensei/issues/7386#issuecomment-1858561298.

merkushin avatar Dec 14 '23 06:12 merkushin

I think we can use Block Hooks to add the pages automatically to the menu for the user so they don't need to do it manually. See https://github.com/woocommerce/woocommerce-blocks/pull/11745 for an example of how Woo did it. They've limited it to just the TT4 theme, apparently due to limitations of the Block Hooks API. If we need to limit support as well for technical reasons, we should start by adding support for the Course theme.

donnapep avatar Dec 15 '23 22:12 donnapep

Related:

  • per0F9-1p1-p2
  • https://core.trac.wordpress.org/ticket/59743

donnapep avatar Jan 15 '24 15:01 donnapep

There are currently 2 blockers for implementing this with Block Hooks.

  1. There is no way to set block attributes with the Block Hooks API. This prevents us from using the Page Link block. Here's the quote from the docs:

There is no way to set the attributes of the hooked block, so only the default instance of the block is inserted. Future improvements to Block Hooks will likely account for this limitation and others, providing a robust way for developers to extend Block Themes.

  1. Inserting child blocks into the Navigation block is not working currently. This most likely will be fixed in 6.5 as mentioned here.

We would have to wait a bit until those are resolved.

m1r0 avatar Jan 17 '24 15:01 m1r0

There was work done in https://github.com/WordPress/gutenberg/pull/57754 that should enable us to add Sensei pages into the Navigation block. It's scheduled to ship in Gutenberg 17.6.

donnapep avatar Jan 31 '24 22:01 donnapep

There are currently 2 blockers for implementing this with Block Hooks.

  1. There is no way to set block attributes with the Block Hooks API. This prevents us from using the Page Link block. Here's the quote from the docs: [...]

👋 This is now fixed by https://github.com/WordPress/wordpress-develop/pull/5835, which will be part of WP 6.5 😊

ockham avatar Feb 05 '24 10:02 ockham

per0F9-1sT-p2

donnapep avatar Feb 05 '24 13:02 donnapep

Inserting child blocks into the Navigation block is not working currently. This most likely will be fixed in 6.5 as mentioned here.

It's confirmed that in 6.5 it's possible to add child blocks into the Navigation block:

Additionally, it is now possible to inject hooked blocks into the Navigation block. Previously, a hooked block could only be added before or after the Navigation block, but now it can also be added as its first or last child.

I'm guessing that this could now be tested on the latest 6.5 branch.

m1r0 avatar Mar 04 '24 12:03 m1r0