Example #1
0
/**
 * Get all translated path of a specific post with ID.
 *
 * @since	2.4
 *
 * @param 	int 	$post_id	Post ID
 * @param 	string 	$post_type 	Post Type
 * @param 	string 	$regex 		Regex to include at the end
 * @return 	array	$urls
 */
function get_rocket_i18n_translated_post_urls($post_id, $post_type = 'page', $regex = null)
{
    $urls = array();
    $path = parse_url(get_permalink($post_id), PHP_URL_PATH);
    $langs = get_rocket_i18n_code();
    if (empty($path)) {
        return $urls;
    }
    // WPML
    if (rocket_is_plugin_active('sitepress-multilingual-cms/sitepress.php')) {
        foreach ($langs as $lang) {
            $urls[] = parse_url(get_permalink(icl_object_id($post_id, $post_type, true, $lang)), PHP_URL_PATH) . $regex;
        }
    }
    // qTranslate
    if (rocket_is_plugin_active('qtranslate/qtranslate.php')) {
        $langs = $GLOBALS['q_config']['enabled_languages'];
        $langs = array_diff($langs, array($GLOBALS['q_config']['default_language']));
        $url = get_permalink($post_id);
        $urls[] = parse_url(get_permalink($post_id), PHP_URL_PATH) . $regex;
        foreach ($langs as $lang) {
            $urls[] = parse_url(qtrans_convertURL($url, $lang, true), PHP_URL_PATH) . $regex;
        }
    }
    // Polylang
    if (rocket_is_plugin_active('polylang/polylang.php') && is_object($GLOBALS['polylang']->model) && ($translations = $GLOBALS['polylang']->model->get_translations('page', $post_id))) {
        foreach ($translations as $post_id) {
            $urls[] = parse_url(get_permalink($post_id), PHP_URL_PATH) . $regex;
        }
    }
    if (trim($path, '/') != '') {
        $urls[] = $path . $regex;
    }
    $urls = array_unique($urls);
    return $urls;
}
Example #2
0
 /**
  * Get URI all of active languages
  *
  * @since 2.0
  * @deprecated 2.2
  * @deprecated Use get_rocket_i18n_code()
  *
  */
 function get_rocket_all_active_langs()
 {
     _deprecated_function(__FUNCTION__, '2.2', 'get_rocket_i18n_code()');
     return get_rocket_i18n_code();
 }