0

Firstly here is a YouTube of me explaining my problem...

https://www.youtube.com/watch?v=Nenu1stzLRw

I want to be able to use postboxes on tabbed pages. Usually tabbed pages are called views to avoid confusion with actual admin registered pages. I have around 5 plugin pages and each has a tab menu. I cannot use postboxes full ability on them because each tab/view shares the same settings registered for the WP admin page they are on. So one page, multiple views.

Wordpress does not appear to have a parameter to create settings per tab/view as it relies on the "page" variable in the URL which is always for a registered page. So I've went ahead and registered all of my views. Around 30 and I want to hide 25 of them say. The 5 left will show menus allowing access to the rest of my plugins admin pages. That is my attempt at a solution but it does not work.

This is the function that prevents postboxes being used properly on tabbed views...

function wp_ajax_meta_box_order() {
check_ajax_referer( 'meta-box-order' );
$order = isset( $_POST['order'] ) ? (array) $_POST['order'] : false;
$page_columns = isset( $_POST['page_columns'] ) ? $_POST['page_columns'] : 'auto';

if ( $page_columns != 'auto' )
    $page_columns = (int) $page_columns;

$page = isset( $_POST['page'] ) ? $_POST['page'] : '';

if ( $page != sanitize_key( $page ) )
    wp_die( 0 );

if ( ! $user = wp_get_current_user() )
    wp_die( -1 );

if ( $order )
    update_user_option($user->ID, "meta-box-order_$page", $order, true);

if ( $page_columns )
    update_user_option($user->ID, "screen_layout_$page", $page_columns, true);

wp_die( 1 );

TablePress See the TablePress plugin for an example of what I DO NOT want my plugin to do. I want the tab menu but I do not want the tabs to be reflected in the main plugin menus and vice-versa. This plugin is great coding standards and makes perfect use of the WP core but I'm trying to improve on it. If I could do it the TablePress plugin could have a single page.

  • Why are you bypassing the register function? – eyoung100 Jun 23 '14 at 16:10
  • What exactly are the "Views" you are talking about? Is this a plugin or theme related question? – kaiser Jun 23 '14 at 16:45
  • @kiaser, I believe this is the Plugin he's working on: CSV 2 POST – eyoung100 Jun 23 '14 at 16:56
  • Wordpress being a CMS admin pages are a big deal in the code. "page" is used a lot in the PHP. A plugin can have many pages and on each page a menu of tags. You might actually refer to each view as a tab as I have seen done but what do you call a tab if you call the view/screen a tab? – Ryan Bayne Jun 23 '14 at 20:02
  • I did not link to CSV 2 POST on Wordpress.org because there is no version on there that demonstrates what I am doing. TablePress is a great plugin, very well coded and has perfect Wordpress standards. That does some of what I'm trying to achieve but only does it for the page, no views within a page. I'm trying to take it further and I don't think it's possible with "views" simply being tabbed content. I think I need to register as much as 35 views as pages. Meaning no more "views" confusion just lots of pages. Then I need to hide most of those pages from the Wordpress plugin menu. – Ryan Bayne Jun 23 '14 at 20:05
0

You need something like the following:

$metabox_array = array (array('view1', 'Metabox for View 1', 'Render View 1', 'Post', 'normal', 'default',
                              'view2', 'Metabox for View 2', 'Render View 2', 'Post', 'normal', 'default',
                              'view_x', 'Metabox for View_x', 'Render View_x', 'Post', 'normal', 'default',));
    function adding_custom_meta_boxes( $post ) {
    add_meta_box($metabox_array);
}
add_action( 'add_meta_boxes_post', 'adding_custom_meta_boxes' );

As kiaser states though, we need more information.

  • Thanks and I know your short of information but this I have done. It's hard to show you guys because it's not a small project. Two classes, I think possibly three are used in making this happen up to the point the posts boxes can be moved around, hidden etc. – Ryan Bayne Jun 23 '14 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.