1.20.x admin_bar.inc admin_bar_links_icon()

Build icon menu links; mostly containing maintenance helpers.

See also

theme_admin_bar_links()

File

modules/admin_bar/admin_bar.inc, line 534
Menu builder functions for Administration bar.

Code

function admin_bar_links_icon() {
  $destination = backdrop_get_destination();

  $links = array(
    '#theme' => 'admin_bar_links',
    '#wrapper_attributes' => array(
      'id' => 'admin-bar-icon',
    ),
    '#weight' => -100,
  );
  $links['icon'] = array(
    '#title' => theme('admin_bar_icon'),
    '#attributes' => array('class' => array('admin-bar-icon')),
    '#href' => '<front>',
    '#options' => array(
      'html' => TRUE,
    ),
  );
  // Add link to manually run cron.
  $links['icon']['cron'] = array(
    '#title' => t('Run cron'),
    '#weight' => 50,
    '#access' => user_access('administer site configuration'),
    '#href' => 'admin/reports/status/run-cron',
  );
  // Add link to run update.php.
  $links['icon']['update'] = array(
    '#title' => t('Run updates'),
    '#weight' => 50,
    // @see update_access_allowed()
    '#access' => $GLOBALS['user']->uid == 1 || settings_get('update_free_access') || user_access('administer software updates'),
    '#href' => base_path() . 'core/update.php',
    '#options' => array(
      'external' => TRUE,
    ),
  );
  // Add items to flush caches.
  $links['icon']['flush-cache'] = array(
    '#title' => t('Flush all caches'),
    '#weight' => 20,
    '#access' => user_access('flush caches'),
    '#href' => 'admin_bar/flush-cache',
    '#options' => array(
      'query' => $destination + array('token' => backdrop_get_token('admin_bar/flush-cache')),
    ),
  );
  $caches = module_invoke_all('admin_bar_cache_info');
  foreach ($caches as $name => $cache) {
    $links['icon']['flush-cache'][$name] = array(
      '#title' => $cache['title'],
      '#href' => 'admin_bar/flush-cache/' . $name,
      '#options' => array(
        'query' => $destination + array('token' => backdrop_get_token('admin_bar/flush-cache/' . $name)),
      ),
    );
  }

  return $links;
}