Skip to content

Function

Add TML actions to the Customizer menu editor.

tml_filter_customize_nav_menu_available_items( array $items, string $type, string $object, int $page )

Parameters

$items array
The avaialble items.
$type string
The item type.
$object string
The object.
$page int
The current page.

Return

array The available items.

Source

function tml_filter_customize_nav_menu_available_items( $items, $type, $object, $page ) { // phpcs:ignore Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound -- matches the customize_nav_menu_available_items filter's documented parameter name.
    if ( 'tml_action' === $type && 0 === $page ) {
        foreach ( tml_get_actions() as $action ) {
            if ( ! $action->show_in_nav_menus ) {
                continue;
            }
            $items[] = array(
                'id'         => 'tml_action-' . $action->get_name(),
                'title'      => $action->get_title(),
                'type'       => 'tml_action',
                'type_label' => __( 'TML Action', 'theme-my-login' ),
                'object'     => $action->get_name(),
                'object_id'  => $action->get_name(),
                'url'        => $action->get_url(),
            );
        }
    }
    return $items;
}

Uses

Changelog

VersionDescription
7.0 Introduced.