Hide button on excluded page

Since the version 3.5 of Weglot plugin, the button is visible even is the page is excluded. Here is how to hide it on excluded page

For example imagine we ecluded /fr/contact:

The button will be visible on /contact and on /fr/contact

To hide button on excluded page:

// Add this using plugin "Code Snippet" or directly in functions.php
add_filter( 'weglot_button_html', 'weglot_button_hide', 10 , 3);

function weglot_button_hide($html, $classes) {
	$show_button = weglot_get_service("Request_Url_Service_Weglot")->is_eligible_url(weglot_get_current_full_url());
	if(!$show_button) {
		return "";
	}
	return $html;
}

Last updated