Last active
August 29, 2015 14:06
-
-
Save groucho75/d6b41a0657646c3e79bb to your computer and use it in GitHub Desktop.
Integrate zTranslate, qTranslate Plus and qTranslate-X in ALO EasyMail - put this file in /wp-content/mu-plugins - report test here: http://wordpress.org/support/topic/qtranslate-versus-ztranslate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/********************************************************************** | |
* zTranslate integration | |
**********************************************************************/ | |
function alo_em_ztrans_set_plugin( $multilang_plugin ){ | |
if ( function_exists('ztrans_init') ) | |
$multilang_plugin = 'zTrans'; | |
return $multilang_plugin; | |
} | |
add_filter ( 'alo_easymail_multilang_enabled_plugin', 'alo_em_ztrans_set_plugin' ); | |
function alo_em_ztrans_get_language( $lang, $detect_from_browser ){ | |
if ( function_exists('ztrans_init') ) | |
$lang = ztrans_getLanguage(); | |
return $lang; | |
} | |
add_filter ( 'alo_easymail_multilang_get_language', 'alo_em_ztrans_get_language', 10, 2 ); | |
function alo_em_ztrans_get_all_languages( $langs, $fallback_by_users ){ | |
if ( function_exists('ztrans_init') ) | |
{ | |
return ztrans_getSortedLanguages(); | |
} | |
return $langs; | |
} | |
add_filter ( 'alo_easymail_multilang_get_all_languages', 'alo_em_ztrans_get_all_languages', 10, 2 ); | |
function alo_em_ztrans_translate_url( $filtered_url, $post, $lang ){ | |
if ( function_exists('ztrans_init') ) | |
{ | |
$filtered_url = add_query_arg( "lang", $lang, get_permalink( $post ) ); | |
} | |
return $filtered_url; | |
} | |
add_filter ( 'alo_easymail_multilang_translate_url', 'alo_em_ztrans_translate_url', 10, 3 ); | |
function alo_em_ztrans_get_subscrpage_id( $translated_id, $lang ){ | |
if ( function_exists('ztrans_init') ) | |
{ | |
$translated_id = get_option('alo_em_subsc_page'); | |
} | |
return $translated_id; | |
} | |
add_filter ( 'alo_easymail_multilang_get_subscrpage_id', 'alo_em_ztrans_get_subscrpage_id', 10, 2 ); | |
function alo_em_ztrans_filter_title( $subject, $newsletter, $recipient ) { | |
if ( function_exists('ztrans_init') ) | |
{ | |
$subject = ztrans_use($recipient->lang, $newsletter->post_title, false); | |
} | |
return $subject; | |
} | |
add_filter ( 'alo_easymail_newsletter_title', 'alo_em_ztrans_filter_title', 2, 3 ); | |
function alo_em_ztrans_alo_em___( $text ) { | |
if ( function_exists('ztrans_useCurrentLanguageIfNotFoundUseDefaultLanguage') ) | |
{ | |
$text = ztrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($text); | |
} | |
return $text; | |
} | |
add_filter ( 'alo_easymail_multilang_alo_em___', 'alo_em_ztrans_alo_em___' ); | |
function alo_em_ztrans_translate_text( $text, $lang, $post, $prop ) { | |
if ( function_exists('ztrans_init') ) | |
{ | |
$text = ztrans_use($lang, $text, false); | |
} | |
return $text; | |
} | |
add_filter ( 'alo_easymail_multilang_translate_text', 'alo_em_ztrans_translate_text', 2, 4 ); | |
/********************************************************************** | |
* qTranslate Plus | |
**********************************************************************/ | |
function alo_em_ppqtrans_set_plugin( $multilang_plugin ){ | |
if ( function_exists('ppqtrans_init') ) | |
$multilang_plugin = 'zTrans'; | |
return $multilang_plugin; | |
} | |
add_filter ( 'alo_easymail_multilang_enabled_plugin', 'alo_em_ppqtrans_set_plugin' ); | |
function alo_em_ppqtrans_get_language( $lang, $detect_from_browser ){ | |
if ( function_exists('ppqtrans_init') ) | |
$lang = ppqtrans_getLanguage(); | |
return $lang; | |
} | |
add_filter ( 'alo_easymail_multilang_get_language', 'alo_em_ppqtrans_get_language', 10, 2 ); | |
function alo_em_ppqtrans_get_all_languages( $langs, $fallback_by_users ){ | |
if ( function_exists('ppqtrans_init') ) | |
{ | |
return ppqtrans_getSortedLanguages(); | |
} | |
return $langs; | |
} | |
add_filter ( 'alo_easymail_multilang_get_all_languages', 'alo_em_ppqtrans_get_all_languages', 10, 2 ); | |
function alo_em_ppqtrans_translate_url( $filtered_url, $post, $lang ){ | |
if ( function_exists('ppqtrans_init') ) | |
{ | |
$filtered_url = add_query_arg( "lang", $lang, get_permalink( $post ) ); | |
} | |
return $filtered_url; | |
} | |
add_filter ( 'alo_easymail_multilang_translate_url', 'alo_em_ppqtrans_translate_url', 10, 3 ); | |
function alo_em_ppqtrans_get_subscrpage_id( $translated_id, $lang ){ | |
if ( function_exists('ppqtrans_init') ) | |
{ | |
$translated_id = get_option('alo_em_subsc_page'); | |
} | |
return $translated_id; | |
} | |
add_filter ( 'alo_easymail_multilang_get_subscrpage_id', 'alo_em_ppqtrans_get_subscrpage_id', 10, 2 ); | |
function alo_em_ppqtrans_filter_title( $subject, $newsletter, $recipient ) { | |
if ( function_exists('ppqtrans_init') ) | |
{ | |
$subject = ppqtrans_use($recipient->lang, $newsletter->post_title, false); | |
} | |
return $subject; | |
} | |
add_filter ( 'alo_easymail_newsletter_title', 'alo_em_ppqtrans_filter_title', 2, 3 ); | |
function alo_em_ppqtrans_alo_em___( $text ) { | |
if ( function_exists('ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage') ) | |
{ | |
$text = ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($text); | |
} | |
return $text; | |
} | |
add_filter ( 'alo_easymail_multilang_alo_em___', 'alo_em_ppqtrans_alo_em___' ); | |
function alo_em_ppqtrans_translate_text( $text, $lang, $post, $prop ) { | |
if ( function_exists('ppqtrans_init') ) | |
{ | |
$text = ppqtrans_use($lang, $text, false); | |
} | |
return $text; | |
} | |
add_filter ( 'alo_easymail_multilang_translate_text', 'alo_em_ppqtrans_translate_text', 2, 4 ); | |
/********************************************************************** | |
* qTranslate X | |
* thanks to Gunu | |
**********************************************************************/ | |
function alo_em_qtranxf_set_plugin( $multilang_plugin ){ | |
if ( function_exists('qtranxf_init') ) | |
$multilang_plugin = 'qtranslate-x'; | |
return $multilang_plugin; | |
} | |
add_filter ( 'alo_easymail_multilang_enabled_plugin', 'alo_em_qtranxf_set_plugin' ); | |
function alo_em_qtranxf_get_language( $lang, $detect_from_browser ){ | |
if ( function_exists('qtranxf_init') ) | |
$lang = qtranxf_getLanguage(); | |
return $lang; | |
} | |
add_filter ( 'alo_easymail_multilang_get_language', 'alo_em_qtranxf_get_language', 10, 2 ); | |
function alo_em_qtranxf_get_all_languages( $langs, $fallback_by_users ){ | |
if ( function_exists('qtranxf_init') ) | |
{ | |
return qtranxf_getSortedLanguages(); | |
} | |
return $langs; | |
} | |
add_filter ( 'alo_easymail_multilang_get_all_languages', 'alo_em_qtranxf_get_all_languages', 10, 2 ); | |
function alo_em_qtranxf_translate_url( $filtered_url, $post, $lang ){ | |
if ( function_exists('qtranxf_init') ) | |
{ | |
$filtered_url = add_query_arg( "lang", $lang, get_permalink( $post ) ); | |
} | |
return $filtered_url; | |
} | |
add_filter ( 'alo_easymail_multilang_translate_url', 'alo_em_qtranxf_translate_url', 10, 3 ); | |
function alo_em_qtranxf_get_subscrpage_id( $translated_id, $lang ){ | |
if ( function_exists('qtranxf_init') ) | |
{ | |
$translated_id = get_option('alo_em_subsc_page'); | |
} | |
return $translated_id; | |
} | |
add_filter ( 'alo_easymail_multilang_get_subscrpage_id', 'alo_em_qtranxf_get_subscrpage_id', 10, 2 ); | |
function alo_em_qtranxf_filter_title( $subject, $newsletter, $recipient ) { | |
if ( function_exists('qtranxf_init') ) | |
{ | |
$subject = qtranxf_use($recipient->lang, $newsletter->post_title, false); | |
} | |
return $subject; | |
} | |
add_filter ( 'alo_easymail_newsletter_title', 'alo_em_qtranxf_filter_title', 2, 3 ); | |
function alo_em_qtranxf_alo_em___( $text ) { | |
if ( function_exists('qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage') ) | |
{ | |
$text = qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text); | |
} | |
return $text; | |
} | |
add_filter ( 'alo_easymail_multilang_alo_em___', 'alo_em_qtranxf_alo_em___' ); | |
function alo_em_qtranxf_translate_text( $text, $lang, $post, $prop ) { | |
if ( function_exists('qtranxf_init') ) | |
{ | |
$text = qtranxf_use($lang, $text, false); | |
} | |
return $text; | |
} | |
add_filter ( 'alo_easymail_multilang_translate_text', 'alo_em_qtranxf_translate_text', 2, 4 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment