You are here

function menu_position_get_condition_callback in Menu Position 7

Same name and namespace in other branches
  1. 6 menu_position.module \menu_position_get_condition_callback()
  2. 7.2 menu_position.module \menu_position_get_condition_callback()

Loads the include file containing a condition's callback function definition.

Parameters

string $plugin: The name of the plugin.

Return value

string/bool The name of the callback function, or FALSE if it could not be found.

1 call to menu_position_get_condition_callback()
menu_position_evaluate_rules in ./menu_position.module
Evaluate all rules based on a given context.

File

./menu_position.module, line 624
Provides dynamic menu links based on configurable rules.

Code

function menu_position_get_condition_callback($plugin) {
  $plugins = menu_position_get_plugins();
  $callback = !empty($plugins[$plugin]['condition_callback']) ? $plugins[$plugin]['condition_callback'] : FALSE;
  if ($callback && !function_exists($callback)) {

    // Load the specified include file.
    if (!empty($plugins[$plugin]['file'])) {
      $file = pathinfo($plugins[$plugin]['file']);

      // Allow plugins to be in a sub-directory.
      if ($file['dirname']) {
        $file['filename'] = $file['dirname'] . '/' . $file['filename'];
      }
      module_load_include($file['extension'], $plugins[$plugin]['module'], $file['filename']);
    }

    // Note if the callback still cannot be found.
    if (!function_exists($callback)) {
      $callback = FALSE;
    }
  }
  return $callback;
}