Menus

Saturn Tables builds on top of WordPress administration menus. WordPress menus defined with add_menu_page and add_submenu_page render pages using a callback and Saturn Tables mimics this functionality. However, Saturn Tables also allows for specifically designed callbacks to render list tables and input forms.

Saturn Tables uses an array added to a WordPress filter to pass values to add_menu_page and add_submenu_page with types menu and submenu. In addition, list tables and input forms can be rendered with types list_table and input_form.

You can read more about administration menus at https://codex.wordpress.org/Adding_Administration_Menus

This function which defines menu values is hooked to the saturn_tables_menu filter. Remember to add type (menu, submenu, list_table, input_form) to the standard WordPress administration menu parameters.

Here are the menus in the sample “Cars” dataset and code base.

add_filter( 'saturn_tables_menus', 'saturn_tables_menus_cars', 10, 1 );

function saturn_tables_menus_cars( $saturn_tables_menus ) {

    $saturn_tables_menus[]= array (
                    'type' => 'list_table',
                    'page_title' => __( 'Cars' ),
                    'menu_title' => __( 'Cars' ),
                    'capability' => 'edit_posts',
                    'menu_slug' => 'saturn-tables-cars-table',
                    'callable' => 'saturn_tables_cars_list_table_func',
                    'icon_url' => '',
                    'position' => '40'
            );

    $saturn_tables_menus[] = array(
                    'type' => 'input_form',
                    'parent_slug' => 'saturn-tables-cars-table',
                    'page_title' => __( 'Add Car' ),
                    'menu_title' => __( 'Add Car' ),
                    'capability' => 'edit_posts',
                    'menu_slug' => 'saturn-tables-cars-add-edit-car',
                    'callable' => 'saturn_tables_cars_add_edit_car_func');


    $saturn_tables_menus[] = array(
                    'type' => 'submenu',
                    'parent_slug' => 'saturn-tables-cars-table',
                    'page_title' => __( 'Cars Import' ),
                    'menu_title' => __( 'Cars Import' ),
                    'capability' => 'edit_posts',
                    'menu_slug' => 'saturn-tables-cars-import-export',
                    'callable' => 'saturn_tables_cars_import_export_func');


    return $saturn_tables_menus;

}