File: //var/tmp/add_js_menu.py
path = "/home/kohlsol/public_html/wp-content/themes/brooklyn-child/functions.php"
with open(path) as f:
fn = f.read()
addition = """
/**
* Efeito de entrada suave ao rolar a página (IntersectionObserver nativo,
* sem biblioteca extra) — pedido de Daniel de "incluir efeitos que o
* template oferece", aplicado com moderação em vez de tudo animado.
*/
function kohl_solucoes_child_reveal_script() {
?>
<script>
document.addEventListener('DOMContentLoaded', function () {
if (!('IntersectionObserver' in window)) {
document.querySelectorAll('.kohl-reveal').forEach(function (el) {
el.classList.add('kohl-revealed');
});
return;
}
var observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add('kohl-revealed');
observer.unobserve(entry.target);
}
});
}, { threshold: 0.15, rootMargin: '0px 0px -60px 0px' });
document.querySelectorAll('.kohl-reveal').forEach(function (el) {
observer.observe(el);
});
});
</script>
<?php
}
add_action( 'wp_footer', 'kohl_solucoes_child_reveal_script' );
"""
assert "kohl_solucoes_child_reveal_script" not in fn
fn += addition
with open(path, "w") as f:
f.write(fn)
print("functions.php: script de reveal adicionado")