shortcut_valid_link

Versions
7
shortcut_valid_link($path)

Determines if a path corresponds to a valid shortcut link.

See also

menu_edit_item_validate()

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.

▾ 2 functions call shortcut_valid_link()

shortcut_link_add_inline in modules/shortcut/shortcut.admin.inc
Menu callback; Creates a new link in the provided shortcut set
shortcut_link_edit_validate in modules/shortcut/shortcut.admin.inc
Validation handler for the shortcut link add and edit forms.

Code

modules/shortcut/shortcut.module, line 475

<?php
function shortcut_valid_link($path) {
  // Do not use URL aliases.
  $normal_path = drupal_get_normal_path($path);
  if ($path != $normal_path) {
    $path = $normal_path;
  }
  // Only accept links that correspond to valid paths on the site itself.
  return !url_is_external($path) && menu_get_item($path);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.