You are here

function menu_position_get_condition_callback in Menu Position 7.2

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

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

Parameters

$plugin: The name of the plugin.

Return value

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
Evaluates all rules based on a given context.

File

./menu_position.module, line 460
Provides menu links for dynamic positioning of nodes 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;
}