function shortcut_valid_link

Determines if a path corresponds to a valid shortcut link.

Parameters

$path: The path to the link.

Return value

TRUE if the shortcut link is valid, FALSE otherwise. Valid links are ones that correspond to actual paths on the site.

See also

menu_edit_item_validate()

2 calls to shortcut_valid_link()
shortcut_link_add_inline in drupal/core/modules/shortcut/shortcut.admin.inc
Menu page callback: creates a new link in the provided shortcut set.
shortcut_link_edit_validate in drupal/core/modules/shortcut/shortcut.admin.inc
Validation handler for the shortcut link add and edit forms.

File

drupal/core/modules/shortcut/shortcut.module, line 617
Allows users to manage customizable lists of shortcut links.

Code

function shortcut_valid_link($path) {

  // Do not use URL aliases.
  $normal_path = drupal_container()
    ->get('path.alias_manager')
    ->getSystemPath($path);
  if ($path != $normal_path) {
    $path = $normal_path;
  }

  // An empty path is valid too and will be converted to <front>.
  return !url_is_external($path) && menu_get_item($path) || empty($path) || $path == '<front>';
}