You are here

function skinr_ui_contextual_links in Skinr 7.2

Set contextual menu items for skinr.

Parameters

$variables: The $variables parameter from a preprocess function.

$hook: The $hook parameter from a preprocess function.

$contextual_links: An array of contextual links data as returned from Skinr's contextual links handler.

1 call to skinr_ui_contextual_links()
skinr_ui_preprocess in ./skinr_ui.module
Implements hook_preprocess().

File

./skinr_ui.module, line 356
Handles Skinr UI functionality allowing users to apply skins to their site.

Code

function skinr_ui_contextual_links(&$variables, $hook, $contextual_links) {
  $hooks = theme_get_registry();

  // Determine the primary theme function argument.
  if (!empty($hooks[$hook]['variables'])) {
    $keys = array_keys($hooks[$hook]['variables']);
    $key = $keys[0];
  }
  elseif (!empty($hooks[$hook]['render element'])) {
    $key = $hooks[$hook]['render element'];
  }
  if (!empty($key) && isset($variables[$key])) {
    $element =& $variables[$key];
  }
  if (isset($element) && is_array($element)) {
    foreach ($contextual_links as $key => $contextual_link) {
      $element['#contextual_links'][$key] = $contextual_link;
    }
  }
}