filtrod 3.5.0
wp_kses_allowed_html
Opis
Rozszerza listę dozwolonych tagów i atrybutów HTML w treści dla konkretnego kontekstu.
Przykład użycia
add_filter( 'wp_kses_allowed_html', ... )php
add_filter( 'wp_kses_allowed_html', 'wpdocs_allow_data_attrs', 10, 2 );
function wpdocs_allow_data_attrs( $allowed, $context ) {
if ( 'post' !== $context ) {
return $allowed;
}
$allowed['div']['data-animate'] = true;
return $allowed;
}
add_filter( 'wp_kses_allowed_html', 'wpdocs_allow_data_attrs', 10, 2 );
function wpdocs_allow_data_attrs( $allowed, $context ) {
if ( 'post' !== $context ) {
return $allowed;
}
$allowed['div']['data-animate'] = true;
return $allowed;
}HTML tags and attribute names are case-insensitive in HTML but must be added to the KSES allow list in lowercase. An item added to the allow list in upper or mixed case will not recognized as permitted by KSES.
Parametry
| Parametr | Typ | Opis |
|---|---|---|
$html | array[] | Allowed HTML tags. |
$context | string | Context name. |
Wywołanie
Rejestracja callbackaphp
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'wp_kses_allowed_html', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}
// rejestracja funkcji zwrotnej — podaj liczbę argumentów!
add_filter( 'wp_kses_allowed_html', 'twoja_funkcja', 10, 2 );
function twoja_funkcja($param_1, $param_2) {
// Twój kod
}Popularne w tej kategorii