Functies
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 argumenten: style (inline, stack, dropdown, select), flags (bool), show_label (bool), class (string).
Voorbeeld:
<?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 | Waar het voor is |
|---|---|
pht_translatable_attributes | Lijst van vertaalbare HTML-attributen per element (ontvangt de lijst en de naam van het element) |
pht_search_params | URL-parameters behandeld als een zoekterm (standaard q, s, search, term, query) |
pht_gettext_sources | Mappen waar de thema- en pluginn teksten vandaan worden gelezen |
Acties
| Actie | Wanneer het afgaat |
|---|---|
pht_purge_urls | Na vertaling; ontvangt de vertaalde adressen om uit de cache te verwijderen |
pht_purge_all | Na een grote run; vraagt om de hele cache leeg te maken |
Om een cache-systeem aan te sluiten dat de plugin niet kent:
add_action( 'pht_purge_urls', function ( array $urls ) {
foreach ( $urls as $url ) {
my_cache_purge( $url );
}
} );
Switcher CSS-variabelen
Gedefinieerd op .pht-switcher: --pht-bg, --pht-fg, --pht-hover, --pht-radius en de rest uit de sectie Uiterlijk.
Constante
define( 'PHT_LICENSE_KEY', 'PHT-...' );