Skip to content

Method

Construct the instance.

__construct( string $name, array $args = array() )

public

Parameters

$name string
The action name.
$args array Default array()
Optional. An array of arguments.
$title string
The action title.
$slug string
The action slug.
$callback callable
The action callback to fire when accessed.
$ajax_callback callable
The action callback to fire when accessed via AJAX.
$show_on_forms bool|string
Whether a link to the action should be shown on forms or not.
$show_in_widget bool
Whether this action should be selectable in the widget or not.
$show_in_nav_menus bool
Whether this action should be available for use in nav menus or not.
$show_nav_menu_item bool
Whether to show an assigned nav menu item or not.
$show_in_slug_settings bool
Whether this action should be shown in the slug settings or not.

Source

public function __construct( $name, $args = array() ) {

    $this->set_name( $name );

    $args = wp_parse_args(
        $args,
        array(
            'title'                 => '',
            'slug'                  => '',
            'callback'              => '',
            'ajax_callback'         => '',
            'network'               => false,
            'show_on_forms'         => true,
            'show_in_widget'        => true,
            'show_in_nav_menus'     => true,
            'show_in_slug_settings' => true,
        )
    );

    if ( ! isset( $args['show_nav_menu_item'] ) ) {
        $args['show_nav_menu_item'] = $args['show_in_nav_menus'];
    }

    $this->set_title( $args['title'] );
    $this->set_slug( $args['slug'] );
    $this->set_callback( $args['callback'] );
    $this->set_ajax_callback( $args['ajax_callback'] );

    $this->network               = (bool) $args['network'];
    $this->show_on_forms         = $args['show_on_forms'];
    $this->show_in_widget        = (bool) $args['show_in_widget'];
    $this->show_in_nav_menus     = (bool) $args['show_in_nav_menus'];
    $this->show_nav_menu_item    = (bool) $args['show_nav_menu_item'];
    $this->show_in_slug_settings = (bool) $args['show_in_slug_settings'];
}

Uses

Used by

Changelog

VersionDescription
7.0 Introduced.