Automattic / sensei

Sensei LMS - Online Courses, Quizzes, & Learning
https://senseilms.com
GNU General Public License v2.0
531 stars 197 forks source link

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

Open merkushin opened 9 months ago

merkushin commented 9 months ago

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.

donnapep commented 9 months ago

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 commented 8 months ago

Related:

m1r0 commented 8 months ago

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.

donnapep commented 7 months ago

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.

ockham commented 7 months ago

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 😊

donnapep commented 7 months ago

per0F9-1sT-p2

m1r0 commented 6 months ago

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.