[\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: 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() && !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 '' . "\n";
}, 5);