Italian (Italy)

apply_filters_ref_array( 'vikappointments_before_build_menu', bool $status, MenuShape &$menu )

Fires before building the back-end main menu of the plugin.


Description

Plugins can use this hook to manipulate the back-end menu of VikAppointments at runtime.

It is useful in case you need to introduce additional separators and/or menu items. Otherwise, it is also possible to remove certain default menu items, such as the payments section.


Parameters

$status

(bool)  True on success, false on failure.

&$menu

(MenuShape)  The current menu instance. Since the argument is passed by reference, any changes applied to the instance will immediately take effect.


Example

The example below adds the Mail Text menu item under the Global category, and removes the Countries menu item from Portal category.

/**
 * Trigger action to allow the plugins to manipulate the back-end menu of VikAppointments.
 *
 * @param  boolean    $status  True on success, false on failure.
 * @param  MenuShape  &$menu   The menu to build.
 */
add_filter('vikappointments_before_build_menu', function($status, &$menu)
{
    $input = JFactory::getApplication()->input;

    // get "Global" separator. It can be found at index [5]
    $global = $menu->get(5);

    // create "Mail Text" menu item
    $mailtext = MenuFactory::createItem(
        __('Mail Text', 'vikappointments'),
        'admin.php?page=vikappointments&view=mailtextcust', $input->get('view') == 'mailtextcust'
    );
    // set icon for mail text
    $mailtext->setCustom('envelope');
	
    // add item at the end of the list
    $global->addChild($mailtext);

    // get "Portal" separator. It can be found at index [3]
    $portal = $menu->get(3);

    // delete "Countries" menu item
    $portal->unsetChild(array(
        'title' => __('Countries', 'vikappointments'),
    ));

    return true;
}, 10, 2);

Changelog

Version Description
1.0 Introduced.
Ultimo aggiornamento: 2021-10-05
Utile?
Potrebbe interessarti: