Functions
pht_switcher( array $args = [] ); // prints the switcher
pht_get_switcher( array $args = [] ); // returns the switcher's HTML
pht_current_language(); // current language prefix ('' in the source language)
$args arguments: style (inline, stack, dropdown, select), flags (bool), show_label (bool), class (string).
Example:
<?php if ( 'en' === pht_current_language() ) : ?>
<p>Free shipping to the UK.</p>
<?php endif; ?>
Shortcode
[pht_switcher show_label="no" class="my-class"]
Filters
| Filter | What it is for |
|---|---|
pht_translatable_attributes | List of translatable HTML attributes per element (receives the list and the element name) |
pht_search_params | URL parameters treated as a search term (by default q, s, search, term, query) |
pht_gettext_sources | Folders the theme and plugin texts are read from |
Actions
| Action | When it fires |
|---|---|
pht_purge_urls | After translating; receives the translated addresses to purge from the cache |
pht_purge_all | After a large run; asks for the whole cache to be emptied |
To connect a caching system the plugin does not know:
add_action( 'pht_purge_urls', function ( array $urls ) {
foreach ( $urls as $url ) {
my_cache_purge( $url );
}
} );
Switcher CSS variables
Defined on .pht-switcher: --pht-bg, --pht-fg, --pht-hover, --pht-radius and the rest from the Appearance section.
Constant
define( 'PHT_LICENSE_KEY', 'PHT-...' );