Documentation

For developers

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

FilterWhat it is for
pht_translatable_attributesList of translatable HTML attributes per element (receives the list and the element name)
pht_search_paramsURL parameters treated as a search term (by default q, s, search, term, query)
pht_gettext_sourcesFolders the theme and plugin texts are read from

Actions

ActionWhen it fires
pht_purge_urlsAfter translating; receives the translated addresses to purge from the cache
pht_purge_allAfter 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-...' );

Publish.
Read it in
every language.

30,000 characters, one site, no card. The key arrives by email after checkout.