Pods UI submenus
I've just created my first for Pods UI plug-in, the code is below, more or less a copy of the MBN example. I'd expect from the add_object & add_submenu options, to get a main admin menu item of Caza Mayor and a single sub-menu of Cotos. What I actually see is two submenus - Caza Mayor and Cotos - the Cotos option works fine, I just don't understand why the Caza mayor submenu is present.

I guess it's not really a pods problem, rather a problem with my plugin code, but I'm not really where to check next.
<?php
/*
Plugin Name: Caza Mayor Pods UI
Description: Customized Pods UI
Version: 0.1
Author: Simon Toulson
*/
function pods_ui_caza_mayor()
{
$icon = '';
add_object_page('Caza Mayor', 'Caza Mayor', 'read', 'caza_mayor', '', $icon);
add_submenu_page('caza_mayor', 'Cotos', 'Cotos', 'read', 'cotos', 'cotos_page');
}
function cotos_page()
{
$object = new Pod('coto');
$add_fields = $edit_fields = array(
'name',
'lema',
'situacion',
'hectareas',
'bichos',
'descripcion',
'lat',
'lon',
'marker',
'thumb',
'gallery');
$object->ui = array(
'title' => 'Coto',
'columns' => array(
'name' => 'Name',
'lema' => 'Lema',
'created' => 'Date Created',
'modified' => 'Last Modified'
),
'add_fields' => $add_fields,
'edit_fields' => $edit_fields
);
pods_ui_manage($object);
}
add_action('admin_menu','pods_ui_caza_mayor');
?>
2 Answers
Your sub-menu code is set to point at a different identifier than the parent one, so it sets up additional sub-menus automatically. This is WP core, so more information can be lifted from their documentation on add_object_page
add_submenu_page('caza_mayor', 'Cotos', 'Cotos', 'read', 'caza_mayor', 'cotos_page');
Thanks for the pointer. It wasn't until I'd added the 2nd submenu that it all became clear.


