[\d]+)']);
return $endpoints;
});
// --- Disable emoji (reduces ~20KB page weight) ---
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action('admin_print_scripts', 'print_emoji_detection_script');
remove_action('admin_print_styles', 'print_emoji_styles');
remove_filter('the_content_feed', 'wp_staticize_emoji');
remove_filter('comment_text_rss', 'wp_staticize_emoji');
remove_filter('wp_mail', 'wp_staticize_emoji_for_email');
// --- Limit post revisions ---
if (!defined('WP_POST_REVISIONS')) {
define('WP_POST_REVISIONS', 3);
}
// --- Global: hide Kadence title section on pages with custom heroes ---
// Kadence free ignores _kadence_post_layout title:hide meta.
// We read it ourselves and output the fix for any page that set it.
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';
if ($hide_title || $full_width) {
$id = get_the_ID();
$rules = [];
if ($hide_title) {
$rules[] = '.page-id-' . $id . ' .entry-hero.page-hero-section{display:none!important}';
}
if ($full_width) {
$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";
}
}
}
}, 5);
// --- Homepage + translations: layout fixes ---
// With the sticky navy header the hero now sits directly below the header.
// These rules clean up Kadence's boxed-content wrappers and size the hero.
add_action('wp_head', function () {
if (!is_front_page() && !is_singular()) return;
$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 '' . "\n";
}, 5);
// --- Single post: spacing fix between featured image and title/meta ---
add_action('wp_head', function () {
if (!is_singular('post')) return;
echo '' . "\n";
}, 8);
// ═══════════════════════════════════════════════════════════════════
// STICKY HEADER + SEARCH
// ═══════════════════════════════════════════════════════════════════
// ── Sticky header CSS + search overlay CSS ──
add_action('wp_head', function () {
echo '' . "\n";
}, 1);
// ── Search icon: append magnifying glass to primary nav menus ──
add_filter('wp_nav_menu_items', function ($items, $args) {
if (empty($args->menu) || !in_array((int) $args->menu->term_id, [2, 16, 17])) {
return $items;
}
$items .= '';
return $items;
}, 10, 2);
// ── Search overlay HTML + AJAX JS ──
add_action('wp_footer', function () {
$lang = function_exists('pll_current_language') ? pll_current_language() : 'es';
$placeholder = $lang === 'ro' ? 'Caută...' : ($lang === 'en' ? 'Search...' : 'Buscar...');
$close_hint = $lang === 'ro' ? 'Apasă ESC pentru a închide' : ($lang === 'en' ? 'Press ESC to close' : 'Pulsa ESC para cerrar');
$no_results = $lang === 'ro' ? 'Niciun rezultat.' : ($lang === 'en' ? 'No results found.' : 'Sin resultados.');
?>
get_posted_data();
$ref = !empty($posted['form-ref']) ? $posted['form-ref'] : '';
// Generate sequential ref if JS didn't supply one
if (!$ref) {
$counter = (int) get_option('acrib_form_counter', 1000) + 1;
update_option('acrib_form_counter', $counter, false);
$ref = 'ACRIB-' . date('Y') . '-' . str_pad($counter, 4, '0', STR_PAD_LEFT);
}
// Ensure ref appears in subject + body even if tag not resolved
$mail = $cf7->prop('mail');
$mail['body'] = str_replace('[form-ref]', $ref, $mail['body']);
$mail['subject'] = str_replace('[form-ref]', $ref, $mail['subject']);
$cf7->set_properties(['mail' => $mail]);
});
// ── CF7 redesign CSS ──
add_action('wp_head', function () {
if (!is_page() && !is_singular()) return;
echo '
';
}, 20);
// ── CF7 JS: populate reference number on page load ──
add_action('wp_footer', function () {
if (!is_page() && !is_singular()) return;
?>