Cmb2: Feature request: Allow non-CMB2 pages to be added to tab-groups

Created on 15 Feb 2021  路  7Comments  路  Source: CMB2/CMB2

Allow non-CMB2 pages to be added to options-page tab-groups.

  1. A filter hook inside get_tab_group_tabs() could facilitate this
    $tabs = apply_filters( 'cmb2/tab_group', $tabs, $tab_group );

  2. Additionally it would be nice if CMB2 would also provide a method to print out these tabs on the non-CMB2 pages. Even with the filter hook, the non-CMB2 page has to render its own tabs, replicating and slightly modifying code from get_tab_group_tabs() and options_page_output().

The second part would require a more involved solution. Separating the tab-printing logic from options_page_output() and making it available statically/globally to other plugins.
And there are probably other considerations to be thought through. So perhaps item 2 can be considered separately from the filter hook.

All 7 comments

Not shooting this down, but curious about the usecase for this. It feels like you're trying to mix CMB2-created options pages and non-CMB2 options pages in both directions.

I have a plugin that has multiple (3) admin-pages that I created with CMB2 using a tab-group. One being a top-level menu item. The other 2 being sub-menu items of the first. All three have their own tab - appearing on the admin pages.
I also have another admin page of that plugin that is not created with CMB2 (and has no reason to be converted to CMB2 - a WP_List_Table page).

Adding the non-CMB2 page as a sub-menu item to the main CMB2 pages menu hierarchy is easy using wp-core's native API ( just pass the parent slug to add_submenu_page ).
Adding it to the tabs-group is not as easy.

It feels like you're trying to mix CMB2-created options pages and non-CMB2 options pages in both directions.

I _am_ trying to integrate CMB2 pages more seamlessly into my plugins, my wp installation and workflow. yes.

@jtsternberg what do you think about this?

Just tested the new filter hook and function - and everything works great.
Thanks :)

Awesome possum :D

This is cool. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mathetos picture mathetos  路  8Comments

kidatart picture kidatart  路  7Comments

GaryJones picture GaryJones  路  3Comments

stabilimenta picture stabilimenta  路  8Comments

angelorocha picture angelorocha  路  6Comments