Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the issue of submenus not appearing #40

Merged
merged 5 commits into from
Oct 19, 2020

Conversation

kienstra
Copy link
Contributor

@kienstra kienstra commented Oct 16, 2020

Changes

  • Ensures that on first activation, the block CPT menus appear:
    the-submenu-items-appear

  • This bug only appeared the first time GCB is ever activated on the site.

Testing instructions

  • Please see the steps to reproduce in BHH-554
  • To destroy the site and create a new one, I've been doing:
wp db drop && wp db create && wp core install --url=https://foo.test --title="Example" --admin_user=foo --admin_email=example@example.com --admin_password=baz

Now, on the first installation,
the submenus appear.
The previous approach didn't work,
as it gave the capabilities
to more than admin users.
Adding these custom capabilities
on the plugins_loaded action looks to work.
@@ -47,7 +47,7 @@ public function __construct() {
*/
public function register_hooks() {
add_action( 'init', [ $this, 'register_post_type' ] );
add_action( 'admin_init', [ $this, 'add_caps' ] );
add_action( 'plugins_loaded', [ $this, 'add_caps' ] );
Copy link
Contributor Author

@kienstra kienstra Oct 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe admin_init was a little too late to add the capabilities.

By moving it earlier to plugins_loaded, the capability is there in time for the submenus to be there.

@kienstra
Copy link
Contributor Author

It should also be possible to revert #23

The same issue that caused
the submenus to not display
also caused the link
to not display.
Now that the capability is added
earlier, this works.
@kienstra kienstra requested review from lukecarbis, nickcernis and mindctrl and removed request for lukecarbis October 19, 2020 02:56
@kienstra
Copy link
Contributor Author

Hi @mindctrl and @nickcernis,
Could you please review this if you have a chance? Not urgent 😄

Copy link
Contributor

@nickcernis nickcernis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Confirmed “Add New” and “All Blocks” appear on first use on a fresh install.

Screenshot 2020-10-19 at 17 32 02

@kienstra
Copy link
Contributor Author

Nice, thanks so much for reviewing this!

@kienstra kienstra merged commit 8c08a37 into develop Oct 19, 2020
@kienstra kienstra deleted the fix/cpt-menus-do-not-appear branch October 19, 2020 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants