Announcing the Classic Menu Block plugin

Jonny Harris avatar
  • Today I am happy to announce a new plugin I have been working on called classic menu block. This is a very simple plugin that adds a new classic menu block to the gutenberg editor. The classic menu block, allows you to embed all the existing menus you have setup on your site, using the existing core function, wp_nav_menu by rendering the block’s output in PHP. This means for those using menus with super custom walkers and plugins that hook into the existing menus filters, these can now be used within, blog posts, block based widget areas and even within full site editing. This differs from the new navigation block, which takes existing menu data and migrates to nested navigation link blocks. For information, checkout the announcement blog post.

    This plugin requires WordPress 5.9 to function, as it relays on the new menus endpoints added in this function. This is something near and dear to my heart, as I worked on the menus endpoints for nearly 2 and half years to get them into core. More details on this announcement can be found on the make.WordPress.org blog.

    For those that wish to customize attributes passed to the wp_nav_menu, there is a filter called classic_menu_block_attributes. This would allow you change any attributes passed to the wp_nav_menu function.

    /**
    * Filters menu attributes.
    *
    * @since 0.1.0
    *
    * @param array $menu_attrs Menu attributes.
    * @param array $attrs Block attributes.
    */
    $menu_attrs = apply_filters( 'classic_menu_block_attributes', $menu_attrs, $attrs );

    The plugin currently only comes with very basic styling of the menu block. Styling for this block, should come from the theme. However, if you are interested in contributing, please feel free to submit a pull request on github.

    I wrote this plugin, to help those that are dipping their toes into the full site editing world. I hope this solves a problem for some people.

    , ,