How to create a menu option with HTML in its title from a module? HTML in a menu option would be very useful from a module too, i.e. inserting an image as a menu option. Is there a way to do use something like function MODULE_preprocess_menu_link(&amp;$variables) inside a module, and not in template.php?
Modules can implement preprocess and process functions for theme functions using a template file; for theme functions not using a template file, Drupal 7 allows module to implement a preprocess function.
For example, the mymodule module could implement mymodule_preprocess_menu_link() which is a Drupal 7 preprocess function for theme_menu_link().

Preprocess and process functions are useful when the variables passed to the theme function need to be changed. If there is the need of changing the output of the theme function, then a module needs to implement hook_theme_registry_alter() and change the function called to serve the output of a theme function.

function mymodule_theme_registry_alter(&amp;$theme_registry) {
  if (isset($theme_registry['menu_link'])) {
    $theme_registry['menu_link']['function'] = 'theme_mymodule_menu_link';
  }
}


With this implementation, theme_mymodule_menu_link() would be the function called when a module calls theme('menu_link', /* … */).

References


theme()