Created
April 10, 2026 08:33
-
-
Save kjtolsma/600d1159b6dee96b255f50a11ca2c1a1 to your computer and use it in GitHub Desktop.
Weglot
This file contains hidden or 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 | |
| /** | |
| * 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