Pods UI submenus

0

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.

alt text

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');

?>

asked Jul 28 '11 at 7:41

caroig

16

add comment
enter at least 15 characters

2 Answers

0

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');

answered Jul 28 '11 at 8:07

sc0ttkclark

2936

add comment
enter at least 15 characters
0

Thanks for the pointer. It wasn't until I'd added the 2nd submenu that it all became clear.

answered Jul 29 '11 at 5:01

caroig

16

add comment
enter at least 15 characters