Last active
August 25, 2017 19:37
-
-
Save Shelob9/8ce901ee5ca6e06c27d3cc4877ea1a9c to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Always "es" language for Caldera Forms Translation when a locale is called for, such as "es_US" | |
*/ | |
add_action( 'cf_translate_get_current_language', function( $language ){ | |
if( 0 === strpos( $language, 'es' ) ){ | |
$language = 'es'; | |
} | |
return $language; | |
}, 15 ); | |
/** | |
* Always 2 letter codes for lanague -- all languages | |
*/ | |
add_action( 'cf_translate_get_current_language', function( $language ){ | |
if( 2 < strlen( $language ) ){ | |
$language = substr( $language, 0, 2 ); | |
} | |
return $language; | |
}, 15 ); | |
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 | |
/** | |
* Change Caldera Forms Translation language based on alternative GET var | |
*/ | |
add_action( 'cf_translate_get_current_language', function( $language ){ | |
if( isset( $_GET[ 'language' ] ){ | |
$language = strip_tags( $_GET[ 'language' ] ); | |
} | |
return $language; | |
}, 15 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment