Funções
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 argumentos: style (inline, stack, dropdown, select), flags (bool), show_label (bool), class (string).
Exemplo:
<?php if ( 'en' === pht_current_language() ) : ?>
<p>Free shipping to the UK.</p>
<?php endif; ?>
Shortcode
[pht_switcher show_label="no" class="my-class"]
Filtros
| Filtro | Para que serve |
|---|---|
pht_translatable_attributes | Lista de atributos HTML traduzíveis por elemento (recebe a lista e o nome do elemento) |
pht_search_params | Parâmetros de URL tratados como um termo de pesquisa (por padrão) q, s, search, term, query) |
pht_gettext_sources | Pastas de onde são lidas as traduções do tema e do plugin |
Ações
| Ação | Quando é acionado |
|---|---|
pht_purge_urls | Após traduzir; recebe os endereços traduzidos a eliminar do cache |
pht_purge_all | Após uma grande execução; pede que todo o cache seja esvaziado |
Para conectar um sistema de cache que o plugin não conhece:
add_action( 'pht_purge_urls', function ( array $urls ) {
foreach ( $urls as $url ) {
my_cache_purge( $url );
}
} );
Variáveis CSS do switcher
Definido em .pht-switcher: --pht-bg, --pht-fg, --pht-hover, --pht-radius e o resto da seção de Aparência.
Constante
define( 'PHT_LICENSE_KEY', 'PHT-...' );