Created
November 19, 2019 16:13
-
-
Save djrmom/04a69aee9199816d417a257e2b81e6de to your computer and use it in GitHub Desktop.
facetwp translate labels
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 | |
/** checks WPML current language if FWP()->facet->http_params['lang'] is not set | |
**/ | |
add_filter( 'facetwp_i18n', function( $string ) { | |
if ( isset( FWP()->facet->http_params['lang'] ) ) { | |
$lang = FWP()->facet->http_params['lang']; | |
else { | |
$lang = apply_filters( 'wpml_current_language', null ); | |
} | |
$translations = []; | |
$translations['es']['Products'] = 'Productos'; | |
$translations['es']['Location'] = 'Ubicación'; | |
if ( isset( $translations[ $lang ][ $string ] ) ) { | |
return $translations[ $lang ][ $string ]; | |
} | |
return $string; | |
}, 11 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment