1 menu.inc theme_menu_toggle($variables)

Returns rendered HTML for a menu toggle.

Parameters

$variables: An associative array containing:

  • enabled: A boolean indicating whether the menu toggle should be shown.
  • id: Unique identifier, generated with backdrop_html_id().
  • text: Translated text for the menu toggle button.

See also

theme_menu_toggle()

Related topics

File

core/includes/menu.inc, line 1913
API for the Backdrop menu system.

Code

function theme_menu_toggle($variables) {
  $output = '';
  if ($variables['enabled']) {
    $id = $variables['id'];
    $output = '<input id="' . $id . '" class="menu-toggle-state element-invisible" type="checkbox" aria-controls="' . $id . '" />';
    $output .= '<label class="menu-toggle-button" for="' . $id . '">';
    $output .= '<span class="menu-toggle-button-icon"></span>';
    $output .= (!empty($variables['text'])) ? '<span class="menu-toggle-button-text">' . check_plain($variables['text']) . '</span>' : '';
    $output .= '<span class="menu-toggle-assistive-text element-invisible">' . t('Toggle menu visibility') . '</span>';
    $output .= '</label>';
  }
  return $output;
}