Ich verwende den Tatsu-Seitenersteller und dessen Code-Modul, um Dotlottie-Code einzufügen, wie zum Beispiel:
Das funktioniert gut; Wenn ich jedoch aus anderen Gründen, die nichts mit dem Seitenersteller zu tun haben, die übliche WordPress-Schaltfläche Aktualisieren verwende, entfernt WordPress diesen Code.
Ich habe versucht, den folgenden Code hinzuzufügen zu functions.php, aber es wurde trotzdem entfernt.
function allow_lottie_tags($tags, $context) {
// Add for all contexts
$allowed_atts = array(
'src' => true,
'background' => true,
'speed' => true,
'loop' => true,
'autoplay' => true,
'class' => true,
'id' => true,
'style' => true
);
// Apply to both default and 'post' context
if ($context === 'post' || $context === 'default') {
$tags['dotlottie-player'] = $allowed_atts;
}
return $tags;
}
// Apply to multiple filters to catch different contexts
add_filter('wp_kses_allowed_html', 'allow_lottie_tags', 999, 2);
add_filter('post_allowed_html', 'allow_lottie_tags', 999, 2);
Ich habe dann versucht, dies hinzuzufügen, ohne Erfolg.
// Also try to force it globally
function hook_lottie_early() {
global $allowedposttags, $allowedtags;
$allowed_atts = array(
'src' => true,
'background' => true,
'speed' => true,
'loop' => true,
'autoplay' => true,
'class' => true,
'id' => true,
'style' => true
);
$allowedposttags['dotlottie-player'] = $allowed_atts;
$allowedtags['dotlottie-player'] = $allowed_atts;
}
add_action('init', 'hook_lottie_early', 1);
Was mache ich falsch? Sollte ich stattdessen zu einem dynamischen Shortcode wechseln oder gibt es eine andere Möglichkeit, damit umzugehen?
Verhindern Sie, dass WordPress das benutzerdefinierte -Element entfernt ⇐ Php
-
- Similar Topics
- Replies
- Views
- Last post