Developers
Hooks and CSS classes
A short reference to the Vabelon hooks, the template tag and the CSS classes, for theme and plugin developers.
Vabelon hooks: the filters
vabelon_post_types sets which kinds of content have a language. The default is posts and pages.
add_filter( 'vabelon_post_types', function ( $types ) {
$types[] = 'book';
return $types;
} );
vabelon_request_is_public tells Vabelon whether the current request is a public page view. Return false to keep Vabelon from applying a language to it.
Template tag
<?php vabelon_switcher(); ?>
It prints the same markup as the [vabelon_switcher] shortcode.
CSS classes
.vabelon-switcher
.vabelon-switcher__list
.vabelon-switcher__item
.vabelon-switcher__link
.vabelon-switcher__link--current
The current language link also carries aria-current="page".
Vabelon hooks: the switcher action
The switcher is also an action, so a theme can print it without checking that the plugin is active:
<?php do_action( 'vabelon_switcher' ); ?>
If Vabelon is not active, the line prints nothing and causes no error. In contrast, a direct call to vabelon_switcher() fails when the plugin is missing.
How to use the Vabelon hooks
Add your code to a small plugin of your own or to the functions.php file of a child theme. Each filter is a standard WordPress filter, so add_filter() is all you need. For example, the first filter above gives a custom post type called book a language and translations.
For the markup the switcher prints, see the language switcher.