michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
339 stars 71 forks source link

Sub Menu of CPT #97

Closed mathetos closed 10 years ago

mathetos commented 10 years ago

Is it possible to define the Root menu item to be a custom post type menu? I tried this and it's not working as I expected:

$w4lmenu = 'edit.php?post_type=whats_4_lunch';
global $w4lmenu;
$this->setRootMenuPage( $w4lmenu );   // create a root page 
    $this->addSubMenuItem(
        array(
            'title' => 'W4L Settings',
            'page_slug' => 'w4l_settings'
            )
        );
michaeluno commented 10 years ago

Try this: $this->setRootMenuPageBySlug( $w4lmenu );

mathetos commented 10 years ago

No luck. That removed the menu completely.

mathetos commented 10 years ago

This seems like a bug if it doesn't support the WordPress parameters for creating sub-menus: http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters

I also just tried commenting out the setRootMenuPage and adding it into the addSubMenuItem, like so:

//$this->setRootMenuPage( );   // create a root page 
        $this->addSubMenuItem(
            array(
                'parent_slug' => 'edit.php?post_type=whats_4_lunch',
                'title' => 'W4L Settings',
                'page_slug' => 'w4l_settings'
            )
        );  
michaeluno commented 10 years ago

Are you sure you used the setRootMenuPageBySlug() method, not setRootMenuPage() since your last posted code is still using setRootMenuPage()?

mathetos commented 10 years ago

Yes, I tried "setRootMenuPageBySlug" and nothing happened, so I kept experimenting.

mathetos commented 10 years ago

Of course... now it worked perfect. Perhaps there was a typo when I first tried it. Thanks! Resolved!

michaeluno commented 10 years ago

Ha, glad it helped! Please close the topic ;)

michaeluno commented 10 years ago

I wonder if it's hard to close a topic...