feat: caching, optimization, legal pages & footer

- WP Super Cache enabled (PHP mode, gzip, Nginx compatible)
- Autoptimize: CSS/HTML minification + deferred JS + Google Fonts optimization
- Cookie Notice: GDPR/LOPD banner styled with brand colors (navy/burgundy/gold)
- Legal pages: Aviso Legal, Política de Privacidad, Política de Cookies (ES)
- MU-plugin: custom footer with legal links + Cloud Host credit
- Footer: copyright, legal nav, Hosted & Maintained by Cloud Host (cloudhost.es)
- Security: X-Frame-Options, X-Content-Type, Referrer-Policy headers
- Security: XML-RPC disabled, REST user enumeration blocked
- Performance: emoji scripts removed, post revisions limited to 3
This commit is contained in:
Malin
2026-05-19 19:58:11 +02:00
parent 67241f537f
commit 6daabcab65
277 changed files with 96841 additions and 0 deletions

View File

@@ -0,0 +1,146 @@
/**
* Handle the buttons for the Boost migration.
* @param {jQuery} $ - jQuery
*/
( $ => {
$( document ).ready( function () {
// Don't run on versions of WordPress too old for the block editor and the translation methods it brings.
// All the install / activate options are plain links with meaningful destinations anyway.
if ( ! window.wp || ! window.wp.i18n ) {
return;
}
const { __, sprintf } = window.wp.i18n;
const ajaxurl = window.ajaxurl;
const wpscAdmin = window.wpscAdmin;
const setupBoostButton = $target => {
if ( ! $target.hasClass( 'wpsc-boost-migration-button' ) ) {
// eslint-disable-next-line no-console
console.warn( 'Unexpected button clicked for Boost migration.' );
return;
}
const $label = $target.find( 'label' );
const $spinner = $target.find( '.spinner' );
const $errorMessage = $target.prev( '.wpsc-boost-migration-error' );
const source = $target.attr( 'data-source' );
const originalText = $label.text();
// Helper function to show an error.
const showError = err => {
reset();
$errorMessage
.text(
err ||
__( 'An error occurred while trying to activate Jetpack Boost', 'wp-super-cache' )
)
.show();
};
// Helper function to show Boost Banner work in progress.
const showBusy = action => {
$target.attr( 'disabled', true );
$label.text( action );
$spinner.addClass( 'is-active' ).show();
};
// Helper function to reset Boost Banner button.
const reset = () => {
$target.attr( 'disabled', false );
$label.text( originalText );
$spinner.removeClass( 'is-active' ).hide();
};
// Activate Jetpack Boost.
const activateBoost = () => {
showBusy( __( 'Activating…', 'wp-super-cache' ) );
$.post( ajaxurl, {
action: 'wpsc_activate_boost',
_ajax_nonce: wpscAdmin.boostActivateNonce,
source: source,
} )
.done( response => {
if ( response.success ) {
$label.text( 'Success! Sending you to Jetpack Boost...' );
$spinner.hide();
window.location.href = 'admin.php?page=jetpack-boost';
} else {
showError( response.data );
}
} )
.fail( response => {
showError(
sprintf(
/* translators: %d is an HTTP error code */
__( 'Failed to activate Jetpack Boost: HTTP %d error received', 'wp-super-cache' ),
response.status
)
);
} );
};
const installBoost = () => {
showBusy( __( 'Installing…', 'wp-super-cache' ) );
$.post( ajaxurl, {
action: 'wpsc_install_plugin',
_ajax_nonce: wpscAdmin.boostInstallNonce,
slug: 'jetpack-boost',
} )
.done( response => {
if ( response.success ) {
activateBoost();
} else {
showError( response.data );
}
} )
.fail( response => {
showError(
sprintf(
/* translators: %d is an HTTP error code */
__( 'Failed to install Jetpack Boost: HTTP %d error received', 'wp-super-cache' ),
response.status
)
);
} );
};
return {
installBoost,
activateBoost,
};
};
// One-click install for Boost.
$( '.wpsc-install-boost-button' ).on( 'click', event => {
event.preventDefault();
const boostActivation = setupBoostButton( $( event.currentTarget ) );
boostActivation.installBoost();
} );
// Handle activate button click.
$( '.wpsc-activate-boost-button' ).on( 'click', event => {
event.preventDefault();
const boostActivation = setupBoostButton( $( event.currentTarget ) );
boostActivation.activateBoost();
} );
// Dismiss Boost banner.
$( '.wpsc-boost-dismiss' ).on( 'click', () => {
$( '.wpsc-boost-banner' ).fadeOut( 'slow' );
$.post( ajaxurl, {
action: 'wpsc-hide-boost-banner',
nonce: wpscAdmin.boostDismissNonce,
} );
} );
// Dismiss admin notice
$( '.boost-notice' ).on( 'click', '.notice-dismiss', event => {
event.preventDefault();
$.post( ajaxurl, {
action: 'wpsc_dismiss_boost_notice',
_ajax_nonce: wpscAdmin.boostNoticeDismissNonce,
} );
} );
} );
} )( jQuery );

View File

@@ -0,0 +1,122 @@
jQuery( document ).ready( function () {
const { __, sprintf } = window.wp.i18n;
// Set how often to check when a preload job is running
const ACTIVE_INTERVAL = 3000;
// Set how often to check when no preload job is running
const INACTIVE_INTERVAL = 30000;
// Get a reference to the log element and the previous log entry
const preloadInfoPanel = jQuery( '#wpsc-preload-status' );
// Abort early if no info panel exists.
if ( ! preloadInfoPanel.length ) {
return;
}
update_preload_status( window.wpsc_preload_ajax.preload_status );
/**
* Schedule the next preload status update.
*
* @param {number} time - time in milliseconds to wait before updating.
*/
function schedule_preload_update( time ) {
setTimeout( () => {
jQuery.post(
window.wpsc_preload_ajax.ajax_url,
{
action: 'wpsc_get_preload_status',
_ajax_nonce: window.wpsc_preload_ajax.nonce,
},
json => {
if ( ! json || ! json.success ) {
return;
}
update_preload_status( json.data );
}
);
}, time );
}
/**
* Update displayed preload status using the provided data.
*
* @param {object} data - description of the preload status.
*/
function update_preload_status( data ) {
// Bail early if no data is available. But try again in a few seconds.
if ( ! data || ( ! data.running && ! data.next && ! data.previous ) ) {
schedule_preload_update( ACTIVE_INTERVAL );
return;
}
preloadInfoPanel.empty();
let nextPreloadTime = data.running ? ACTIVE_INTERVAL : INACTIVE_INTERVAL;
if ( data.running ) {
const panel = jQuery( '<div class="notice notice-warning">' );
panel.append(
jQuery( '<p>' ).append( jQuery( '<b>' ).text( __( 'Preloading', 'wp-super-cache' ) ) )
);
panel.append(
jQuery( '<p>' ).text( __( 'Preloading is currently running.', 'wp-super-cache' ) )
);
const ul = panel.append( jQuery( '<ul>' ) );
for ( const entry of data.history ) {
ul.append( jQuery( '<li>' ).text( entry.group + ' ' + entry.progress + ': ' + entry.url ) );
}
preloadInfoPanel.append( panel );
} else if ( data.next || data.previous ) {
const panel = jQuery( '<div class="notice notice-info">' );
if ( data.next ) {
const diff = Math.max( 0, data.next - Math.floor( Date.now() / 1000 ) );
const seconds = diff % 60;
const minutes = Math.floor( diff / 60 ) % 60;
const hours = Math.floor( diff / 3600 ) % 24;
const days = Math.floor( diff / 86400 );
// If we're preloading within the next minute, start loading faster.
if ( minutes + hours === 0 ) {
nextPreloadTime = ACTIVE_INTERVAL;
}
const p = jQuery( '<p>' );
p.append(
jQuery( '<b>' ).html(
sprintf(
/* Translators: 1: Number of days, 2: Number of hours, 3: Number of minutes, 4: Number of seconds */
__(
'<b>Next preload scheduled</b> in %1$s days, %2$s hours, %3$s minutes and %4$s seconds.',
'wp-super-cache'
),
days,
hours,
minutes,
seconds
)
)
);
panel.append( p );
}
if ( data.previous ) {
const p = jQuery( '<p>' );
p.append( jQuery( '<b>' ).text( __( 'Last preload finished:', 'wp-super-cache' ) + ' ' ) );
p.append( jQuery( '<span>' ).text( new Date( data.previous * 1000 ).toLocaleString() ) );
panel.append( p );
}
preloadInfoPanel.append( panel );
}
schedule_preload_update( nextPreloadTime );
}
} );