How to create custom menu link wrapper function in Drupal 7? As you know default wrapper for menu item in Drupal 7 can be modified via function theme_menu_link().

by overriding 

theme_menu_link($variables) {} 


function we can modify the rendered html output of menu link but it will change all of menu items that their #theme attribute is set to this function. for example in main menu, each item has menu_link__main_menu value in it's #theme attribute.

Now I want to create a custom wrapper function in my theme.

I searched and I found I must create a function with structure like

theme_menu_link($variables) {}


and also I must REGISTER the function name in my theme.

For registration, I used function theme_theme() {}

function theme_theme() {return array('custom_menu_item_wrapper' =&gt; array());}


** theme is replaced by name of theme
** custom_menu_item_wrapper is the name of my function for wrapping operation

But I don't know, how should I define parameters in theme function registration because when custom_menu_item_wrapper($variables) function is called $variables is NULL
Indeed, you need to register a new theme implementation. Looking about the specification of the hook_theme(), each information array must contain either a variables element or a render element. This is missing in your case and causes the empty $variables argument.

function YOURTHEME_theme()
{
    // define a custom theme implementation
    return array(
        'menu_link_custom' =&gt; array(
            'render element' =&gt; 'element',
        ),
    );
}

function YOURTHEME_menu_link_custom($variables)
{
    //Build and return custom HTML for your link
}