OptionsPage
Add custom admin pages with ease.
Usage
use WPDev\Facades\OptionsPage;
OptionsPage::create('Site Settings')
->topLevel()
->menuIcon('dashicons-admin-settings')
->register();
API Reference
Public Methods
Method | Summary |
__construct |
Constructor. For a more fluid syntax use OptionsPage::create() .
|
contentCallback | Set the page content callback. |
capability | The capability required for this menu to be displayed to the user. |
create
static |
Allows for more fluid syntax. |
menuIcon | Set the menu icon. |
menuSlug | Set the slug for the page. |
menuTitle | Sets the menu title. |
parentSlug | Sets the parent slug. Used to make this page a child page. |
position | Sets the position of the menu item. |
register | Registers the page with WP. Hooks and all. |
registerManually |
Registers the page but not within the appropriate hook admin_menu .
|
sampleCallback |
A sample page callback. You should be setting your own callback via contentCallback() .
|
topLevel | Make the page top level. |
-
__construct
__construct( string
$page_title
)SummaryConstructor. For a more fluid syntax useOptionsPage::create()
.Parameterspage_titleThe title of the page. By default this will also be used as the menu title and the page slug (a slugified version of course). -
contentCallback
contentCallback( callable
$callback
)SummarySet the page content callback.ParameterscallbackThe callback in charge of generating the content for the page.Returns$this
-
capability
capability( string
$capability
)SummaryThe capability required for this menu to be displayed to the user.ParameterscapabilityReturns$this
-
create
create( string
$page_title
)SummaryAllows for more fluid syntax.Parameterspage_titleThe title of the page. By default this will also be used as the menu title and the page slug (a slugified version of course).Returns$this
-
parentSlug
parentSlug( [ string
$slug
] )SummarySets the parent slug. Used to make this page a child page.ParametersslugThe slug of the parent page.Returns$this
-
position
position( [ int
$position
] )SummarySets the position of the menu item.ParameterspositionReturns$this
-
register
register( )
SummaryRegisters the page with WP. Hooks and all. -
registerManually
registerManually( )
SummaryRegisters the page but not within the appropriate hookadmin_menu
. -
sampleCallback
sampleCallback( )
SummaryA sample page callback. You should be setting your own callback viacontentCallback()
. -
topLevel
topLevel( [ bool
$bool
] )SummaryMake the page top level.ParametersboolReturns$this