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 )

    Summary
    Constructor. For a more fluid syntax use OptionsPage::create().
    Parameters
    page_title
    The 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 )

    Summary
    Set the page content callback.
    Parameters
    callback
    The callback in charge of generating the content for the page.
    Returns

    $this

  • capability

    capability( string $capability )

    Summary
    The capability required for this menu to be displayed to the user.
    Parameters
    capability
    Returns

    $this

  • create

    create( string $page_title )

    Summary
    Allows for more fluid syntax.
    Parameters
    page_title
    The 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

  • menuIcon

    menuIcon( [ string $icon ] )

    Summary
    Set the menu icon.
    Parameters
    icon
    name of Dashicon, URL to icon, or base64 encoded svg with fill="black"
    Returns

    $this

  • menuSlug

    menuSlug( string $menu_slug )

    Summary
    Set the slug for the page.
    Parameters
    menu_slug
    Returns

    $this

  • menuTitle

    menuTitle( string $menu_title )

    Summary
    Sets the menu title.
    Parameters
    menu_title
    Returns

    $this

  • parentSlug

    parentSlug( [ string $slug ] )

    Summary
    Sets the parent slug. Used to make this page a child page.
    Parameters
    slug
    The slug of the parent page.
    Returns

    $this

  • position

    position( [ int $position ] )

    Summary
    Sets the position of the menu item.
    Parameters
    position
    Returns

    $this

  • register

    register( )

    Summary
    Registers the page with WP. Hooks and all.
  • registerManually

    registerManually( )

    Summary
    Registers the page but not within the appropriate hook admin_menu.
  • sampleCallback

    sampleCallback( )

    Summary
    A sample page callback. You should be setting your own callback via contentCallback().
  • topLevel

    topLevel( [ bool $bool ] )

    Summary
    Make the page top level.
    Parameters
    bool
    Returns

    $this