my-admin-panel

Display an admin settings page with a corresponding entry in the admin menu. Admin pages can have tabs for better organization.

How to Create

Can be created from TitanFramework Instance:

$titan = TitanFramework::getInstance( 'my-theme' );
$adminPanel = $titan->createAdminPanel( array(
'name' => 'My Admin Panel',
) );
// Create options in My Admin Panel
$adminPanel->createOption( ... );

[zilla_alert]This will create an admin menu item named ‘My Admin Panel’ on the bottom of the admin menu.[/zilla_alert]

Can be created from an Admin Panel Object:

$titan = TitanFramework::getInstance( 'my-theme' );
$adminPanel = $titan->createAdminPanel( array(
'name' => 'My Admin Panel',
) );
$layoutPanel = $adminPanel->createAdminPanel( array(
'name' => 'My Layout Panel',
) );
// Create options in My Layout Panel
$layoutOptions->createOption( ... );

[zilla_alert]This will create a submenu item below the ‘My Admin Panel’ named ‘My Layout Panel’.[/zilla_alert]

my-admin-panel-object

Settings / Parameters

Parameter Type Description
name string The name of the admin page. This is also the name shown in the admin menu.
title string (Optional) The title displayed on the top of this admin page. Defaults to the name parameter.
desc string (Optional) A description displayed just below the title of this admin page.
id string (Optional) A unique slug for this admin page. Defaults to a generated slug from the name parameter.
parent string (Optional) If given, the admin page will become a submenu of this slug ID. Useful if you want your menu to be inside a core WordPress menu. The list of menu slug IDs can be found in the codex. Defaults to ''
capability string (Optional) The required capability of the user for this admin page. Defaults to manage_options
icon string (Optional) The menu icon for the admin menu for this page. This can either be a URL to the icon image file, or the name of a WordPress DashIcon. Defaults to dashicons-admin-generic
position int (Optional) The position where the menu should appear. This value corresponds to the core menu positions found in the codex. Defaults to null
use_form boolean (Optional) If false, the main form tag in the admin page will not be rendered. Useful only when the admin page doesn’t save anything. Defaults to true

Examples

Creating an admin panel:

$titan = TitanFramework::getInstance( 'my-theme' );
$adminPanel = $titan->createAdminPanel( array(
'name' => 'Theme Options',
) );

Creating a submenu:

$titan = TitanFramework::getInstance( 'my-theme' );
$adminPanel = $titan->createAdminPanel( array(
'name' => 'Theme Options',
) );
$layoutPanel = $adminPanel->createAdminPanel( array(
'name' => 'Layout Options',
) );

Creating an admin panel as a submenu in the Settings menu:

$titan = TitanFramework::getInstance( 'my-theme' );
$adminPanel = $titan->createAdminPanel( array(
'name' => 'Theme Options',
'parent' => 'options-general.php',
) );