You are here

function helper_preprocess_menu_local_action in Helper 7

Implements hook_preprocess_HOOK().

Add destination query string to local action links to take you back to the page where you clicked the location action when done.

File

./helper.module, line 154

Code

function helper_preprocess_menu_local_action(&$variables) {
  if (helper_is_tweak_enabled('local_action_destination')) {
    $link =& $variables['element']['#link'];
    if (isset($link['href'])) {

      // Some local actions need to be whitelisted as having a redirect causes bugs.
      switch ($link['href']) {
        case 'admin/appearance/install':
        case 'admin/modules/install':
        case 'admin/reports/updates/install':
        case 'admin/structure/views/add':
        case 'admin/structure/flags/add':
        case 'admin/structure/multifield/add':
        case 'admin/config/media/theplatform/accounts/add':
          return;
      }
      $link += array(
        'localized_options' => array(),
      );
      $link['localized_options'] += array(
        'query' => array(),
      );
      $link['localized_options']['query'] += drupal_get_destination();
    }
  }
}