function bogo_metabox_add_translation($post)
{
    if ('auto-draft' == $post->post_status) {
        return;
    }
    $post_locale = bogo_get_post_locale($post->ID);
    $user_locale = bogo_get_user_locale();
    if ($post_locale == $user_locale) {
        return;
    }
    $locale = $user_locale;
    $translations = bogo_get_post_translations($post->ID);
    if (isset($translations[$locale])) {
        return;
    }
    $lang = bogo_get_language($locale);
    if (empty($lang)) {
        $lang = $locale;
    }
    $edit_link = admin_url('post-new.php?post_type=' . $post->post_type . '&locale=' . $locale . '&original_post=' . $post->ID);
    ?>
<p class="textright"><a href="<?php 
    echo $edit_link;
    ?>
" target="_blank" class="button"><?php 
    echo esc_html(sprintf(__('Add %s translation', 'bogo'), $lang));
    ?>
</a></p>
<?php 
}
function bogo_language_switcher_links($args = '')
{
    global $wp_query;
    $args = wp_parse_args($args, array());
    $locale = get_locale();
    $available_languages = bogo_available_languages();
    $translations = array();
    $is_singular = false;
    if (is_singular() || !empty($wp_query->is_posts_page)) {
        $translations = bogo_get_post_translations(get_queried_object_id());
        $is_singular = true;
    }
    $links = array();
    foreach ($available_languages as $code => $name) {
        $link = array('locale' => $code, 'lang' => bogo_language_tag($code), 'title' => $name, 'native_name' => bogo_get_language_native_name($code), 'href' => '');
        if ($is_singular) {
            if ($locale != $code && !empty($translations[$code])) {
                $link['href'] = get_permalink($translations[$code]);
            }
        } else {
            if ($locale != $code) {
                $link['href'] = bogo_url(null, $code);
            }
        }
        $links[] = $link;
    }
    return apply_filters('bogo_language_switcher_links', $links, $args);
}