feat: LOPDP Ecuador — router, permalinks, política privacidad, banner, nav, index temas

This commit is contained in:
2026-06-05 15:06:52 -05:00
parent 5d575db5e3
commit 90fee1947f
16 changed files with 180 additions and 108 deletions
@@ -330,14 +330,10 @@ function pflores_get_cv_data(): array
3. LOPDP — Política de privacidad, banner y widget
────────────────────────────────────────────── */
// A) Crear página de Política de Privacidad (una sola vez)
// A) Crear / reparar página de Política de Privacidad
add_action('admin_init', 'pflores_create_privacy_page');
function pflores_create_privacy_page(): void
{
if (get_option('pflores_privacy_page_created')) {
return;
}
$content = '<h2>Responsable del tratamiento</h2>
<p>Patricia Soledad Flores Sánchez · <a href="mailto:patricflorsanchez@gmail.com">patricflorsanchez@gmail.com</a> · pflores.linkedcorp.net</p>
@@ -359,6 +355,28 @@ function pflores_create_privacy_page(): void
<h2>Última actualización</h2>
<p>Junio de 2026.</p>';
// Si ya existe, reparar si tiene contenido genérico de WordPress
$existing = get_page_by_path('politica-de-privacidad');
if ($existing) {
update_option('pflores_privacy_page_created', $existing->ID);
if (str_contains((string) $existing->post_content, 'Qui') ||
str_contains((string) $existing->post_content, 'sample') ||
trim($existing->post_content) === '') {
wp_update_post([
'ID' => $existing->ID,
'post_content' => $content,
'post_status' => 'publish',
'post_name' => 'politica-de-privacidad',
]);
}
return;
}
// Si no existe, crearla
if (get_option('pflores_privacy_page_created')) {
return;
}
$id = wp_insert_post([
'post_title' => 'Política de Privacidad',
'post_name' => 'politica-de-privacidad',
@@ -369,7 +387,14 @@ function pflores_create_privacy_page(): void
]);
if ($id && ! is_wp_error($id)) {
update_option('pflores_privacy_page_created', 1);
update_option('pflores_privacy_page_created', $id);
// Asegurar permalinks bonitos
global $wpdb;
$wpdb->update(
$wpdb->options,
['option_value' => '/%postname%/'],
['option_name' => 'permalink_structure']
);
}
}
@@ -380,6 +405,7 @@ function pflores_lopd_banner(): void
if (is_admin()) {
return;
}
$privacy_url = esc_url(home_url('/politica-de-privacidad/'));
?>
<style>
#pflores-lopd-banner {
@@ -415,22 +441,19 @@ function pflores_lopd_banner(): void
<strong>Ley Orgánica de Protección de Datos Personales del Ecuador (LOPDP)</strong>.
</p>
<div class="pflores-lopd-actions">
<a href="/politica-de-privacidad/" class="pflores-lopd-link">Política de privacidad</a>
<a href="<?php echo $privacy_url; ?>" class="pflores-lopd-link">Política de privacidad</a>
<button id="pflores-lopd-accept" type="button">Aceptar</button>
</div>
</div>
<script>
(function(){
var banner = document.getElementById('pflores-lopd-banner');
if (!banner) return;
if (!localStorage.getItem('pflores_lopd_ok')) {
banner.style.display = 'flex';
}
document.getElementById('pflores-lopd-accept')
.addEventListener('click', function(){
localStorage.setItem('pflores_lopd_ok', '1');
banner.style.display = 'none';
});
var b = document.getElementById('pflores-lopd-banner');
if (!b) return;
if (!localStorage.getItem('pflores_lopd_ok')) b.style.display = 'flex';
document.getElementById('pflores-lopd-accept').addEventListener('click', function(){
localStorage.setItem('pflores_lopd_ok', '1');
b.style.display = 'none';
});
})();
</script>
<?php