tml_register_action()

Register a TML action.

Description

Theme_My_Login_Action tml_register_action( mixed $action [, array $args ] )

Register an action for use within TML.

Parameters

action

Can either be a string to be used for the action name or a Theme_My_Login_Action object.

args

An array of arguments used for registering an action. This parameter is only used if the action parameter is a string. Acceptable arguments are as follows:

  • string title
    The title of the action to be displayed for the page title.
  • string slug
    The slug to be used to access the action.
  • callable callback
    The function to be called when the action is accessed.
  • bool network
    Whether this action should be considered network-wide or not.
  • mixed show_on_forms
    Whether a link to this action should be shown on other action forms. If set to true, this action will be linked to on other forms using the title argument as the link text. Setting this argument to a string value will use that string as the link text. Setting this argument to false will disable the action link from showing on other forms.
  • bool show_in_widget
    Whether this action should be selectable in the widget or not.
  • bool show_in_nav_menus
    Whether this action should be available for use in nav menus or not.
  • bool show_nav_menu_item
    Whether to show an assigned nav menu item or not.
  • bool show_in_slug_settings
    Whether this action should be shown in the slug settings or not.

Return Values

Returns a Theme_My_Login_Action instance.

Examples

Example #1 Registering an action using an array

tml_register_action( 'foo', array(
	'title' => 'Foo',
	'slug' => 'foo',
	'callback' => 'do_something',
	'network' => false,
	'show_on_forms' => 'Do foo?',
	'show_in_widget' => true,
	'show_in_nav_menus' => true,
	'show_in_slug_settings' => false,
) );

Example #2 Registering an action using an action object and an array of arguments

$action = new Theme_My_Login_Action( 'foo', array(
	'title' => 'Foo',
	'slug' => 'foo',
	'callback' => 'do_something',
	'network' => false,
	'show_on_forms' => 'Do foo?',
	'show_in_widget' => true,
	'show_in_nav_menus' => true,
	'show_in_slug_settings' => false,
) );

tml_register_action( $action );

Example #3 Registering an action using an action object and class methods/properties

$action = new Theme_My_Login_Action( 'foo' );
$action->set_title( 'Foo' );
$action->set_slug( 'foo' );
$action->set_callback( 'do_something' );
$action->network = false;
$action->show_on_forms = 'Do foo?';
$action->show_in_widget = true;
$action->show_in_nav_menus = true;
$action->show_in_slug_settings = false;

tml_register_action( $action );