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:
@@ -0,0 +1,89 @@
|
||||
( function( window, document, undefined ) {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Initialize recaptcha.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function initRecaptcha() {
|
||||
wpcf7_recaptcha = {
|
||||
...( wpcf7_recaptcha ?? {} )
|
||||
};
|
||||
|
||||
const siteKey = wpcf7_recaptcha.sitekey;
|
||||
const { homepage, contactform } = wpcf7_recaptcha.actions;
|
||||
|
||||
const execute = options => {
|
||||
const { action, func, params } = options;
|
||||
|
||||
grecaptcha.execute( siteKey, {
|
||||
action,
|
||||
} ).then( token => {
|
||||
const event = new CustomEvent( 'wpcf7grecaptchaexecuted', {
|
||||
detail: {
|
||||
action,
|
||||
token
|
||||
}
|
||||
} );
|
||||
|
||||
document.dispatchEvent( event );
|
||||
} ).then( () => {
|
||||
if ( typeof func === 'function' ) {
|
||||
func( ...params );
|
||||
}
|
||||
} ).catch( error => console.error( error ) );
|
||||
};
|
||||
|
||||
grecaptcha.ready( () => {
|
||||
execute( {
|
||||
action: homepage
|
||||
} );
|
||||
} );
|
||||
|
||||
document.addEventListener( 'change', event => {
|
||||
execute( {
|
||||
action: contactform
|
||||
} );
|
||||
} );
|
||||
|
||||
if ( typeof wpcf7 !== 'undefined' && typeof wpcf7.submit === 'function' ) {
|
||||
const submit = wpcf7.submit;
|
||||
|
||||
wpcf7.submit = ( form, options = {} ) => {
|
||||
execute( {
|
||||
action: contactform,
|
||||
func: submit,
|
||||
params: [ form, options ]
|
||||
} );
|
||||
};
|
||||
}
|
||||
|
||||
document.addEventListener( 'wpcf7grecaptchaexecuted', event => {
|
||||
const fields = document.querySelectorAll( 'form.wpcf7-form input[name="_wpcf7_recaptcha_response"]' );
|
||||
|
||||
for ( let i = 0; i < fields.length; i++ ) {
|
||||
let field = fields[ i ];
|
||||
|
||||
field.setAttribute( 'value', event.detail.token );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle cookies-unblocked event.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
document.addEventListener( 'cookies-unblocked.hu', function( e ) {
|
||||
e.detail.data.scripts.forEach( function( script ) {
|
||||
// find google recaptcha in valid category
|
||||
if ( script.id === 'google-recaptcha-js' && e.detail.categories[script.dataset.huCategory] === true ) {
|
||||
script.onload = initRecaptcha;
|
||||
script.onreadystatechange = initRecaptcha;
|
||||
}
|
||||
} );
|
||||
}, false );
|
||||
|
||||
} )( window, document );
|
||||
Reference in New Issue
Block a user