Skip to content

Instantly share code, notes, and snippets.

@kjtolsma
Created April 10, 2026 08:33
Show Gist options
  • Select an option

  • Save kjtolsma/600d1159b6dee96b255f50a11ca2c1a1 to your computer and use it in GitHub Desktop.

Select an option

Save kjtolsma/600d1159b6dee96b255f50a11ca2c1a1 to your computer and use it in GitHub Desktop.
Weglot
<?php
/**
* Weglot
*/
class Weglot {
/**
* Construct
*/
public function __construct() {
/**
* Weglot dynamic translation for Algolia search results.
*/
\add_filter( 'weglot_translate_dynamics', '__return_true' );
\add_filter( 'weglot_allowed_urls', [ $this, 'weglot_allowed_urls' ] );
\add_filter( 'weglot_dynamics_selectors', [ $this, 'weglot_dynamics_selectors' ] );
\add_filter( 'weglot_whitelist_selectors', [ $this, 'weglot_dynamics_selectors' ] );
}
/**
* Weglot allowed URLs for Algolia search results.
*
* @param array $urls Default Weglot allowed URLs.
*/
public function weglot_allowed_urls( $urls ) {
return 'all';
}
/**
* Weglot dynamic translation for Algolia search results.
*
* @param array $default_dynamics Default Weglot dynamic selectors.
*/
public function weglot_dynamics_selectors( $default_dynamics ) {
return [
[
'value' => '.algolia-search',
],
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment