function bogo_post_type_link($permalink, $post, $leavename, $sample)
{
    if (!bogo_is_localizable_post_type($post->post_type)) {
        return $permalink;
    }
    $locale = bogo_get_post_locale($post->ID);
    $permalink_structure = get_option('permalink_structure');
    $using_permalinks = $permalink_structure && ($sample || !in_array($post->post_status, array('draft', 'pending', 'auto-draft')));
    $permalink = bogo_get_url_with_lang($permalink, $locale, array('using_permalinks' => $using_permalinks));
    return $permalink;
}
function bogo_url($url = null, $lang = null)
{
    if (!$lang) {
        $lang = get_locale();
    }
    $args = array('using_permalinks' => (bool) get_option('permalink_structure'));
    return bogo_get_url_with_lang($url, $lang, $args);
}