Files
acrib.es/wp-content/mu-plugins/acrib-core.php

69 lines
2.5 KiB
PHP
Raw Normal View History

<?php
/**
* ACRIB Core MU-Plugin
* Always-on: custom footer, security hardening, performance tweaks.
* @version 1.0
*/
// --- Footer: bottom bar with legal links + Cloud Host credit ---
add_action('wp_footer', function () {
$year = date('Y');
$legal_url = home_url('/aviso-legal/');
$pp_url = home_url('/politica-privacidad/');
$cookie_url = home_url('/politica-cookies/');
?>
<div class="acrib-footer-bottom">
<div class="acrib-footer-bottom-inner">
<p class="acrib-footer-copyright">
&copy; <?php echo $year; ?> <strong>ACRIB</strong> &mdash; Asociaci&oacute;n Casa Rom&acirc;neasc&#259; de las Islas Baleares
</p>
<ul class="acrib-footer-legal-links">
<li><a href="<?php echo esc_url($legal_url); ?>">Aviso Legal</a></li>
<li><a href="<?php echo esc_url($pp_url); ?>">Privacidad</a></li>
<li><a href="<?php echo esc_url($cookie_url); ?>">Cookies</a></li>
</ul>
<p class="acrib-footer-hosted">
Hosted &amp; Maintained by <a href="https://cloudhost.es" target="_blank" rel="noopener noreferrer">Cloud Host</a>
</p>
</div>
</div>
<?php
}, 100);
// --- Security headers ---
add_action('send_headers', function () {
if (!is_admin()) {
header('X-Frame-Options: SAMEORIGIN');
header('X-Content-Type-Options: nosniff');
header('Referrer-Policy: strict-origin-when-cross-origin');
header('Permissions-Policy: camera=(), microphone=(), geolocation=()');
}
});
// --- Disable XML-RPC ---
add_filter('xmlrpc_enabled', '__return_false');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wp_shortlink_wp_head');
// --- Disable REST API user enumeration ---
add_filter('rest_endpoints', function ($endpoints) {
unset($endpoints['/wp/v2/users'], $endpoints['/wp/v2/users/(?P<id>[\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);
}