Administration pages appear on the left side bar when you login to the WordPress administration area by browsing to http://yourdomain.com/wp-admin. Vulnero supports two types of administration pages, menu and options. The menu style appears as a top level menu item with its own icon. The options style (default) appears as a sub-item in the Settings top-level menu.
Auto-loading
Administration pages, like widgets, are auto-loaded from classes extending Vulnero_AdminPage in the application/admin-pages/AdminPage directory. So the first step is simply to create your new class:
/* vim application/admin-pages/AdminPage/General.php */
class AdminPage_General extends Vulnero_AdminPage
{
protected $_pageTitle = 'Setup';
protected $_menuTitle = 'My New Plugin Setup';
protected function _init()
{
$this->setIconUrl(PROJECT_BASE_URI . '/public/images/admin-icon.png')
->setPosition(3)
->setType(Vulnero_AdminPage::ADMIN_MENU);
}
}
Here we've created a new admin page with the menu style with its own custom position and icon. The above is simply to demonstrate many of the popular options; but, only the page title and menu title are required. The _init method can be extended to perform additional tasks if needed, such as we've done above.
Rendering the Content
The admin page works much a like a controller and requires you to create a displayAction method to inject any view variables or perform any logic (e.g.: initializing forms):
class AdminPage_General extends Vulnero_AdminPage
public function displayAction()
{
$form = new Form_AdminGeneral();
$this->view->form = $form;
}
Resources
In your displayAction logic, you'll probably need access to the bootstrap to obtain resources for working with the WordPress API, the database, the cache or other items. For convenience, you can access the bootstrap via the $this->_bootstrap property:
class AdminPage_General extends Vulnero_AdminPage
public function displayAction()
{
$wordPress = $this->_bootstrap->bootstrap('wordPress')
->getResource('wordPress');
$this->view->displayFooter = $wordPress->getCustomOption('display_footer');
}
