Algolia integration
Integration between Algolia and the Weglot WordPress plugin.
function algolia_load_assets() {
wp_enqueue_script( 'xhook', 'https://unpkg.com/xhook@1.6.2/dist/xhook.min.js', array(), '1.6.2', true );
$algolia_url = WEGLOT_DIRURL . 'app/javascripts/algolia.js';
$algolia_file = WEGLOT_DIR . '/app/javascripts/algolia.js';
$algolia_ver = file_exists( $algolia_file ) ? filemtime( $algolia_file ) : WEGLOT_VERSION;
wp_enqueue_script( 'wg-algolia-js', $algolia_url, array( 'xhook' ), $algolia_ver, true );
wp_localize_script( 'wg-algolia-js', 'weglotData', array(
'api_key' => weglot_get_option( 'api_key' ),
'original_language' => weglot_get_original_language(),
'current_language' => weglot_get_current_language(),
) );
}
add_action( 'wp_enqueue_scripts', 'algolia_load_assets' );
Last updated