function editlink_sProjects($link)
{
    global $id, $wp;
    $projectDirUrl = wpmanga_get('wpmanga_projectslist_url', 'projects');
    if ($wp->query_vars["pagename"] == $projectDirUrl && $wp->query_vars["pid"] && $id) {
        if (get_sProjectId($wp->query_vars["pid"])) {
            return preg_replace('/<(.*?)href="(.*?)"(.*?)>/i', '<\\1href="' . get_bloginfo('siteurl') . '/wp-admin/admin.php?page=manga/project&action=edit&id=' . get_sProjectId($wp->query_vars["pid"]) . '"\\3>', $link);
        } else {
            return preg_replace('/<(.*?)href="(.*?)"(.*?)>/i', '<\\1href="' . get_bloginfo('siteurl') . '/wp-admin/admin.php?page=manga"\\3>', $link);
        }
    } elseif ($wp->query_vars["pagename"] == $projectDirUrl && $id) {
        return preg_replace('/<(.*?)href="(.*?)"(.*?)>/i', '<\\1href="' . get_bloginfo('siteurl') . '/wp-admin/admin.php?page=manga"\\3>', $link);
    } else {
        return $link;
    }
}
/**
 * Returns the Permalink for the project specified.
 * @param integer $id Query the ID to obtain the permalink.
 * @return string
 */
function get_sPermalink($project = NULL)
{
    global $wp, $wpdb;
    if (!$project) {
        $id = get_sProjectId($wp->query_vars["pid"]);
        $project = $wpdb->get_row($wpdb->prepare("SELECT `id`, `slug` FROM `{$wpdb->prefix}projects` WHERE `id` = '%d' ORDER BY `title` ASC", $id));
    } elseif (is_int($project)) {
        $id = (int) $project;
        $project = $wpdb->get_row($wpdb->prepare("SELECT `id`, `slug` FROM `{$wpdb->prefix}projects` WHERE `id` = '%d' ORDER BY `title` ASC", $id));
    }
    if ($project) {
        $projectDirUrl = wpmanga_get('wpmanga_projectslist_url', 'projects');
        if ($project->slug != NULL) {
            return (string) get_bloginfo('siteurl') . "/{$projectDirUrl}/" . $project->slug . '/';
        } else {
            return (string) get_bloginfo('siteurl') . "/{$projectDirUrl}/" . $project->id . '/';
        }
    }
    //else
    return NULL;
}