You are here

function om_maximenu_link_attrib in OM Maximenu 8

Same name and namespace in other branches
  1. 6 inc/om_maximenu.utils.inc \om_maximenu_link_attrib()
  2. 7 inc/om_maximenu.utils.inc \om_maximenu_link_attrib()

Link attribute

5 calls to om_maximenu_link_attrib()
template_preprocess_om_maximenu_accordion_links in inc/om_maximenu.render.inc
Process variables for om_maximenu_accordion_links.tpl.php
template_preprocess_om_maximenu_modal_links in inc/om_maximenu.render.inc
Process variables for om_maximenu_modal_links.tpl.php
template_preprocess_om_maximenu_roundabout_links in inc/om_maximenu.render.inc
Process variables for om_maximenu_roundabout_links.tpl.php
template_preprocess_om_maximenu_submenu_links in inc/om_maximenu.render.inc
Process variables for om_maximenu_submenu_links.tpl.php
template_preprocess_om_maximenu_tabbed_links in inc/om_maximenu.render.inc
Process variables for om_maximenu_tabbed_links.tpl.php

File

inc/om_maximenu.utils.inc, line 81
OM Maximenu Admin Utilities

Code

function om_maximenu_link_attrib($content = array()) {

  // initialize link attributes and classes
  $attributes = array();

  // id link attributes
  if (!empty($content['id'])) {
    $attributes['id'] = om_string_name($content['id']);
  }

  // user added custom classes
  $custom_classes = '';
  $classes = explode(' ', $content['class']);
  foreach ($classes as $ckey => $class) {
    $custom_classes .= ' ' . om_string_name($class);
  }
  $title_class = om_string_name($content['link_title']);
  if (empty($title_class)) {
    $title_class = 'script';
  }

  // class link attributes
  $attributes['class'] = 'om-link' . $custom_classes . ' link-' . $title_class;

  // active class
  $uri = trim($_SERVER['REQUEST_URI']);
  $path_relative = base_path() . $content['path'];
  if ($_GET['q'] == $content['path'] || $path_relative == $uri) {
    $attributes['class'] .= ' active';
  }
  if ((empty($content['path']) || $content['path'] == '<front>') && drupal_is_front_page()) {
    $attributes['class'] .= ' active';
  }

  // link description options
  if (!empty($content['description']) && $content['description_option'] == 'hover') {
    $attributes['title'] = check_plain($content['description']);
  }

  // relationship
  if (!empty($content['rel'])) {
    $attributes['rel'] = $content['rel'];
  }

  // target
  if (!empty($content['target']) && $content['target'] != '_self') {
    $attributes['target'] = $content['target'];
  }
  return $attributes;
}