Skip to main content
Rollback to Revision 1
Source Link
Colin Shipton
  • 2.5k
  • 1
  • 17
  • 26

By implementing hook_link_alter()hook_link_alter in either a custom module or your theme, the.

The code (untested) code would be similar to the following one.:

/**
 * Implements hook_link_alter().
 */
function mymodule_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}
/**
 * Implements hook_link_alter().
 */
function MODULE/THEME_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}

By implementing hook_link_alter() in either a custom module or your theme, the (untested) code would be similar to the following one.

/**
 * Implements hook_link_alter().
 */
function mymodule_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}

By implementing hook_link_alter in either a custom module or your theme.

The code (untested) would be similar to:

/**
 * Implements hook_link_alter().
 */
function MODULE/THEME_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}
improved formatting
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

By implementing hook_link_alterhook_link_alter() in either a custom module or your theme.

The code, the (untested) code would be similar to: the following one.

/**
 * Implements hook_link_alter().
 */
function MODULE/THEME_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}
/**
 * Implements hook_link_alter().
 */
function mymodule_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}

By implementing hook_link_alter in either a custom module or your theme.

The code (untested) would be similar to:

/**
 * Implements hook_link_alter().
 */
function MODULE/THEME_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}

By implementing hook_link_alter() in either a custom module or your theme, the (untested) code would be similar to the following one.

/**
 * Implements hook_link_alter().
 */
function mymodule_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}
Source Link
Colin Shipton
  • 2.5k
  • 1
  • 17
  • 26

By implementing hook_link_alter in either a custom module or your theme.

The code (untested) would be similar to:

/**
 * Implements hook_link_alter().
 */
function MODULE/THEME_link_alter(&$variables) {
  if (isset($variables['options']['attributes']['target']) && $variables['options']['attributes']['target'] == '_blank') {
    $variables['options']['attributes']['rel'] = 'noopener noreferrer';
  }
}