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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 '<style id="acrib-page-fixes-' . get_the_ID() . '">' . implode("\n", $rules) . '</style>' . "\n";
|
||||
echo '<style id="acrib-page-fixes-' . $id . '">' . implode("\n", $rules) . '</style>' . "\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 '<style id="acrib-homepage-fixes">
|
||||
/* ── Transparent header overlay on homepage ───────────────────────── */
|
||||
/* Position header absolutely so it overlays the hero without pushing */
|
||||
/* content down — this is the Kadence Pro "transparent header" effect. */
|
||||
.home #masthead.site-header{
|
||||
/* ── Transparent header overlay on homepage and translated versions ───── */
|
||||
/* Position header absolutely so it overlays the hero without pushing */
|
||||
/* content down — Kadence Pro transparent header effect, replicated. */
|
||||
.home #masthead.site-header,
|
||||
.transparent-header #masthead.site-header{
|
||||
position:absolute;
|
||||
top:0;left:0;right:0;
|
||||
z-index:1000;
|
||||
background:transparent!important;
|
||||
box-shadow:none!important;
|
||||
}
|
||||
/* Remove the top padding/margin Kadence normally adds to offset the header */
|
||||
/* Remove top margin Kadence adds to offset the header height */
|
||||
.home .content-area,
|
||||
.home .site-content,
|
||||
.home #content{
|
||||
.home #content,
|
||||
.transparent-header .content-area,
|
||||
.transparent-header .site-content,
|
||||
.transparent-header #content{
|
||||
margin-top:0!important;
|
||||
padding-top:0!important;
|
||||
}
|
||||
/* Remove Kadence blank page-title section above hero (title:hide meta ignored) */
|
||||
/* Remove Kadence blank page-title section above hero on Spanish homepage */
|
||||
.home .entry-hero.page-hero-section{display:none!important}
|
||||
/* Remove bottom margin that creates gap after the last section */
|
||||
.home .content-area{margin-bottom:0!important}
|
||||
/* Remove boxed content styling on homepage */
|
||||
.home .entry-content-wrap{
|
||||
.home .content-area,
|
||||
.transparent-header .content-area{margin-bottom:0!important}
|
||||
/* Remove boxed content styling */
|
||||
.home .entry-content-wrap,
|
||||
.transparent-header .entry-content-wrap{
|
||||
padding:0!important;
|
||||
box-shadow:none!important;
|
||||
margin:0!important;
|
||||
background:none!important;
|
||||
}
|
||||
/* ── Hero: fill exactly one viewport height ───────────────────────── */
|
||||
/* ── Hero: fill exactly one viewport height ─────────────────────────── */
|
||||
.acrib-hero.wp-block-cover{
|
||||
height:100svh!important;
|
||||
height:100vh!important;
|
||||
|
||||
Reference in New Issue
Block a user