From 34714e99986314ea69094756e18525a37aad94c1 Mon Sep 17 00:00:00 2001 From: Malin Date: Wed, 20 May 2026 06:53:35 +0200 Subject: [PATCH] feat: multilingual support - RO/EN translations and menu fixes - Convert RO (ID 33) and EN (ID 34) homepages from post to page type - Create Nav RO (ID 16) and Nav EN (ID 17) menus with translated labels - Create RO and EN CF7 contact forms (IDs 61, 62) with translated fields - Update MU-plugin v1.4: transparent-header body class now applies to all front page translations (detected via pll_get_post_translations) - Update homepage CSS to use .transparent-header alongside .home selectors so RO/EN hero layouts match the Spanish homepage - Fix page-specific CSS selectors (page-id-N after post_type correction) Co-Authored-By: Claude Sonnet 4.6 --- wp-content/mu-plugins/acrib-core.php | 73 +++++++++++++++++++--------- 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/wp-content/mu-plugins/acrib-core.php b/wp-content/mu-plugins/acrib-core.php index a9c9b2d..7b3f3b3 100644 --- a/wp-content/mu-plugins/acrib-core.php +++ b/wp-content/mu-plugins/acrib-core.php @@ -2,7 +2,7 @@ /** * ACRIB Core MU-Plugin * Always-on: custom footer, security hardening, performance tweaks. - * @version 1.2 + * @version 1.4 */ // --- Remove Kadence default copyright footer --- @@ -13,11 +13,21 @@ add_action('after_setup_theme', function () { remove_action('kadence_footer_html', 'Kadence\footer_html'); }, 999); -// --- Transparent header body class on homepage (Kadence Pro workaround) --- +// --- Transparent header body class on homepage + its Polylang translations --- // Kadence's layout/component.php adds non-transparent-header at priority 10. // We run at 999 to remove it and add transparent-header (used by Kadence JS). add_filter('body_class', function ($classes) { - if (is_front_page()) { + $is_front = is_front_page(); + // Also detect translated homepages via Polylang + $is_front_translation = false; + if (!$is_front && is_singular() && function_exists('pll_get_post_translations')) { + $front_id = (int) get_option('page_on_front'); + if ($front_id) { + $translations = pll_get_post_translations($front_id); + $is_front_translation = in_array(get_the_ID(), $translations, true); + } + } + if ($is_front || $is_front_translation) { $classes = array_diff($classes, ['non-transparent-header', 'mobile-non-transparent-header']); $classes[] = 'transparent-header'; $classes[] = 'mobile-transparent-header'; @@ -94,58 +104,75 @@ add_action('wp_head', function () { if (is_singular()) { $layout = get_post_meta(get_the_ID(), '_kadence_post_layout', true); $meta = $layout ? json_decode($layout, true) : []; - $hide_title = isset($meta['title']) && $meta['title'] === 'hide'; - $full_width = isset($meta['layout']) && $meta['layout'] === 'fullwidth'; + $hide_title = isset($meta['title']) && $meta['title'] === 'hide'; + $full_width = isset($meta['layout']) && $meta['layout'] === 'fullwidth'; if ($hide_title || $full_width) { + $id = get_the_ID(); $rules = []; if ($hide_title) { - $rules[] = '.page-id-' . get_the_ID() . ' .entry-hero.page-hero-section{display:none!important}'; + $rules[] = '.page-id-' . $id . ' .entry-hero.page-hero-section{display:none!important}'; } if ($full_width) { - // Remove boxed content wrap styling added by content-style-boxed body class - $rules[] = '.page-id-' . get_the_ID() . ' .entry-content-wrap{padding:0!important;box-shadow:none!important;margin:0!important;background:none!important}'; - $rules[] = '.page-id-' . get_the_ID() . ' .content-area{max-width:100%!important;padding:0!important}'; + $rules[] = '.page-id-' . $id . ' .entry-content-wrap{padding:0!important;box-shadow:none!important;margin:0!important;background:none!important}'; + $rules[] = '.page-id-' . $id . ' .content-area{max-width:100%!important;padding:0!important}'; } if ($rules) { - echo '' . "\n"; + echo '' . "\n"; } } } }, 5); -// --- Homepage: inject critical CSS fixes --- +// --- Homepage + translations: inject critical CSS fixes --- +// Uses .home (Spanish front page) and .transparent-header (all front page variants) +// so the same rules apply to RO and EN translated homepages. add_action('wp_head', function () { - if (!is_front_page()) return; + if (!is_front_page() && !is_singular()) return; + // Only inject for actual front page or its translations + $inject = is_front_page(); + if (!$inject && function_exists('pll_get_post_translations')) { + $front_id = (int) get_option('page_on_front'); + if ($front_id) { + $inject = in_array(get_the_ID(), pll_get_post_translations($front_id), true); + } + } + if (!$inject) return; echo '