File: //usr/tmp/fix_btn_context_and_cache.py
path = "/home/kohlsol/public_html/wp-content/themes/brooklyn-child/functions.php"
with open(path) as f:
content = f.read()
# 1. Cache-busting definitivo: versao pelo mtime do arquivo, nao herdada do WP core
old_enqueue = """function kohl_solucoes_child_enqueue_styles() {
$parent_style = 'ut-main-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style(
'kohl-solucoes-child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style )
);
}"""
new_enqueue = """function kohl_solucoes_child_enqueue_styles() {
$parent_style = 'ut-main-style';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
/**
* Versao pelo mtime do arquivo, nao pela versao do tema (que so muda em
* update do WP core/tema). Sem isso, toda edicao neste style.css fica
* presa em cache do Cloudflare e do navegador com a MESMA URL, e nada de
* novo chega a quem visita -- foi exatamente o que aconteceu no Bloco 4.
*/
$child_style_path = get_stylesheet_directory() . '/style.css';
$child_style_ver = file_exists( $child_style_path ) ? filemtime( $child_style_path ) : '1.0.0';
wp_enqueue_style(
'kohl-solucoes-child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
$child_style_ver
);
}"""
assert content.count(old_enqueue) == 1, "enqueue: padrao nao encontrado"
content = content.replace(old_enqueue, new_enqueue)
# 2. Botao invisivel em fundo marinho (marinho sobre marinho) -- variante de contexto
old_btn = """.bklyn-btn:hover, .bklyn-btn:focus {
background-color: var(--kohl-champagne) !important;
border-color: var(--kohl-champagne) !important;
color: var(--kohl-marinho) !important;
}"""
new_btn = """.bklyn-btn:hover, .bklyn-btn:focus {
background-color: var(--kohl-champagne) !important;
border-color: var(--kohl-champagne) !important;
color: var(--kohl-marinho) !important;
}
/* Marinho sobre marinho = botao invisivel (achado na captura real do
Daniel). Em secao de fundo marinho, o botao vira branco -- nao e
"cor", e neutro, entao nao cai na regra de evitar texto escuro
sobre cor; so o hover usa champagne, igual em qualquer contexto. */
.kohl-bg-marinho .bklyn-btn {
background-color: var(--kohl-branco) !important;
border-color: var(--kohl-branco) !important;
color: var(--kohl-marinho) !important;
}
.kohl-bg-marinho .bklyn-btn:hover, .kohl-bg-marinho .bklyn-btn:focus {
background-color: var(--kohl-champagne) !important;
border-color: var(--kohl-champagne) !important;
color: var(--kohl-marinho) !important;
}"""
assert content.count(old_btn) == 1, "botao: padrao nao encontrado"
content = content.replace(old_btn, new_btn)
with open(path, "w") as f:
f.write(content)
print("cache-busting por mtime + botao contextual em fundo marinho corrigidos")