Skip to content

Make the LifterLMS menu meta box initially available on Appearance -> Menus#2333

Merged
ideadude merged 1 commit into
gocodebox:devfrom
eri-trabiccolo:lifterlms-menu-metabox
Feb 14, 2023
Merged

Make the LifterLMS menu meta box initially available on Appearance -> Menus#2333
ideadude merged 1 commit into
gocodebox:devfrom
eri-trabiccolo:lifterlms-menu-metabox

Conversation

@eri-trabiccolo

@eri-trabiccolo eri-trabiccolo commented Jan 25, 2023

Copy link
Copy Markdown
Contributor

Description

@chrisbadgett asked me to look into how to make the LifterLMS meta box available/visible by default under Appearance -> Menus, without the need of enabling it via Screen Options.
This PR allows that. Of course it will only apply to new users from now on, as for older users who already opened that page WordPress already saved the hiding of that item as user "preference".

More in depth description:

  • as soon as you go in Appearance -> Menu, WordPress runs this:
    https://developer.wordpress.org/reference/functions/wp_initial_nav_menu_meta_boxes/
  • so the first time you go there the option metaboxhidden_nav-menus is not set, so only the defined initial meta boxes are displayed: $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' );
  • All the others (see global $wp_meta_boxes ) that have been added until that point are marked as hidden, and the list of the hidden meta boxes is saved into the option metaboxhidden_nav-menus., so next time they won't be shown. This option can be altered then via the Screen Options on that Appearance -> Menus page.
  • In this PR we add the meta box after the wp_initial_nav_menu_meta_boxes() has run, so our meta box won't be part of the global $wp_meta_boxes seen by that function, so it won't be automatically marked as hidden, while prior to this PR the meta box addition would run before wp_initial_nav_menu_meta_boxes(), so the added meta box would be marked as hidden and saved as such.
  • This means that an admin user headed to that menus page prior to this PR would have the LifterLMS meta box automatically saved as hidden, hence this PR won't affect them.

(the new hook is the same hook used by WooCommerce for the same purpose)

How has this been tested?

manually, creating a new (administrator) user and switching to it.

Screenshots

screenshotW-20230125_130512_381105809

Types of changes

UX improvement?

Checklist:

  • My code has been tested.
  • My code passes all existing automated tests.
  • My code follows the LifterLMS Coding & Documentation Standards.

@eri-trabiccolo eri-trabiccolo added the Type: Enhancement Improvements existing features or code label Jan 25, 2023
@eri-trabiccolo eri-trabiccolo requested a review from a team January 25, 2023 12:14
@eri-trabiccolo eri-trabiccolo self-assigned this Jan 25, 2023
@ideadude ideadude merged commit e61c4d1 into gocodebox:dev Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Severity: Normal Type: Enhancement Improvements existing features or code

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants